Newsletter - Version 4.7.1

Version Description

  • Fixed missing files in the package
Download this release

Release Info

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

Code changes from version 4.6.8 to 4.7.1

admin.css CHANGED
@@ -252,7 +252,7 @@
252
  }
253
 
254
 
255
- p.submit {
256
  margin-top: 5px;
257
  padding: 5px;
258
  }
@@ -709,6 +709,7 @@ p.description {
709
  border-color: #34495E;
710
  border-width: 10px;
711
  border-style: solid;
 
712
  }
713
 
714
  .tnp-darkbg {
@@ -848,6 +849,10 @@ p.description {
848
 
849
  /* Dashboard Box */
850
 
 
 
 
 
851
  .postbox {
852
  border: none;
853
  }
@@ -970,7 +975,7 @@ p.description {
970
  /* Wrapper Background */
971
 
972
  #wpwrap {
973
- background-color: #2C3E50;
974
  }
975
 
976
  /* Global buttons styles */
252
  }
253
 
254
 
255
+ div.submit {
256
  margin-top: 5px;
257
  padding: 5px;
258
  }
709
  border-color: #34495E;
710
  border-width: 10px;
711
  border-style: solid;
712
+ overflow: auto;
713
  }
714
 
715
  .tnp-darkbg {
849
 
850
  /* Dashboard Box */
851
 
852
+ .metabox-holder {
853
+ width: 100%;
854
+ }
855
+
856
  .postbox {
857
  border: none;
858
  }
975
  /* Wrapper Background */
976
 
977
  #wpwrap {
978
+ background-color: #2C3E50 !important;
979
  }
980
 
981
  /* Global buttons styles */
emails/edit.php CHANGED
@@ -287,7 +287,7 @@ if ($email['editor'] == 0) {
287
  <form method="post" action="" id="newsletter-form">
288
  <?php $controls->init(array('cookie_name' => 'newsletter_emails_edit_tab')); ?>
289
 
290
- <p class="submit">
291
  <?php $controls->button_back('?page=newsletter_emails_index') ?>
292
  <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_save(); ?>
293
  <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_confirm('test', 'Save and test', 'Save and send test emails to test addresses?'); ?>
@@ -297,7 +297,7 @@ if ($email['editor'] == 0) {
297
  <?php if ($email['status'] == 'paused') $controls->button_confirm('continue', __('Continue', 'newsletter'), 'Continue the delivery?'); ?>
298
  <?php if ($email['status'] == 'paused') $controls->button_confirm('abort', __('Stop', 'newsletter'), __('This totally stop the delivery, ok?', 'newsletter')); ?>
299
  <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_confirm('editor', 'Save and switch to ' . ($email['editor'] == 0 ? 'HTML source' : 'visual') . ' editor', 'Sure?'); ?>
300
- </p>
301
 
302
  <div id="tabs">
303
  <ul>
287
  <form method="post" action="" id="newsletter-form">
288
  <?php $controls->init(array('cookie_name' => 'newsletter_emails_edit_tab')); ?>
289
 
290
+ <div class="submit">
291
  <?php $controls->button_back('?page=newsletter_emails_index') ?>
292
  <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_save(); ?>
293
  <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_confirm('test', 'Save and test', 'Save and send test emails to test addresses?'); ?>
297
  <?php if ($email['status'] == 'paused') $controls->button_confirm('continue', __('Continue', 'newsletter'), 'Continue the delivery?'); ?>
298
  <?php if ($email['status'] == 'paused') $controls->button_confirm('abort', __('Stop', 'newsletter'), __('This totally stop the delivery, ok?', 'newsletter')); ?>
299
  <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_confirm('editor', 'Save and switch to ' . ($email['editor'] == 0 ? 'HTML source' : 'visual') . ' editor', 'Sure?'); ?>
300
+ </div>
301
 
302
  <div id="tabs">
303
  <ul>
emails/emails.php CHANGED
@@ -38,13 +38,15 @@ class NewsletterEmails extends NewsletterModule {
38
  }
39
 
40
  if ($email->private == 1) {
41
- die('Email not found');
42
  }
43
 
44
  $user = NewsletterSubscription::instance()->get_user_from_request();
45
  header('Content-Type: text/html;charset=UTF-8');
46
  header('X-Robots-Tag: noindex,nofollow,noarchive');
47
  header('Cache-Control: no-cache,no-store,private');
 
 
48
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/view.php')) {
49
  include WP_CONTENT_DIR . '/extensions/newsletter/view.php';
50
  die();
@@ -179,13 +181,13 @@ class NewsletterEmails extends NewsletterModule {
179
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column `type` `type` varchar(50) not null default ''");
180
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column token varchar(10) not null default ''");
181
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column visibility");
182
- $this->upgrade_query("update " . NEWSLETTER_EMAILS_TABLE . " set type='message' where type=''");
183
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column private tinyint(1) not null default 0");
184
 
185
  // Force a token to email without one already set.
186
  //$token = self::get_token();
187
  //$wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set token='" . $token . "' where token=''");
188
  if ($this->old_version < '1.1.5') {
 
189
  $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set token=''");
190
  }
191
  $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set total=sent where status='sent' and type='message'");
38
  }
39
 
40
  if ($email->private == 1) {
41
+ die('No available for online view');
42
  }
43
 
44
  $user = NewsletterSubscription::instance()->get_user_from_request();
45
  header('Content-Type: text/html;charset=UTF-8');
46
  header('X-Robots-Tag: noindex,nofollow,noarchive');
47
  header('Cache-Control: no-cache,no-store,private');
48
+
49
+ // TODO: To be removed
50
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/view.php')) {
51
  include WP_CONTENT_DIR . '/extensions/newsletter/view.php';
52
  die();
181
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column `type` `type` varchar(50) not null default ''");
182
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column token varchar(10) not null default ''");
183
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column visibility");
 
184
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column private tinyint(1) not null default 0");
185
 
186
  // Force a token to email without one already set.
187
  //$token = self::get_token();
188
  //$wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set token='" . $token . "' where token=''");
189
  if ($this->old_version < '1.1.5') {
190
+ $this->upgrade_query("update " . NEWSLETTER_EMAILS_TABLE . " set type='message' where type=''");
191
  $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set token=''");
192
  }
193
  $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set total=sent where status='sent' and type='message'");
emails/tnp-composer/blocks/content-02-heading.block.php CHANGED
@@ -2,7 +2,7 @@
2
  <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="content-02">
3
  <tr>
4
  <td bgcolor="#ffffff" align="center" style="padding: 15px; font-family: Helvetica, Arial, sans-serif;" class="section-padding edit-block">
5
- <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table" style="width: 500px!important; max-width: 100%!important">
6
  <tr>
7
  <td align="center" style="font-size: 25px; color: #333333; padding-top: 30px;" class="padding-copy tnpc-row-edit" data-type="title">An Awesome Title</td>
8
  </tr>
2
  <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="content-02">
3
  <tr>
4
  <td bgcolor="#ffffff" align="center" style="padding: 15px; font-family: Helvetica, Arial, sans-serif;" class="section-padding edit-block">
5
+ <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table" style="max-width: 100%!important">
6
  <tr>
7
  <td align="center" style="font-size: 25px; color: #333333; padding-top: 30px;" class="padding-copy tnpc-row-edit" data-type="title">An Awesome Title</td>
8
  </tr>
includes/controls.php CHANGED
@@ -118,6 +118,13 @@ class NewsletterControls {
118
  }
119
  $this->messages .= __('Saved.', 'newsletter');
120
  }
 
 
 
 
 
 
 
121
 
122
  function hint($text, $url = '') {
123
  echo '<div class="hints">';
@@ -222,6 +229,15 @@ class NewsletterControls {
222
 
223
  $this->checkboxes_group($name, $list);
224
  }
 
 
 
 
 
 
 
 
 
225
 
226
  /** Used to create a select which is part of a group of controls identified by $name that will
227
  * produce an array of values as $_REQUEST['name'].
@@ -449,7 +465,7 @@ class NewsletterControls {
449
 
450
  function textarea($name, $width = '100%', $height = '50') {
451
  $value = $this->get_value($name);
452
- echo '<textarea class="dynamic" name="options[' . esc_attr($name) . ']" wrap="off" style="width:' . esc_attr($width) . ';height:' . esc_attr($height) . '">';
453
  echo esc_html($value);
454
  echo '</textarea>';
455
  }
118
  }
119
  $this->messages .= __('Saved.', 'newsletter');
120
  }
121
+
122
+ function add_message_done() {
123
+ if (!empty($this->messages)) {
124
+ $this->messages .= '<br><br>';
125
+ }
126
+ $this->messages .= __('Done.', 'newsletter');
127
+ }
128
 
129
  function hint($text, $url = '') {
130
  echo '<div class="hints">';
229
 
230
  $this->checkboxes_group($name, $list);
231
  }
232
+
233
+ function page($name='page', $first = null) {
234
+ $pages = get_pages();
235
+ $options = array();
236
+ foreach ($pages as $page) {
237
+ $options[$page->ID] = $page->post_title;
238
+ }
239
+ $this->select($name, $options, $first);
240
+ }
241
 
242
  /** Used to create a select which is part of a group of controls identified by $name that will
243
  * produce an array of values as $_REQUEST['name'].
465
 
466
  function textarea($name, $width = '100%', $height = '50') {
467
  $value = $this->get_value($name);
468
+ echo '<textarea id="options-' . esc_attr($name) . '" class="dynamic" name="options[' . esc_attr($name) . ']" wrap="off" style="width:' . esc_attr($width) . ';height:' . esc_attr($height) . '">';
469
  echo esc_html($value);
470
  echo '</textarea>';
471
  }
includes/module.php CHANGED
@@ -101,9 +101,9 @@ class NewsletterModule {
101
  $options = array_merge($default_options, $options);
102
  $this->save_options($options, $sub);
103
  if ($autoload) {
104
- $this->upgrade_query('update ' . $wpdb->options . " set autoload='yes' where option_name='" . $this->get_prefix($sub) . "' limit 1");
105
  } else {
106
- $this->upgrade_query('update ' . $wpdb->options . " set autoload='no' where option_name='" . $this->get_prefix($sub) . "' limit 1");
107
  }
108
  }
109
 
@@ -760,6 +760,7 @@ class NewsletterModule {
760
  echo '<html><head></head><body>';
761
  echo '<form method="post" action="' . home_url('/') . '" id="form">';
762
  foreach ($_REQUEST as $name => $value) {
 
763
  if (is_array($value)) {
764
  foreach ($value as $element) {
765
  echo '<input type="hidden" name="';
101
  $options = array_merge($default_options, $options);
102
  $this->save_options($options, $sub);
103
  if ($autoload) {
104
+ $this->upgrade_query('update ' . $wpdb->options . " set autoload='yes' where option_name='" . esc_sql($this->get_prefix($sub)) . "' limit 1");
105
  } else {
106
+ $this->upgrade_query('update ' . $wpdb->options . " set autoload='no' where option_name='" . esc_sql($this->get_prefix($sub)) . "' limit 1");
107
  }
108
  }
109
 
760
  echo '<html><head></head><body>';
761
  echo '<form method="post" action="' . home_url('/') . '" id="form">';
762
  foreach ($_REQUEST as $name => $value) {
763
+ if ($name == 'submit') continue;
764
  if (is_array($value)) {
765
  foreach ($value as $element) {
766
  echo '<input type="hidden" name="';
main/diagnostic.php CHANGED
@@ -41,6 +41,11 @@ if ($controls->is_action('engine_on')) {
41
  $controls->messages = 'Delivery engine reactivated.';
42
  }
43
 
 
 
 
 
 
44
  if ($controls->is_action('upgrade')) {
45
  // TODO: Compact them in a call to Newsletter which should be able to manage the installed modules
46
  Newsletter::instance()->upgrade();
@@ -167,7 +172,7 @@ if (count($calls) > 1) {
167
  $max = $diff;
168
  }
169
  }
170
- $mean = $mean / count($calls) - 1;
171
  }
172
 
173
  // Send calls stats
@@ -316,11 +321,11 @@ if (count($send_calls)) {
316
 
317
  <tbody>
318
  <tr>
319
- <td>Scheduler execution interval mean</td>
320
  <td>
321
  <?php
322
  if (count($calls) > 10) {
323
- echo (int) $mean . ' seconds';
324
  if ($mean < NEWSLETTER_CRON_INTERVAL * 1.2) {
325
  echo ' (<span style="color: green; font-weight: bold">OK</span>)';
326
  } else {
@@ -330,6 +335,8 @@ if (count($send_calls)) {
330
  echo 'Still not enough data. It requires few hours to collect a relevant data set.';
331
  }
332
  ?>
 
 
333
 
334
  <p class="description">
335
  Should be less than <?php echo esc_html(NEWSLETTER_CRON_INTERVAL) ?> seconds.
@@ -390,14 +397,7 @@ if (count($send_calls)) {
390
  </p>
391
  </td>
392
  </tr>
393
- <tr>
394
- <td>Collected samples</td>
395
- <td>
396
- <?php echo count($calls); ?>
397
- <p class="description">Samples are collected in a maximum number of <?php echo Newsletter::MAX_CRON_SAMPLES; ?></p>
398
- </td>
399
- </tr>
400
-
401
  <tr>
402
  <td>Sending statistics</td>
403
  <td>
@@ -584,23 +584,6 @@ if (count($send_calls)) {
584
  <?php echo DB_CHARSET; ?> <?php echo DB_COLLATE; ?>
585
  </td>
586
  </tr>
587
-
588
- <tr>
589
- <td>File permissions (obsolete)</td>
590
- <td>
591
- <?php
592
- $index_owner = fileowner(ABSPATH . '/index.php');
593
- $index_permissions = fileperms(ABSPATH . '/index.php');
594
- $subscribe_permissions = fileperms(NEWSLETTER_DIR . '/do/subscribe.php');
595
- $subscribe_owner = fileowner(NEWSLETTER_DIR . '/do/subscribe.php');
596
- if ($index_permissions != $subscribe_permissions || $index_owner != $subscribe_owner) {
597
- echo 'Plugin file permissions or owner differ from blog index.php permissions, that may compromise the subscription process';
598
- } else {
599
- echo 'OK';
600
- }
601
- ?>
602
- </td>
603
- </tr>
604
  </tbody>
605
  </table>
606
 
41
  $controls->messages = 'Delivery engine reactivated.';
42
  }
43
 
44
+ if ($controls->is_action('reset_stats')) {
45
+ update_option('newsletter_diagnostic_cron_calls', array(), false);
46
+ $controls->messages = 'Scheduler statistics reset.';
47
+ }
48
+
49
  if ($controls->is_action('upgrade')) {
50
  // TODO: Compact them in a call to Newsletter which should be able to manage the installed modules
51
  Newsletter::instance()->upgrade();
172
  $max = $diff;
173
  }
174
  }
175
+ $mean = $mean / (count($calls) - 1);
176
  }
177
 
178
  // Send calls stats
321
 
322
  <tbody>
323
  <tr>
324
+ <td>Average scheduler activation interval</td>
325
  <td>
326
  <?php
327
  if (count($calls) > 10) {
328
+ echo (int) $mean . ' seconds/' . count($calls) . ' samples';
329
  if ($mean < NEWSLETTER_CRON_INTERVAL * 1.2) {
330
  echo ' (<span style="color: green; font-weight: bold">OK</span>)';
331
  } else {
335
  echo 'Still not enough data. It requires few hours to collect a relevant data set.';
336
  }
337
  ?>
338
+
339
+ <?php $controls->button('reset_stats', 'Reset'); ?>
340
 
341
  <p class="description">
342
  Should be less than <?php echo esc_html(NEWSLETTER_CRON_INTERVAL) ?> seconds.
397
  </p>
398
  </td>
399
  </tr>
400
+
 
 
 
 
 
 
 
401
  <tr>
402
  <td>Sending statistics</td>
403
  <td>
584
  <?php echo DB_CHARSET; ?> <?php echo DB_COLLATE; ?>
585
  </td>
586
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
587
  </tbody>
588
  </table>
589
 
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
- Version: 4.6.8
8
  Author: Stefano Lissa & The Newsletter Team
9
  Author URI: http://www.thenewsletterplugin.com
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -14,7 +14,7 @@
14
  */
15
 
16
  // Used as dummy parameter on css and js links
17
- define('NEWSLETTER_VERSION', '4.6.8');
18
 
19
  global $wpdb, $newsletter;
20
 
@@ -705,10 +705,10 @@ class Newsletter extends NewsletterModule {
705
 
706
  function mail($to, $subject, $message, $headers = null) {
707
  $this->mail_last_error = '';
708
- $this->logger->debug('mail> To: ' . $to);
709
- $this->logger->debug('mail> Subject: ' . $subject);
710
  if (empty($subject)) {
711
- $this->logger->debug('mail> Subject empty, skipped');
712
  return true;
713
  }
714
 
@@ -732,7 +732,7 @@ class Newsletter extends NewsletterModule {
732
  }
733
 
734
  if ($this->mail_method != null) {
735
- $this->logger->debug('mail> alternative mail method found');
736
  return call_user_func($this->mail_method, $to, $subject, $message, $headers);
737
  }
738
 
@@ -837,13 +837,6 @@ class Newsletter extends NewsletterModule {
837
  require_once ABSPATH . WPINC . '/class-smtp.php';
838
 
839
  $smtp_options = $this->get_smtp_options();
840
- // $smtp_options['enabled'] = $this->options['smtp_enabled'];
841
- // $smtp_options['host'] = $this->options['smtp_host'];
842
- // $smtp_options['port'] = $this->options['smtp_port'];
843
- // $smtp_options['user'] = $this->options['smtp_user'];
844
- // $smtp_options['pass'] = $this->options['smtp_pass'];
845
- // $smtp_options['secure'] = $this->options['smtp_secure'];
846
- //$smtp_options = apply_filters('newsletter_smtp', $smtp_options);
847
 
848
 
849
  if ($smtp_options['enabled'] == 1) {
@@ -972,43 +965,6 @@ class Newsletter extends NewsletterModule {
972
 
973
  $user = $this->get_user_by_wp_user_id($wp_user_id);
974
  return $user;
975
-
976
-
977
- /*
978
- if ($this->options_main['wp_integration'] != 1) {
979
- return null;
980
- }
981
-
982
- get_currentuserinfo();
983
-
984
- // Retrieve the related newsletter user
985
- $user = $wpdb->get_row("select * from " . NEWSLETTER_USERS_TABLE . " where wp_user_id=" . $current_user->ID . " limit 1");
986
- // There is an email matching?
987
- if (empty($user)) {
988
- $user = $wpdb->get_row($wpdb->prepare("select * from " . NEWSLETTER_USERS_TABLE . " where email=%s limit 1", strtolower($current_user->user_email)));
989
- // If not found, create a new Newsletter user, else update the wp_user_id since this email must be linked
990
- // to the WP user email.
991
- if (empty($user)) {
992
- return null;
993
- //echo 'WP user not found';
994
- $user = array();
995
- $user['status'] = 'C';
996
- $user['wp_user_id'] = $current_user->ID;
997
- $user['token'] = $this->get_token();
998
- $user['email'] = strtolower($current_user->user_email);
999
-
1000
- $id = $wpdb->insert(NEWSLETTER_USERS_TABLE, $user);
1001
- $user = NewsletterUsers::instance()->get_user($id);
1002
- } else {
1003
- //echo 'WP user found via email';
1004
- $wpdb->query($wpdb->prepare("update " . NEWSLETTER_USERS_TABLE . " set wp_user_id=" . $current_user->ID . ", email=%s", $current_user->user_email));
1005
- }
1006
- } else {
1007
- //echo 'WP user found via id';
1008
- }
1009
-
1010
- return $user;
1011
- */
1012
  }
1013
 
1014
  function replace_date($text) {
@@ -1098,7 +1054,7 @@ class Newsletter extends NewsletterModule {
1098
  $text = str_replace('%7Bkey%7D', $user->id . '-' . $user->token, $text);
1099
 
1100
  if (strpos($text, '{profile_form}') !== false) {
1101
- $text = str_replace('{profile_form}', NewsletterSubscription::instance()->get_profile_form($user), $text);
1102
  }
1103
 
1104
  for ($i = 1; $i < NEWSLETTER_PROFILE_MAX; $i++) {
@@ -1485,7 +1441,8 @@ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-mandrill')) {
1485
  }
1486
 
1487
 
1488
- require_once(dirname(__FILE__) . '/widget.php');
 
1489
 
1490
  register_activation_hook(__FILE__, 'newsletter_activate');
1491
 
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
+ Version: 4.7.1
8
  Author: Stefano Lissa & The Newsletter Team
9
  Author URI: http://www.thenewsletterplugin.com
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
14
  */
15
 
16
  // Used as dummy parameter on css and js links
17
+ define('NEWSLETTER_VERSION', '4.7.1');
18
 
19
  global $wpdb, $newsletter;
20
 
705
 
706
  function mail($to, $subject, $message, $headers = null) {
707
  $this->mail_last_error = '';
708
+ //$this->logger->debug('mail> To: ' . $to);
709
+ //$this->logger->debug('mail> Subject: ' . $subject);
710
  if (empty($subject)) {
711
+ $this->logger->error('mail> Subject empty, skipped');
712
  return true;
713
  }
714
 
732
  }
733
 
734
  if ($this->mail_method != null) {
735
+ //$this->logger->debug('mail> alternative mail method found');
736
  return call_user_func($this->mail_method, $to, $subject, $message, $headers);
737
  }
738
 
837
  require_once ABSPATH . WPINC . '/class-smtp.php';
838
 
839
  $smtp_options = $this->get_smtp_options();
 
 
 
 
 
 
 
840
 
841
 
842
  if ($smtp_options['enabled'] == 1) {
965
 
966
  $user = $this->get_user_by_wp_user_id($wp_user_id);
967
  return $user;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
968
  }
969
 
970
  function replace_date($text) {
1054
  $text = str_replace('%7Bkey%7D', $user->id . '-' . $user->token, $text);
1055
 
1056
  if (strpos($text, '{profile_form}') !== false) {
1057
+ $text = str_replace('{profile_form}', NewsletterSubscription::instance()->get_profile_form_html5($user), $text);
1058
  }
1059
 
1060
  for ($i = 1; $i < NEWSLETTER_PROFILE_MAX; $i++) {
1441
  }
1442
 
1443
 
1444
+ require_once(dirname(__FILE__) . '/widget/standard.php');
1445
+ require_once(dirname(__FILE__) . '/widget/minimal.php');
1446
 
1447
  register_activation_hook(__FILE__, 'newsletter_activate');
1448
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
3
  Requires at least: 3.4.0
4
  Tested up to: 4.6.1
5
- Stable tag: 4.6.8
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
@@ -77,6 +77,18 @@ Thank you, The Newsletter Team
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  = 4.6.8 =
81
 
82
  * Fixed the image browser/upload URL error in themes
@@ -371,7 +383,7 @@ Thank you, The Newsletter Team
371
  * Added import subscribers from CSV file
372
  * Updated the WP compatibility version number
373
  * Fixed the save button on sent emails
374
- * Fixed the ListUnsubscribe header with new URL schema
375
 
376
  = 3.7.8 =
377
 
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
3
  Requires at least: 3.4.0
4
  Tested up to: 4.6.1
5
+ Stable tag: 4.7.1
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
77
 
78
  == Changelog ==
79
 
80
+ = 4.7.1 =
81
+
82
+ * Fixed missing files in the package
83
+
84
+ = 4.7.0 =
85
+
86
+ * Added the selection for the Newsletter messages dedicated page
87
+ * New forms CSS and validator
88
+ * New widget for a minimal form
89
+ * Use shortcode attribute "layout" to revert to old style table forms, using layout=table
90
+ * Added reset button for diagnostic scheduler statistics
91
+
92
  = 4.6.8 =
93
 
94
  * Fixed the image browser/upload URL error in themes
383
  * Added import subscribers from CSV file
384
  * Updated the WP compatibility version number
385
  * Fixed the save button on sent emails
386
+ * Fixed the List-�Unsubscribe header with new URL schema
387
 
388
  = 3.7.8 =
389
 
statistics/statistics.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
- if (!defined('ABSPATH')) exit;
 
 
3
 
4
  require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
5
 
@@ -18,10 +20,7 @@ class NewsletterStatistics extends NewsletterModule {
18
  }
19
 
20
  function __construct() {
21
- global $wpdb;
22
-
23
  parent::__construct('statistics', '1.1.6');
24
-
25
  add_action('wp_loaded', array($this, 'hook_wp_loaded'));
26
  }
27
 
@@ -34,67 +33,63 @@ class NewsletterStatistics extends NewsletterModule {
34
 
35
  // Newsletter Link Tracking
36
  if (isset($_GET['nltr'])) {
37
-
38
- list($email_id, $user_id, $url, $anchor, $key) = explode(';', base64_decode($_GET['nltr']), 5);
39
 
40
- if (!is_user_logged_in()) {
41
- if (empty($email_id) || empty($user_id) || empty($url)) {
42
- header("HTTP/1.0 404 Not Found");
43
- die();
44
- }
 
 
 
 
45
  }
46
 
47
  $parts = parse_url($url);
48
 
49
  $verified = $parts['host'] == $_SERVER['HTTP_HOST'];
50
  if (!$verified) {
51
- $verified = $key == md5($email_id . ';' . $user_id . ';' . $url . ';' . $anchor . $this->options['key']);
 
 
 
 
 
52
  }
53
 
54
- // For feed by mail tests
55
- if ($verified && empty($email_id) && is_user_logged_in()) {
 
 
 
 
 
 
56
  header('Location: ' . $url);
57
  die();
58
  }
59
 
 
 
 
 
 
 
 
 
60
  $ip = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
61
 
62
- if ($verified) {
63
- $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
64
- 'email_id' => $email_id,
65
- 'user_id' => $user_id,
66
- 'url' => $url,
67
- 'ip' => $ip
68
- )
69
- );
70
 
71
- $wpdb->query($wpdb->prepare("update " . NEWSLETTER_SENT_TABLE . " set open=2, ip=%s where email_id=%d and user_id=%d limit 1", $ip, $email_id, $user_id));
72
 
73
- $user = Newsletter::instance()->get_user($user_id);
74
- if ($user) {
75
- setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
76
- }
77
- header('Location: ' . $url);
78
- die();
79
- } else {
80
- header("HTTP/1.0 404 Not Found");
81
- }
82
- ?><html>
83
- <head>
84
- <style>
85
- body {
86
- font-family: sans-serif;
87
- }
88
- </style>
89
- </head>
90
- <body>
91
- <div style="max-width: 100%; width: 500px; margin: 40px auto; text-align: center">
92
- <p>The requested URL (<?php echo esc_html($url) ?>) has not been verified.</p>
93
- <p>You can follow it if you recognize it as a valid URL.</p>
94
- </div>
95
- </body>
96
- </html>
97
- <?php
98
  die();
99
  }
100
 
@@ -132,7 +127,7 @@ class NewsletterStatistics extends NewsletterModule {
132
  $this->logger->info('Open already registered');
133
  // MAybe an update for some fields?
134
  } else {
135
-
136
  $res = $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
137
  'email_id' => (int) $email_id,
138
  'user_id' => (int) $user_id,
1
  <?php
2
+
3
+ if (!defined('ABSPATH'))
4
+ exit;
5
 
6
  require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
7
 
20
  }
21
 
22
  function __construct() {
 
 
23
  parent::__construct('statistics', '1.1.6');
 
24
  add_action('wp_loaded', array($this, 'hook_wp_loaded'));
25
  }
26
 
33
 
34
  // Newsletter Link Tracking
35
  if (isset($_GET['nltr'])) {
 
 
36
 
37
+ list($email_id, $user_id, $url, $anchor, $signature) = explode(';', base64_decode($_GET['nltr']), 5);
38
+
39
+ $url = esc_url_raw($url);
40
+ $user_id = (int) $user_id;
41
+ $email_id = (int) $email_id;
42
+
43
+ if (empty($user_id) || empty($url)) {
44
+ header("HTTP/1.0 404 Not Found");
45
+ die('Invalid data');
46
  }
47
 
48
  $parts = parse_url($url);
49
 
50
  $verified = $parts['host'] == $_SERVER['HTTP_HOST'];
51
  if (!$verified) {
52
+ $verified = $signature == md5($email_id . ';' . $user_id . ';' . $url . ';' . $anchor . $this->options['key']);
53
+ }
54
+
55
+ if (!$verified) {
56
+ header("HTTP/1.0 404 Not Found");
57
+ die('Url not verified');
58
  }
59
 
60
+ $user = Newsletter::instance()->get_user($user_id);
61
+ if (!$user) {
62
+ header("HTTP/1.0 404 Not Found");
63
+ die('Invalid subscriber');
64
+ }
65
+
66
+ // Test emails
67
+ if (empty($email_id)) {
68
  header('Location: ' . $url);
69
  die();
70
  }
71
 
72
+ $email = $this->get_email($email_id);
73
+ if (!$email) {
74
+ header("HTTP/1.0 404 Not Found");
75
+ die('Invalid newsletter');
76
+ }
77
+
78
+ setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
79
+
80
  $ip = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
81
 
82
+ $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
83
+ 'email_id' => $email_id,
84
+ 'user_id' => $user_id,
85
+ 'url' => $url,
86
+ 'ip' => $ip
87
+ )
88
+ );
 
89
 
90
+ $wpdb->query($wpdb->prepare("update " . NEWSLETTER_SENT_TABLE . " set open=2, ip=%s where email_id=%d and user_id=%d limit 1", $ip, $email_id, $user_id));
91
 
92
+ header('Location: ' . $url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  die();
94
  }
95
 
127
  $this->logger->info('Open already registered');
128
  // MAybe an update for some fields?
129
  } else {
130
+
131
  $res = $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
132
  'email_id' => (int) $email_id,
133
  'user_id' => (int) $user_id,
subscription/options.php CHANGED
@@ -53,6 +53,10 @@ if ($controls->is_action()) {
53
 
54
  $controls->data['confirmed_url'] = trim($controls->data['confirmed_url']);
55
  $controls->data['confirmation_url'] = trim($controls->data['confirmation_url']);
 
 
 
 
56
 
57
  $module->merge_options($controls->data);
58
  $controls->add_message_saved();
@@ -123,6 +127,21 @@ if ($controls->is_action()) {
123
  } else {
124
  $controls->data = get_option('newsletter', array());
125
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  ?>
127
 
128
  <div class="wrap" id="tnp-wrap">
@@ -173,25 +192,20 @@ if ($controls->is_action()) {
173
  <tr valign="top">
174
  <th>Newsletter dedicated page</th>
175
  <td>
176
- <?php $controls->text('url', 70); ?>
177
  <?php
178
- if (empty($controls->data['url'])) {
179
  $controls->button('create', 'Create a page for me');
180
  }
181
  ?>
182
-
183
  <p class="description">
184
- Optional (but recommended) an address of a WordPress page (eg. <?php echo get_option('home') . '/newsletter'; ?>)
185
- you <strong>manually created</strong> for subscription and messages.
186
- <br>
187
- The page must have in its body <strong>only</strong> the short code <strong>[newsletter]</strong> (as is).
188
-
189
- <?php if (!empty($controls->data['url'])) { ?>
190
- <br>
191
- If something is not working as expected with this address you can empty the field above and save: a button will appear
192
- to create that page automatically.
193
- <?php } ?>
194
  </p>
 
195
  </td>
196
  </tr>
197
  <tr valign="top">
53
 
54
  $controls->data['confirmed_url'] = trim($controls->data['confirmed_url']);
55
  $controls->data['confirmation_url'] = trim($controls->data['confirmation_url']);
56
+
57
+ if (!empty($controls->data['page'])) {
58
+ $controls->data['url'] = ''; // do not unset
59
+ }
60
 
61
  $module->merge_options($controls->data);
62
  $controls->add_message_saved();
127
  } else {
128
  $controls->data = get_option('newsletter', array());
129
  }
130
+
131
+ if (empty($controls->data['page'])) {
132
+ $controls->messages .= '<p>You should set a dedicated page for Newsletter which used to interact with your subscribers.</p>';
133
+ } else {
134
+ $post = get_post($controls->data['page']);
135
+
136
+ if (!$post || $post->post_status != 'publish') {
137
+ $controls->errors .= '<p>The dedicated page selected below does not exist anymore or has been unpublished. Please, select a different one.</p>';
138
+ } else {
139
+ if (strpos($post->post_content, '[newsletter]') === false) {
140
+ $controls->errors .= '<p>The dedicated page selected DOES NOT contain the [newsletter] shortcode. Please fix it. It should contain ONLY the [newsletter] shortcode.</p>';
141
+ }
142
+ }
143
+ }
144
+
145
  ?>
146
 
147
  <div class="wrap" id="tnp-wrap">
192
  <tr valign="top">
193
  <th>Newsletter dedicated page</th>
194
  <td>
195
+ <?php $controls->page('page', 'The Newsletter standard unstyled page'); ?>
196
  <?php
197
+ if (empty($controls->data['url']) && empty($controls->data['page'])) {
198
  $controls->button('create', 'Create a page for me');
199
  }
200
  ?>
201
+ <?php if (!empty($controls->data['url'])) { ?>
202
  <p class="description">
203
+ <strong>
204
+ You're currently using the URL <code><?php echo esc_html($controls->data['url'])?></code>
205
+ as dedicated page. Please select the corrisponding page above (new as version 4.6.5+).
206
+ </strong>
 
 
 
 
 
 
207
  </p>
208
+ <?php } ?>
209
  </td>
210
  </tr>
211
  <tr valign="top">
subscription/profile.php CHANGED
@@ -54,7 +54,6 @@ $rules = array(0 => 'Optional', 1 => 'Required');
54
  <li><a href="#tabs-2">Main profile fields</a></li>
55
  <li><a href="#tabs-3">Extra profile fields</a></li>
56
  <li><a href="#tabs-5">Form code</a></li>
57
- <li><a href="#tabs-6">Form style</a></li>
58
  </ul>
59
 
60
  <div id="tabs-2">
@@ -108,6 +107,7 @@ $rules = array(0 => 'Optional', 1 => 'Required');
108
  male: <?php $controls->text('sex_male'); ?>
109
  not specified: <?php $controls->text('sex_none'); ?>
110
  </td></tr>
 
111
 
112
  <tr><th>Salutation titles</th><td>
113
 
@@ -210,24 +210,6 @@ $rules = array(0 => 'Optional', 1 => 'Required');
210
 
211
  </div>
212
 
213
- <div id="tabs-6">
214
-
215
- <table class="form-table">
216
- <tr>
217
- <th>Subscription form style</th>
218
- <td>
219
- <?php $controls->select('style', $module->get_styles()); ?>
220
- </td>
221
- </tr>
222
- <tr>
223
- <th>Widget style</th>
224
- <td>
225
- <?php $controls->select('widget_style', $module->get_styles()); ?>
226
- </td>
227
- </tr>
228
- </table>
229
- </div>
230
-
231
  </div>
232
 
233
  <p>
@@ -240,4 +222,4 @@ $rules = array(0 => 'Optional', 1 => 'Required');
240
 
241
  <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
242
 
243
- </div>
54
  <li><a href="#tabs-2">Main profile fields</a></li>
55
  <li><a href="#tabs-3">Extra profile fields</a></li>
56
  <li><a href="#tabs-5">Form code</a></li>
 
57
  </ul>
58
 
59
  <div id="tabs-2">
107
  male: <?php $controls->text('sex_male'); ?>
108
  not specified: <?php $controls->text('sex_none'); ?>
109
  </td></tr>
110
+ <tr><th>Rules</th><td><?php $controls->select('sex_rules', $rules); ?></td></tr>
111
 
112
  <tr><th>Salutation titles</th><td>
113
 
210
 
211
  </div>
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  </div>
214
 
215
  <p>
222
 
223
  <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
224
 
225
+ </div>
subscription/style.css ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .newsletter-subscription {
2
+ font-size: 13px;
3
+ display: block;
4
+ margin: 15px auto;
5
+ max-width: 500px;
6
+ width: 100%;
7
+ }
8
+
9
+ /* Generic field wrapper */
10
+ .newsletter-subscription div.newsletter-field {
11
+ margin-bottom: 10px;
12
+ border: 0!important;
13
+ padding: 0!important;
14
+ }
15
+
16
+ .newsletter-subscription label {
17
+ display: block;
18
+ color: inherit;
19
+ font-size: 14px!important;
20
+ font-weight: 700;
21
+ line-height: normal;
22
+ padding: 5px;;
23
+ margin: 0;
24
+ }
25
+
26
+ .newsletter-subscription input[type=text], .newsletter-subscription input[type=email], .newsletter-subscription input[type=submit], .newsletter-subscription select {
27
+ width: 100%;
28
+ padding: 10px!important;
29
+ display: block;
30
+ border: 1px!important;
31
+ border-color: #ddd;
32
+ background-color: #f4f4f4!important;
33
+ color: #444;
34
+ font-size: 14px;
35
+ margin: 0!important;
36
+ }
37
+
38
+ .newsletter-subscription input[type=checkbox], .newsletter-widget input[type=radio] {
39
+ width: auto;
40
+ display: inline;
41
+ }
42
+
43
+ /* Antireset - http://www.satollo.net/css-and-select-space-between-the-options-and-the-arrow */
44
+ .newsletter-subscription select option {
45
+ margin-right: 10px!important;
46
+ }
47
+
48
+ .newsletter-subscription input[type=submit] {
49
+ background-color: #444!important;
50
+ color: #fff!important;
51
+ width: auto;
52
+ }
53
+
54
+ @media all and (max-width: 480px) {
55
+ .newsletter-subscription input[type=submit] {
56
+ width: 100%;
57
+ }
58
+ }
59
+
60
+
61
+ /* Profile form */
62
+
63
+ .newsletter-profile {
64
+ font-size: 13px;
65
+ }
66
+
67
+ .newsletter-profile .newsletter-field {
68
+ margin-bottom: 10px;
69
+ border: 0!important;
70
+ padding: 0!important;
71
+ }
72
+
73
+ .newsletter-profile label {
74
+ display: block;
75
+ color: #333;
76
+ font-size: 14px!important;
77
+ }
78
+
79
+ .newsletter-profile input[type=text], .newsletter-profile input[type=email], .newsletter-profile input[type=submit], .newsletter-profile select {
80
+ width: 100%!important;
81
+ padding: 10px!important;
82
+ display: block;
83
+ border: 1px!important;
84
+ border-color: #ddd;
85
+ background-color: #f4f4f4!important;
86
+ color: #444;
87
+ font-size: 14px;
88
+ margin: 0!important;
89
+ }
90
+
91
+ .newsletter-profile input[type=checkbox], .newsletter-widget input[type=radio] {
92
+ width: auto;
93
+ display: inline;
94
+ }
95
+
96
+ .newsletter-profile .newsletter-list-label {
97
+ margin-left: 15px;
98
+ }
99
+
100
+ /* Antireset - http://www.satollo.net/css-and-select-space-between-the-options-and-the-arrow */
101
+ .newsletter-profile select option {
102
+ margin-right: 10px!important;
103
+ }
104
+
105
+ .newsletter-profile input[type=submit] {
106
+ background-color: #444!important;
107
+ color: #fff!important;
108
+ }
109
+
110
+
111
+
112
+ .newsletter-widget {
113
+ width: 100%;
114
+ display: block;
115
+ }
116
+
117
+ .newsletter-widget .newsletter-field {
118
+ margin-bottom: 10px;
119
+ border: 0!important;
120
+ padding: 0!important;
121
+ }
122
+
123
+ .newsletter-widget label {
124
+ display: block;
125
+ color: inherit;
126
+ font-size: 14px!important;
127
+ }
128
+
129
+ .newsletter-widget input[type=text], .newsletter-widget input[type=email], .newsletter-widget input[type=submit], .newsletter-widget select {
130
+ width: 100%!important;
131
+ padding: 10px!important;
132
+ display: block;
133
+ border: 1px!important;
134
+ border-color: #ddd;
135
+ background-color: #f4f4f4!important;
136
+ color: #444;
137
+ font-size: 14px;
138
+ }
139
+
140
+ .newsletter-widget input[type=checkbox], .newsletter-widget input[type=radio] {
141
+ width: auto;
142
+ display: inline;
143
+ }
144
+
145
+ /* Antireset - http://www.satollo.net/css-and-select-space-between-the-options-and-the-arrow */
146
+ .newsletter-widget select option {
147
+ margin-right: 10px!important;
148
+ }
149
+
150
+ .newsletter-widget input[type=submit] {
151
+ background-color: #444!important;
152
+ color: #fff!important;
153
+ }
154
+
155
+ .newsletter-field input[type="submit"] {
156
+ position: inherit!important;
157
+ }
158
+
159
+ .newsletter-field label {
160
+
161
+ }
162
+
163
+ /* Newsletter Widget Minimal */
164
+
165
+ .newsletter-widget-minimal {
166
+ width: 100%;
167
+ }
168
+
169
+ .newsletter-widget-minimal form {
170
+ margin: 0!important;
171
+ padding: 0!important;
172
+ border: 0!important;
173
+ }
174
+
175
+ .newsletter-widget-minimal input.newsletter-email {
176
+ width: 70%!important;
177
+ box-sizing: border-box!important;
178
+ padding: 10px!important;
179
+ display: inline-block;
180
+ border: 1px!important;
181
+ border-color: #ddd;
182
+ background-color: #f4f4f4!important;
183
+ color: #444;
184
+ font-size: 14px;
185
+ }
186
+
187
+ .newsletter-widget-minimal input.newsletter-submit {
188
+ width: 30%!important;
189
+ box-sizing: border-box!important;
190
+ padding: 10px!important;
191
+ display: inline-block;
192
+ border: 1px!important;
193
+ border-color: #ddd;
194
+ background-color: #444!important;
195
+ color: #fff!important;
196
+ font-size: 14px;
197
+ line-height: 22px;
198
+ border-radius: 0px!important;
199
+ }
200
+
201
+
202
+ .newsletter-subscription-minimal {
203
+ width: 100%;
204
+ }
205
+
206
+ .newsletter-subscription-minimal form {
207
+ margin: 0!important;
208
+ padding: 0!important;
209
+ border: 0!important;
210
+ }
211
+
212
+ .newsletter-subscription-minimal input.newsletter-email {
213
+ width: 70%!important;
214
+ max-width: 300px;
215
+ box-sizing: border-box!important;
216
+ padding: 10px!important;
217
+ display: inline-block;
218
+ border: 1px!important;
219
+ border-color: #ddd;
220
+ background-color: #f4f4f4!important;
221
+ color: #444;
222
+ font-size: 14px;
223
+ }
224
+
225
+ .newsletter-subscription-minimal input.newsletter-submit {
226
+ width: 29%!important;
227
+ box-sizing: border-box!important;
228
+ padding: 10px!important;
229
+ display: inline-block;
230
+ border: 1px!important;
231
+ border-color: #ddd;
232
+ background-color: #444!important;
233
+ color: #fff!important;
234
+ font-size: 14px;
235
+ }
236
+
237
+
subscription/styles/gray.css DELETED
@@ -1,34 +0,0 @@
1
- .newsletter {
2
- text-align: center;
3
- }
4
-
5
- .newsletter table {
6
- margin-left: auto;
7
- margin-right: auto;
8
- text-align: left;
9
- border: 1px solid #eee;
10
- background-color: #f9f9f9;
11
- box-shadow: 0px 0px 10px #999;
12
- padding: 10px;
13
- width: auto;
14
- }
15
-
16
- .newsletter th, .newsletter td {
17
- padding: 10px;
18
- border: 0;
19
- }
20
-
21
- .newsletter th {
22
- text-align: right;
23
- }
24
-
25
- .newsletter-td-submit {
26
- text-align: center;
27
- }
28
-
29
- .newsletter-submit {
30
- font-size: 18px;
31
- background-color: #eee;
32
- padding: 10px;
33
- border: 1px solid #ddd;
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
subscription/styles/neutral.css DELETED
@@ -1,62 +0,0 @@
1
- .newsletter, .newsletter td {
2
- text-align: left;
3
- font-family: sans-serif;
4
- font-size: 14px;
5
- line-height: normal;
6
- }
7
-
8
- .newsletter p {
9
- margin: 0 0 10px 0;
10
- padding: 0;
11
- }
12
-
13
- .newsletter input, .newsletter select {
14
- border: 1px solid #ccc;
15
- border-radius: 5px;
16
- padding: 5px 8px 5px 8px;
17
- color: #666;
18
- background-color: #fff!important;
19
- box-shadow: none;
20
- line-height: normal;
21
- font-size: 14px;
22
- font-family: sans-serif;
23
- }
24
-
25
- .newsletter option {
26
- padding-left: 0;
27
- margin-left: 0;
28
- }
29
- .newsletter .newsletter-email {
30
-
31
- }
32
-
33
- .newsletter .newsletter-firstname {
34
-
35
- }
36
-
37
- .newsletter .newsletter-lastname {
38
-
39
- }
40
-
41
- .newsletter .newsletter-sex {
42
-
43
- }
44
-
45
- .newsletter .newsletter-profile {
46
-
47
- }
48
-
49
- .newsletter .newsletter-submit {
50
- border: 1px solid #ccc;
51
- border-radius: 3px;
52
- background-image: url(widget-neutral/button.png);
53
- color: #fff;
54
- }
55
-
56
- .newsletter td {
57
- border: 0;
58
- }
59
-
60
- .newsletter table {
61
- border: 0;
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
subscription/styles/shortcode/default.css DELETED
@@ -1,36 +0,0 @@
1
- .newsletter-form {
2
- width: 100%;
3
- display: block;
4
- margin: 15px 0;
5
- border: 0;
6
- }
7
-
8
- .newsletter-field {
9
- clear: both;
10
- text-align: left;
11
- }
12
-
13
- .newsletter-field label {
14
- display: block;
15
- font-size: 14px;
16
- line-height: normal;
17
- }
18
-
19
- .newsletter-field input, .newsletter-field select {
20
- padding: 5px;
21
- font-size: 14px;
22
- margin-right: 0;
23
- line-height: normal;
24
- border: 1px solid rgba(0,0,0,.1);
25
- border-radius: 2px;
26
- }
27
-
28
- .newsletter-field-checkbox label, .newsletter-field-preference label, .newsletter-field-list label {
29
- text-align: left;
30
- display: inline;
31
- padding-left: 1em;
32
- }
33
-
34
- @media all and (max-width: 480px) {
35
- }
36
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
subscription/styles/white.css DELETED
@@ -1,34 +0,0 @@
1
- .newsletter {
2
- text-align: center;
3
- }
4
-
5
- .newsletter table {
6
- margin-left: auto;
7
- margin-right: auto;
8
- text-align: left;
9
- border: 1px solid #eee;
10
- background-color: #fff;
11
- box-shadow: 0px 0px 10px #999;
12
- padding: 10px;
13
- width: auto;
14
- }
15
-
16
- .newsletter th, .newsletter td {
17
- padding: 10px;
18
- border: 0;
19
- }
20
-
21
- .newsletter th {
22
- text-align: right;
23
- }
24
-
25
- .newsletter-td-submit {
26
- text-align: center;
27
- }
28
-
29
- .newsletter-submit {
30
- font-size: 18px;
31
- background-color: #eee;
32
- padding: 10px;
33
- border: 1px solid #ddd;
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
subscription/styles/widget-neutral.css DELETED
@@ -1,54 +0,0 @@
1
- .newsletter-widget {
2
- text-align: left;
3
- font-family: sans-serif;
4
- font-size: 14px;
5
- line-height: normal;
6
- }
7
-
8
- .newsletter-widget p {
9
- margin: 0 0 10px 0!important;
10
- padding: 0;
11
- }
12
-
13
- .newsletter-widget input, .newsletter-widget select {
14
- border: 1px solid #ccc;
15
- border-radius: 5px;
16
- padding: 5px 8px 5px 8px;
17
- color: #666;
18
- background-color: #fff!important;
19
- box-shadow: none;
20
- line-height: normal;
21
- font-size: 14px;
22
- font-family: sans-serif;
23
- }
24
-
25
- .newsletter-widget option {
26
- padding-left: 0;
27
- margin-left: 0;
28
- }
29
- .newsletter-widget .newsletter-email {
30
-
31
- }
32
-
33
- .newsletter-widget .newsletter-firstname {
34
-
35
- }
36
-
37
- .newsletter-widget .newsletter-lastname {
38
-
39
- }
40
-
41
- .newsletter-widget .newsletter-sex {
42
-
43
- }
44
-
45
- .newsletter-widget .newsletter-profile {
46
-
47
- }
48
-
49
- .newsletter-widget .newsletter-submit {
50
- border: 1px solid #ccc;
51
- border-radius: 3px;
52
- background-image: url(widget-neutral/button.png);
53
- color: #fff;
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
subscription/styles/widget-neutral/button.png DELETED
Binary file
subscription/subscription.php CHANGED
@@ -9,7 +9,6 @@ class NewsletterSubscription extends NewsletterModule {
9
 
10
  const MESSAGE_CONFIRMED = 'confirmed';
11
 
12
- // var $options_lock;
13
  static $instance;
14
 
15
  /**
@@ -24,7 +23,7 @@ class NewsletterSubscription extends NewsletterModule {
24
 
25
  function __construct() {
26
 
27
- parent::__construct('subscription', '2.0.2');
28
 
29
  // Must be called after the Newsletter::hook_init, since some constants are defined
30
  // there.
@@ -33,12 +32,35 @@ class NewsletterSubscription extends NewsletterModule {
33
 
34
  function hook_init() {
35
  add_action('wp_loaded', array($this, 'hook_wp_loaded'));
36
- //add_action('delete_user', array($this, 'hook_delete_user'));
 
 
 
 
 
 
 
 
 
 
 
37
 
38
- add_shortcode('newsletter_profile', array($this, 'shortcode_profile'));
39
- add_shortcode('newsletter_field', array($this, 'shortcode_field'));
40
- add_action('wp_footer', array($this, 'hook_wp_footer'));
41
- //add_shortcode('newsletter_lock', array($this, 'shortcode_newsletter_lock'));
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
  function hook_wp_loaded() {
@@ -48,9 +70,9 @@ class NewsletterSubscription extends NewsletterModule {
48
  case 'm':
49
  include dirname(__FILE__) . '/page.php';
50
  die();
51
-
52
- case 's':
53
 
 
 
54
  if (isset($this->options['antibot_disable']) || $this->antibot_form_check()) {
55
 
56
  $user = $this->subscribe();
@@ -68,7 +90,24 @@ class NewsletterSubscription extends NewsletterModule {
68
  $this->request_to_antibot_form('Subscribe');
69
  }
70
  die();
71
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  case 'u':
73
  $user = $this->get_user_from_request();
74
  $email = $this->get_email_from_request();
@@ -78,7 +117,7 @@ class NewsletterSubscription extends NewsletterModule {
78
  $this->show_message('unsubscription', $user, null, $email);
79
  }
80
  die();
81
-
82
  case 'uc':
83
  if ($this->antibot_form_check()) {
84
  $user = $this->unsubscribe();
@@ -131,6 +170,14 @@ class NewsletterSubscription extends NewsletterModule {
131
  }
132
  }
133
 
 
 
 
 
 
 
 
 
134
  function upgrade() {
135
  global $wpdb, $charset_collate, $newsletter;
136
 
@@ -139,8 +186,6 @@ class NewsletterSubscription extends NewsletterModule {
139
  $this->init_options('profile');
140
  $this->init_options('lists');
141
 
142
-
143
-
144
  $default_options = $this->get_default_options();
145
 
146
  if (empty($this->options['error_text'])) {
@@ -167,25 +212,27 @@ class NewsletterSubscription extends NewsletterModule {
167
  update_option('newsletter_profile', $options_profile);
168
  }
169
 
170
- // Very old...
171
- if (!isset($this->options['url']) && !empty($newsletter->options['url'])) {
172
- $this->options['url'] = $newsletter->options['url'];
173
- $this->save_options($this->options);
174
- }
175
 
176
- $options_template = $this->get_options('template');
177
- if (empty($options_template) && isset($this->options['template'])) {
178
- $options_template['enabled'] = isset($this->options['template_enabled']) ? 1 : 0;
179
- $options_template['template'] = $this->options['template'];
180
- add_option('newsletter_subscription_template', $options_template, null, 'no');
 
 
 
 
 
 
 
181
  }
182
- $this->init_options('template', false);
183
 
184
- if (isset($this->options['template'])) {
185
- unset($this->options['template']);
186
- unset($this->options['template_enabled']);
187
- $this->save_options($this->options);
188
- }
189
 
190
  return true;
191
  }
@@ -193,19 +240,12 @@ class NewsletterSubscription extends NewsletterModule {
193
  function admin_menu() {
194
  $this->add_menu_page('options', 'List building');
195
  $this->add_admin_page('profile', 'Subscription Form');
196
- //$this->add_admin_page('lock', 'Locked content');
197
- // $this->add_admin_page('wpusers', 'WP Registration');
198
  $this->add_admin_page('forms', 'Forms');
199
  $this->add_admin_page('lists', 'Lists');
200
  $this->add_admin_page('template', 'Template');
201
  $this->add_admin_page('unsubscription', 'Unsubscription');
202
  }
203
 
204
-
205
- function hook_wp_footer() {
206
-
207
- }
208
-
209
  /**
210
  * This method has been redefined for compatibility with the old options naming. It would
211
  * be better to change them instead. The subscription options should be named
@@ -696,7 +736,7 @@ class NewsletterSubscription extends NewsletterModule {
696
  }
697
 
698
  if (isset($_REQUEST['ncu'])) {
699
- $this->options['confirmation_url'] = $_REQUEST['ncu'];
700
  }
701
 
702
  if ($email) {
@@ -710,14 +750,20 @@ class NewsletterSubscription extends NewsletterModule {
710
  die();
711
  }
712
 
713
- // Is there a dedicated page?
714
- if (!empty($this->options['url'])) {
715
- header('Location: ' . self::add_qs($this->options['url'], 'nm=' . $key . '&nk=' . $user->id . '-' . $user->token, false) . $params);
716
- die();
717
  }
718
 
719
- // Use the standard page.
720
- header('Location: ' . home_url('/') . '?na=m&nm=' . $key . '&nk=' . $user->id . '-' . $user->token . $params);
 
 
 
 
 
 
 
 
721
  die();
722
  }
723
 
@@ -880,20 +926,25 @@ class NewsletterSubscription extends NewsletterModule {
880
  }
881
 
882
  function _shortcode_label($name, $attrs, $suffix = null) {
883
- if (!$suffix)
884
  $suffix = $name;
 
885
  $options_profile = get_option('newsletter_profile');
886
  $buffer = '<label for="newsletter-' . $suffix . '">';
887
- if (isset($attrs['label']) && $attrs['label'] != '') {
888
- $buffer .= $attrs['label'];
 
 
 
 
889
  } else {
890
- $buffer .= $options_profile[$name];
891
  }
892
  $buffer .= "</label>\n";
893
  return $buffer;
894
  }
895
 
896
- function shortcode_field($attrs, $content) {
897
  $options_profile = get_option('newsletter_profile');
898
  $name = $attrs['name'];
899
 
@@ -903,29 +954,34 @@ class NewsletterSubscription extends NewsletterModule {
903
  $buffer .= '<div class="newsletter-field newsletter-field-email">';
904
  $buffer .= $this->_shortcode_label('email', $attrs);
905
 
906
- $buffer .= '<input class="newsletter-email" id="newsletter-email" type="email" name="ne" required style="width: 69%">';
 
 
 
907
  if (isset($attrs['button_label'])) {
908
  $label = $attrs['button_label'];
909
  if (strpos($label, 'http') === 0) {
910
- $buffer .= ' <input class="newsletter-button-image" type="image" src="' . $label . '">';
911
  } else {
912
- $buffer .= ' <input class="newsletter-button" type="submit" value="' . $label . '" style="width: 29%">';
913
  }
914
  }
915
- $buffer .= '</div>';
916
  return $buffer;
917
  }
918
 
919
  if ($name == 'first_name' || $name == 'name') {
920
- $buffer .= '<div class="newsletter-field newsletter-field-name">';
921
  $buffer .= $this->_shortcode_label('name', $attrs);
922
 
923
- $buffer .= '<input class="newsletter-name" type="text" name="nn" id="newsletter-name"';
 
 
924
  if ($options_profile['name_rules'] == 1) {
925
  $buffer .= ' required';
926
  }
927
  $buffer .= '>';
928
- $buffer .= '</div>';
929
  return $buffer;
930
  }
931
 
@@ -933,7 +989,9 @@ class NewsletterSubscription extends NewsletterModule {
933
  $buffer .= '<div class="newsletter-field newsletter-field-surname">';
934
  $buffer .= $this->_shortcode_label('surname', $attrs);
935
 
936
- $buffer .= '<input class="newsletter-surname" type="text" name="ns" id="newsletter-surname"';
 
 
937
  if ($options_profile['surname_rules'] == 1) {
938
  $buffer .= ' required';
939
  }
@@ -959,11 +1017,12 @@ class NewsletterSubscription extends NewsletterModule {
959
  } else {
960
  $buffer .= '<label for="nl' . esc_attr($list) . '">' . esc_html($options_profile['list_' . $list]) . '</label>';
961
  }
962
- $buffer .= '</div>';
963
 
964
  return $buffer;
965
  }
966
 
 
967
  if ($name == 'lists' || $name == 'preferences') {
968
  $lists = '';
969
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
@@ -975,7 +1034,7 @@ class NewsletterSubscription extends NewsletterModule {
975
  if ($options_profile['list_' . $i . '_checked'] == 1)
976
  $lists .= ' checked';
977
  $lists .= '> <label for="nl' . $i . '>' . esc_html($options_profile['list_' . $i]) . '</label>';
978
- $lists .= '</div>';
979
  }
980
  return $lists;
981
  }
@@ -994,7 +1053,7 @@ class NewsletterSubscription extends NewsletterModule {
994
  $buffer .= '<option value="m">' . esc_html($options_profile['sex_male']) . '</option>';
995
  $buffer .= '<option value="f">' . esc_html($options_profile['sex_female']) . '</option>';
996
  $buffer .= '</select>';
997
- $buffer .= '</div>';
998
  return $buffer;
999
  }
1000
 
@@ -1005,10 +1064,10 @@ class NewsletterSubscription extends NewsletterModule {
1005
  $buffer .= '<div class="newsletter-field newsletter-field-profile">';
1006
  if (isset($attrs['label'])) {
1007
  if ($attrs['label'] != '') {
1008
- $buffer .= '<label for="">' . esc_html($attrs['label']) . '</label>';
1009
  }
1010
  } else {
1011
- $buffer .= '<label for="">' . $options_profile['profile_' . $number] . '</label>';
1012
  }
1013
  $placeholder = isset($attrs['placeholder']) ? $attrs['placeholder'] : $options_profile['profile_' . $number . '_placeholder'];
1014
 
@@ -1037,10 +1096,10 @@ class NewsletterSubscription extends NewsletterModule {
1037
  for ($j = 0; $j < count($opts); $j++) {
1038
  $buffer .= '<option>' . esc_html(trim($opts[$j])) . '</option>';
1039
  }
1040
- $buffer .= '</select>';
1041
  }
1042
 
1043
- $buffer .= '</div>';
1044
 
1045
  return $buffer;
1046
  }
@@ -1226,6 +1285,14 @@ class NewsletterSubscription extends NewsletterModule {
1226
  return $buffer;
1227
  }
1228
 
 
 
 
 
 
 
 
 
1229
  function get_subscription_form_html5($referrer = null, $action = null, $attrs = array()) {
1230
  if (isset($attrs['action'])) {
1231
  $action = $attrs['action'];
@@ -1239,15 +1306,15 @@ class NewsletterSubscription extends NewsletterModule {
1239
  $buffer = $this->get_form_javascript();
1240
 
1241
  if (empty($action)) {
1242
- $action = esc_attr(home_url('/') . '?na=s');
1243
  }
1244
 
1245
- $buffer .= '<div class="newsletter newsletter-subscription">' . "\n";
1246
 
1247
- $buffer .= '<form method="post" action="' . $action . '" onsubmit="return newsletter_check(this)">' . "\n\n";
1248
 
1249
  if (!empty($referrer)) {
1250
- $buffer .= "<input type='hidden' name='nr' value='$referrer'>\n";
1251
  }
1252
  if (isset($attrs['confirmation_url'])) {
1253
  $buffer .= "<input type='hidden' name='ncu' value='" . esc_attr($attrs['confirmation_url']) . "'>\n";
@@ -1256,31 +1323,36 @@ class NewsletterSubscription extends NewsletterModule {
1256
  if (isset($attrs['list'])) {
1257
  $arr = explode(',', $attrs['list']);
1258
  foreach ($arr as $a) {
1259
- $buffer .= "<input type='hidden' name='nl[]' value='" . esc_attr(trim($a)) . "'>\n";
1260
  }
1261
  }
1262
 
1263
  if ($options_profile['name_status'] == 2) {
1264
- $buffer .= '<div class="newsletter-field newsletter-field-name"><label>' . $options_profile['name'] . '</label>';
1265
  $buffer .= '<input class="newsletter-name" type="text" name="nn" ' . ($options_profile['name_rules'] == 1 ? 'required' : '') . '></div>';
1266
  $buffer .= "\n";
1267
  }
1268
 
1269
  if ($options_profile['surname_status'] == 2) {
1270
- $buffer .= '<div class="newsletter-field newsletter-field-lastname"><label>' . $options_profile['surname'] . '</label>';
1271
  $buffer .= '<input class="newsletter-lastname" type="text" name="ns" ' . ($options_profile['surname_rules'] == 1 ? 'required' : '') . '></div>';
1272
  $buffer .= "\n";
1273
  }
1274
 
1275
- $buffer .= '<div class="newsletter-field newsletter-field-email"><label>' . $options_profile['email'] . '</label>';
1276
  $buffer .= '<input class="newsletter-email" type="email" name="ne" required></div>';
1277
  $buffer .= "\n";
1278
 
1279
  if ($options_profile['sex_status'] == 2) {
1280
- $buffer .= '<div class="newsletter-field newsletter-field-gender"><label>' . $options_profile['sex'] . '</label>';
1281
- $buffer .= '<select name="nx" class="newsletter-sex">';
1282
- $buffer .= '<option value="m">' . $options_profile['sex_male'] . '</option>';
1283
- $buffer .= '<option value="f">' . $options_profile['sex_female'] . '</option>';
 
 
 
 
 
1284
  $buffer .= '</select></div>';
1285
  $buffer .= "\n";
1286
  }
@@ -1290,11 +1362,11 @@ class NewsletterSubscription extends NewsletterModule {
1290
  if ($options_profile['list_' . $i . '_status'] != 2) {
1291
  continue;
1292
  }
1293
- $lists .= "\t\t" . '<div class="newsletter-field newsletter-field-list"><label><input class="newsletter-preference" type="checkbox" name="nl[]" value="' . $i . '"';
1294
  if ($options_profile['list_' . $i . '_checked'] == 1) {
1295
  $lists .= ' checked';
1296
  }
1297
- $lists .= '/>&nbsp;' . $options_profile['list_' . $i] . '</label></div>';
1298
  }
1299
  if (!empty($lists)) {
1300
  $buffer .= '<div class="newsletter-lists">' . $lists . '</div>';
@@ -1309,22 +1381,20 @@ class NewsletterSubscription extends NewsletterModule {
1309
 
1310
 
1311
  $buffer .= '<div class="newsletter-field newsletter-field-profile"><label>' .
1312
- $options_profile['profile_' . $i] . '</label>';
1313
 
1314
  // Text field
1315
  if ($options_profile['profile_' . $i . '_type'] == 'text') {
1316
- $buffer .= '<div class="newsletter-field newsletter-field-profile"><label>' .
1317
- $options_profile['profile_' . $i] . "</label>' . "
1318
- . '<input class="newsletter-profile newsletter-profile-' . $i . '" type="text" name="np' . $i . '">' .
1319
- "\n";
1320
  }
1321
 
1322
  // Select field
1323
  if ($options_profile['profile_' . $i . '_type'] == 'select') {
1324
- $buffer .= '<select class="newsletter-profile newsletter-profile-' . $i . '" name="np' . $i . '">' . "\n";
 
1325
  $opts = explode(',', $options_profile['profile_' . $i . '_options']);
1326
  for ($j = 0; $j < count($opts); $j++) {
1327
- $buffer .= "<option>" . trim($opts[$j]) . "</option>\n";
1328
  }
1329
  $buffer .= "</select>\n";
1330
  }
@@ -1332,44 +1402,45 @@ class NewsletterSubscription extends NewsletterModule {
1332
  }
1333
 
1334
  $extra = apply_filters('newsletter_subscription_extra', array());
1335
- foreach ($extra as &$x) {
1336
  $label = $x['label'];
1337
  if (empty($label)) {
1338
  $label = '&nbsp;';
1339
  }
1340
  $name = '';
1341
- if (!empty($x['name']))
1342
  $name = $x['name'];
 
1343
  $buffer .= '<div class="newsletter-field newsletter-field-' . $name . '"><label>' . $label . "</label>";
1344
  $buffer .= $x['field'] . "</div>\n";
1345
  }
1346
 
1347
  if ($options_profile['privacy_status'] == 1) {
1348
- $buffer .= "<p class='newsletter-privacy-div'>\n\t";
1349
- $buffer .= '<input type="checkbox" name="ny" required class="newsletter-privacy">&nbsp;';
1350
  if (!empty($options_profile['privacy_url'])) {
1351
- $buffer .= '<label><a target="_blank" href="' . $options_profile['privacy_url'] . '"></label>';
1352
- $buffer .= $options_profile['privacy'] . '</a>';
1353
  } else {
1354
- $buffer .= '<label>' . $options_profile['privacy'] . '</label>';
1355
  }
1356
- $buffer .= '</div>';
1357
- $buffer .= "\n";
1358
  }
1359
 
1360
  $buffer .= '<div class="newsletter-field newsletter-field-button">';
1361
 
1362
  if (strpos($options_profile['subscribe'], 'http://') !== false) {
1363
- $buffer .= "\t\t" . '<input class="newsletter-submit-image" type="image" src="' . $options_profile['subscribe'] . '">' . "\n\t";
1364
  } else {
1365
- $buffer .= "\t\t" . '<input class="newsletter-submit" type="submit" value="' . $options_profile['subscribe'] . '">' . "\n\t";
1366
  }
1367
 
1368
  $buffer .= "</div>\n</form>\n</div>";
1369
  return $buffer;
1370
  }
1371
 
1372
- function shortcode_profile($attrs, $content) {
1373
  $user = $this->check_user();
1374
 
1375
  if (empty($user)) {
@@ -1380,7 +1451,11 @@ class NewsletterSubscription extends NewsletterModule {
1380
  }
1381
  }
1382
 
1383
- return $this->get_profile_form($user);
 
 
 
 
1384
  }
1385
 
1386
  /**
@@ -1472,6 +1547,113 @@ class NewsletterSubscription extends NewsletterModule {
1472
  return $buffer;
1473
  }
1474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1475
  function get_form($number) {
1476
  $options = get_option('newsletter_forms');
1477
 
@@ -1554,99 +1736,112 @@ class NewsletterSubscription extends NewsletterModule {
1554
  Newsletter::instance()->mail($email, '[' . $blogname . '] ' . $subject, array('text' => $message));
1555
  }
1556
 
1557
- }
 
 
 
 
1558
 
1559
- NewsletterSubscription::instance();
 
 
 
 
 
 
1560
 
1561
- // TODO: Remove in version 3.5. For compatibility.
1562
- add_shortcode('newsletter_embed', 'newsletter_shortcode_form');
1563
 
1564
- add_shortcode('newsletter_form', 'newsletter_shortcode_form');
1565
 
1566
- function newsletter_shortcode_form($attrs, $content) {
1567
- if (!empty($content)) {
1568
- return NewsletterSubscription::instance()->shortcode_subscription($attrs, $content);
1569
- }
1570
- if (isset($attrs['form'])) {
1571
- return NewsletterSubscription::instance()->get_form((int) $attrs['form']);
1572
- } else if (isset($attrs['number'])) {
1573
- return NewsletterSubscription::instance()->get_form((int) $attrs['number']);
1574
- } else {
1575
- if (isset($attrs['layout']) && $attrs['layout'] == 'html5') {
1576
- return NewsletterSubscription::instance()->get_subscription_form_html5(null, null, $attrs);
1577
  } else {
1578
- return NewsletterSubscription::instance()->get_subscription_form(null, null, $attrs);
 
 
 
 
1579
  }
1580
  }
1581
- }
1582
-
1583
- add_shortcode('newsletter', 'newsletter_shortcode');
1584
 
1585
- /**
1586
- *
1587
- * @global type $wpdb
1588
- * @global boolean $cache_stop
1589
- * @global Newsletter $newsletter
1590
- * @param type $attrs
1591
- * @param type $content
1592
- * @return string
1593
- */
1594
- function newsletter_shortcode($attrs, $content) {
1595
- global $wpdb, $cache_stop, $newsletter;
1596
 
1597
- $cache_stop = true;
1598
 
1599
- $module = NewsletterSubscription::instance();
1600
- $user = $module->get_user_from_request();
1601
- $message_key = $module->get_message_key_from_request();
1602
 
1603
  // if ($message_key != 'subscription' && $user == null) {
1604
  // die('Invalid subscriber');
1605
  // }
1606
 
1607
 
1608
- $message = $module->options[$message_key . '_text'];
1609
 
1610
- // TODO: the if can be removed
1611
- if ($message_key == 'confirmed') {
1612
- $message .= $module->options[$message_key . '_tracking'];
1613
- }
1614
 
1615
- // Now check what form must be added
1616
- if ($message_key == 'subscription') {
1617
 
1618
- // Compatibility check
1619
- if (stripos($message, '<form') !== false) {
1620
- $message .= $module->get_form_javascript();
1621
- $message = str_ireplace('<form', '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)"', $message);
1622
- } else {
1623
 
1624
- if (strpos($message, '{subscription_form') === false) {
1625
- $message .= '{subscription_form}';
1626
- }
1627
 
1628
- if (isset($attrs['form'])) {
1629
- $message = str_replace('{subscription_form}', $module->get_form($attrs['form']), $message);
1630
- } else {
1631
- if (isset($attrs['layout']) && $attrs['layout'] == 'html5') {
1632
- $message = str_replace('{subscription_form}', $module->get_subscription_form_html5('page'), $message);
1633
  } else {
1634
- $message = str_replace('{subscription_form}', $module->get_subscription_form('page'), $message);
 
 
 
 
1635
  }
1636
  }
1637
  }
1638
- }
1639
 
1640
- $email = NewsletterSubscription::instance()->get_email_from_request();
1641
 
1642
- $message = $newsletter->replace($message, $user, $email, 'page');
 
 
 
 
 
1643
 
1644
- if (isset($_REQUEST['alert'])) {
1645
- // slashes are already added by wordpress!
1646
- $message .= '<script>alert("' . strip_tags($_REQUEST['alert']) . '");</script>';
1647
  }
1648
 
1649
- return $message;
1650
  }
1651
 
1652
  NewsletterSubscription::instance();
9
 
10
  const MESSAGE_CONFIRMED = 'confirmed';
11
 
 
12
  static $instance;
13
 
14
  /**
23
 
24
  function __construct() {
25
 
26
+ parent::__construct('subscription', '2.0.3');
27
 
28
  // Must be called after the Newsletter::hook_init, since some constants are defined
29
  // there.
32
 
33
  function hook_init() {
34
  add_action('wp_loaded', array($this, 'hook_wp_loaded'));
35
+ if (is_admin()) {
36
+ // Something
37
+ } else {
38
+ add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts'));
39
+ add_action('wp_head', array($this, 'hook_wp_head'));
40
+ add_action('wp_footer', array($this, 'hook_wp_footer'));
41
+ add_shortcode('newsletter', array($this, 'shortcode_newsletter'));
42
+ add_shortcode('newsletter_form', array($this, 'shortcode_newsletter_form'));
43
+ add_shortcode('newsletter_profile', array($this, 'shortcode_newsletter_profile'));
44
+ add_shortcode('newsletter_field', array($this, 'shortcode_newsletter_field'));
45
+ }
46
+ }
47
 
48
+ function hook_wp_enqueue_scripts() {
49
+ if (apply_filters('newsletter_enqueue_style', true)) {
50
+ wp_enqueue_style('newsletter-subscription', plugins_url('newsletter') . '/subscription/style.css');
51
+ }
52
+
53
+ wp_enqueue_script('newsletter-subscription', plugins_url('newsletter') . '/subscription/validate.js', array(), null, true);
54
+ $options = $this->get_options('profile');
55
+ $data = array();
56
+ $data['messages'] = array();
57
+ $data['messages']['email_error'] = $options['email_error'];
58
+ $data['messages']['name_error'] = $options['name_error'];
59
+ $data['messages']['surname_error'] = $options['surname_error'];
60
+ $data['messages']['profile_error'] = $options['profile_error'];
61
+ $data['messages']['privacy_error'] = $options['privacy_error'];
62
+ $data['profile_max'] = NEWSLETTER_PROFILE_MAX;
63
+ wp_localize_script('newsletter-subscription', 'newsletter', $data);
64
  }
65
 
66
  function hook_wp_loaded() {
70
  case 'm':
71
  include dirname(__FILE__) . '/page.php';
72
  die();
 
 
73
 
74
+ // normal subscription
75
+ case 's':
76
  if (isset($this->options['antibot_disable']) || $this->antibot_form_check()) {
77
 
78
  $user = $this->subscribe();
90
  $this->request_to_antibot_form('Subscribe');
91
  }
92
  die();
93
+
94
+ // AJAX subscription
95
+ case 'ajaxsub':
96
+ $user = $this->subscribe();
97
+ if ($user->status == 'E')
98
+ $key = 'error';
99
+ if ($user->status == 'C')
100
+ $key = 'confirmed';
101
+ if ($user->status == 'A')
102
+ $key = 'already_confirmed';
103
+ if ($user->status == 'S')
104
+ $key = 'confirmation';
105
+ $module = NewsletterSubscription::instance();
106
+ $message = $newsletter->replace($module->options[$key . '_text'], $user);
107
+ $message .= $module->options[$key . '_tracking'];
108
+ echo $message;
109
+ die();
110
+
111
  case 'u':
112
  $user = $this->get_user_from_request();
113
  $email = $this->get_email_from_request();
117
  $this->show_message('unsubscription', $user, null, $email);
118
  }
119
  die();
120
+ break;
121
  case 'uc':
122
  if ($this->antibot_form_check()) {
123
  $user = $this->unsubscribe();
170
  }
171
  }
172
 
173
+ function hook_wp_head() {
174
+
175
+ }
176
+
177
+ function hook_wp_footer() {
178
+ // Consider this: http://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript
179
+ }
180
+
181
  function upgrade() {
182
  global $wpdb, $charset_collate, $newsletter;
183
 
186
  $this->init_options('profile');
187
  $this->init_options('lists');
188
 
 
 
189
  $default_options = $this->get_default_options();
190
 
191
  if (empty($this->options['error_text'])) {
212
  update_option('newsletter_profile', $options_profile);
213
  }
214
 
215
+ if ($this->old_version < '2.0.0') {
216
+ if (!isset($this->options['url']) && !empty($newsletter->options['url'])) {
217
+ $this->options['url'] = $newsletter->options['url'];
218
+ $this->save_options($this->options);
219
+ }
220
 
221
+ $options_template = $this->get_options('template');
222
+ if (empty($options_template) && isset($this->options['template'])) {
223
+ $options_template['enabled'] = isset($this->options['template_enabled']) ? 1 : 0;
224
+ $options_template['template'] = $this->options['template'];
225
+ add_option('newsletter_subscription_template', $options_template, null, 'no');
226
+ }
227
+
228
+ if (isset($this->options['template'])) {
229
+ unset($this->options['template']);
230
+ unset($this->options['template_enabled']);
231
+ $this->save_options($this->options);
232
+ }
233
  }
 
234
 
235
+ $this->init_options('template', false);
 
 
 
 
236
 
237
  return true;
238
  }
240
  function admin_menu() {
241
  $this->add_menu_page('options', 'List building');
242
  $this->add_admin_page('profile', 'Subscription Form');
 
 
243
  $this->add_admin_page('forms', 'Forms');
244
  $this->add_admin_page('lists', 'Lists');
245
  $this->add_admin_page('template', 'Template');
246
  $this->add_admin_page('unsubscription', 'Unsubscription');
247
  }
248
 
 
 
 
 
 
249
  /**
250
  * This method has been redefined for compatibility with the old options naming. It would
251
  * be better to change them instead. The subscription options should be named
736
  }
737
 
738
  if (isset($_REQUEST['ncu'])) {
739
+ $this->options['confirmation_url'] = esc_url($_REQUEST['ncu']);
740
  }
741
 
742
  if ($email) {
750
  die();
751
  }
752
 
753
+ if (!empty($this->options['page'])) {
754
+ $url = get_permalink($this->options['page']);
 
 
755
  }
756
 
757
+ // Old URL
758
+ if (!$url && !empty($this->options['url'])) {
759
+ $url = $this->options['url'];
760
+ }
761
+
762
+ if (!$url) {
763
+ $url = home_url('/') . '?na=m';
764
+ }
765
+
766
+ header('Location: ' . self::add_qs($url, 'nm=' . $key . '&nk=' . $user->id . '-' . $user->token, false) . $params);
767
  die();
768
  }
769
 
926
  }
927
 
928
  function _shortcode_label($name, $attrs, $suffix = null) {
929
+ if (!$suffix) {
930
  $suffix = $name;
931
+ }
932
  $options_profile = get_option('newsletter_profile');
933
  $buffer = '<label for="newsletter-' . $suffix . '">';
934
+ if (isset($attrs['label'])) {
935
+ if (empty($attrs['label'])) {
936
+ return;
937
+ } else {
938
+ $buffer .= esc_html($attrs['label']);
939
+ }
940
  } else {
941
+ $buffer .= esc_html($options_profile[$name]);
942
  }
943
  $buffer .= "</label>\n";
944
  return $buffer;
945
  }
946
 
947
+ function shortcode_newsletter_field($attrs, $content) {
948
  $options_profile = get_option('newsletter_profile');
949
  $name = $attrs['name'];
950
 
954
  $buffer .= '<div class="newsletter-field newsletter-field-email">';
955
  $buffer .= $this->_shortcode_label('email', $attrs);
956
 
957
+ $buffer .= '<input class="newsletter-email" type="email" name="ne" value=""';
958
+ if (isset($attrs['placeholder']))
959
+ $buffer .= ' placeholder="' . esc_attr($attrs['placeholder']) . '"';
960
+ $buffer .= 'required>';
961
  if (isset($attrs['button_label'])) {
962
  $label = $attrs['button_label'];
963
  if (strpos($label, 'http') === 0) {
964
+ $buffer .= ' <input class="newsletter-button-image" type="image" src="' . esc_attr(esc_url_raw($label)) . '">';
965
  } else {
966
+ $buffer .= ' <input class="newsletter-button" type="submit" value="' . esc_attr($label) . '" style="width: 29%">';
967
  }
968
  }
969
+ $buffer .= "</div>\n";
970
  return $buffer;
971
  }
972
 
973
  if ($name == 'first_name' || $name == 'name') {
974
+ $buffer .= '<div class="newsletter-field newsletter-field-firstname">';
975
  $buffer .= $this->_shortcode_label('name', $attrs);
976
 
977
+ $buffer .= '<input class="newsletter-name" type="text" name="nn" value=""';
978
+ if (isset($attrs['placeholder']))
979
+ $buffer .= ' placeholder="' . esc_attr($attrs['placeholder']) . '"';
980
  if ($options_profile['name_rules'] == 1) {
981
  $buffer .= ' required';
982
  }
983
  $buffer .= '>';
984
+ $buffer .= "</div>\n";
985
  return $buffer;
986
  }
987
 
989
  $buffer .= '<div class="newsletter-field newsletter-field-surname">';
990
  $buffer .= $this->_shortcode_label('surname', $attrs);
991
 
992
+ $buffer .= '<input class="newsletter-surname" type="text" name="ns" value=""';
993
+ if (isset($attrs['placeholder']))
994
+ $buffer .= ' placeholder="' . esc_attr($attrs['placeholder']) . '"';
995
  if ($options_profile['surname_rules'] == 1) {
996
  $buffer .= ' required';
997
  }
1017
  } else {
1018
  $buffer .= '<label for="nl' . esc_attr($list) . '">' . esc_html($options_profile['list_' . $list]) . '</label>';
1019
  }
1020
+ $buffer .= "</div>\n";
1021
 
1022
  return $buffer;
1023
  }
1024
 
1025
+ // All the lists
1026
  if ($name == 'lists' || $name == 'preferences') {
1027
  $lists = '';
1028
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
1034
  if ($options_profile['list_' . $i . '_checked'] == 1)
1035
  $lists .= ' checked';
1036
  $lists .= '> <label for="nl' . $i . '>' . esc_html($options_profile['list_' . $i]) . '</label>';
1037
+ $lists .= "</div>\n";
1038
  }
1039
  return $lists;
1040
  }
1053
  $buffer .= '<option value="m">' . esc_html($options_profile['sex_male']) . '</option>';
1054
  $buffer .= '<option value="f">' . esc_html($options_profile['sex_female']) . '</option>';
1055
  $buffer .= '</select>';
1056
+ $buffer .= "</div>\n";
1057
  return $buffer;
1058
  }
1059
 
1064
  $buffer .= '<div class="newsletter-field newsletter-field-profile">';
1065
  if (isset($attrs['label'])) {
1066
  if ($attrs['label'] != '') {
1067
+ $buffer .= '<label>' . esc_html($attrs['label']) . '</label>';
1068
  }
1069
  } else {
1070
+ $buffer .= '<label>' . esc_html($options_profile['profile_' . $number]) . '</label>';
1071
  }
1072
  $placeholder = isset($attrs['placeholder']) ? $attrs['placeholder'] : $options_profile['profile_' . $number . '_placeholder'];
1073
 
1096
  for ($j = 0; $j < count($opts); $j++) {
1097
  $buffer .= '<option>' . esc_html(trim($opts[$j])) . '</option>';
1098
  }
1099
+ $buffer .= "</select>\n";
1100
  }
1101
 
1102
+ $buffer .= "</div>\n";
1103
 
1104
  return $buffer;
1105
  }
1285
  return $buffer;
1286
  }
1287
 
1288
+ /**
1289
+ * The new standard form.
1290
+ *
1291
+ * @param type $referrer
1292
+ * @param type $action
1293
+ * @param type $attrs
1294
+ * @return string
1295
+ */
1296
  function get_subscription_form_html5($referrer = null, $action = null, $attrs = array()) {
1297
  if (isset($attrs['action'])) {
1298
  $action = $attrs['action'];
1306
  $buffer = $this->get_form_javascript();
1307
 
1308
  if (empty($action)) {
1309
+ $action = home_url('/') . '?na=s';
1310
  }
1311
 
1312
+ $buffer .= '<div class="newsletter-subscription">' . "\n";
1313
 
1314
+ $buffer .= '<form method="post" action="' . esc_attr($action) . '" onsubmit="return newsletter_check(this)">' . "\n\n";
1315
 
1316
  if (!empty($referrer)) {
1317
+ $buffer .= '<input type="hidden" name="nr" value="' . esc_attr($referrer) . '">' . "\n";
1318
  }
1319
  if (isset($attrs['confirmation_url'])) {
1320
  $buffer .= "<input type='hidden' name='ncu' value='" . esc_attr($attrs['confirmation_url']) . "'>\n";
1323
  if (isset($attrs['list'])) {
1324
  $arr = explode(',', $attrs['list']);
1325
  foreach ($arr as $a) {
1326
+ $buffer .= "<input type='hidden' name='nl[]' value='" . ((int) trim($a)) . "'>\n";
1327
  }
1328
  }
1329
 
1330
  if ($options_profile['name_status'] == 2) {
1331
+ $buffer .= '<div class="newsletter-field newsletter-field-firstname"><label>' . esc_html($options_profile['name']) . '</label>';
1332
  $buffer .= '<input class="newsletter-name" type="text" name="nn" ' . ($options_profile['name_rules'] == 1 ? 'required' : '') . '></div>';
1333
  $buffer .= "\n";
1334
  }
1335
 
1336
  if ($options_profile['surname_status'] == 2) {
1337
+ $buffer .= '<div class="newsletter-field newsletter-field-lastname"><label>' . esc_html($options_profile['surname']) . '</label>';
1338
  $buffer .= '<input class="newsletter-lastname" type="text" name="ns" ' . ($options_profile['surname_rules'] == 1 ? 'required' : '') . '></div>';
1339
  $buffer .= "\n";
1340
  }
1341
 
1342
+ $buffer .= '<div class="newsletter-field newsletter-field-email"><label>' . esc_html($options_profile['email']) . '</label>';
1343
  $buffer .= '<input class="newsletter-email" type="email" name="ne" required></div>';
1344
  $buffer .= "\n";
1345
 
1346
  if ($options_profile['sex_status'] == 2) {
1347
+ $buffer .= '<div class="newsletter-field newsletter-field-gender"><label>' . esc_html($options_profile['sex']) . '</label>';
1348
+ $buffer .= '<select name="nx" class="newsletter-sex"';
1349
+ if ($options_profile['sex_rules'] == 1) {
1350
+ $buffer .= ' required><option value=""></option>';
1351
+ } else {
1352
+ $buffer .= '><option value="n">' . esc_html($options_profile['sex_none']) . '</option>';
1353
+ }
1354
+ $buffer .= '<option value="m">' . esc_html($options_profile['sex_male']) . '</option>';
1355
+ $buffer .= '<option value="f">' . esc_html($options_profile['sex_female']) . '</option>';
1356
  $buffer .= '</select></div>';
1357
  $buffer .= "\n";
1358
  }
1362
  if ($options_profile['list_' . $i . '_status'] != 2) {
1363
  continue;
1364
  }
1365
+ $lists .= '<div class="newsletter-field newsletter-field-list"><label><input class="newsletter-preference" type="checkbox" name="nl[]" value="' . $i . '"';
1366
  if ($options_profile['list_' . $i . '_checked'] == 1) {
1367
  $lists .= ' checked';
1368
  }
1369
+ $lists .= '/>&nbsp;' . esc_html($options_profile['list_' . $i]) . '</label></div>';
1370
  }
1371
  if (!empty($lists)) {
1372
  $buffer .= '<div class="newsletter-lists">' . $lists . '</div>';
1381
 
1382
 
1383
  $buffer .= '<div class="newsletter-field newsletter-field-profile"><label>' .
1384
+ esc_html($options_profile['profile_' . $i]) . '</label>';
1385
 
1386
  // Text field
1387
  if ($options_profile['profile_' . $i . '_type'] == 'text') {
1388
+ $buffer .= '<input class="newsletter-profile newsletter-profile-' . $i . '" type="text"' . ($options_profile['profile_' . $i . '_rules'] == 1 ? ' required' : '') . ' name="np' . $i . '">';
 
 
 
1389
  }
1390
 
1391
  // Select field
1392
  if ($options_profile['profile_' . $i . '_type'] == 'select') {
1393
+ $buffer .= '<select class="newsletter-profile newsletter-profile-' . $i . '" name="np' . $i . '" required>' . "\n";
1394
+ $buffer .= "<option></option>\n";
1395
  $opts = explode(',', $options_profile['profile_' . $i . '_options']);
1396
  for ($j = 0; $j < count($opts); $j++) {
1397
+ $buffer .= "<option>" . esc_html(trim($opts[$j])) . "</option>\n";
1398
  }
1399
  $buffer .= "</select>\n";
1400
  }
1402
  }
1403
 
1404
  $extra = apply_filters('newsletter_subscription_extra', array());
1405
+ foreach ($extra as $x) {
1406
  $label = $x['label'];
1407
  if (empty($label)) {
1408
  $label = '&nbsp;';
1409
  }
1410
  $name = '';
1411
+ if (!empty($x['name'])) {
1412
  $name = $x['name'];
1413
+ }
1414
  $buffer .= '<div class="newsletter-field newsletter-field-' . $name . '"><label>' . $label . "</label>";
1415
  $buffer .= $x['field'] . "</div>\n";
1416
  }
1417
 
1418
  if ($options_profile['privacy_status'] == 1) {
1419
+ $buffer .= '<div class="newsletter-field newsletter-field-privacy">';
1420
+ $buffer .= '<label><input type="checkbox" name="ny" required class="newsletter-privacy">&nbsp;';
1421
  if (!empty($options_profile['privacy_url'])) {
1422
+ $buffer .= '<a target="_blank" href="' . esc_attr($options_profile['privacy_url']) . '"></label>';
1423
+ $buffer .= esc_attr($options_profile['privacy']) . '</a>';
1424
  } else {
1425
+ $buffer .= esc_html($options_profile['privacy']);
1426
  }
1427
+
1428
+ $buffer .= "</label></div>\n";
1429
  }
1430
 
1431
  $buffer .= '<div class="newsletter-field newsletter-field-button">';
1432
 
1433
  if (strpos($options_profile['subscribe'], 'http://') !== false) {
1434
+ $buffer .= '<input class="newsletter-submit-image" type="image" src="' . esc_attr($options_profile['subscribe']) . '">' . "\n";
1435
  } else {
1436
+ $buffer .= '<input class="newsletter-submit" type="submit" value="' . esc_attr($options_profile['subscribe']) . '">' . "\n";
1437
  }
1438
 
1439
  $buffer .= "</div>\n</form>\n</div>";
1440
  return $buffer;
1441
  }
1442
 
1443
+ function shortcode_newsletter_profile($attrs, $content) {
1444
  $user = $this->check_user();
1445
 
1446
  if (empty($user)) {
1451
  }
1452
  }
1453
 
1454
+ if (isset($attrs['layout']) && $attrs['layout'] == 'table') {
1455
+ return $this->get_profile_form($user);
1456
+ } else {
1457
+ return $this->get_profile_form_html5($user);
1458
+ }
1459
  }
1460
 
1461
  /**
1547
  return $buffer;
1548
  }
1549
 
1550
+ function get_profile_form_html5($user) {
1551
+ $options = get_option('newsletter_profile');
1552
+
1553
+ $buffer .= '<div class="newsletter newsletter-profile">';
1554
+ $buffer .= '<form action="' . esc_attr(home_url('/') . '?na=ps') . '" method="post">';
1555
+ $buffer .= '<input type="hidden" name="nk" value="' . esc_attr($user->id . '-' . $user->token) . '">';
1556
+
1557
+ $buffer .= '<div class="newsletter-field newsletter-field-firstname">';
1558
+ $buffer .= '<label>' . esc_html($options['email']) . '</label>';
1559
+ $buffer .= '<input class="newsletter-email" type="text" name="ne" required value="' . esc_attr($user->email) . '">';
1560
+ $buffer .= "</div>\n";
1561
+
1562
+
1563
+ if ($options['name_status'] >= 1) {
1564
+ $buffer .= '<div class="newsletter-field newsletter-field-firstname">';
1565
+ $buffer .= '<label>' . esc_html($options['name']) . '</label>';
1566
+ $buffer .= '<input class="newsletter-firstname" type="text" name="nn" value="' . esc_attr($user->name) . '">';
1567
+ $buffer .= "</div>\n";
1568
+ }
1569
+
1570
+ if ($options['surname_status'] >= 1) {
1571
+ $buffer .= '<div class="newsletter-field newsletter-field-lastname">';
1572
+ $buffer .= '<label>' . esc_html($options['surname']) . '</label>';
1573
+ $buffer .= '<input class="newsletter-lastname" type="text" name="ns" value="' . esc_attr($user->surname) . '">';
1574
+ $buffer .= "</div>\n";
1575
+ }
1576
+
1577
+ if ($options['sex_status'] >= 1) {
1578
+ $buffer .= '<div class="newsletter-field newsletter-field-gender">';
1579
+ $buffer .= '<label>' . esc_html($options['sex']) . '</label>';
1580
+ $buffer .= '<select name="nx" class="newsletter-gender">';
1581
+ $buffer .= '<option value="f"' . ($user->sex == 'f' ? ' selected' : '') . '>' . esc_html($options['sex_female']) . '</option>';
1582
+ $buffer .= '<option value="m"' . ($user->sex == 'm' ? ' selected' : '') . '>' . esc_html($options['sex_male']) . '</option>';
1583
+ $buffer .= '<option value="n"' . ($user->sex == 'n' ? ' selected' : '') . '>' . esc_html($options['sex_none']) . '</option>';
1584
+ $buffer .= '</select>';
1585
+ $buffer .= "</div>\n";
1586
+ }
1587
+
1588
+ // Profile
1589
+ for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
1590
+ if ($options['profile_' . $i . '_status'] == 0) {
1591
+ continue;
1592
+ }
1593
+
1594
+ $buffer .= '<div class="newsletter-field newsletter-field-profile">';
1595
+ $buffer .= '<label>' . esc_html($options['profile_' . $i]) . '</label>';
1596
+
1597
+ $field = 'profile_' . $i;
1598
+
1599
+ if ($options['profile_' . $i . '_type'] == 'text') {
1600
+ $buffer .= '<input class="newsletter-profile newsletter-profile-' . $i . '" type="text" name="np' . $i . '" value="' . esc_attr($user->$field) . '">';
1601
+ }
1602
+
1603
+ if ($options['profile_' . $i . '_type'] == 'select') {
1604
+ $buffer .= '<select class="newsletter-profile newsletter-profile-' . $i . '" name="np' . $i . '">';
1605
+ $opts = explode(',', $options['profile_' . $i . '_options']);
1606
+ for ($j = 0; $j < count($opts); $j++) {
1607
+ $opts[$j] = trim($opts[$j]);
1608
+ $buffer .= '<option';
1609
+ if ($opts[$j] == $user->$field)
1610
+ $buffer .= ' selected';
1611
+ $buffer .= '>' . esc_html($opts[$j]) . '</option>';
1612
+ }
1613
+ $buffer .= '</select>';
1614
+ }
1615
+
1616
+ $buffer .= "</div>\n";
1617
+ }
1618
+
1619
+ // Lists
1620
+ $lists = '';
1621
+ for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
1622
+ if ($options['list_' . $i . '_status'] == 0) {
1623
+ continue;
1624
+ }
1625
+
1626
+ $lists .= '<div class="newsletter-field newsletter-field-list">';
1627
+ $lists .= '<label><input class="newsletter-list newsletter-list-' . $i . '" type="checkbox" name="nl[]" value="' . $i . '"';
1628
+ $field = 'list_' . $i;
1629
+ if ($user->$field == 1) {
1630
+ $lists .= ' checked';
1631
+ }
1632
+ $lists .= '><span class="newsletter-list-label">' . esc_html($options['list_' . $i]) . '</span></label>';
1633
+ $lists .= "</div>\n";
1634
+ }
1635
+
1636
+ if (!empty($lists)) {
1637
+ $buffer .= '<div class="newsletter-lists">' . "\n" . $lists . "\n" . '</div>';
1638
+ }
1639
+
1640
+ $extra = apply_filters('newsletter_profile_extra', array(), $user);
1641
+ foreach ($extra as $x) {
1642
+ $buffer .= '<div class="newsletter-field">';
1643
+ $buffer .= '<label>' . $x['label'] . "</label>";
1644
+ $buffer .= $x['field'];
1645
+ $buffer .= "</div>\n";
1646
+ }
1647
+
1648
+ $buffer .= '<div class="newsletter-field newsletter-field-button">';
1649
+ $buffer .= '<input class="newsletter-submit" type="submit" value="' . esc_attr($options['save']) . '">';
1650
+ $buffer .= "</div>\n";
1651
+
1652
+ $buffer .= "</form>\n</div>\n";
1653
+
1654
+ return $buffer;
1655
+ }
1656
+
1657
  function get_form($number) {
1658
  $options = get_option('newsletter_forms');
1659
 
1736
  Newsletter::instance()->mail($email, '[' . $blogname . '] ' . $subject, array('text' => $message));
1737
  }
1738
 
1739
+ function get_subscription_form_minimal($attrs) {
1740
+ $options_profile = get_option('newsletter_profile');
1741
+ if (!is_array($attrs))
1742
+ $attrs = array();
1743
+ $attrs = array_merge(array('referrer' => 'minimal', 'button' => $options_profile['subscribe'], 'placeholder' => $options_profile['email']), $attrs);
1744
 
1745
+ $form = '';
1746
+ $form .= '<div class="newsletter-subscription-minimal">';
1747
+ $form .= '<form action="' . esc_attr(home_url('/')) . '?na=s" method="post">';
1748
+ $form .= '<input type="hidden" name="nr" value="' . esc_attr($attrs['referrer']) . '">';
1749
+ $form .= '<input class="newsletter-email" type="email" required name="ne" value="" placeholder="' . esc_attr($attrs['placeholder']) . '">';
1750
+ $form .= '<input class="newsletter-submit" type="submit" value="' . esc_attr($attrs['button']) . '">';
1751
+ $form .= "</form></div>\n";
1752
 
1753
+ return $form;
1754
+ }
1755
 
1756
+ function shortcode_newsletter_form($attrs, $content) {
1757
 
1758
+ if (isset($attrs['type']) && $attrs['type'] == 'minimal') {
1759
+ return NewsletterSubscription::instance()->get_subscription_form_minimal($attrs);
1760
+ }
1761
+
1762
+ if (!empty($content)) {
1763
+ return NewsletterSubscription::instance()->shortcode_subscription($attrs, $content);
1764
+ }
1765
+ if (isset($attrs['form'])) {
1766
+ return NewsletterSubscription::instance()->get_form((int) $attrs['form']);
1767
+ } else if (isset($attrs['number'])) {
1768
+ return NewsletterSubscription::instance()->get_form((int) $attrs['number']);
1769
  } else {
1770
+ if (isset($attrs['layout']) && $attrs['layout'] == 'table') {
1771
+ return NewsletterSubscription::instance()->get_subscription_form(null, null, $attrs);
1772
+ } else {
1773
+ return NewsletterSubscription::instance()->get_subscription_form_html5(null, null, $attrs);
1774
+ }
1775
  }
1776
  }
 
 
 
1777
 
1778
+ /**
1779
+ *
1780
+ * @global type $wpdb
1781
+ * @global boolean $cache_stop
1782
+ * @global Newsletter $newsletter
1783
+ * @param type $attrs
1784
+ * @param type $content
1785
+ * @return string
1786
+ */
1787
+ function shortcode_newsletter($attrs, $content) {
1788
+ global $wpdb, $cache_stop, $newsletter;
1789
 
1790
+ $cache_stop = true;
1791
 
1792
+ $module = NewsletterSubscription::instance();
1793
+ $user = $module->get_user_from_request();
1794
+ $message_key = $module->get_message_key_from_request();
1795
 
1796
  // if ($message_key != 'subscription' && $user == null) {
1797
  // die('Invalid subscriber');
1798
  // }
1799
 
1800
 
1801
+ $message = $module->options[$message_key . '_text'];
1802
 
1803
+ // TODO: the if can be removed
1804
+ if ($message_key == 'confirmed') {
1805
+ $message .= $module->options[$message_key . '_tracking'];
1806
+ }
1807
 
1808
+ // Now check what form must be added
1809
+ if ($message_key == 'subscription') {
1810
 
1811
+ // Compatibility check
1812
+ if (stripos($message, '<form') !== false) {
1813
+ $message .= $module->get_form_javascript();
1814
+ $message = str_ireplace('<form', '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)"', $message);
1815
+ } else {
1816
 
1817
+ if (strpos($message, '{subscription_form') === false) {
1818
+ $message .= '{subscription_form}';
1819
+ }
1820
 
1821
+ if (isset($attrs['form'])) {
1822
+ $message = str_replace('{subscription_form}', $module->get_form($attrs['form']), $message);
 
 
 
1823
  } else {
1824
+ if (isset($attrs['layout']) && $attrs['layout'] == 'table') {
1825
+ $message = str_replace('{subscription_form}', $module->get_subscription_form('page'), $message);
1826
+ } else {
1827
+ $message = str_replace('{subscription_form}', $module->get_subscription_form_html5('page'), $message);
1828
+ }
1829
  }
1830
  }
1831
  }
 
1832
 
1833
+ $email = NewsletterSubscription::instance()->get_email_from_request();
1834
 
1835
+ $message = $newsletter->replace($message, $user, $email, 'page');
1836
+
1837
+ if (isset($_REQUEST['alert'])) {
1838
+ // slashes are already added by wordpress!
1839
+ $message .= '<script>alert("' . strip_tags($_REQUEST['alert']) . '");</script>';
1840
+ }
1841
 
1842
+ return $message;
 
 
1843
  }
1844
 
 
1845
  }
1846
 
1847
  NewsletterSubscription::instance();
subscription/template.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
- if (!defined('ABSPATH')) exit;
 
3
 
4
  @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
5
  $controls = new NewsletterControls();
@@ -12,21 +13,21 @@ if (!$controls->is_action()) {
12
  $module->save_options($controls->data, 'template');
13
 
14
  if (strpos($controls->data['template'], '{message}') === false) {
15
- $controls->errors = 'Warning: the tag {message} is missing in your template';
16
  }
17
 
18
- $controls->messages = 'Saved.';
19
  }
20
  if ($controls->is_action('reset')) {
21
  $controls->data['template'] = file_get_contents(dirname(__FILE__) . '/email.html');
22
- $controls->messages = 'Done.';
23
  }
24
 
25
  if ($controls->is_action('test')) {
26
 
27
  $users = NewsletterUsers::instance()->get_test_users();
28
  if (count($users) == 0) {
29
- $controls->errors = 'There are no test subscribers. Read more about test subscribers <a href="http://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#test" target="_blank">here</a>.';
30
  } else {
31
  $template = $controls->data['template'];
32
  if (strpos($template, '{message}') === false) {
@@ -45,12 +46,32 @@ if (!$controls->is_action()) {
45
  Newsletter::instance()->mail($user->email, 'Newsletter Messages Template Test', $newsletter->replace($message, $user));
46
  }
47
  $controls->messages .= 'Test emails sent to ' . count($users) . ' test subscribers: ' .
48
- implode(', ', $addresses) . '. Read more about test subscribers <a href="http://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#test" target="_blank">here</a>.';
49
  }
50
  }
51
  }
52
  ?>
53
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  <div class="wrap" id="tnp-wrap">
55
 
56
  <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
1
  <?php
2
+ if (!defined('ABSPATH'))
3
+ exit;
4
 
5
  @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
  $controls = new NewsletterControls();
13
  $module->save_options($controls->data, 'template');
14
 
15
  if (strpos($controls->data['template'], '{message}') === false) {
16
+ $controls->errors = __('The tag {message} is missing in your template', 'newsletter');
17
  }
18
 
19
+ $controls->add_message_saved();
20
  }
21
  if ($controls->is_action('reset')) {
22
  $controls->data['template'] = file_get_contents(dirname(__FILE__) . '/email.html');
23
+ $controls->add_message_done();
24
  }
25
 
26
  if ($controls->is_action('test')) {
27
 
28
  $users = NewsletterUsers::instance()->get_test_users();
29
  if (count($users) == 0) {
30
+ $controls->errors = __('No test subscribers found.', 'newsletter') . ' <a href="http://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#test" target="_blank"><i class="fa fa-info-circle"></i></a>';
31
  } else {
32
  $template = $controls->data['template'];
33
  if (strpos($template, '{message}') === false) {
46
  Newsletter::instance()->mail($user->email, 'Newsletter Messages Template Test', $newsletter->replace($message, $user));
47
  }
48
  $controls->messages .= 'Test emails sent to ' . count($users) . ' test subscribers: ' .
49
+ implode(', ', $addresses) . '.' . ' <a href="http://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#test" target="_blank"><i class="fa fa-info-circle"></i></a>';
50
  }
51
  }
52
  }
53
  ?>
54
+ <!--
55
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/codemirror.css" type="text/css">
56
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/addon/hint/show-hint.css">
57
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/codemirror.js"></script>
58
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/mode/xml/xml.js"></script>
59
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/mode/css/css.js"></script>
60
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/mode/javascript/javascript.js"></script>
61
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/mode/htmlmixed/htmlmixed.js"></script>
62
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/addon/hint/show-hint.js"></script>
63
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/addon/hint/xml-hint.js"></script>
64
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.20.2/addon/hint/html-hint.js"></script>
65
+ <script>
66
+ jQuery(function () {
67
+ var editor = CodeMirror.fromTextArea(document.getElementById("options-template"), {
68
+ lineNumbers: true,
69
+ mode: 'htmlmixed',
70
+ extraKeys: {"Ctrl-Space": "autocomplete"}
71
+ });
72
+ });
73
+ </script>
74
+ -->
75
  <div class="wrap" id="tnp-wrap">
76
 
77
  <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
subscription/validate.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function newsletter_check_field(field, message) {
2
+ if (!field) return true;
3
+ if (field.type == "checkbox" && !field.checked) {
4
+ alert(message);
5
+ return false;
6
+ }
7
+
8
+ if (field.required !== undefined && field.value == "") {
9
+ alert(message);
10
+ return false;
11
+ }
12
+ return true;
13
+ }
14
+
15
+ function newsletter_check(f) {
16
+ var re = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-]{1,})+\.)+([a-zA-Z0-9]{2,})+$/;
17
+ if (!re.test(f.elements["ne"].value)) {
18
+ alert(newsletter.messages.email_error);
19
+ return false;
20
+ }
21
+ if (!newsletter_check_field(f.elements["nn"], newsletter.messages.name_error)) return false;
22
+ if (!newsletter_check_field(f.elements["ns"], newsletter.messages.surname_error)) return false;
23
+
24
+ for (var i=1; i<newsletter.profile_max; i++) {
25
+ if (!newsletter_check_field(f.elements["np" + i], newsletter.messages.profile_error)) return false;
26
+ }
27
+
28
+ if (!newsletter_check_field(f.elements["ny"], newsletter.messages.privacy_error)) return false;
29
+
30
+ return true;
31
+ }
tnp-header.php CHANGED
@@ -179,7 +179,7 @@ function newsletter_print_entries($group) {
179
  </div>
180
  <?php } ?>
181
 
182
- <?php if (NEWSLETTER_DEBUG || !isset($dismissed['newsletter-page']) && empty(NewsletterSubscription::instance()->options['url'])) { ?>
183
  <div class="tnp-notice">
184
  <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-page' ?>" class="tnp-dismiss">&times;</a>
185
 
179
  </div>
180
  <?php } ?>
181
 
182
+ <?php if (NEWSLETTER_DEBUG || !isset($dismissed['newsletter-page']) && empty(NewsletterSubscription::instance()->options['page'])) { ?>
183
  <div class="tnp-notice">
184
  <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-page' ?>" class="tnp-dismiss">&times;</a>
185
 
users/import.php CHANGED
@@ -103,7 +103,7 @@ if ($controls->is_action('import')) {
103
 
104
  foreach ($controls->data['preferences'] as $i) {
105
  $subscriber['list_' . $i] = 1;
106
- }
107
  }
108
 
109
  if ($mode == 'update') {
@@ -113,11 +113,11 @@ if ($controls->is_action('import')) {
113
  $subscriber['sex'] = $newsletter->normalize_sex($data[3]);
114
  }
115
  if (isset($controls->data['override_status'])) {
116
- $subscriber['status'] = $controls->data['import_as'];
117
  }
118
  foreach ($controls->data['preferences'] as $i) {
119
  $subscriber['list_' . $i] = 1;
120
- }
121
  }
122
 
123
  NewsletterUsers::instance()->save_user($subscriber);
103
 
104
  foreach ($controls->data['preferences'] as $i) {
105
  $subscriber['list_' . $i] = 1;
106
+ }
107
  }
108
 
109
  if ($mode == 'update') {
113
  $subscriber['sex'] = $newsletter->normalize_sex($data[3]);
114
  }
115
  if (isset($controls->data['override_status'])) {
116
+ $subscriber['status'] = $controls->data['import_as'];
117
  }
118
  foreach ($controls->data['preferences'] as $i) {
119
  $subscriber['list_' . $i] = 1;
120
+ }
121
  }
122
 
123
  NewsletterUsers::instance()->save_user($subscriber);
widget/minimal.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NewsletterWidgetMinimal extends WP_Widget {
4
+
5
+ function __construct() {
6
+ parent::__construct(false, $name = 'Newsletter Minimal', array('description' => 'Newsletter widget to add a minimal subscription form'), array('width' => '350px'));
7
+ }
8
+
9
+ function widget($args, $instance) {
10
+ global $newsletter;
11
+ extract($args);
12
+
13
+ echo $before_widget;
14
+
15
+ if (!is_array($instance)) {
16
+ $instance = array();
17
+ }
18
+ // Filters are used for WPML
19
+ if (!empty($instance['title'])) {
20
+ $title = apply_filters('widget_title', $instance['title'], $instance);
21
+ echo $before_title . $title . $after_title;
22
+ }
23
+
24
+ if (empty($instance['button'])) {
25
+ $instance['button'] = 'Subscribe';
26
+ }
27
+
28
+ $options_profile = get_option('newsletter_profile');
29
+
30
+ $form = '';
31
+ $form .= '<div class="newsletter-widget-minimal">';
32
+ $form .= '<form action="' . esc_attr(home_url('/')) . '?na=s" method="post">';
33
+ // Referrer
34
+ $form .= '<input type="hidden" name="nr" value="widget-minimal"/>';
35
+
36
+ $form .= '<input class="newsletter-email" type="email" required name="ne" value="" placeholder="' . esc_attr($options_profile['email']) . '">';
37
+
38
+ $form .= '<input class="newsletter-submit" type="submit" value="' . esc_attr($instance['button']) . '">';
39
+
40
+ $form .= '</form>';
41
+
42
+ $buffer .= $form;
43
+
44
+ echo $buffer;
45
+ echo $after_widget;
46
+ }
47
+
48
+ function update($new_instance, $old_instance) {
49
+ return $new_instance;
50
+ }
51
+
52
+ function form($instance) {
53
+ if (!is_array($instance)) {
54
+ $instance = array();
55
+ }
56
+ $instance = array_merge(array('title' => '', 'text' => ''), $instance);
57
+ ?>
58
+ <p>
59
+ <label for="<?php echo $this->get_field_id('title'); ?>">
60
+ Title:
61
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>">
62
+ </label>
63
+
64
+ <label for="<?php echo $this->get_field_id('button'); ?>">
65
+ Button label:
66
+ <input class="widefat" id="<?php echo $this->get_field_id('button'); ?>" name="<?php echo $this->get_field_name('button'); ?>" type="text" value="<?php echo esc_attr($instance['button']); ?>">
67
+ Use a short one!
68
+ </label>
69
+ </p>
70
+
71
+ <?php
72
+ }
73
+
74
+ }
75
+
76
+ add_action('widgets_init', create_function('', 'return register_widget("NewsletterWidgetMinimal");'));
77
+ ?>
widget.php → widget/standard.php RENAMED
@@ -10,10 +10,26 @@ class NewsletterWidget extends WP_Widget {
10
  parent::__construct(false, $name = 'Newsletter', array('description' => 'Newsletter widget to add subscription forms on sidebars'), array('width' => '350px'));
11
  }
12
 
13
- static function get_widget_form() {
 
 
 
14
  $options_profile = get_option('newsletter_profile');
15
- $form = NewsletterSubscription::instance()->get_form_javascript();
 
 
 
 
 
 
 
 
16
 
 
 
 
 
 
17
  $form .= '<form action="' . home_url('/') . '?na=s" onsubmit="return newsletter_check(this)" method="post">';
18
  // Referrer
19
  $form .= '<input type="hidden" name="nr" value="widget"/>';
@@ -74,8 +90,7 @@ class NewsletterWidget extends WP_Widget {
74
  if ($options_profile['privacy_status'] == 1) {
75
  if (!empty($options_profile['privacy_url'])) {
76
  $form .= '<p><input type="checkbox" name="ny"/>&nbsp;<a target="_blank" href="' . $options_profile['privacy_url'] . '">' . $options_profile['privacy'] . '</a></p>';
77
- }
78
- else
79
  $form .= '<p><input type="checkbox" name="ny"/>&nbsp;' . $options_profile['privacy'] . '</p>';
80
  }
81
 
@@ -86,6 +101,7 @@ class NewsletterWidget extends WP_Widget {
86
  }
87
 
88
  $form .= '</form>';
 
89
 
90
  return $form;
91
  }
@@ -93,9 +109,10 @@ class NewsletterWidget extends WP_Widget {
93
  function widget($args, $instance) {
94
  global $newsletter;
95
  extract($args);
96
-
97
- if (empty($instance)) $instance = array();
98
- $instance = array_merge(array('text'=>'', 'title'=>''), $instance);
 
99
 
100
  echo $before_widget;
101
 
@@ -111,11 +128,11 @@ class NewsletterWidget extends WP_Widget {
111
 
112
  if (stripos($instance['text'], '<form') === false) {
113
 
114
- $form = NewsletterSubscription::instance()->get_form_javascript();
115
-
116
- $form .= '<div class="newsletter newsletter-widget">';
117
- $form .= NewsletterWidget::get_widget_form();
118
- $form .= '</div>';
119
 
120
  // Canot user directly the replace, since the form is different on the widget...
121
  if (strpos($buffer, '{subscription_form}') !== false)
@@ -141,15 +158,20 @@ class NewsletterWidget extends WP_Widget {
141
  }
142
 
143
  function update($new_instance, $old_instance) {
144
- $instance = $old_instance;
145
- $instance['title'] = strip_tags($new_instance['title']);
146
- $instance['text'] = $new_instance['text'];
147
- return $instance;
 
 
 
 
148
  }
149
 
150
  function form($instance) {
151
- if (!is_array($instance)) $instance = array();
152
- $instance = array_merge(array('title'=>'', 'text'=>''), $instance);
 
153
  ?>
154
  <p>
155
  <label for="<?php echo $this->get_field_id('title'); ?>">
@@ -162,7 +184,15 @@ class NewsletterWidget extends WP_Widget {
162
  Introduction:
163
  <textarea class="widefat" rows="10" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_html($instance['text']); ?></textarea>
164
  </label>
165
- <p>Use the tag {subscription_form} to place the subscription form within your personal text.
 
 
 
 
 
 
 
 
166
  </p>
167
  <?php
168
  }
10
  parent::__construct(false, $name = 'Newsletter', array('description' => 'Newsletter widget to add subscription forms on sidebars'), array('width' => '350px'));
11
  }
12
 
13
+ static function get_widget_form($instance) {
14
+
15
+ $field_wrapper_tag = 'div';
16
+
17
  $options_profile = get_option('newsletter_profile');
18
+ //$form = NewsletterSubscription::instance()->get_form_javascript();
19
+ $form = '';
20
+
21
+ $form .= '<div class="newsletter-widget">';
22
+ $form .= NewsletterSubscription::instance()->get_subscription_form_html5('widget');
23
+ $form .= "</div>\n";
24
+
25
+ return $form;
26
+ }
27
 
28
+ static function get_old_widget_form() {
29
+ $options_profile = get_option('newsletter_profile');
30
+ $form = NewsletterSubscription::instance()->get_form_javascript();
31
+
32
+ $form .= '<div class="newsletter newsletter-widget">';
33
  $form .= '<form action="' . home_url('/') . '?na=s" onsubmit="return newsletter_check(this)" method="post">';
34
  // Referrer
35
  $form .= '<input type="hidden" name="nr" value="widget"/>';
90
  if ($options_profile['privacy_status'] == 1) {
91
  if (!empty($options_profile['privacy_url'])) {
92
  $form .= '<p><input type="checkbox" name="ny"/>&nbsp;<a target="_blank" href="' . $options_profile['privacy_url'] . '">' . $options_profile['privacy'] . '</a></p>';
93
+ } else
 
94
  $form .= '<p><input type="checkbox" name="ny"/>&nbsp;' . $options_profile['privacy'] . '</p>';
95
  }
96
 
101
  }
102
 
103
  $form .= '</form>';
104
+ $form .= '</div>';
105
 
106
  return $form;
107
  }
109
  function widget($args, $instance) {
110
  global $newsletter;
111
  extract($args);
112
+
113
+ if (empty($instance))
114
+ $instance = array();
115
+ $instance = array_merge(array('text' => '', 'title' => ''), $instance);
116
 
117
  echo $before_widget;
118
 
128
 
129
  if (stripos($instance['text'], '<form') === false) {
130
 
131
+ if (isset($instance['old_form'])) {
132
+ $form = NewsletterWidget::get_old_widget_form();
133
+ } else {
134
+ $form = NewsletterWidget::get_widget_form($instance);
135
+ }
136
 
137
  // Canot user directly the replace, since the form is different on the widget...
138
  if (strpos($buffer, '{subscription_form}') !== false)
158
  }
159
 
160
  function update($new_instance, $old_instance) {
161
+ // $instance = $old_instance;
162
+ // $instance['title'] = strip_tags($new_instance['title']);
163
+ // $instance['text'] = $new_instance['text'];
164
+ // if (isset($new_instance['old_form']))
165
+ // $instance['old_form'] = 1;
166
+ // else
167
+ // unset($instance['old_form']);
168
+ return $new_instance;
169
  }
170
 
171
  function form($instance) {
172
+ if (!is_array($instance))
173
+ $instance = array();
174
+ $instance = array_merge(array('title' => '', 'text' => ''), $instance);
175
  ?>
176
  <p>
177
  <label for="<?php echo $this->get_field_id('title'); ?>">
184
  Introduction:
185
  <textarea class="widefat" rows="10" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_html($instance['text']); ?></textarea>
186
  </label>
187
+
188
+ <label for="<?php echo $this->get_field_id('old_form'); ?>">
189
+ <input type="checkbox" id="<?php echo $this->get_field_id('old_form'); ?>" name="<?php echo $this->get_field_name('old_form'); ?>" <?php echo isset($instance['old_form']) ? 'checked' : '' ?>>
190
+ Use the old form (will be removed in future versions)
191
+ </label>
192
+ </p>
193
+
194
+ <p>
195
+ Use the tag {subscription_form} to place the subscription form within your personal text.
196
  </p>
197
  <?php
198
  }