Newsletter - Version 3.3.2

Version Description

  • Disabled the save button on composer when the newsletter is "sending" or "sent"
  • Added ip field on statistics
  • Reviewed the subscriber statistics panel
  • Fixed some links on welcome panel
  • Added extensions version check
  • Added the Mandrill Extension support
  • Fixed the banner options on default theme
  • New "new newsletter" panel (hope simpler to use)
Download this release

Release Info

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

Code changes from version 3.3.1 to 3.3.2

admin.css CHANGED
@@ -929,3 +929,14 @@ table.clicks {
929
  vertical-align: top;
930
  }
931
 
 
 
 
 
 
 
 
 
 
 
 
929
  vertical-align: top;
930
  }
931
 
932
+ .newsletter-box {
933
+ border: 1px solid #ddd;
934
+ padding: 10px;
935
+ background-color: #fafafa;
936
+ margin-bottom: 15px;
937
+ }
938
+
939
+ .newsletter-box h3 {
940
+ margin-top: 0;
941
+ }
942
+
emails/edit.php CHANGED
@@ -229,8 +229,8 @@ if ($email['editor'] == 0) {
229
  <?php $controls->init(); ?>
230
 
231
  <p class="submit">
232
- <?php if ($email['status'] != 'sending') $controls->button('save', 'Save'); ?>
233
- <?php if ($email['status'] != 'sending') $controls->button_confirm('test', 'Save and test', 'Save and send test emails to test addresses?'); ?>
234
 
235
  <?php if ($email['status'] == 'new') $controls->button_confirm('send', 'Send', 'Start a real delivery?'); ?>
236
  <?php if ($email['status'] == 'sending') $controls->button_confirm('pause', 'Pause', 'Pause the delivery?'); ?>
229
  <?php $controls->init(); ?>
230
 
231
  <p class="submit">
232
+ <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button('save', 'Save'); ?>
233
+ <?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_confirm('test', 'Save and test', 'Save and send test emails to test addresses?'); ?>
234
 
235
  <?php if ($email['status'] == 'new') $controls->button_confirm('send', 'Send', 'Start a real delivery?'); ?>
236
  <?php if ($email['status'] == 'sending') $controls->button_confirm('pause', 'Pause', 'Pause the delivery?'); ?>
emails/new.php CHANGED
@@ -100,46 +100,55 @@ function newsletter_emails_get_theme_options($theme) {
100
 
101
  <form method="post" action="<?php echo $module->get_admin_page_url('new'); ?>">
102
  <?php $controls->init(); ?>
 
 
103
  <h3>Choose a theme</h3>
104
  <?php //$controls->select('theme', NewsletterEmails::instance()->themes->get_all()); ?>
105
  <?php //$controls->button('change', 'Change theme'); ?>
106
 
107
  <?php $controls->themes('theme', $module->themes->get_all_with_data()); ?>
108
-
109
- <p>
110
- <?php $controls->button_primary('create', 'Create the email'); ?>
111
- </p>
112
-
113
  <div id="tabs">
114
  <ul>
115
  <li><a href="#tabs-2">Preview</a></li>
116
- <li><a href="#tabs-1">Theme options</a></li>
117
  <li><a href="#tabs-3">Preview (textual)</a></li>
118
  </ul>
119
 
 
 
120
 
121
- <div id="tabs-1">
122
- <p>Theme options are saved for next time you'll use it!</p>
123
- <?php @include $module->get_current_theme_file_path('theme-options.php');?>
124
- <div class="newsletter-buttons newsletter-buttons-bottom">
125
- <?php $controls->button('save', 'Save options and refresh'); ?>
126
- </div>
127
- </div>
128
-
129
 
 
130
  <div id="tabs-2">
 
131
  <div class="tab-preamble">
132
  <p>After the email is created, you can edit every part of this message.</p>
133
  </div>
134
  <iframe src="<?php echo wp_nonce_url(plugins_url('newsletter') . '/emails/preview.php?' . time()); ?>" width="100%" height="700"></iframe>
 
135
  </div>
136
-
137
-
138
  <div id="tabs-3">
139
  <iframe src="<?php echo wp_nonce_url(plugins_url('newsletter') . '/emails/preview-text.php?' . time()); ?>" width="100%" height="500"></iframe>
140
  </div>
141
-
142
- </div>
143
-
 
 
 
 
144
  </form>
145
  </div>
100
 
101
  <form method="post" action="<?php echo $module->get_admin_page_url('new'); ?>">
102
  <?php $controls->init(); ?>
103
+
104
+ <div class="newsletter-box">
105
  <h3>Choose a theme</h3>
106
  <?php //$controls->select('theme', NewsletterEmails::instance()->themes->get_all()); ?>
107
  <?php //$controls->button('change', 'Change theme'); ?>
108
 
109
  <?php $controls->themes('theme', $module->themes->get_all_with_data()); ?>
110
+ </div>
111
+
112
+ <!--
 
 
113
  <div id="tabs">
114
  <ul>
115
  <li><a href="#tabs-2">Preview</a></li>
116
+ <li><a href="#tabs-options">Theme options</a></li>
117
  <li><a href="#tabs-3">Preview (textual)</a></li>
118
  </ul>
119
 
120
+ -->
121
+ <div class="newsletter-box">
122
 
123
+ <h3>Set the theme options</h3>
124
+ <?php @include $module->get_current_theme_file_path('theme-options.php'); ?>
125
+
126
+ <?php $controls->button('save', 'Save options and refresh'); ?>
127
+ <?php $controls->button_primary('create', 'Create the email'); ?>
128
+
129
+ <div class="hints">Theme options are saved for next time you'll use it!</div>
130
+ </div>
131
 
132
+ <!--
133
  <div id="tabs-2">
134
+
135
  <div class="tab-preamble">
136
  <p>After the email is created, you can edit every part of this message.</p>
137
  </div>
138
  <iframe src="<?php echo wp_nonce_url(plugins_url('newsletter') . '/emails/preview.php?' . time()); ?>" width="100%" height="700"></iframe>
139
+
140
  </div>
141
+ -->
142
+ <!--
143
  <div id="tabs-3">
144
  <iframe src="<?php echo wp_nonce_url(plugins_url('newsletter') . '/emails/preview-text.php?' . time()); ?>" width="100%" height="500"></iframe>
145
  </div>
146
+ -->
147
+ <!--</div>-->
148
+
149
+ <h3>Preview</h3>
150
+
151
+ <iframe src="<?php echo wp_nonce_url(plugins_url('newsletter') . '/emails/preview.php?' . time()); ?>" width="700" height="700" style="border: 1px solid #ccc"></iframe>
152
+
153
  </form>
154
  </div>
emails/themes/default/theme-options.php CHANGED
@@ -4,10 +4,11 @@
4
  <td><?php $controls->color('theme_color'); ?></td>
5
  </tr>
6
  <tr>
7
- <th>Banner</th>
8
  <td><?php $controls->wp_editor('theme_banner'); ?>
9
  <div class="hints">
10
- Create a content with an image (500 pixel wide) that will be your newsletter banner.
 
11
  </div>
12
  </td>
13
  </tr>
4
  <td><?php $controls->color('theme_color'); ?></td>
5
  </tr>
6
  <tr>
7
+ <th>Banner/Title</th>
8
  <td><?php $controls->wp_editor('theme_banner'); ?>
9
  <div class="hints">
10
+ Create a content with an image (500 pixel wide) that will be your newsletter banner and that will replace the
11
+ title with your blog name.
12
  </div>
13
  </td>
14
  </tr>
emails/themes/default/theme.php CHANGED
@@ -32,11 +32,16 @@ if (isset($theme_options['theme_posts'])) $posts = get_posts(array('showposts'=>
32
  <table align="center">
33
  <tr>
34
  <td style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #666;">
35
- <div style="text-align: left; max-width: 500px; border-top: 10px solid <?php echo $color; ?>; border-bottom: 3px solid <?php echo $color; ?>;">
36
 
 
 
 
 
37
  <div style="padding: 10px 20px; color: #000; font-size: 20px; background-color: #EFEFEF; border-bottom: 1px solid #ddd">
38
  <?php echo get_option('blogname'); ?>
39
  </div>
 
40
 
41
  <div style="padding: 20px; background-color: #fff; line-height: 18px">
42
 
32
  <table align="center">
33
  <tr>
34
  <td style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #666;">
35
+ <div style="text-align: left; background-color: #fff; max-width: 500px; border-top: 10px solid <?php echo $color; ?>; border-bottom: 3px solid <?php echo $color; ?>;">
36
 
37
+ <?php
38
+ if (!empty($theme_options['theme_banner'])) {
39
+ echo $theme_options['theme_banner'];
40
+ } else { ?>
41
  <div style="padding: 10px 20px; color: #000; font-size: 20px; background-color: #EFEFEF; border-bottom: 1px solid #ddd">
42
  <?php echo get_option('blogname'); ?>
43
  </div>
44
+ <?php } ?>
45
 
46
  <div style="padding: 20px; background-color: #fff; line-height: 18px">
47
 
header.php CHANGED
@@ -38,9 +38,9 @@ if (isset($_REQUEST['dismiss']) && check_admin_referer()) {
38
  </div>
39
  <?php } ?>
40
 
41
- <?php if ($dismissed['newsletter-page'] != 1 && empty($newsletter->options['url'])) { ?>
42
  <div class="newsletter-notice">
43
- Do you know you can create a page in your blog used to show all Newsletter messages to subscribers? Go to the
44
  <a href="?page=newsletter_subscription_options">subscription panel</a> to
45
  configure it.
46
  <div class="newsletter-dismiss"><a href="<?php echo wp_nonce_url($_SERVER['REQUEST_URI'] . '&dismiss=newsletter-page')?>">Dismiss</a></div>
38
  </div>
39
  <?php } ?>
40
 
41
+ <?php if ($dismissed['newsletter-page'] != 1 && empty(NewsletterSubscription::instance()->options['url'])) { ?>
42
  <div class="newsletter-notice">
43
+ Create a page with your blog style to show the subscription form and the subscription messages. Go to the
44
  <a href="?page=newsletter_subscription_options">subscription panel</a> to
45
  configure it.
46
  <div class="newsletter-dismiss"><a href="<?php echo wp_nonce_url($_SERVER['REQUEST_URI'] . '&dismiss=newsletter-page')?>">Dismiss</a></div>
includes/module.php CHANGED
@@ -67,9 +67,9 @@ class NewsletterModule {
67
  add_action('admin_menu', array($this, 'admin_menu'));
68
  $this->available_version = get_option($this->prefix . '_available_version');
69
  }
70
- if (!empty($this->module_id)) {
71
- add_action($this->prefix . '_version_check', array($this, 'hook_version_check'), 1);
72
- }
73
  }
74
 
75
  /**
@@ -86,10 +86,10 @@ class NewsletterModule {
86
  } else {
87
  // TODO: Try with an array_merge()?
88
  }
89
- if (!empty($this->module_id)) {
90
- wp_clear_scheduled_hook($this->prefix . '_version_check');
91
- wp_schedule_event(time() + 30, 'daily', $this->prefix . '_version_check');
92
- }
93
  }
94
 
95
  function upgrade_query($query) {
@@ -102,15 +102,15 @@ class NewsletterModule {
102
  }
103
  }
104
 
105
- function hook_version_check() {
106
- $this->logger->info('Checking for new version');
107
- if (empty($this->module_id)) return;
108
- $version = @file_get_contents('http://www.satollo.net/wp-content/plugins/file-commerce-pro/version.php?f=' . $this->module_id);
109
- if ($version) {
110
- update_option($this->prefix . '_available_version', $version);
111
- $this->available_version = $version;
112
- }
113
- }
114
 
115
  /**
116
  * Return, eventually, the version of this moduke available on satollo.net.
67
  add_action('admin_menu', array($this, 'admin_menu'));
68
  $this->available_version = get_option($this->prefix . '_available_version');
69
  }
70
+ // if (!empty($this->module_id)) {
71
+ // add_action($this->prefix . '_version_check', array($this, 'hook_version_check'), 1);
72
+ // }
73
  }
74
 
75
  /**
86
  } else {
87
  // TODO: Try with an array_merge()?
88
  }
89
+ // if (!empty($this->module_id)) {
90
+ // wp_clear_scheduled_hook($this->prefix . '_version_check');
91
+ // wp_schedule_event(time() + 30, 'daily', $this->prefix . '_version_check');
92
+ // }
93
  }
94
 
95
  function upgrade_query($query) {
102
  }
103
  }
104
 
105
+ // function hook_version_check() {
106
+ // $this->logger->info('Checking for new version');
107
+ // if (empty($this->module_id)) return;
108
+ // $version = @file_get_contents('http://www.satollo.net/wp-content/plugins/file-commerce-pro/version.php?f=' . $this->module_id);
109
+ // if ($version) {
110
+ // update_option($this->prefix . '_available_version', $version);
111
+ // $this->available_version = $version;
112
+ // }
113
+ // }
114
 
115
  /**
116
  * Return, eventually, the version of this moduke available on satollo.net.
main/index.php CHANGED
@@ -13,6 +13,10 @@ if ($controls->is_action('feed_disable')) {
13
  $controls->messages = 'Feed by Mail demo panel disabled. On next page reload it will disappear.';
14
  }
15
 
 
 
 
 
16
  ?>
17
  <div class="wrap main-index">
18
 
@@ -78,12 +82,12 @@ if ($controls->is_action('feed_disable')) {
78
 
79
  <ol>
80
  <li>
81
- <em>I want to create a newsletter.</em> Use the <a href="http://www.satollo.net/wp-admin/admin.php?page=newsletter_emails_index">newsletters panel</a>
82
  <strong>choose a theme</strong>, preview, twick it if needed and create your message.
83
  </li>
84
  <li>
85
  <em>I want to test my newsletter.</em> Save the newsletter and move to the
86
- <a href="http://www.satollo.net/wp-admin/admin.php?page=newsletter_users_index">subscribers panel</a>.
87
  Create some subscribers manually using your own email addresses and mark them as test subscribers. They will be
88
  used for newsletter tests.
89
  </li>
@@ -127,7 +131,7 @@ if ($controls->is_action('feed_disable')) {
127
  <?php } else { ?>
128
  <td>Not installed</td>
129
  <?php } ?>
130
- <td><?php echo NewsletterModule::get_available_version(34); ?></td>
131
  </tr>
132
  <tr>
133
  <td>
@@ -151,7 +155,7 @@ if ($controls->is_action('feed_disable')) {
151
  <?php } else { ?>
152
  <td>Not installed</td>
153
  <?php } ?>
154
- <td><?php echo NewsletterModule::get_available_version(35); ?></td>
155
  </tr>
156
  <tr>
157
  <td>
@@ -163,7 +167,7 @@ if ($controls->is_action('feed_disable')) {
163
  <?php } else { ?>
164
  <td>Not installed</td>
165
  <?php } ?>
166
- <td><?php echo NewsletterModule::get_available_version(37); ?></td>
167
  </tr>
168
  <tr>
169
  <td>
@@ -175,11 +179,11 @@ if ($controls->is_action('feed_disable')) {
175
  <?php } else { ?>
176
  <td>Not installed</td>
177
  <?php } ?>
178
- <td><?php echo NewsletterModule::get_available_version(41); ?></td>
179
  </tr>
180
  <tr>
181
  <td>
182
- <a href="http://www.satollo.net/plugins/newsletter/sendgrid-up-module" target="_blank">SendGrid</a>
183
  <br><small>Integrates with <a href="http://www.satollo.net/affiliate/sendgrid" target="_blank">SendGrid</a> SMTP and bounce report</small>
184
  </td>
185
  <?php if (class_exists('NewsletterSendgrid')) { ?>
@@ -187,8 +191,32 @@ if ($controls->is_action('feed_disable')) {
187
  <?php } else { ?>
188
  <td>Not installed</td>
189
  <?php } ?>
190
- <td><?php echo NewsletterModule::get_available_version(40); ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
191
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
192
  <tr>
193
  <td>
194
  <a href="http://www.satollo.net/plugins/newsletter/mailjet-module" target="_blank">MailJet</a>
@@ -199,11 +227,12 @@ if ($controls->is_action('feed_disable')) {
199
  <?php } else { ?>
200
  <td>Not installed</td>
201
  <?php } ?>
202
- <td><?php echo NewsletterModule::get_available_version(38); ?></td>
203
  </tr>
204
  </tbody>
205
  </table>
206
-
 
207
 
208
  <h3>Support</h3>
209
  <p>
13
  $controls->messages = 'Feed by Mail demo panel disabled. On next page reload it will disappear.';
14
  }
15
 
16
+ if ($controls->is_action('check_versions')) {
17
+ $newsletter->hook_check_versions();
18
+ $controls->messages = 'Module versions updated';
19
+ }
20
  ?>
21
  <div class="wrap main-index">
22
 
82
 
83
  <ol>
84
  <li>
85
+ <em>I want to create a newsletter.</em> Use the <a href="admin.php?page=newsletter_emails_index">newsletters panel</a>
86
  <strong>choose a theme</strong>, preview, twick it if needed and create your message.
87
  </li>
88
  <li>
89
  <em>I want to test my newsletter.</em> Save the newsletter and move to the
90
+ <a href="admin.php?page=newsletter_users_index">subscribers panel</a>.
91
  Create some subscribers manually using your own email addresses and mark them as test subscribers. They will be
92
  used for newsletter tests.
93
  </li>
131
  <?php } else { ?>
132
  <td>Not installed</td>
133
  <?php } ?>
134
+ <td><?php echo get_option('newsletter_reports_available_version'); ?></td>
135
  </tr>
136
  <tr>
137
  <td>
155
  <?php } else { ?>
156
  <td>Not installed</td>
157
  <?php } ?>
158
+ <td><?php echo get_option('newsletter_feed_available_version'); ?></td>
159
  </tr>
160
  <tr>
161
  <td>
167
  <?php } else { ?>
168
  <td>Not installed</td>
169
  <?php } ?>
170
+ <td><?php echo get_option('newsletter_followup_available_version'); ?></td>
171
  </tr>
172
  <tr>
173
  <td>
179
  <?php } else { ?>
180
  <td>Not installed</td>
181
  <?php } ?>
182
+ <td><?php echo get_option('newsletter_facebook_available_version'); ?></td>
183
  </tr>
184
  <tr>
185
  <td>
186
+ <a href="http://www.satollo.net/plugins/newsletter/sendgrid-module" target="_blank">SendGrid</a>
187
  <br><small>Integrates with <a href="http://www.satollo.net/affiliate/sendgrid" target="_blank">SendGrid</a> SMTP and bounce report</small>
188
  </td>
189
  <?php if (class_exists('NewsletterSendgrid')) { ?>
191
  <?php } else { ?>
192
  <td>Not installed</td>
193
  <?php } ?>
194
+ <td><?php echo get_option('newsletter_sendgrid_available_version'); ?></td>
195
+ </tr>
196
+ <tr>
197
+ <td>
198
+ <a href="http://www.satollo.net/plugins/newsletter/mandrill-module" target="_blank">Mandrill</a>
199
+ <br><small>Integrates with <a href="http://www.mandrill.com/" target="_blank">Mandrill by Mailchimp</a> SMTP and bounce report (experimental)</small>
200
+ </td>
201
+ <?php if (class_exists('NewsletterMandrill')) { ?>
202
+ <td><?php echo NewsletterMandrill::instance()->version; ?></td>
203
+ <?php } else { ?>
204
+ <td>Not installed</td>
205
+ <?php } ?>
206
+ <td><?php echo get_option('newsletter_mandrill_available_version'); ?></td>
207
  </tr>
208
+ <tr>
209
+ <td>
210
+ <a href="http://www.satollo.net/plugins/newsletter/popup-module" target="_blank">Popup</a>
211
+ <br><small>A very simple subscription popup (experimental)</small>
212
+ </td>
213
+ <?php if (class_exists('NewsletterPopup')) { ?>
214
+ <td><?php echo NewsletterPopup::instance()->version; ?></td>
215
+ <?php } else { ?>
216
+ <td>Not installed</td>
217
+ <?php } ?>
218
+ <td><?php echo get_option('newsletter_popup_available_version'); ?></td>
219
+ </tr>
220
  <tr>
221
  <td>
222
  <a href="http://www.satollo.net/plugins/newsletter/mailjet-module" target="_blank">MailJet</a>
227
  <?php } else { ?>
228
  <td>Not installed</td>
229
  <?php } ?>
230
+ <td><?php echo get_option('newsletter_mailjet_available_version'); ?></td>
231
  </tr>
232
  </tbody>
233
  </table>
234
+
235
+ <?php $controls->button('check_versions', 'Check for new versions'); ?>
236
 
237
  <h3>Support</h3>
238
  <p>
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
- Version: 3.3.1
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -13,7 +13,7 @@
13
  */
14
 
15
  // Useed as dummy parameter on css and js links
16
- define('NEWSLETTER_VERSION', '3.3.1');
17
 
18
  global $wpdb, $newsletter;
19
 
@@ -119,7 +119,7 @@ class Newsletter extends NewsletterModule {
119
  // Here because the upgrade is called by the parent constructor and uses the scheduler
120
  add_filter('cron_schedules', array($this, 'hook_cron_schedules'), 1000);
121
 
122
- parent::__construct('main', '1.1.6');
123
 
124
  $max = $this->options['scheduler_max'];
125
  if (!is_numeric($max))
@@ -128,6 +128,7 @@ class Newsletter extends NewsletterModule {
128
 
129
  add_action('init', array($this, 'hook_init'));
130
  add_action('newsletter', array($this, 'hook_newsletter'), 1);
 
131
 
132
 
133
  // This specific event is created by "Feed by mail" panel on configuration
@@ -232,6 +233,9 @@ class Newsletter extends NewsletterModule {
232
  wp_clear_scheduled_hook('newsletter');
233
  wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
234
 
 
 
 
235
  wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
236
  wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
237
 
@@ -344,6 +348,20 @@ class Newsletter extends NewsletterModule {
344
  return NewsletterStatistics::instance()->relink($text, $email_id, $user_id);
345
  }
346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  /**
348
  * Runs every 5 minutes and look for emails that need to be processed.
349
  */
@@ -763,7 +781,7 @@ class Newsletter extends NewsletterModule {
763
  } else {
764
  $text = str_replace('{name}', $user->name, $text);
765
  }
766
-
767
  switch ($user->sex) {
768
  case 'm': $text = str_replace('{title}', $options_profile['title_male'], $text);
769
  break;
@@ -1092,6 +1110,10 @@ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php')) {
1092
  require_once WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php';
1093
  }
1094
 
 
 
 
 
1095
  require_once(dirname(__FILE__) . '/widget.php');
1096
 
1097
  register_activation_hook(__FILE__, 'newsletter_activate');
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
+ Version: 3.3.2
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
13
  */
14
 
15
  // Useed as dummy parameter on css and js links
16
+ define('NEWSLETTER_VERSION', '3.3.2');
17
 
18
  global $wpdb, $newsletter;
19
 
119
  // Here because the upgrade is called by the parent constructor and uses the scheduler
120
  add_filter('cron_schedules', array($this, 'hook_cron_schedules'), 1000);
121
 
122
+ parent::__construct('main', '1.1.7');
123
 
124
  $max = $this->options['scheduler_max'];
125
  if (!is_numeric($max))
128
 
129
  add_action('init', array($this, 'hook_init'));
130
  add_action('newsletter', array($this, 'hook_newsletter'), 1);
131
+ add_action('newsletter_check_versions', array($this, 'hook_check_versions'), 99);
132
 
133
 
134
  // This specific event is created by "Feed by mail" panel on configuration
233
  wp_clear_scheduled_hook('newsletter');
234
  wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
235
 
236
+ wp_clear_scheduled_hook('newsletter_update');
237
+ wp_schedule_event(time() + 30, 'daily', 'newsletter_check_versions');
238
+
239
  wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
240
  wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
241
 
348
  return NewsletterStatistics::instance()->relink($text, $email_id, $user_id);
349
  }
350
 
351
+ function hook_check_versions() {
352
+ $this->logger->info('Checking for new versions');
353
+ $url = 'http://www.satollo.net/wp-content/plugins/file-commerce-pro/version.php?f=';
354
+ $modules = array('reports' => 34, 'feed' => 35, 'followup' => 37,
355
+ 'facebook' => 41, 'sendgrid' => 40, 'popup' => 43, 'mandrill' => 44);
356
+
357
+ foreach ($modules as $name => $id) {
358
+ $version = @file_get_contents($url . $id);
359
+ if ($version) {
360
+ update_option('newsletter_' . $name . '_available_version', $version);
361
+ }
362
+ }
363
+ }
364
+
365
  /**
366
  * Runs every 5 minutes and look for emails that need to be processed.
367
  */
781
  } else {
782
  $text = str_replace('{name}', $user->name, $text);
783
  }
784
+
785
  switch ($user->sex) {
786
  case 'm': $text = str_replace('{title}', $options_profile['title_male'], $text);
787
  break;
1110
  require_once WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php';
1111
  }
1112
 
1113
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php')) {
1114
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php';
1115
+ }
1116
+
1117
  require_once(dirname(__FILE__) . '/widget.php');
1118
 
1119
  register_activation_hook(__FILE__, 'newsletter_activate');
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing
3
  Requires at least: 3.3.0
4
  Tested up to: 3.5.1
5
- Stable tag: 3.3.1
6
  Donate link: http://www.satollo.net/donations
7
 
8
  Add a real newsletter to your blog. In seconds. For free. With unlimited emails and subscribers.
@@ -55,6 +55,17 @@ No screen shots are available at this time.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
 
 
 
 
 
58
  = 3.3.1 =
59
 
60
  * Fixed a bug in an administrative query
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing
3
  Requires at least: 3.3.0
4
  Tested up to: 3.5.1
5
+ Stable tag: 3.3.2
6
  Donate link: http://www.satollo.net/donations
7
 
8
  Add a real newsletter to your blog. In seconds. For free. With unlimited emails and subscribers.
55
 
56
  == Changelog ==
57
 
58
+ = 3.3.2 =
59
+
60
+ * Disabled the save button on composer when the newsletter is "sending" or "sent"
61
+ * Added ip field on statistics
62
+ * Reviewed the subscriber statistics panel
63
+ * Fixed some links on welcome panel
64
+ * Added extensions version check
65
+ * Added the Mandrill Extension support
66
+ * Fixed the banner options on default theme
67
+ * New "new newsletter" panel (hope simpler to use)
68
+
69
  = 3.3.1 =
70
 
71
  * Fixed a bug in an administrative query
statistics/link.php CHANGED
@@ -8,7 +8,8 @@ $wpdb->insert(NEWSLETTER_STATS_TABLE,
8
  'email_id' => $email_id,
9
  'user_id' => $user_id,
10
  'url' => $url,
11
- 'anchor' => $anchor
 
12
  )
13
  );
14
 
8
  'email_id' => $email_id,
9
  'user_id' => $user_id,
10
  'url' => $url,
11
+ 'anchor' => $anchor,
12
+ 'ip' => $_SERVER['REMOTE_ADDR']
13
  )
14
  );
15
 
statistics/statistics.php CHANGED
@@ -4,8 +4,6 @@ require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
4
 
5
  class NewsletterStatistics extends NewsletterModule {
6
 
7
- const VERSION = '1.0.3';
8
-
9
  static $instance;
10
 
11
  /**
@@ -19,7 +17,7 @@ class NewsletterStatistics extends NewsletterModule {
19
  }
20
 
21
  function __construct() {
22
- parent::__construct('statistics', self::VERSION, 34);
23
  }
24
 
25
  function upgrade() {
@@ -42,10 +40,11 @@ class NewsletterStatistics extends NewsletterModule {
42
  // Future... see the links table
43
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column link_id int not null default 0");
44
 
45
- $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column user_id int not null default 0");
46
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column created timestamp not null default current_timestamp");
47
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column url varchar(255) not null default ''");
48
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column anchor varchar(200) not null default ''");
 
 
49
 
50
  // Stores the link of every email to create short links
51
  // $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_links (id int auto_increment, primary key (id)) $charset_collate");
4
 
5
  class NewsletterStatistics extends NewsletterModule {
6
 
 
 
7
  static $instance;
8
 
9
  /**
17
  }
18
 
19
  function __construct() {
20
+ parent::__construct('statistics', '1.0.5');
21
  }
22
 
23
  function upgrade() {
40
  // Future... see the links table
41
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column link_id int not null default 0");
42
 
 
43
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column created timestamp not null default current_timestamp");
44
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column url varchar(255) not null default ''");
45
  $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column anchor varchar(200) not null default ''");
46
+ $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column ip varchar(20) not null default ''");
47
+ $this->upgrade_query("alter table {$wpdb->prefix}newsletter_stats add column country varchar(4) not null default ''");
48
 
49
  // Stores the link of every email to create short links
50
  // $this->upgrade_query("create table if not exists {$wpdb->prefix}newsletter_links (id int auto_increment, primary key (id)) $charset_collate");
users/stats.php CHANGED
@@ -7,198 +7,261 @@
7
 
8
 
9
  <div class="wrap">
10
- <?php $help_url = 'http://www.satollo.net/plugins/newsletter/subscribers-module'; ?>
11
- <?php include NEWSLETTER_DIR . '/header.php'; ?>
 
12
  <?php include NEWSLETTER_DIR . '/users/menu.inc.php'; ?>
13
 
14
- <h2>Subscriber Statistics</h2>
15
-
16
- <p>Counts are limited to confirmed subscribers.</p>
17
-
18
- <h3>Overview</h3>
19
- <table class="widefat" style="width: 300px;">
20
- <thead><tr><th>Status</th><th>Total</th></thead>
21
- <tr valign="top">
22
- <td>Any</td>
23
- <td>
24
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter"); ?>
25
- </td>
26
- </tr>
27
- <tr>
28
- <td>Confirmed</td>
29
- <td>
30
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='C'"); ?>
31
- </td>
32
- </tr>
33
- <tr>
34
- <td>Not confirmed</td>
35
- <td>
36
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='S'"); ?>
37
- </td>
38
- </tr>
39
- <tr>
40
- <td>Subscribed to feed by mail</td>
41
- <td>
42
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='C' and feed=1"); ?>
43
- </td>
44
- </tr>
45
- <tr>
46
- <td>Unsubscribed</td>
47
- <td>
48
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='U'"); ?>
49
- </td>
50
- </tr>
51
- <tr>
52
- <td>Bounced</td>
53
- <td>
54
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='B'"); ?>
55
- </td>
56
- </tr>
57
- </table>
58
-
59
- <h3>Totals by preference</h3>
60
- <p><a href="http://www.satollo.net/plugins/newsletter/newsletter-preferences" target="_blank">Click here know more about preferences.</a> They can be configured on Subscription/Form field panel.</p>
61
- <table class="widefat" style="width: 300px;">
62
- <thead><tr><th>Preference</th><th>Total</th></thead>
63
- <?php for ($i=1; $i<=NEWSLETTER_LIST_MAX; $i++) { ?>
64
- <?php if (empty($options_profile['list_' . $i])) continue; ?>
65
- <tr>
66
- <td><?php echo '(' . $i . ') ' . $options_profile['list_' . $i]; ?></td>
67
- <td>
68
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where list_" . $i . "=1 and status='C'"); ?>
69
- </td>
70
- </tr>
71
- <?php } ?>
72
- </table>
73
-
74
- <h3>Referrer</h3>
75
- <?php
76
- $list = $wpdb->get_results("select referrer, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' group by referrer order by referrer");
77
- ?>
78
- <table class="widefat" style="width: 300px">
79
- <thead><tr><th>Referrer</th><th>Total</th></thead>
80
- <?php foreach($list as $row) { ?>
81
- <tr><td><?php echo $row->referrer; ?></td><td><?php echo $row->total; ?></td></tr>
82
- <?php } ?>
83
- </table>
84
-
85
- <h3>Source</h3>
86
- <?php
87
- $list = $wpdb->get_results("select http_referer, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' group by http_referer order by count(*) desc");
88
- ?>
89
- <table class="widefat" style="width: 300px">
90
- <thead><tr><th>URL</th><th>Total</th></thead>
91
- <?php foreach($list as $row) { ?>
92
- <tr><td><?php echo $row->http_referer; ?></td><td><?php echo $row->total; ?></td></tr>
93
- <?php } ?>
94
- </table>
95
-
96
- <h3>Sex</h3>
97
- <?php
98
- $male_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='m'");
99
- $female_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='f'");
100
- $other_count = ($all_count-$male_count-$female_count)
101
- ?>
102
- <table class="widefat" style="width: 300px">
103
- <thead><tr><th>Sex</th><th>Total</th></thead>
104
- <tr><td>Male</td><td><?php echo $male_count; ?></td></tr>
105
- <tr><td>Female</td><td><?php echo $female_count; ?></td></tr>
106
- <tr><td>Not specified</td><td><?php echo $other_count; ?></td></tr>
107
- </table>
108
-
109
- <p>
110
- <div id="sex-chart" style="width:400; height:300"></div>
111
- </p>
112
-
113
-
114
- <h3>Subscriptions over time</h3>
115
-
116
- <h4>Subscriptions by month</h4>
117
- <?php
118
- $months = $wpdb->get_results("select count(*) as c, concat(year(created), '-', date_format(created, '%m')) as d from " . $wpdb->prefix . "newsletter where status='C' group by concat(year(created), '-', date_format(created, '%m')) order by d desc limit 24");
119
- ?>
120
-
121
- <div id="months-chart" style="width:400; height:300"></div>
122
-
123
- <table class="widefat" style="width: 300px">
124
- <thead>
125
- <tr valign="top">
126
- <th>Date</th>
127
- <th>Subscribers</th>
128
- </tr>
129
- </thead>
130
- <?php foreach ($months as $day) { ?>
131
- <tr valign="top">
132
- <td><?php echo $day->d; ?></td>
133
- <td><?php echo $day->c; ?></td>
134
- </tr>
135
- <?php } ?>
136
- </table>
137
-
138
-
139
- <h4>Subscriptions by day</h4>
140
- <?php
141
- $list = $wpdb->get_results("select count(*) as c, date(created) as d from " . $wpdb->prefix . "newsletter where status='C' group by date(created) order by d desc limit 365");
142
- ?>
143
- <table class="widefat" style="width: 300px">
144
- <thead>
145
- <tr valign="top">
146
- <th>Date</th>
147
- <th>Subscribers</th>
148
- </tr>
149
- </thead>
150
- <?php foreach ($list as $day) { ?>
151
- <tr valign="top">
152
- <td><?php echo $day->d; ?></td>
153
- <td><?php echo $day->c; ?></td>
154
- </tr>
155
  <?php } ?>
156
- </table>
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
  </div>
160
 
 
161
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
162
  <script type="text/javascript">
 
163
 
164
- // Load the Visualization API and the piechart package.
165
- google.load('visualization', '1.0', {'packages':['corechart']});
166
 
167
- // Set a callback to run when the Google Visualization API is loaded.
168
- google.setOnLoadCallback(drawChart);
169
 
170
- function drawChart() {
171
 
172
- // Create the data table.
173
- var data = new google.visualization.DataTable();
174
- data.addColumn('string', 'Topping');
175
- data.addColumn('number', 'Slices');
176
- data.addRows([
177
- ['None', <?php echo $other_count; ?>],
178
- ['Female', <?php echo $female_count; ?>],
179
- ['Male', <?php echo $male_count; ?>]
180
- ]);
181
 
182
- // Set chart options
183
- var options = {'title':'Gender',
184
- 'width':400,
185
- 'height':300};
186
 
187
- var chart = new google.visualization.PieChart(document.getElementById('sex-chart'));
188
- chart.draw(data, options);
189
 
190
- var months = new google.visualization.DataTable();
191
- months.addColumn('string', 'Topping');
192
- months.addColumn('number', 'Slices');
193
 
194
- <?php foreach ($months as $day) { ?>
195
- months.addRow(['<?php echo $day->d; ?>', <?php echo $day->c; ?>]);
196
- <?php } ?>
 
 
197
 
198
- var options = {'title':'By months', 'width':400, 'height':300};
 
199
 
200
- var chart = new google.visualization.BarChart(document.getElementById('months-chart'));
201
- chart.draw(months, options);
202
- }
 
 
 
 
203
 
 
 
 
 
 
204
  </script>
7
 
8
 
9
  <div class="wrap">
10
+
11
+ <?php $help_url = 'http://www.satollo.net/plugins/newsletter/subscribers-module'; ?>
12
+ <?php include NEWSLETTER_DIR . '/header.php'; ?>
13
  <?php include NEWSLETTER_DIR . '/users/menu.inc.php'; ?>
14
 
15
+ <h2>Subscriber Statistics</h2>
16
+
17
+ <p>Reports are limited to confirmed subscribers.</p>
18
+
19
+ <div id="tabs">
20
+
21
+ <ul>
22
+ <li><a href="#tab-overview">Overview</a></li>
23
+ <li><a href="#tabs-preferences">Preferences</a></li>
24
+ <li><a href="#tabs-countries">Countries</a></li>
25
+ <li><a href="#tabs-referrers">Referrers</a></li>
26
+ <li><a href="#tabs-sources">Sources</a></li>
27
+ <li><a href="#tabs-gender">Gender</a></li>
28
+ <li><a href="#tabs-time">By time</a></li>
29
+ </ul>
30
+
31
+ <div id="tab-overview">
32
+
33
+ <table class="widefat" style="width: 300px;">
34
+ <thead><tr><th>Status</th><th>Total</th></thead>
35
+ <tr valign="top">
36
+ <td>Any</td>
37
+ <td>
38
+ <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter"); ?>
39
+ </td>
40
+ </tr>
41
+ <tr>
42
+ <td>Confirmed</td>
43
+ <td>
44
+ <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='C'"); ?>
45
+ </td>
46
+ </tr>
47
+ <tr>
48
+ <td>Not confirmed</td>
49
+ <td>
50
+ <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='S'"); ?>
51
+ </td>
52
+ </tr>
53
+ <tr>
54
+ <td>Subscribed to feed by mail</td>
55
+ <td>
56
+ <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='C' and feed=1"); ?>
57
+ </td>
58
+ </tr>
59
+ <tr>
60
+ <td>Unsubscribed</td>
61
+ <td>
62
+ <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='U'"); ?>
63
+ </td>
64
+ </tr>
65
+ <tr>
66
+ <td>Bounced</td>
67
+ <td>
68
+ <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='B'"); ?>
69
+ </td>
70
+ </tr>
71
+ </table>
72
+
73
+ </div>
74
+
75
+
76
+ <div id="tabs-preferences">
77
+
78
+ <div class="tab-preamble">
79
+ <a href="http://www.satollo.net/plugins/newsletter/newsletter-preferences" target="_blank">Click here know more about preferences.</a>
80
+ They can be configured on Subscription/Form field panel.
81
+ </div>
82
+
83
+ <table class="widefat" style="width: 300px;">
84
+ <thead><tr><th>Preference</th><th>Total</th></thead>
85
+ <?php for ($i=1; $i<=NEWSLETTER_LIST_MAX; $i++) { ?>
86
+ <?php if (empty($options_profile['list_' . $i])) continue; ?>
87
+ <tr>
88
+ <td><?php echo '(' . $i . ') ' . $options_profile['list_' . $i]; ?></td>
89
+ <td>
90
+ <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where list_" . $i . "=1 and status='C'"); ?>
91
+ </td>
92
+ </tr>
93
+ <?php } ?>
94
+ </table>
95
+
96
+ </div>
97
+
98
+
99
+ <div id="tabs-countries">
100
+
101
+ <?php
102
+ if (class_exists('NewsletterReports')) {
103
+ $countries = $wpdb->get_results("select country, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' and country<>'' group by country order by total");
104
+ }
105
+ ?>
106
+
107
+ <?php if (!class_exists('NewsletterReports')) { ?>
108
+ <p>You need the <a href="http://www.satollo.net/plugins/newsletter/reports-module" target="_blank">Reports Extension</a> for this chart.</p>
109
+ <?php } else if (empty($countries)) { ?>
110
+ <p>No data available, just wait some time to let the processor to work on your subscriber list. Thank you.</p>
111
+ <?php } else { ?>
112
+ <p><div id="country-chart" style="width:400; height:300"></div></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  <?php } ?>
 
114
 
115
+ </div>
116
+
117
+
118
+ <div id="tabs-referrers">
119
+
120
+ <?php
121
+ $list = $wpdb->get_results("select referrer, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' group by referrer order by total desc");
122
+ ?>
123
+ <table class="widefat" style="width: 300px">
124
+ <thead><tr><th>Referrer</th><th>Total</th></thead>
125
+ <?php foreach($list as $row) { ?>
126
+ <tr><td><?php echo $row->referrer; ?></td><td><?php echo $row->total; ?></td></tr>
127
+ <?php } ?>
128
+ </table>
129
+
130
+ </div>
131
+
132
+
133
+ <div id="tabs-sources">
134
+
135
+ <?php
136
+ $list = $wpdb->get_results("select http_referer, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' group by http_referer order by count(*) desc limit 100");
137
+ ?>
138
+ <table class="widefat" style="width: 300px">
139
+ <thead><tr><th>URL</th><th>Total</th></thead>
140
+ <?php foreach($list as $row) { ?>
141
+ <tr><td><?php echo $row->http_referer; ?></td><td><?php echo $row->total; ?></td></tr>
142
+ <?php } ?>
143
+ </table>
144
+
145
+ </div>
146
+
147
+
148
+ <div id="tabs-gender">
149
+
150
+ <?php
151
+ $male_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='m'");
152
+ $female_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='f'");
153
+ $other_count = ($all_count-$male_count-$female_count)
154
+ ?>
155
+ <table class="widefat" style="width: 300px">
156
+ <thead><tr><th>Sex</th><th>Total</th></thead>
157
+ <tr><td>Male</td><td><?php echo $male_count; ?></td></tr>
158
+ <tr><td>Female</td><td><?php echo $female_count; ?></td></tr>
159
+ <tr><td>Not specified</td><td><?php echo $other_count; ?></td></tr>
160
+ </table>
161
+
162
+ <p><div id="sex-chart"></div></p>
163
+
164
+ </div>
165
+
166
+
167
+ <div id="tabs-time">
168
+
169
+ <h4>Subscriptions by month (max 24 months)</h4>
170
+ <?php
171
+ $months = $wpdb->get_results("select count(*) as c, concat(year(created), '-', date_format(created, '%m')) as d from " . $wpdb->prefix . "newsletter where status='C' group by concat(year(created), '-', date_format(created, '%m')) order by d desc limit 24");
172
+ ?>
173
+ <div id="months-chart"></div>
174
+
175
+ <table class="widefat" style="width: 300px">
176
+ <thead>
177
+ <tr valign="top">
178
+ <th>Date</th>
179
+ <th>Subscribers</th>
180
+ </tr>
181
+ </thead>
182
+ <?php foreach ($months as &$day) { ?>
183
+ <tr valign="top">
184
+ <td><?php echo $day->d; ?></td>
185
+ <td><?php echo $day->c; ?></td>
186
+ </tr>
187
+ <?php } ?>
188
+ </table>
189
+
190
+ <h4>Subscriptions by day (max 90 days)</h4>
191
+ <?php
192
+ $list = $wpdb->get_results("select count(*) as c, date(created) as d from " . $wpdb->prefix . "newsletter where status='C' group by date(created) order by d desc limit 90");
193
+ ?>
194
+ <table class="widefat" style="width: 300px">
195
+ <thead>
196
+ <tr valign="top">
197
+ <th>Date</th>
198
+ <th>Subscribers</th>
199
+ </tr>
200
+ </thead>
201
+ <?php foreach ($list as $day) { ?>
202
+ <tr valign="top">
203
+ <td><?php echo $day->d; ?></td>
204
+ <td><?php echo $day->c; ?></td>
205
+ </tr>
206
+ <?php } ?>
207
+ </table>
208
+
209
+ </div>
210
+
211
+ </div>
212
 
213
  </div>
214
 
215
+
216
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
217
  <script type="text/javascript">
218
+ google.load('visualization', '1', {'packages':['corechart', 'geochart']});
219
 
220
+ google.setOnLoadCallback(drawChart);
 
221
 
222
+ function drawChart() {
 
223
 
 
224
 
225
+ var data = new google.visualization.DataTable();
226
+ data.addColumn('string', 'Gender');
227
+ data.addColumn('number', 'Total');
228
+ data.addRows([
229
+ ['None', <?php echo $other_count; ?>],
230
+ ['Female', <?php echo $female_count; ?>],
231
+ ['Male', <?php echo $male_count; ?>]
232
+ ]);
 
233
 
234
+ var options = {'title':'Gender',
235
+ 'width':400,
236
+ 'height':300};
 
237
 
238
+ var chart = new google.visualization.PieChart(document.getElementById('sex-chart'));
239
+ chart.draw(data, options);
240
 
241
+ var months = new google.visualization.DataTable();
242
+ months.addColumn('string', 'Month');
243
+ months.addColumn('number', 'Subscribers');
244
 
245
+ <?php foreach ($months as $day) { ?>
246
+ months.addRow(['<?php echo $day->d; ?>', <?php echo $day->c; ?>]);
247
+ <?php } ?>
248
+
249
+ var options = {'title':'By months', 'width':700, 'height':500};
250
 
251
+ var chart = new google.visualization.BarChart(document.getElementById('months-chart'));
252
+ chart.draw(months, options);
253
 
254
+ <?php if (!empty($countries)) { ?>
255
+ var countries = new google.visualization.DataTable();
256
+ countries.addColumn('string', 'Country');
257
+ countries.addColumn('number', 'Total');
258
+ <?php foreach ($countries as &$country) { ?>
259
+ countries.addRow(['<?php echo $country->country; ?>', <?php echo $country->total; ?>]);
260
+ <?php } ?>
261
 
262
+ var options = {'title': 'Country', 'width': 700, 'height': 500};
263
+ var chart = new google.visualization.GeoChart(document.getElementById('country-chart'));
264
+ chart.draw(countries, options);
265
+ <?php } ?>
266
+ }
267
  </script>
users/users.php CHANGED
@@ -4,8 +4,6 @@ require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
4
 
5
  class NewsletterUsers extends NewsletterModule {
6
 
7
- const VERSION = '1.0.3';
8
-
9
  static $instance;
10
 
11
  /**
@@ -19,7 +17,7 @@ class NewsletterUsers extends NewsletterModule {
19
  }
20
 
21
  function __construct() {
22
- parent::__construct('users', self::VERSION);
23
  }
24
 
25
  function upgrade() {
@@ -42,6 +40,7 @@ class NewsletterUsers extends NewsletterModule {
42
  // Feed by mail
43
  $this->upgrade_query("alter table " . $wpdb->prefix . "newsletter add column feed tinyint(4) not null default 0");
44
  $this->upgrade_query("alter table " . $wpdb->prefix . "newsletter add column feed_time bigint(20) not null default 0");
 
45
 
46
  // List/Preferences
47
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
4
 
5
  class NewsletterUsers extends NewsletterModule {
6
 
 
 
7
  static $instance;
8
 
9
  /**
17
  }
18
 
19
  function __construct() {
20
+ parent::__construct('users', '1.0.4');
21
  }
22
 
23
  function upgrade() {
40
  // Feed by mail
41
  $this->upgrade_query("alter table " . $wpdb->prefix . "newsletter add column feed tinyint(4) not null default 0");
42
  $this->upgrade_query("alter table " . $wpdb->prefix . "newsletter add column feed_time bigint(20) not null default 0");
43
+ $this->upgrade_query("alter table {$wpdb->prefix}newsletter add column country varchar(4) not null default ''");
44
 
45
  // List/Preferences
46
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {