Subscribe2 - Version 8.0

Version Description

Download this release

Release Info

Developer MattyRob
Plugin Icon 128x128 Subscribe2
Version 8.0
Comparing to
See all releases

Code changes from version 7.2 to 8.0

ReadMe.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_butt
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 3.1
6
  Tested up to: 3.3.1
7
- Stable tag: 7.2
8
 
9
  Sends a list of subscribers an email notification when new posts are published to your blog
10
 
@@ -188,6 +188,10 @@ In order to force sending you'd need to change the date of publication on the po
188
 
189
  If you opt for the latter way look in the options table for the subscribe2_options settings (it's an array) and you'll need to change the 'last_s2cron' value to a timestamp for last week. Then force the cron event to run again with [WP-Crontrol](http://wordpress.org/extend/plugins/wp-crontrol/).
190
 
 
 
 
 
191
  = How do I make use of the support for Custom Post Types =
192
 
193
  In a plugin file for your site or perhaps functions.php in your theme add the following code where 'my_post_type' is change to the name of your custom post type.
@@ -299,6 +303,20 @@ Secondly, make sure that the token ([subscribe2] or <!--subscribe2-->) is correc
299
 
300
  == Changelog ==
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  = Version 7.2 by Matthew Robinson =
303
 
304
  * Fix for non-sending Preview emails when sender details match recipient details exactly
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 3.1
6
  Tested up to: 3.3.1
7
+ Stable tag: 8.0
8
 
9
  Sends a list of subscribers an email notification when new posts are published to your blog
10
 
188
 
189
  If you opt for the latter way look in the options table for the subscribe2_options settings (it's an array) and you'll need to change the 'last_s2cron' value to a timestamp for last week. Then force the cron event to run again with [WP-Crontrol](http://wordpress.org/extend/plugins/wp-crontrol/).
190
 
191
+ = I would really like Registered users to have the Subscription page themed like my site, is this possible? =
192
+
193
+ Yes, it is. There is a small extension to Subscribe2 that delivers exactly this functionality. It is available from [Theme Tailors(http://stiofan.themetailors.com/store/products/tt-subscribe2-front-end-plugin/) for just $2.
194
+
195
  = How do I make use of the support for Custom Post Types =
196
 
197
  In a plugin file for your site or perhaps functions.php in your theme add the following code where 'my_post_type' is change to the name of your custom post type.
303
 
304
  == Changelog ==
305
 
306
+ = Version 8.0 by Matthew Robinson =
307
+
308
+ * Split the main plugin file into separate classes for more efficient (60% less RAM) server resource usage - huge thanks to Milan Petrovic
309
+ * Ensure notifications for posts are sent to all active registered users
310
+ * Fixed bug in Bulk Management code to include all filtered Registered Subscribers, not just those on current screen - thanks to samandiriel
311
+ * Fixed some PHP messages regarding use of deprecated clean_url() function and WordPress version checking - thanks to anmari
312
+ * Improved white space trimming in the code so it respects tabs and line breaks - thanks to belg4mit
313
+ * Updated screenshots to Subscribe2 8.0 and WordPress 3.3.1 screen layouts
314
+ * Implemented one-click buttons to subscribe and unsubscribe - thanks to dimadin for code patch
315
+ * Changed some default settings, sender to BLOGNAME and number of recipients per email to 1
316
+ * Implemented a change so that categories are not displayed in the filter dropdowns when using Subscribe2 in digest mode
317
+ * Ensure an action is specified for HTML5 validity - thanks to Franco Carinato
318
+ * Introduced 4 new hooks to filter per-post subscribers for each of the 4 email types - thanks to Nicolas Noé
319
+
320
  = Version 7.2 by Matthew Robinson =
321
 
322
  * Fix for non-sending Preview emails when sender details match recipient details exactly
admin/send_email.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !function_exists('add_action') ) {
3
+ exit();
4
+ }
5
+
6
+ global $wpdb, $s2nonce, $current_user;
7
+
8
+ // was anything POSTed?
9
+ if ( isset($_POST['s2_admin']) && 'mail' == $_POST['s2_admin'] ) {
10
+ check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
11
+ $subject = $this->substitute(stripslashes(strip_tags($_POST['subject'])));
12
+ $body = $this->substitute(stripslashes($_POST['content']));
13
+ if ( '' != $current_user->display_name || '' != $current_user->user_email ) {
14
+ $this->myname = html_entity_decode($current_user->display_name, ENT_QUOTES);
15
+ $this->myemail = $current_user->user_email;
16
+ }
17
+ if ( isset($_POST['send']) ) {
18
+ if ( 'confirmed' == $_POST['what'] ) {
19
+ $recipients = $this->get_public();
20
+ } elseif ( 'unconfirmed' == $_POST['what'] ) {
21
+ $recipients = $this->get_public(0);
22
+ } elseif ( 'public' == $_POST['what'] ) {
23
+ $confirmed = $this->get_public();
24
+ $unconfirmed = $this->get_public(0);
25
+ $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
26
+ } elseif ( is_numeric($_POST['what']) ) {
27
+ $cat = intval($_POST['what']);
28
+ $recipients = $this->get_registered("cats=$cat");
29
+ } elseif ( 'all_users' == $_POST['what'] ) {
30
+ $recipients = $this->get_all_registered();
31
+ } else {
32
+ $recipients = $this->get_registered();
33
+ }
34
+ } elseif ( isset($_POST['preview']) ) {
35
+ global $user_email;
36
+ $recipients[] = $user_email;
37
+ }
38
+ $status = $this->mail($recipients, $subject, $body, 'text');
39
+ if ( $status ) {
40
+ $message = $this->mail_sent;
41
+ } else {
42
+ global $phpmailer;
43
+ $message = $this->mail_failed . $phpmailer->ErrorInfo;
44
+ }
45
+ echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
46
+ }
47
+
48
+ // show our form
49
+ echo "<div class=\"wrap\">";
50
+ echo "<div id=\"icon-edit\" class=\"icon32\"></div>";
51
+ echo "<h2>" . __('Send an email to subscribers', 'subscribe2') . "</h2>\r\n";
52
+ echo "<form method=\"post\" action=\"\">\r\n";
53
+ if ( function_exists('wp_nonce_field') ) {
54
+ wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
55
+ }
56
+ if ( isset($_POST['subject']) ) {
57
+ $subject = $_POST['subject'];
58
+ } else {
59
+ $subject = __('A message from', 'subscribe2') . " " . html_entity_decode(get_option('blogname'), ENT_QUOTES);
60
+ }
61
+ if ( !isset($_POST['content']) ) {
62
+ $body = '';
63
+ }
64
+ echo "<p>" . __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . $subject . "\" /> <br /><br />";
65
+ echo "<textarea rows=\"12\" cols=\"75\" name=\"content\">" . $body . "</textarea>";
66
+ echo "<br /><br />\r\n";
67
+ echo __('Recipients:', 'subscribe2') . " ";
68
+ $this->display_subscriber_dropdown('registered', false, array('all'));
69
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
70
+ echo "</p>";
71
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Preview', 'subscribe2') . "\" \><input type=\"submit\" class=\"button-primary\" name=\"send\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
72
+ echo "</form></div>\r\n";
73
+ echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
74
+
75
+ include(ABSPATH . 'wp-admin/admin-footer.php');
76
+ // just to be sure
77
+ die;
78
+ ?>
admin/settings.php ADDED
@@ -0,0 +1,481 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !function_exists('add_action') ) {
3
+ exit();
4
+ }
5
+
6
+ global $s2nonce, $wpdb, $wp_version;
7
+
8
+ // send error message if no WordPress page exists
9
+ $sql = "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1";
10
+ $id = $wpdb->get_var($sql);
11
+ if ( empty($id) ) {
12
+ echo "<div id=\"message\" class=\"error\"><p><strong>$this->no_page</strong></p></div>";
13
+ }
14
+
15
+ // was anything POSTed?
16
+ if ( isset( $_POST['s2_admin']) ) {
17
+ check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
18
+ if ( $_POST['reset'] ) {
19
+ $this->reset();
20
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_reset</strong></p></div>";
21
+ } elseif ( $_POST['preview'] ) {
22
+ global $user_email;
23
+ $this->preview_email = true;
24
+ if ( 'never' == $this->subscribe2_options['email_freq'] ) {
25
+ $post = get_posts('numberposts=1');
26
+ $this->publish($post[0], $user_email);
27
+ } else {
28
+ $this->subscribe2_cron($user_email);
29
+ }
30
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Preview message(s) sent to logged in user', 'subscribe2') . "</strong></p></div>";
31
+ } elseif ( $_POST['resend'] ) {
32
+ $status = $this->subscribe2_cron('', 'resend');
33
+ if ( $status === false ) {
34
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('The Digest Notification email contained no post information. No email was sent', 'subscribe2') . "</strong></p></div>";
35
+ } else {
36
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Attempt made to resend the Digest Notification email', 'subscribe2') . "</strong></p></div>";
37
+ }
38
+ } elseif ( $_POST['submit'] ) {
39
+ // BCClimit
40
+ if ( is_numeric($_POST['bcc']) && $_POST['bcc'] >= 0 ) {
41
+ $this->subscribe2_options['bcclimit'] = $_POST['bcc'];
42
+ }
43
+ // admin_email
44
+ $this->subscribe2_options['admin_email'] = $_POST['admin_email'];
45
+
46
+ // send as blogname, author or admin?
47
+ if ( is_numeric($_POST['sender']) ) {
48
+ $sender = $_POST['sender'];
49
+ } elseif ($_POST['sender'] == 'author') {
50
+ $sender = 'author';
51
+ } else {
52
+ $sender = 'blogname';
53
+ }
54
+ $this->subscribe2_options['sender'] = $sender;
55
+
56
+ // send email for pages, private and password protected posts
57
+ $this->subscribe2_options['stylesheet'] = $_POST['stylesheet'];
58
+ $this->subscribe2_options['pages'] = $_POST['pages'];
59
+ $this->subscribe2_options['password'] = $_POST['password'];
60
+ $this->subscribe2_options['private'] = $_POST['private'];
61
+ $this->subscribe2_options['cron_order'] = $_POST['cron_order'];
62
+ $this->subscribe2_options['tracking'] = $_POST['tracking'];
63
+
64
+ // send per-post or digest emails
65
+ $email_freq = $_POST['email_freq'];
66
+ $scheduled_time = wp_next_scheduled('s2_digest_cron');
67
+ if ( $email_freq != $this->subscribe2_options['email_freq'] || $_POST['hour'] != date('H', $scheduled_time) ) {
68
+ // make sure the timezone strings are right
69
+ if ( function_exists('date_default_timezone_get') && date_default_timezone_get() != get_option('timezone_string') ) {
70
+ date_default_timezone_set(get_option('timezone_string'));
71
+ }
72
+ $this->subscribe2_options['email_freq'] = $email_freq;
73
+ wp_clear_scheduled_hook('s2_digest_cron');
74
+ $scheds = (array)wp_get_schedules();
75
+ $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
76
+ if ( $interval == 0 ) {
77
+ // if we are on per-post emails remove last_cron entry
78
+ unset($this->subscribe2_options['last_s2cron']);
79
+ unset($this->subscribe2_options['previous_s2cron']);
80
+ } else {
81
+ // if we are using digest schedule the event and prime last_cron as now
82
+ $time = time() + $interval;
83
+ if ( $interval < 86400 ) {
84
+ // Schedule CRON events occurring less than daily starting now and periodically thereafter
85
+ $maybe_time = mktime($_POST['hour'], 0, 0, date('m', time()), date('d', time()), date('Y', time()));
86
+ // is maybe_time in the future
87
+ $offset = $maybe_time - time();
88
+ // is maybe_time + $interval in the future
89
+ $offset2 = ($maybe_time + $interval) - time();
90
+ if ( $offset < 0 ) {
91
+ if ( $offset2 < 0 ) {
92
+ $timestamp = &$time;
93
+ } else {
94
+ $timestamp = $maybe_time + $interval;
95
+ }
96
+ } else {
97
+ $timestamp = &$maybe_time;
98
+ }
99
+ } else {
100
+ // Schedule other CRON events starting at user defined hour and periodically thereafter
101
+ $timestamp = mktime($_POST['hour'], 0, 0, date('m', $time), date('d', $time), date('Y', $time));
102
+ }
103
+ wp_schedule_event($timestamp, $email_freq, 's2_digest_cron');
104
+ if ( !isset($this->subscribe2_options['last_s2cron']) ) {
105
+ $this->subscribe2_options['last_s2cron'] = current_time('mysql');
106
+ }
107
+ }
108
+ }
109
+
110
+ // email subject and body templates
111
+ // ensure that are not empty before updating
112
+ if ( !empty($_POST['notification_subject']) ) {
113
+ $this->subscribe2_options['notification_subject'] = $_POST['notification_subject'];
114
+ }
115
+ if ( !empty($_POST['mailtext']) ) {
116
+ $this->subscribe2_options['mailtext'] = $_POST['mailtext'];
117
+ }
118
+ if ( !empty($_POST['confirm_subject']) ) {
119
+ $this->subscribe2_options['confirm_subject'] = $_POST['confirm_subject'];
120
+ }
121
+ if ( !empty($_POST['confirm_email']) ) {
122
+ $this->subscribe2_options['confirm_email'] = $_POST['confirm_email'];
123
+ }
124
+ if ( !empty($_POST['remind_subject']) ) {
125
+ $this->subscribe2_options['remind_subject'] = $_POST['remind_subject'];
126
+ }
127
+ if ( !empty($_POST['remind_email']) ) {
128
+ $this->subscribe2_options['remind_email'] = $_POST['remind_email'];
129
+ }
130
+
131
+ // excluded categories
132
+ if ( !empty($_POST['category']) ) {
133
+ sort($_POST['category']);
134
+ $exclude_cats = implode(',', $_POST['category']);
135
+ } else {
136
+ $exclude_cats = '';
137
+ }
138
+ $this->subscribe2_options['exclude'] = $exclude_cats;
139
+ // allow override?
140
+ ( isset($_POST['reg_override']) ) ? $override = '1' : $override = '0';
141
+ $this->subscribe2_options['reg_override'] = $override;
142
+
143
+ // excluded formats
144
+ if ( !empty($_POST['format']) ) {
145
+ $exclude_formats = implode(',', $_POST['format']);
146
+ } else {
147
+ $exclude_formats = '';
148
+ }
149
+ $this->subscribe2_options['exclude_formats'] = $exclude_formats;
150
+
151
+ // default WordPress page where Subscribe2 token is placed
152
+ if ( is_numeric($_POST['page']) && $_POST['page'] >= 0 ) {
153
+ $this->subscribe2_options['s2page'] = $_POST['page'];
154
+ }
155
+
156
+ // Number of subscriber per page
157
+ if ( is_numeric($_POST['entries']) && $_POST['entries'] > 0 ) {
158
+ $this->subscribe2_options['entries'] = (int)$_POST['entries'];
159
+ }
160
+
161
+ // show meta link?
162
+ ( $_POST['show_meta'] == '1' ) ? $showmeta = '1' : $showmeta = '0';
163
+ $this->subscribe2_options['show_meta'] = $showmeta;
164
+
165
+ // show button?
166
+ ( $_POST['show_button'] == '1' ) ? $showbutton = '1' : $showbutton = '0';
167
+ $this->subscribe2_options['show_button'] = $showbutton;
168
+
169
+ // enable AJAX style form
170
+ ( $_POST['ajax'] == '1' ) ? $ajax = '1' : $ajax = '0';
171
+ $this->subscribe2_options['ajax'] = $ajax;
172
+
173
+ // show widget in Presentation->Widgets
174
+ ( $_POST['widget'] == '1' ) ? $showwidget = '1' : $showwidget = '0';
175
+ $this->subscribe2_options['widget'] = $showwidget;
176
+
177
+ // show counterwidget in Presentation->Widgets
178
+ ( $_POST['counterwidget'] == '1' ) ? $showcounterwidget = '1' : $showcounterwidget = '0';
179
+ $this->subscribe2_options['counterwidget'] = $showcounterwidget;
180
+
181
+ // Subscribe2 over ride postmeta checked by default
182
+ ( $_POST['s2meta_default'] == '1' ) ? $s2meta_default = '1' : $s2meta_default = '0';
183
+ $this->subscribe2_options['s2meta_default'] = $s2meta_default;
184
+
185
+ //automatic subscription
186
+ $this->subscribe2_options['autosub'] = $_POST['autosub'];
187
+ $this->subscribe2_options['newreg_override'] = $_POST['newreg_override'];
188
+ $this->subscribe2_options['wpregdef'] = $_POST['wpregdef'];
189
+ $this->subscribe2_options['autoformat'] = $_POST['autoformat'];
190
+ $this->subscribe2_options['show_autosub'] = $_POST['show_autosub'];
191
+ $this->subscribe2_options['autosub_def'] = $_POST['autosub_def'];
192
+ $this->subscribe2_options['comment_subs'] = $_POST['comment_subs'];
193
+ $this->subscribe2_options['one_click_profile'] = $_POST['one_click_profile'];
194
+
195
+ //barred domains
196
+ $this->subscribe2_options['barred'] = $_POST['barred'];
197
+
198
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_saved</strong></p></div>";
199
+ update_option('subscribe2_options', $this->subscribe2_options);
200
+ }
201
+ }
202
+ // show our form
203
+ echo "<div class=\"wrap\">";
204
+ echo "<div id=\"icon-options-general\" class=\"icon32\"></div>";
205
+ echo "<h2>" . __('Subscribe2 Settings', 'subscribe2') . "</h2>\r\n";
206
+ echo "<a href=\"http://subscribe2.wordpress.com/\">" . __('Plugin Blog', 'subscribe2') . "</a> | ";
207
+ echo "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904\">" . __('Make a donation via PayPal', 'subscribe2') . "</a>";
208
+ echo "<form method=\"post\" action=\"\">\r\n";
209
+ if ( function_exists('wp_nonce_field') ) {
210
+ wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
211
+ }
212
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
213
+ echo "<input type=\"hidden\" id=\"jsbcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" />";
214
+ echo "<input type=\"hidden\" id=\"jspage\" value=\"" . $this->subscribe2_options['s2page'] . "\" />";
215
+ echo "<input type=\"hidden\" id=\"jsentries\" value=\"" . $this->subscribe2_options['entries'] . "\" />";
216
+
217
+ // settings for outgoing emails
218
+ echo "<div class=\"s2_admin\" id=\"s2_notification_settings\">\r\n";
219
+ echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
220
+ echo __('Restrict the number of recipients per email to (0 for unlimited)', 'subscribe2') . ': ';
221
+ echo "<span id=\"s2bcc_1\"><span id=\"s2bcc\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['bcclimit'] . "</span> ";
222
+ echo "<a href=\"#\" onclick=\"s2_show('bcc'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
223
+ echo "<span id=\"s2bcc_2\">\r\n";
224
+ echo "<input type=\"text\" name=\"bcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" size=\"3\" />\r\n";
225
+ echo "<a href=\"#\" onclick=\"s2_update('bcc'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
226
+ echo "<a href=\"#\" onclick=\"s2_revert('bcc'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
227
+
228
+ echo "<br /><br />" . __('Send Admins notifications for new', 'subscribe2') . ': ';
229
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"subs\"" . checked($this->subscribe2_options['admin_email'], 'subs', false) . " />\r\n";
230
+ echo __('Subscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
231
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"unsubs\"" . checked($this->subscribe2_options['admin_email'], 'unsubs', false) . " />\r\n";
232
+ echo __('Unsubscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
233
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"both\"" . checked($this->subscribe2_options['admin_email'], 'both', false) . " />\r\n";
234
+ echo __('Both', 'subscribe2') . "</label>&nbsp;&nbsp;";
235
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"none\"" . checked($this->subscribe2_options['admin_email'], 'none', false) . " />\r\n";
236
+ echo __('Neither', 'subscribe2') . "</label><br /><br />\r\n";
237
+
238
+ echo __('Include theme CSS stylesheet in HTML notifications', 'subscribe2') . ': ';
239
+ echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"yes\"" . checked($this->subscribe2_options['stylesheet'], 'yes', false) . " /> ";
240
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
241
+ echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"no\"" . checked($this->subscribe2_options['stylesheet'], 'no', false) . " /> ";
242
+ echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
243
+
244
+ echo __('Send Emails for Pages', 'subscribe2') . ': ';
245
+ echo "<label><input type=\"radio\" name=\"pages\" value=\"yes\"" . checked($this->subscribe2_options['pages'], 'yes', false) . " /> ";
246
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
247
+ echo "<label><input type=\"radio\" name=\"pages\" value=\"no\"" . checked($this->subscribe2_options['pages'], 'no', false) . " /> ";
248
+ echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
249
+ $s2_post_types = apply_filters('s2_post_types', NULL);
250
+ if ( !empty($s2_post_types) ) {
251
+ $types = '';
252
+ echo __('Subscribe2 will send email notifications for the following custom post types', 'subscribe2') . ': <strong>';
253
+ foreach ($s2_post_types as $type) {
254
+ ('' == $types) ? $types = ucwords($type) : $types .= ", " . ucwords($type);
255
+ }
256
+ echo $types . "</strong><br /><br />\r\n";
257
+ }
258
+ echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
259
+ echo "<label><input type=\"radio\" name=\"password\" value=\"yes\"" . checked($this->subscribe2_options['password'], 'yes', false) . " /> ";
260
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
261
+ echo "<label><input type=\"radio\" name=\"password\" value=\"no\"" . checked($this->subscribe2_options['password'], 'no', false) . " /> ";
262
+ echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
263
+ echo __('Send Emails for Private Posts', 'subscribe2') . ': ';
264
+ echo "<label><input type=\"radio\" name=\"private\" value=\"yes\"" . checked($this->subscribe2_options['private'], 'yes', false) . " /> ";
265
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
266
+ echo "<label><input type=\"radio\" name=\"private\" value=\"no\"" . checked($this->subscribe2_options['private'], 'no', false) . " /> ";
267
+ echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
268
+ echo __('Send Email From', 'subscribe2') . ': ';
269
+ echo "<label>\r\n";
270
+ $this->admin_dropdown(true);
271
+ echo "</label><br /><br />\r\n";
272
+ if ( function_exists('wp_schedule_event') ) {
273
+ echo __('Send Emails', 'subscribe2') . ": <br /><br />\r\n";
274
+ $this->display_digest_choices();
275
+ echo __('For digest notifications, date order for posts is', 'subscribe2') . ": \r\n";
276
+ echo "<label><input type=\"radio\" name=\"cron_order\" value=\"desc\"" . checked($this->subscribe2_options['cron_order'], 'desc', false) . " /> ";
277
+ echo __('Descending', 'subscribe2') . "</label>&nbsp;&nbsp;";
278
+ echo "<label><input type=\"radio\" name=\"cron_order\" value=\"asc\"" . checked($this->subscribe2_options['cron_order'], 'asc', false) . " /> ";
279
+ echo __('Ascending', 'subscribe2') . "</label><br /><br />\r\n";
280
+ }
281
+ echo __('Add Tracking Parameters to the Permalink', 'subscribe2') . ": ";
282
+ echo "<input type=\"text\" name=\"tracking\" value=\"" . stripslashes($this->subscribe2_options['tracking']) . "\" size=\"50\" /> ";
283
+ echo "<br />" . __('eg. utm_source=subscribe2&utm_medium=email&utm_campaign=postnotify', 'subscribe2') . "<br /><br />\r\n";
284
+ echo "</div>\r\n";
285
+
286
+ // email templates
287
+ echo "<div class=\"s2_admin\" id=\"s2_templates\">\r\n";
288
+ echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
289
+ echo "<br />";
290
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
291
+ echo "<tr><td>";
292
+ echo __('New Post email (must not be empty)', 'subscribe2') . ":<br />\r\n";
293
+ echo __('Subject Line', 'subscribe2') . ": ";
294
+ echo "<input type=\"text\" name=\"notification_subject\" value=\"" . stripslashes($this->subscribe2_options['notification_subject']) . "\" size=\"30\" />";
295
+ echo "<br />\r\n";
296
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
297
+ echo "</td><td valign=\"top\" rowspan=\"3\">";
298
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Send Email Preview', 'subscribe2') . "\" /></p>\r\n";
299
+ echo "<h3>" . __('Message substitutions', 'subscribe2') . "</h3>\r\n";
300
+ echo "<dl>";
301
+ echo "<dt><b><em style=\"color: red\">" . __('IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED' ,'subscribe2') . "</em></b></dt><dd></dd>\r\n";
302
+ echo "<dt><b>{BLOGNAME}</b></dt><dd>" . get_option('blogname') . "</dd>\r\n";
303
+ echo "<dt><b>{BLOGLINK}</b></dt><dd>" . get_option('home') . "</dd>\r\n";
304
+ echo "<dt><b>{TITLE}</b></dt><dd>" . __("the post's title<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
305
+ echo "<dt><b>{POST}</b></dt><dd>" . __("the excerpt or the entire post<br />(<i>based on the subscriber's preferences</i>)", 'subscribe2') . "</dd>\r\n";
306
+ echo "<dt><b>{POSTTIME}</b></dt><dd>" . __("the excerpt of the post and the time it was posted<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
307
+ echo "<dt><b>{TABLE}</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
308
+ echo "<dt><b>{TABLELINKS}</b></dt><dd>" . __("a list of post titles followed by links to the atricles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
309
+ echo "<dt><b>{PERMALINK}</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
310
+ echo "<dt><b>{TINYLINK}</b></dt><dd>" . __("the post's permalink after conversion by TinyURL<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
311
+ echo "<dt><b>{DATE}</b></dt><dd>" . __("the date the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
312
+ echo "<dt><b>{TIME}</b></dt><dd>" . __("the time the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
313
+ echo "<dt><b>{MYNAME}</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
314
+ echo "<dt><b>{EMAIL}</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
315
+ echo "<dt><b>{AUTHORNAME}</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
316
+ echo "<dt><b>{LINK}</b></dt><dd>" . __("the generated link to confirm a request<br />(<i>only used in the confirmation email template</i>)", 'subscribe2') . "</dd>\r\n";
317
+ echo "<dt><b>{ACTION}</b></dt><dd>" . __("Action performed by LINK in confirmation email<br />(<i>only used in the confirmation email template</i>)", 'subscribe2') . "</dd>\r\n";
318
+ echo "<dt><b>{CATS}</b></dt><dd>" . __("the post's assigned categories", 'subscribe2') . "</dd>\r\n";
319
+ echo "<dt><b>{TAGS}</b></dt><dd>" . __("the post's assigned Tags", 'subscribe2') . "</dd>\r\n";
320
+ echo "<dt><b>{COUNT}</b></dt><dd>" . __("the number of posts included in the digest email<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
321
+ echo "</dl></td></tr><tr><td>";
322
+ echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
323
+ echo __('Subject Line', 'subscribe2') . ": ";
324
+ echo "<input type=\"text\" name=\"confirm_subject\" value=\"" . stripslashes($this->subscribe2_options['confirm_subject']) . "\" size=\"30\" /><br />\r\n";
325
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
326
+ echo "</td></tr><tr valign=\"top\"><td>";
327
+ echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
328
+ echo __('Subject Line', 'subscribe2') . ": ";
329
+ echo "<input type=\"text\" name=\"remind_subject\" value=\"" . stripslashes($this->subscribe2_options['remind_subject']) . "\" size=\"30\" /><br />\r\n";
330
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
331
+ echo "</td></tr></table><br />\r\n";
332
+ echo "</div>\r\n";
333
+
334
+ // excluded categories
335
+ echo "<div class=\"s2_admin\" id=\"s2_excluded_categories\">\r\n";
336
+ echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
337
+ echo "<p>";
338
+ echo "<strong><em style=\"color: red\">" . __('Posts assigned to any Excluded Category do not generate notifications and are not included in digest notifications', 'subscribe2') . "</em></strong><br />\r\n";
339
+ echo "</p>";
340
+ $this->display_category_form(explode(',', $this->subscribe2_options['exclude']));
341
+ echo "<center><label><input type=\"checkbox\" name=\"reg_override\" value=\"1\"" . checked($this->subscribe2_options['reg_override'], '1', false) . " /> ";
342
+ echo __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</label></center><br />\r\n";
343
+
344
+ // excluded post formats
345
+ $formats = get_theme_support('post-formats');
346
+ if ( $formats !== false ) {
347
+ // excluded formats
348
+ echo "<h2>" . __('Excluded Formats', 'subscribe2') . "</h2>\r\n";
349
+ echo "<p>";
350
+ echo "<strong><em style=\"color: red\">" . __('Posts assigned to any Excluded Format do not generate notifications and are not included in digest notifications', 'subscribe2') . "</em></strong><br />\r\n";
351
+ echo "</p>";
352
+ $this->display_format_form($formats, explode(',', $this->subscribe2_options['exclude_formats']));
353
+ }
354
+ echo "</div>\r\n";
355
+
356
+ // Appearance options
357
+ echo "<div class=\"s2_admin\" id=\"s2_appearance_settings\">\r\n";
358
+ echo "<h2>" . __('Appearance', 'subscribe2') . "</h2>\r\n";
359
+ echo "<p>";
360
+
361
+ // WordPress page ID where subscribe2 token is used
362
+ echo __('Set default Subscribe2 page as ID', 'subscribe2') . ': ';
363
+ echo "<select name=\"page\">\r\n";
364
+ $this->pages_dropdown($this->subscribe2_options['s2page']);
365
+ echo "</select>\r\n";
366
+
367
+ // Number of subscribers per page
368
+ echo "<br /><br />" . __('Set the number of Subscribers displayed per page', 'subscribe2') . ': ';
369
+ echo "<span id=\"s2entries_1\"><span id=\"s2entries\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['entries'] . "</span> ";
370
+ echo "<a href=\"#\" onclick=\"s2_show('entries'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
371
+ echo "<span id=\"s2entries_2\">\r\n";
372
+ echo "<input type=\"text\" name=\"entries\" value=\"" . $this->subscribe2_options['entries'] . "\" size=\"3\" />\r\n";
373
+ echo "<a href=\"#\" onclick=\"s2_update('entries'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
374
+ echo "<a href=\"#\" onclick=\"s2_revert('entries'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
375
+
376
+ // show link to WordPress page in meta
377
+ echo "<br /><br /><label><input type=\"checkbox\" name=\"show_meta\" value=\"1\"" . checked($this->subscribe2_options['show_meta'], '1', false) . " /> ";
378
+ echo __('Show a link to your subscription page in "meta"?', 'subscribe2') . "</label><br /><br />\r\n";
379
+
380
+ // show QuickTag button
381
+ echo "<label><input type=\"checkbox\" name=\"show_button\" value=\"1\"" . checked($this->subscribe2_options['show_button'], '1', false) . " /> ";
382
+ echo __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "</label><br /><br />\r\n";
383
+
384
+ // enable AJAX style form
385
+ echo "<label><input type=\"checkbox\" name=\"ajax\" value=\"1\"" . checked($this->subscribe2_options['ajax'], '1', false) . " />";
386
+ echo __('Enable AJAX style subscription form?', 'subscribe2') . "</label><br /><br />\r\n";
387
+
388
+ // show Widget
389
+ echo "<label><input type=\"checkbox\" name=\"widget\" value=\"1\"" . checked($this->subscribe2_options['widget'], '1', false) . " /> ";
390
+ echo __('Enable Subscribe2 Widget?', 'subscribe2') . "</label><br /><br />\r\n";
391
+
392
+ // show Counter Widget
393
+ echo "<label><input type=\"checkbox\" name=\"counterwidget\" value=\"1\"" . checked($this->subscribe2_options['counterwidget'], '1', false) . " /> ";
394
+ echo __('Enable Subscribe2 Counter Widget?', 'subscribe2') . "</label><br /><br />\r\n";
395
+
396
+ // s2_meta checked by default
397
+ echo "<label><input type =\"checkbox\" name=\"s2meta_default\" value=\"1\"" . checked($this->subscribe2_options['s2meta_default'], '1', false) . " /> ";
398
+ echo __('Disable email notifications is checked by default on authoring pages?', 'subscribe2') . "</label>\r\n";
399
+ echo "</p>";
400
+ echo "</div>\r\n";
401
+
402
+ //Auto Subscription for new registrations
403
+ echo "<div class=\"s2_admin\" id=\"s2_autosubscribe_settings\">\r\n";
404
+ echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
405
+ echo "<p>";
406
+ echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
407
+ echo "<label><input type=\"radio\" name=\"autosub\" value=\"yes\"" . checked($this->subscribe2_options['autosub'], 'yes', false) . " /> ";
408
+ echo __('Automatically', 'subscribe2') . "</label>&nbsp;&nbsp;";
409
+ echo "<label><input type=\"radio\" name=\"autosub\" value=\"wpreg\"" . checked($this->subscribe2_options['autosub'], 'wpreg', false) . " /> ";
410
+ echo __('Display option on Registration Form', 'subscribe2') . "</label>&nbsp;&nbsp;";
411
+ echo "<label><input type=\"radio\" name=\"autosub\" value=\"no\"" . checked($this->subscribe2_options['autosub'], 'no', false) . " /> ";
412
+ echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
413
+ echo __('Auto-subscribe includes any excluded categories', 'subscribe2') . ":<br />\r\n";
414
+ echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"yes\"" . checked($this->subscribe2_options['newreg_override'], 'yes', false) . " /> ";
415
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
416
+ echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"no\"" . checked($this->subscribe2_options['newreg_override'], 'no', false) . " /> ";
417
+ echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
418
+ echo __('Registration Form option is checked by default', 'subscribe2') . ":<br />\r\n";
419
+ echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"yes\"" . checked($this->subscribe2_options['wpregdef'], 'yes', false) . " /> ";
420
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
421
+ echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"no\"" . checked($this->subscribe2_options['wpregdef'], 'no', false) . " /> ";
422
+ echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
423
+ echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
424
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html\"" . checked($this->subscribe2_options['autoformat'], 'html', false) . " /> ";
425
+ echo __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
426
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html_excerpt\"" . checked($this->subscribe2_options['autoformat'], 'html_excerpt', false) . " /> ";
427
+ echo __('HTML - Excerpt', 'subscribe2') ."</label>&nbsp;&nbsp;";
428
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"post\"" . checked($this->subscribe2_options['autoformat'], 'post', false) . " /> ";
429
+ echo __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
430
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"excerpt\"" . checked($this->subscribe2_options['autoformat'], 'excerpt', false) . " /> ";
431
+ echo __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />";
432
+ echo __('Registered Users have the option to auto-subscribe to new categories', 'subscribe2') . ": <br />\r\n";
433
+ echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"yes\"" . checked($this->subscribe2_options['show_autosub'], 'yes', false) . " /> ";
434
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
435
+ echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"no\"" . checked($this->subscribe2_options['show_autosub'], 'no', false) . " /> ";
436
+ echo __('No', 'subscribe2') . "</label>&nbsp;&nbsp;";
437
+ echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"exclude\"" . checked($this->subscribe2_options['show_autosub'], 'exclude', false) . " /> ";
438
+ echo __('New categories are immediately excluded', 'subscribe2') . "</label><br /><br />";
439
+ echo __('Option for Registered Users to auto-subscribe to new categories is checked by default', 'subscribe2') . ": <br />\r\n";
440
+ echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"yes\"" . checked($this->subscribe2_options['autosub_def'], 'yes', false) . " /> ";
441
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
442
+ echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"no\"" . checked($this->subscribe2_options['autosub_def'], 'no', false) . " /> ";
443
+ echo __('No', 'subscribe2') . "</label><br /><br />";
444
+ echo __('Display checkbox to allow subscriptions from the comment form', 'subscribe2') . ": <br />\r\n";
445
+ echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"before\"" . checked($this->subscribe2_options['comment_subs'], 'before', false) . " /> ";
446
+ echo __('Before the Comment Submit button', 'subscribe2') . "</label>&nbsp;&nbsp;";
447
+ echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"after\"" . checked($this->subscribe2_options['comment_subs'], 'after', false) . " /> ";
448
+ echo __('After the Comment Submit button', 'subscribe2') . "</label>&nbsp;&nbsp;";
449
+ echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"no\"" . checked($this->subscribe2_options['comment_subs'], 'no', false) . " /> ";
450
+ echo __('No', 'subscribe2') . "</label><br /><br />";
451
+ echo __('Show one-click subscription on profile page', 'subscribe2') . ":<br />\r\n";
452
+ echo "<label><input type=\"radio\" name=\"one_click_profile\" value=\"yes\"" . checked($this->subscribe2_options['one_click_profile'], 'yes', false) . " /> ";
453
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
454
+ echo "<label><input type=\"radio\" name=\"one_click_profile\" value=\"no\"" . checked($this->subscribe2_options['one_click_profile'], 'no', false) . " /> ";
455
+ echo __('No', 'subscribe2') . "</label>\r\n";
456
+ echo "</p></div>\r\n";
457
+
458
+ //barred domains
459
+ echo "<div class=\"s2_admin\" id=\"s2_barred_domains\">\r\n";
460
+ echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
461
+ echo "<p>";
462
+ echo __('Enter domains to bar from public subscriptions: <br /> (Use a new line for each entry and omit the "@" symbol, for example email.com)', 'subscribe2');
463
+ echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
464
+ echo "</p>";
465
+ echo "</div>\r\n";
466
+
467
+ // submit
468
+ echo "<p class=\"submit\" align=\"center\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p>";
469
+
470
+ // reset
471
+ echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
472
+ echo "<p>" . __('Use this to reset all options to their defaults. This <strong><em>will not</em></strong> modify your list of subscribers.', 'subscribe2') . "</p>\r\n";
473
+ echo "<p class=\"submit\" align=\"center\">";
474
+ echo "<input type=\"submit\" id=\"deletepost\" name=\"reset\" value=\"" . __('RESET', 'subscribe2') .
475
+ "\" />";
476
+ echo "</p></form></div>\r\n";
477
+
478
+ include(ABSPATH . 'wp-admin/admin-footer.php');
479
+ // just to be sure
480
+ die;
481
+ ?>
admin/subscribers.php ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !function_exists('add_action') ) {
3
+ exit();
4
+ }
5
+
6
+ global $wpdb, $s2nonce;
7
+
8
+ //Get Registered Subscribers for bulk management
9
+ $registered = $this->get_registered();
10
+ $all_users = $this->get_all_registered();
11
+
12
+ // was anything POSTed ?
13
+ if ( isset($_POST['s2_admin']) ) {
14
+ check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
15
+ if ( $_POST['addresses'] ) {
16
+ $sub_error = '';
17
+ $unsub_error = '';
18
+ foreach ( preg_split ("|[\s,]+|", $_POST['addresses']) as $email ) {
19
+ $email = $this->sanitize_email($email);
20
+ if ( is_email($email) && $_POST['subscribe'] ) {
21
+ if ( $this->is_public($email) !== false ) {
22
+ ('' == $sub_error) ? $sub_error = "$email" : $sub_error .= ", $email";
23
+ continue;
24
+ }
25
+ $this->add($email, true);
26
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) subscribed!', 'subscribe2') . "</strong></p></div>";
27
+ } elseif ( is_email($email) && $_POST['unsubscribe'] ) {
28
+ if ( $this->is_public($email) === false ) {
29
+ ('' == $unsub_error) ? $unsub_error = "$email" : $unsub_error .= ", $email";
30
+ continue;
31
+ }
32
+ $this->delete($email);
33
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) unsubscribed!', 'subscribe2') . "</strong></p></div>";
34
+ }
35
+ }
36
+ if ( $sub_error != '' ) {
37
+ echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were already subscribed' , 'subscribe2') . ":<br />$sub_error</strong></p></div>";
38
+ }
39
+ if ( $unsub_error != '' ) {
40
+ echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were not in the database' , 'subscribe2') . ":<br />$unsub_error</strong></p></div>";
41
+ }
42
+ echo $message;
43
+ $_POST['what'] = 'confirmed';
44
+ } elseif ( $_POST['process'] ) {
45
+ if ( $_POST['delete'] ) {
46
+ foreach ( $_POST['delete'] as $address ) {
47
+ $this->delete($address);
48
+ }
49
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) deleted!', 'subscribe2') . "</strong></p></div>";
50
+ }
51
+ if ( $_POST['confirm'] ) {
52
+ foreach ( $_POST['confirm'] as $address ) {
53
+ $this->toggle($this->sanitize_email($address));
54
+ }
55
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
56
+ }
57
+ if ( $_POST['unconfirm'] ) {
58
+ foreach ( $_POST['unconfirm'] as $address ) {
59
+ $this->toggle($this->sanitize_email($address));
60
+ }
61
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
62
+ }
63
+ echo $message;
64
+ } elseif ( $_POST['searchterm'] ) {
65
+ $confirmed = $this->get_public();
66
+ $unconfirmed = $this->get_public(0);
67
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
68
+ foreach ( $subscribers as $subscriber ) {
69
+ if ( is_numeric(stripos($subscriber, $_POST['searchterm'])) ) {
70
+ $result[] = $subscriber;
71
+ }
72
+ }
73
+ } elseif ( $_POST['remind'] ) {
74
+ $this->remind($_POST['reminderemails']);
75
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Reminder Email(s) Sent!', 'subscribe2') . "</strong></p></div>";
76
+ } elseif ( $_POST['sub_categories'] && 'subscribe' == $_POST['manage'] ) {
77
+ $this->subscribe_registered_users($_POST['exportcsv'], $_POST['category']);
78
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Subscribed!', 'subscribe2') . "</strong></p></div>";
79
+ } elseif ( $_POST['sub_categories'] && 'unsubscribe' == $_POST['manage'] ) {
80
+ $this->unsubscribe_registered_users($_POST['exportcsv'], $_POST['category']);
81
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Unsubscribed!', 'subscribe2') . "</strong></p></div>";
82
+ } elseif ( $_POST['sub_format'] ) {
83
+ $this->format_change( $_POST['format'], $_POST['exportcsv'] );
84
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Format updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
85
+ } elseif ( $_POST['sub_digest'] ) {
86
+ $this->digest_change( $_POST['sub_category'], $_POST['exportcsv'] );
87
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Digest Subscription updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
88
+ }
89
+ }
90
+
91
+ //Get Public Subscribers once for filter
92
+ $confirmed = $this->get_public();
93
+ $unconfirmed = $this->get_public(0);
94
+ // safety check for our arrays
95
+ if ( '' == $confirmed ) { $confirmed = array(); }
96
+ if ( '' == $unconfirmed ) { $unconfirmed = array(); }
97
+ if ( '' == $registered ) { $registered = array(); }
98
+ if ( '' == $all_users ) { $all_users = array(); }
99
+
100
+ $reminderform = false;
101
+ $urlpath = str_replace("\\", "/", S2PATH);
102
+ $urlpath = trailingslashit(get_option('siteurl')) . substr($urlpath,strpos($urlpath, "wp-content/"));
103
+ if ( isset($_GET['s2page']) ) {
104
+ $page = (int) $_GET['s2page'];
105
+ } else {
106
+ $page = 1;
107
+ }
108
+
109
+ if ( isset($_POST['what']) ) {
110
+ $page = 1;
111
+ if ( 'all' == $_POST['what'] ) {
112
+ $what = 'all';
113
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
114
+ } elseif ( 'public' == $_POST['what'] ) {
115
+ $what = 'public';
116
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
117
+ } elseif ( 'confirmed' == $_POST['what'] ) {
118
+ $what = 'confirmed';
119
+ $subscribers = $confirmed;
120
+ } elseif ( 'unconfirmed' == $_POST['what'] ) {
121
+ $what = 'unconfirmed';
122
+ $subscribers = $unconfirmed;
123
+ if ( !empty($subscribers) ) {
124
+ $reminderemails = implode(",", $subscribers);
125
+ $reminderform = true;
126
+ }
127
+ } elseif ( is_numeric($_POST['what']) ) {
128
+ $what = intval($_POST['what']);
129
+ $subscribers = $this->get_registered("cats=$what");
130
+ } elseif ( 'registered' == $_POST['what'] ) {
131
+ $what = 'registered';
132
+ $subscribers = $registered;
133
+ } elseif ( 'all_users' == $_POST['what'] ) {
134
+ $what = 'all_users';
135
+ $subscribers = $all_users;
136
+ }
137
+ } elseif ( isset($_GET['what']) ) {
138
+ if ( 'all' == $_GET['what'] ) {
139
+ $what = 'all';
140
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
141
+ } elseif ( 'public' == $_GET['what'] ) {
142
+ $what = 'public';
143
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
144
+ } elseif ( 'confirmed' == $_GET['what'] ) {
145
+ $what = 'confirmed';
146
+ $subscribers = $confirmed;
147
+ } elseif ( 'unconfirmed' == $_GET['what'] ) {
148
+ $what = 'unconfirmed';
149
+ $subscribers = $unconfirmed;
150
+ if ( !empty($subscribers) ) {
151
+ $reminderemails = implode(",", $subscribers);
152
+ $reminderform = true;
153
+ }
154
+ } elseif ( is_numeric($_GET['what']) ) {
155
+ $what = intval($_GET['what']);
156
+ $subscribers = $this->get_registered("cats=$what");
157
+ } elseif ( 'registered' == $_GET['what'] ) {
158
+ $what = 'registered';
159
+ $subscribers = $registered;
160
+ } elseif ( 'all_users' == $_GET['what'] ) {
161
+ $what = 'all_users';
162
+ $subscribers = $all_users;
163
+ }
164
+ } else {
165
+ $what = 'all';
166
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
167
+ }
168
+ if ( $_POST['searchterm'] ) {
169
+ $subscribers = &$result;
170
+ $what = 'public';
171
+ }
172
+
173
+ if ( !empty($subscribers) ) {
174
+ natcasesort($subscribers);
175
+ // Displays a page number strip - adapted from code in Akismet
176
+ $args['what'] = $what;
177
+ $total_subscribers = count($subscribers);
178
+ $total_pages = ceil($total_subscribers / $this->subscribe2_options['entries']);
179
+ $strip = '';
180
+ if ( $page > 1 ) {
181
+ $args['s2page'] = $page - 1;
182
+ $strip .= '<a class="prev" href="' . esc_url(add_query_arg($args)) . '">&laquo; '. __('Previous Page', 'subscribe2') .'</a>' . "\n";
183
+ }
184
+ if ( $total_pages > 1 ) {
185
+ for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) {
186
+ if ( $page == $page_num ) {
187
+ $strip .= "<strong>Page " . $page_num . "</strong>\n";
188
+ } else {
189
+ if ( $page_num < 3 || ( $page_num >= $page - 2 && $page_num <= $page + 2 ) || $page_num > $total_pages - 2 ) {
190
+ $args['s2page'] = $page_num;
191
+ $strip .= "<a class=\"page-numbers\" href=\"" . esc_url(add_query_arg($args)) . "\">" . $page_num . "</a>\n";
192
+ $trunc = true;
193
+ } elseif ( $trunc == true ) {
194
+ $strip .= "...\n";
195
+ $trunc = false;
196
+ }
197
+ }
198
+ }
199
+ }
200
+ if ( ( $page ) * $this->subscribe2_options['entries'] < $total_subscribers ) {
201
+ $args['s2page'] = $page + 1;
202
+ $strip .= "<a class=\"next\" href=\"" . esc_url(add_query_arg($args)) . "\">". __('Next Page', 'subscribe2') . " &raquo;</a>\n";
203
+ }
204
+ }
205
+
206
+ // show our form
207
+ echo "<div class=\"wrap\">";
208
+ echo "<div id=\"icon-tools\" class=\"icon32\"></div>";
209
+ echo "<h2>" . __('Manage Subscribers', 'subscribe2') . "</h2>\r\n";
210
+ echo "<form method=\"post\" action=\"\">\r\n";
211
+ if ( function_exists('wp_nonce_field') ) {
212
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
213
+ }
214
+ echo "<div class=\"s2_admin\" id=\"s2_add_subscribers\">\r\n";
215
+ echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
216
+ echo "<p>" . __('Enter addresses, one per line or comma-separated', 'subscribe2') . "<br />\r\n";
217
+ echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea></p>\r\n";
218
+ echo "<input type=\"hidden\" name=\"s2_admin\" />\r\n";
219
+ echo "<p class=\"submit\" style=\"border-top: none;\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
220
+ echo "&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" /></p>\r\n";
221
+ echo "</div>\r\n";
222
+
223
+ // subscriber lists
224
+ echo "<div class=\"s2_admin\" id=\"s2_current_subscribers\">\r\n";
225
+ echo "<h2>" . __('Current Subscribers', 'subscribe2') . "</h2>\r\n";
226
+ echo "<br />";
227
+ $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
228
+ echo "<br /><br />";
229
+ // show the selected subscribers
230
+ $alternate = 'alternate';
231
+ echo "<table class=\"widefat\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">";
232
+ $searchterm = ( $_POST['searchterm'] ) ? $_POST['searchterm'] : '';
233
+ echo "<tr class=\"alternate\"><td colspan=\"3\"><input type=\"text\" name=\"searchterm\" value=\"" . $searchterm . "\" /></td>\r\n";
234
+ echo "<td><input type=\"submit\" class=\"button-secondary\" name=\"search\" value=\"" . __('Search Subscribers', 'subscribe2') . "\" /></td>\r\n";
235
+ if ( $reminderform ) {
236
+ echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"reminderemails\" value=\"" . $reminderemails . "\" />\r\n";
237
+ echo "<input type=\"submit\" class=\"button-secondary\" name=\"remind\" value=\"" . __('Send Reminder Email', 'subscribe2') . "\" /></td>\r\n";
238
+ } else {
239
+ echo "<td width=\"25%\"></td>";
240
+ }
241
+ if ( !empty($subscribers) ) {
242
+ $exportcsv = implode(",\r\n", $subscribers);
243
+ echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"exportcsv\" value=\"" . $exportcsv . "\" />\r\n";
244
+ echo "<input type=\"submit\" class=\"button-secondary\" name=\"csv\" value=\"" . __('Save Emails to CSV File', 'subscribe2') . "\" /></td>\r\n";
245
+ } else {
246
+ echo "<td width=\"25%\"></td>";
247
+ }
248
+ echo "</tr>";
249
+
250
+ if ( !empty($subscribers) ) {
251
+ echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
252
+ echo "<td colspan=\"3\" align=\"right\">" . $strip . "</td></tr>\r\n";
253
+ }
254
+ if ( !empty($subscribers) ) {
255
+ if ( is_int($this->subscribe2_options['entries']) ) {
256
+ $subscriber_chunks = array_chunk($subscribers, $this->subscribe2_options['entries']);
257
+ } else {
258
+ $subscriber_chunks = array_chunk($subscribers, 25);
259
+ }
260
+ $chunk = $page - 1;
261
+ $subscribers = $subscriber_chunks[$chunk];
262
+ echo "<tr class=\"alternate\" style=\"height:1.5em;\">\r\n";
263
+ echo "<td width=\"4%\" align=\"center\">";
264
+ echo "<img src=\"" . $urlpath . "include/accept.png\" alt=\"&lt;\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" /></td>\r\n";
265
+ echo "<td width=\"4%\" align=\"center\">";
266
+ echo "<img src=\"" . $urlpath . "include/exclamation.png\" alt=\"&gt;\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" /></td>\r\n";
267
+ echo "<td width=\"4%\" align=\"center\">";
268
+ echo "<img src=\"" . $urlpath . "include/cross.png\" alt=\"X\" title=\"" . __('Delete this email address', 'subscribe2') . "\" /></td><td colspan=\"3\"></td></tr>\r\n";
269
+ echo "<tr class=\"\"><td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"confirm_checkall\" /></td>\r\n";
270
+ echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"unconfirm_checkall\" /></td>\r\n";
271
+ echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"delete_checkall\" /></td>\r\n";
272
+ echo "<td colspan =\"3\" align=\"left\"><strong>" . __('Select / Unselect All', 'subscribe2') . "</strong></td></tr>\r\n";
273
+
274
+ foreach ( $subscribers as $subscriber ) {
275
+ echo "<tr class=\"$alternate\" style=\"height:1.5em;\">";
276
+ echo "<td align=\"center\">\r\n";
277
+ if ( in_array($subscriber, $confirmed) ) {
278
+ echo "</td><td align=\"center\">\r\n";
279
+ echo "<input class=\"unconfirm_checkall\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"unconfirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
280
+ echo "<td align=\"center\">\r\n";
281
+ echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
282
+ echo "</td>\r\n";
283
+ echo "<td colspan=\"3\"><span style=\"color:#006600\">&#x221A;&nbsp;&nbsp;</span><abbr title=\"" . $this->signup_ip($subscriber) . "\"><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a></abbr>\r\n";
284
+ echo "(<span style=\"color:#006600\">" . $this->signup_date($subscriber) . "</span>)\r\n";
285
+ } elseif ( in_array($subscriber, $unconfirmed) ) {
286
+ echo "<input class=\"confirm_checkall\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"confirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
287
+ echo "<td align=\"center\"></td>\r\n";
288
+ echo "<td align=\"center\">\r\n";
289
+ echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
290
+ echo "</td>\r\n";
291
+ echo "<td colspan=\"3\"><span style=\"color:#FF0000\">&nbsp;!&nbsp;&nbsp;&nbsp;</span><abbr title=\"" . $this->signup_ip($subscriber) . "\"><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a></abbr>\r\n";
292
+ echo "(<span style=\"color:#FF0000\">" . $this->signup_date($subscriber) . "</span>)\r\n";
293
+ } elseif ( in_array($subscriber, $all_users) ) {
294
+ $user_info = get_user_by('email', $subscriber);
295
+ echo "</td><td align=\"center\"></td><td align=\"center\"></td>\r\n";
296
+ echo "<td colspan=\"3\"><span style=\"color:#006600\">&reg;&nbsp;&nbsp;</span><abbr title=\"" . $user_info->user_login . "\"><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a></abbr>\r\n";
297
+ echo "(<a href=\"" . get_option('siteurl') . "/wp-admin/admin.php?page=s2&amp;email=" . urlencode($subscriber) . "\">" . __('edit', 'subscribe2') . "</a>)\r\n";
298
+ }
299
+ echo "</td></tr>\r\n";
300
+ ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
301
+ }
302
+ } else {
303
+ if ( $_POST['searchterm'] ) {
304
+ echo "<tr><td colspan=\"6\" align=\"center\"><b>" . __('No matching subscribers found', 'subscribe2') . "</b></td></tr>\r\n";
305
+ } else {
306
+ echo "<tr><td colspan=\"6\" align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
307
+ }
308
+ }
309
+ if ( !empty($subscribers) ) {
310
+ echo "<tr class=\"$alternate\"><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
311
+ echo "<td colspan=\"3\" align=\"right\">" . $strip . "</td></tr>\r\n";
312
+ }
313
+ echo "</table>\r\n";
314
+ echo "</div>\r\n";
315
+
316
+ // show bulk managment form if filtered in some Registered Users
317
+ if ( in_array($what, array('registered', 'all_users')) || is_numeric($what) ) {
318
+ echo "<div class=\"s2_admin\" id=\"s2_bulk_manage\">\r\n";
319
+ echo "<h2>" . __('Bulk Management', 'subscribe2') . "</h2>\r\n";
320
+ if ( $this->subscribe2_options['email_freq'] == 'never' ) {
321
+ echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
322
+ echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
323
+ echo "<br />" . __('Action to perform', 'subscribe2') . ":\r\n";
324
+ echo "<label><input type=\"radio\" name=\"manage\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
325
+ echo "<label><input type=\"radio\" name=\"manage\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . "</label><br /><br />\r\n";
326
+ $this->display_category_form();
327
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_categories\" value=\"" . __('Bulk Update Categories', 'subscribe2') . "\" /></p>";
328
+ echo "<br />" . __('Send email as', 'subscribe2') . ":\r\n";
329
+ echo "<label><input type=\"radio\" name=\"format\" value=\"html\" /> " . __('HTML - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
330
+ echo "<label><input type=\"radio\" name=\"format\" value=\"html_excerpt\" /> " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
331
+ echo "<label><input type=\"radio\" name=\"format\" value=\"post\" /> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
332
+ echo "<label><input type=\"radio\" name=\"format\" value=\"excerpt\" checked=\"checked\" /> " . __('Plain Text - Excerpt', 'subscribe2') . "</label>\r\n";
333
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_format\" value=\"" . __('Bulk Update Format', 'subscribe2') . "\" /></p>";
334
+ } else {
335
+ echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
336
+ echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
337
+ echo "<br />" . __('Subscribe Selected Users to recieve a periodic digest notification', 'subscribe2') . ":\r\n";
338
+ echo "<label><input type=\"radio\" name=\"sub_category\" value=\"digest\" checked=\"checked\" /> ";
339
+ echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
340
+ echo "<label><input type=\"radio\" name=\"sub_category\" value=\"-1\" /> ";
341
+ echo __('No', 'subscribe2') . "</label>";
342
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_digest\" value=\"" . __('Bulk Update Digest Subscription', 'subscribe2') . "\" /></p>";
343
+ }
344
+ echo "</div>\r\n";
345
+ }
346
+ echo "</form></div>\r\n";
347
+
348
+ include(ABSPATH . 'wp-admin/admin-footer.php');
349
+ // just to be sure
350
+ die;
351
+ ?>
admin/your_subscriptions.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !function_exists('add_action') ) {
3
+ exit();
4
+ }
5
+
6
+ global $user_ID, $s2nonce;
7
+
8
+ if ( isset($_GET['email']) ) {
9
+ global $wpdb;
10
+ $user_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . urldecode($_GET['email']) . "'");
11
+ } else {
12
+ get_currentuserinfo();
13
+ }
14
+
15
+ // was anything POSTed?
16
+ if ( isset($_POST['s2_admin']) && 'user' == $_POST['s2_admin'] ) {
17
+ check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
18
+
19
+ if ( $_POST['submit'] ) {
20
+ if ( isset($_POST['s2_format']) ) {
21
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $_POST['s2_format']);
22
+ } else {
23
+ // value has not been set so use default
24
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
25
+ }
26
+ if ( isset($_POST['new_category']) ) {
27
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $_POST['new_category']);
28
+ } else {
29
+ // value has not been passed so use Settings defaults
30
+ if ( $this->subscribe2_options['show_autosub'] == 'yes' && $this->subscribe2_options['autosub_def'] == 'yes' ) {
31
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes');
32
+ } else {
33
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'no');
34
+ }
35
+ }
36
+
37
+ $cats = $_POST['category'];
38
+
39
+ if ( empty($cats) || $cats == '-1' ) {
40
+ $oldcats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
41
+ if ( $oldcats ) {
42
+ foreach ( $oldcats as $cat ) {
43
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat);
44
+ }
45
+ }
46
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
47
+ } elseif ( $cats == 'digest' ) {
48
+ $all_cats = $this->all_cats(false, 'ID');
49
+ foreach ( $all_cats as $cat ) {
50
+ ('' == $catids) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
51
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
52
+ }
53
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $catids);
54
+ } else {
55
+ if ( !is_array($cats) ) {
56
+ $cats = (array)$_POST['category'];
57
+ }
58
+ sort($cats);
59
+ $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
60
+ $remove = array_diff($old_cats, $cats);
61
+ $new = array_diff($cats, $old_cats);
62
+ if ( !empty($remove) ) {
63
+ // remove subscription to these cat IDs
64
+ foreach ( $remove as $id ) {
65
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
66
+ }
67
+ }
68
+ if ( !empty($new) ) {
69
+ // add subscription to these cat IDs
70
+ foreach ( $new as $id ) {
71
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
72
+ }
73
+ }
74
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $cats));
75
+ }
76
+
77
+ $authors = $_POST['author'];
78
+ if ( is_array($authors) ) {
79
+ $authors = implode(',', $authors);
80
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), $authors);
81
+ } elseif ( empty($authors) ) {
82
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
83
+ }
84
+ } elseif ( $_POST['subscribe'] ) {
85
+ $this->one_click_handler($user_ID, 'subscribe');
86
+ } elseif ( $_POST['unsubscribe'] ) {
87
+ $this->one_click_handler($user_ID, 'unsubscribe');
88
+ }
89
+
90
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
91
+ }
92
+
93
+ // show our form
94
+ echo "<div class=\"wrap\">";
95
+ echo "<div id=\"icon-users\" class=\"icon32\"></div>";
96
+ echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
97
+ if ( isset($_GET['email']) ) {
98
+ $user = get_userdata($user_ID);
99
+ echo "<span style=\"color: red;line-height: 300%;\">" . __('Editing Subscribe2 preferences for user', 'subscribe2') . ": " . $user->display_name . "</span>";
100
+ }
101
+ echo "<form method=\"post\" action=\"\">";
102
+ echo "<p>";
103
+ if ( function_exists('wp_nonce_field') ) {
104
+ wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
105
+ }
106
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
107
+ if ( $this->subscribe2_options['email_freq'] == 'never' ) {
108
+ echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
109
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'html', false) . " />";
110
+ echo " " . __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
111
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html_excerpt\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'html_excerpt', false) . " />";
112
+ echo " " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;";
113
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"post\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'post', false) . " />";
114
+ echo " " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
115
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"excerpt\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'excerpt', false) . " />";
116
+ echo " " . __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />\r\n";
117
+
118
+ if ( $this->subscribe2_options['show_autosub'] == 'yes' ) {
119
+ echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
120
+ echo "<label><input type=\"radio\" name=\"new_category\" value=\"yes\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), true), 'yes', false) . " />";
121
+ echo " " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
122
+ echo "<label><input type=\"radio\" name=\"new_category\" value=\"no\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), true), 'no', false) . " />";
123
+ echo " " . __('No', 'subscribe2') . "</label>";
124
+ echo "</p>";
125
+ }
126
+
127
+ // One-click subscribe and unsubscribe buttons
128
+ echo "<h2>" . __('One Click Subscription / Unsubscription', 'subscribe2') . "</h2>\r\n";
129
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __("Subscribe to All", 'subscribe2') . "\" />&nbsp;&nbsp;";
130
+ echo "<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __("Unsubscribe from All", 'subscribe2') . "\" /></p>";
131
+
132
+ // subscribed categories
133
+ if ( $this->s2_mu ) {
134
+ global $blog_id;
135
+ $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
136
+ // if we are subscribed to the current blog display an "unsubscribe" link
137
+ if ( !empty($subscribed) ) {
138
+ $unsubscribe_link = esc_url( add_query_arg('s2mu_unsubscribe', $blog_id) );
139
+ echo "<p><a href=\"". $unsubscribe_link ."\" class=\"button\">" . __('Unsubscribe me from this blog', 'subscribe2') . "</a></p>";
140
+ } else {
141
+ // else we show a "subscribe" link
142
+ $subscribe_link = esc_url( add_query_arg('s2mu_subscribe', $blog_id) );
143
+ echo "<p><a href=\"". $subscribe_link ."\" class=\"button\">" . __('Subscribe to all categories', 'subscribe2') . "</a></p>";
144
+ }
145
+ echo "<h2>" . __('Subscribed Categories on', 'subscribe2') . " " . get_option('blogname') . " </h2>\r\n";
146
+ } else {
147
+ echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
148
+ }
149
+ $this->display_category_form(explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true)), $this->subscribe2_options['reg_override']);
150
+ } else {
151
+ // we're doing daily digests, so just show
152
+ // subscribe / unnsubscribe
153
+ echo __('Receive periodic summaries of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
154
+ echo "<label>";
155
+ echo "<input type=\"radio\" name=\"category\" value=\"digest\"";
156
+ if ( get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
157
+ echo " checked=\"checked\"";
158
+ }
159
+ echo " /> " . __('Yes', 'subscribe2') . "</label> <label><input type=\"radio\" name=\"category\" value=\"-1\" ";
160
+ if ( !get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
161
+ echo " checked=\"checked\"";
162
+ }
163
+ echo " /> " . __('No', 'subscribe2');
164
+ echo "</label></p>";
165
+ }
166
+
167
+ if ( count($this->get_authors()) > 1 && $this->subscribe2_options['email_freq'] == 'never' ) {
168
+ echo "<div class=\"s2_admin\" id=\"s2_authors\">\r\n";
169
+ echo "<h2>" . __('Do not send notifications for post made by these authors', 'subscribe2') . "</h2>\r\n";
170
+ $this->display_author_form(explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), true)));
171
+ echo "</div>\r\n";
172
+ }
173
+
174
+ // submit
175
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __("Update Preferences", 'subscribe2') . " &raquo;\" /></p>";
176
+ echo "</form>\r\n";
177
+
178
+ // list of subscribed blogs on wordpress mu
179
+ if ( $this->s2_mu && !isset($_GET['email']) ) {
180
+ global $blog_id, $current_user;
181
+ $s2blog_id = $blog_id;
182
+ get_currentuserinfo();
183
+ $blogs = $s2class_multisite->get_mu_blog_list();
184
+
185
+ $blogs_subscribed = array();
186
+ $blogs_notsubscribed = array();
187
+
188
+ foreach ( $blogs as $blog ) {
189
+ // switch to blog
190
+ switch_to_blog($blog['blog_id']);
191
+
192
+ // check that the Subscribe2 plugin is active on the current blog
193
+ $current_plugins = get_option('active_plugins');
194
+ if ( !is_array($current_plugins) ) {
195
+ $current_plugins = (array)$current_plugins;
196
+ }
197
+ if ( !in_array(S2DIR . 'subscribe2.php', $current_plugins) ) {
198
+ continue;
199
+ }
200
+
201
+ // check if we're subscribed to the blog
202
+ $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
203
+
204
+ $blogname = get_option('blogname');
205
+ if ( strlen($blogname) > 30 ) {
206
+ $blog['blogname'] = wp_html_excerpt($blogname, 30) . "..";
207
+ } else {
208
+ $blog['blogname'] = $blogname;
209
+ }
210
+ $blog['description'] = get_option('blogdescription');
211
+ $blog['blogurl'] = get_option('home');
212
+ $blog['subscribe_page'] = get_option('home') . "/wp-admin/users.php?page=s2_users";
213
+
214
+ $key = strtolower($blog['blogname'] . "-" . $blog['blog_id']);
215
+ if ( !empty($subscribed) ) {
216
+ $blogs_subscribed[$key] = $blog;
217
+ } else {
218
+ $blogs_notsubscribed[$key] = $blog;
219
+ }
220
+ restore_current_blog();
221
+ }
222
+
223
+ if ( !empty($blogs_subscribed) ) {
224
+ ksort($blogs_subscribed);
225
+ echo "<h2>" . __('Subscribed Blogs', 'subscribe2') . "</h2>\r\n";
226
+ echo "<ul class=\"s2_blogs\">\r\n";
227
+ foreach ( $blogs_subscribed as $blog ) {
228
+ echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
229
+ if ( $s2blog_id == $blog['blog_id'] ) {
230
+ echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
231
+ } else {
232
+ echo "<span class=\"buttons\">";
233
+ if ( is_user_member_of_blog($current_user->id, $blog['blog_id']) ) {
234
+ echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
235
+ }
236
+ echo "<a href=\"" . esc_url( add_query_arg('s2mu_unsubscribe', $blog['blog_id']) ) . "\">" . __('Unsubscribe', 'subscribe2') . "</a></span>\r\n";
237
+ }
238
+ echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
239
+ echo "</li>";
240
+ }
241
+ echo "</ul>\r\n";
242
+ }
243
+
244
+ if ( !empty($blogs_notsubscribed) ) {
245
+ ksort($blogs_notsubscribed);
246
+ echo "<h2>" . __('Subscribe to new blogs', 'subscribe2') . "</h2>\r\n";
247
+ echo "<ul class=\"s2_blogs\">";
248
+ foreach ( $blogs_notsubscribed as $blog ) {
249
+ echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
250
+ if ( $s2blog_id == $blog['blog_id'] ) {
251
+ echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
252
+ } else {
253
+ echo "<span class=\"buttons\">";
254
+ if ( is_user_member_of_blog($current_user->id, $blog['blog_id']) ) {
255
+ echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
256
+ }
257
+ echo "<a href=\"" . esc_url( add_query_arg('s2mu_subscribe', $blog['blog_id']) ) . "\">" . __('Subscribe', 'subscribe2') . "</a></span>\r\n";
258
+ }
259
+ echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
260
+ echo "</li>";
261
+ }
262
+ echo "</ul>\r\n";
263
+ }
264
+ }
265
+
266
+ echo "</div>\r\n";
267
+
268
+ include(ABSPATH . 'wp-admin/admin-footer.php');
269
+ // just to be sure
270
+ die;
271
+ ?>
classes/class-s2-admin.php ADDED
@@ -0,0 +1,744 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class s2_admin extends s2class {
3
+ /* ===== WordPress menu registration and scripts ===== */
4
+ /**
5
+ Hook the menu
6
+ */
7
+ function admin_menu() {
8
+ add_menu_page (__('Subscribe2', 'subscribe2'), __('Subscribe2', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', NULL, S2URL . 'include/email_edit.png');
9
+
10
+ $s2user = add_submenu_page('s2', __('Your Subscriptions', 'subscribe2'), __('Your Subscriptions', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', array(&$this, 'user_menu'), S2URL . 'include/email_edit.png');
11
+ add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
12
+ add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
13
+
14
+ $s2subscribers = add_submenu_page('s2', __('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'manage'), 's2_tools', array(&$this, 'subscribers_menu'));
15
+ add_action("admin_print_scripts-$s2subscribers", array(&$this, 'checkbox_form_js'));
16
+
17
+ $s2settings = add_submenu_page('s2', __('Settings', 'subscribe2'), __('Settings', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'settings'), 's2_settings', array(&$this, 'settings_menu'));
18
+ add_action("admin_print_scripts-$s2settings", array(&$this, 'checkbox_form_js'));
19
+ add_action("admin_print_scripts-$s2settings", array(&$this, 'option_form_js'));
20
+ add_filter('plugin_row_meta', array(&$this, 'plugin_links'), 10, 2);
21
+
22
+ add_submenu_page('s2', __('Send Email', 'subscribe2'), __('Send Email', 'subscribe2'), apply_filters('s2_capability', "publish_posts", 'send'), 's2_posts', array(&$this, 'write_menu'));
23
+
24
+ $s2nonce = md5('subscribe2');
25
+ } // end admin_menu()
26
+
27
+ /**
28
+ Hook for Admin Drop Down Icons
29
+ */
30
+ function ozh_s2_icon() {
31
+ return S2URL . 'include/email_edit.png';
32
+ } // end ozh_s2_icon()
33
+
34
+ /**
35
+ Insert Javascript and CSS into admin_header
36
+ */
37
+ function checkbox_form_js() {
38
+ wp_register_script('s2_checkbox', S2URL . 'include/s2_checkbox' . $this->script_debug . '.js', array('jquery'), '1.1');
39
+ wp_enqueue_script('s2_checkbox');
40
+ } //end checkbox_form_js()
41
+
42
+ function user_admin_css() {
43
+ wp_register_style('s2_user_admin', S2URL . 'include/s2_user_admin.css', array(), '1.0');
44
+ wp_enqueue_script('s2_user_admin');
45
+ } // end user_admin_css()
46
+
47
+ function option_form_js() {
48
+ wp_register_script('s2_edit', S2URL . 'include/s2_edit' . $this->script_debug . '.js', array('jquery'), '1.0');
49
+ wp_enqueue_script('s2_edit');
50
+ } // end option_form_js()
51
+
52
+ /**
53
+ Adds a links directly to the settings page from the plugin page
54
+ */
55
+ function plugin_links($links, $file) {
56
+ if ( $file == S2DIR.'subscribe2.php' ) {
57
+ $links[] = "<a href='admin.php?page=s2_settings'>" . __('Settings', 'subscribe2') . "</a>";
58
+ $links[] = "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904'><b>" . __('Donate', 'subscribe2') . "</b></a>";
59
+ }
60
+ return $links;
61
+ } // end plugin_links()
62
+
63
+ /* ===== Menus ===== */
64
+ /**
65
+ Our subscriber management page
66
+ */
67
+ function subscribers_menu() {
68
+ require_once(S2PATH . 'admin/subscribers.php');
69
+ } // end subscribers_menu()
70
+
71
+ /**
72
+ Our settings page
73
+ */
74
+ function settings_menu() {
75
+ require_once(S2PATH . 'admin/settings.php');
76
+ } // end settings_menu()
77
+
78
+ /**
79
+ Our profile menu
80
+ */
81
+ function user_menu() {
82
+ require_once(S2PATH . 'admin/your_subscriptions.php');
83
+ } // end user_menu()
84
+
85
+ /**
86
+ Display the Write sub-menu
87
+ */
88
+ function write_menu() {
89
+ require_once(S2PATH . 'admin/send_email.php');
90
+ } // end write_menu()
91
+
92
+ /* ===== Write Toolbar Button Functions ===== */
93
+ /**
94
+ Register our button in the QuickTags bar
95
+ */
96
+ function button_init() {
97
+ global $pagenow;
98
+ if ( !in_array($pagenow, array('post-new.php', 'post.php', 'page-new.php', 'page.php')) ) { return; }
99
+ if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) { return; }
100
+ if ( 'true' == get_user_option('rich_editing') ) {
101
+ // Hook into the rich text editor
102
+ add_filter('mce_external_plugins', array(&$this, 'mce3_plugin'));
103
+ add_filter('mce_buttons', array(&$this, 'mce3_button'));
104
+ } else {
105
+ if ( version_compare($this->wp_release, '3.3', '<') ) {
106
+ wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button' . $this->script_debug . '.js', array('quicktags'), '1.0' );
107
+ } else {
108
+ // use QTags.addButton for WordPress 3.3 and greater
109
+ wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button2' . $this->script_debug . '.js', array('quicktags'), '2.0' );
110
+ }
111
+ }
112
+ } // end button_init()
113
+
114
+ /**
115
+ Add buttons for Rich Text Editor
116
+ */
117
+ function mce3_plugin($arr) {
118
+ $path = S2URL . 'tinymce3/editor_plugin' . $this->script_debug . '.js';
119
+ $arr['subscribe2'] = $path;
120
+ return $arr;
121
+ } // end mce3_plugin()
122
+
123
+ function mce3_button($arr) {
124
+ $arr[] = 'subscribe2';
125
+ return $arr;
126
+ } // end mce3_button()
127
+
128
+ /* ===== widget functions ===== */
129
+ /**
130
+ Function to add css and js files to admin header
131
+ */
132
+ function widget_s2counter_css_and_js() {
133
+ // ensure we only add colorpicker js to widgets page
134
+ if ( stripos($_SERVER['REQUEST_URI'], 'widgets.php' ) !== false ) {
135
+ wp_register_style('colorpicker', S2URL . 'include/colorpicker/css/colorpicker.css', '', '20090523'); // colorpicker css
136
+ wp_register_script('colorpicker_js', S2URL . 'include/colorpicker/js/colorpicker' . $this->script_debug . '.js', array('jquery'), '20090523'); // colorpicker js
137
+ wp_register_script('s2_colorpicker', S2URL . 'include/s2_colorpicker' . $this->script_debug . '.js', array('colorpicker_js'), '1.3'); //my js
138
+ wp_enqueue_style('colorpicker');
139
+ wp_enqueue_script('colorpicker_js');
140
+ wp_enqueue_script('s2_colorpicker');
141
+ }
142
+ } // end widget_s2_counter_css_and_js()
143
+
144
+ /* ===== meta box functions to allow per-post override ===== */
145
+ /**
146
+ Create meta box on write pages
147
+ */
148
+ function s2_meta_init() {
149
+ add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'post', 'advanced');
150
+ add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'page', 'advanced');
151
+ } // end s2_meta_init()
152
+
153
+ /**
154
+ Meta box code
155
+ */
156
+ function s2_meta_box() {
157
+ global $post_ID;
158
+ $s2mail = get_post_meta($post_ID, 's2mail', true);
159
+ echo "<input type=\"hidden\" name=\"s2meta_nonce\" id=\"s2meta_nonce\" value=\"" . wp_create_nonce(md5(plugin_basename(__FILE__))) . "\" />";
160
+ echo __("Check here to disable sending of an email notification for this post/page", 'subscribe2');
161
+ echo "&nbsp;&nbsp;<input type=\"checkbox\" name=\"s2_meta_field\" value=\"no\"";
162
+ if ( $s2mail == 'no' || ($this->subscribe2_options['s2meta_default'] == "1" && $s2mail == "") ) {
163
+ echo " checked=\"checked\"";
164
+ }
165
+ echo " />";
166
+ } // end s2_meta_box()
167
+
168
+ /**
169
+ Meta box form handler
170
+ */
171
+ function s2_meta_handler($post_id) {
172
+ if ( !isset($_POST['s2meta_nonce']) || !wp_verify_nonce($_POST['s2meta_nonce'], md5(plugin_basename(__FILE__))) ) { return $post_id; }
173
+
174
+ if ( 'page' == $_POST['post_type'] ) {
175
+ if ( !current_user_can('edit_page', $post_id) ) { return $post_id; }
176
+ } else {
177
+ if ( !current_user_can('edit_post', $post_id) ) { return $post_id; }
178
+ }
179
+
180
+ if ( isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no' ) {
181
+ update_post_meta($post_id, 's2mail', $_POST['s2_meta_field']);
182
+ } else {
183
+ update_post_meta($post_id, 's2mail', 'yes');
184
+ }
185
+ } // end s2_meta_box_handler()
186
+
187
+ /* ===== WordPress menu helper functions ===== */
188
+ /**
189
+ Display a table of categories with checkboxes
190
+ Optionally pre-select those categories specified
191
+ */
192
+ function display_category_form($selected = array(), $override = 1) {
193
+ global $wpdb;
194
+
195
+ if ( $override == 0 ) {
196
+ $all_cats = $this->all_cats(true);
197
+ } else {
198
+ $all_cats = $this->all_cats(false);
199
+ }
200
+
201
+ $half = (count($all_cats) / 2);
202
+ $i = 0;
203
+ $j = 0;
204
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
205
+ echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
206
+ echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_cat\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
207
+ echo "</td></tr>\r\n";
208
+ echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
209
+ foreach ( $all_cats as $cat ) {
210
+ if ( $i >= $half && 0 == $j ){
211
+ echo "</td><td width=\"50%\" align=\"left\">\r\n";
212
+ $j++;
213
+ }
214
+ $catName = '';
215
+ $parents = array_reverse( get_ancestors($cat->term_id, $cat->taxonomy) );
216
+ if ( $parents ) {
217
+ foreach ( $parents as $parent ) {
218
+ $parent = get_term($parent, $cat->taxonomy);
219
+ $catName .= $parent->name . ' &raquo; ';
220
+ }
221
+ }
222
+ $catName .= $cat->name;
223
+
224
+ if ( 0 == $j ) {
225
+ echo "<label><input class=\"checkall_cat\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
226
+ if ( in_array($cat->term_id, $selected) ) {
227
+ echo " checked=\"checked\"";
228
+ }
229
+ echo " /> <abbr title=\"" . $cat->slug . "\">" . $catName . "</abbr></label><br />\r\n";
230
+ } else {
231
+ echo "<label><input class=\"checkall_cat\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
232
+ if ( in_array($cat->term_id, $selected) ) {
233
+ echo " checked=\"checked\"";
234
+ }
235
+ echo " /> <abbr title=\"" . $cat->slug . "\">" . $catName . "</abbr></label><br />\r\n";
236
+ }
237
+ $i++;
238
+ }
239
+ echo "</td></tr>\r\n";
240
+ echo "</table>\r\n";
241
+ } // end display_category_form()
242
+
243
+ /**
244
+ Display a table of post formats supported by the currently active theme
245
+ */
246
+ function display_format_form($formats, $selected = array()) {
247
+ $half = (count($formats[0]) / 2);
248
+ $i = 0;
249
+ $j = 0;
250
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
251
+ echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
252
+ echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_format\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
253
+ echo "</td></tr>\r\n";
254
+ echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
255
+ foreach ( $formats[0] as $format ) {
256
+ if ( $i >= $half && 0 == $j ){
257
+ echo "</td><td width=\"50%\" align=\"left\">\r\n";
258
+ $j++;
259
+ }
260
+
261
+ if ( 0 == $j ) {
262
+ echo "<label><input class=\"checkall_format\" type=\"checkbox\" name=\"format[]\" value=\"" . $format . "\"";
263
+ if ( in_array($format, $selected) ) {
264
+ echo " checked=\"checked\"";
265
+ }
266
+ echo " /> " . ucwords($format) . "</label><br />\r\n";
267
+ } else {
268
+ echo "<label><input class=\"checkall_format\" type=\"checkbox\" name=\"format[]\" value=\"" . $format . "\"";
269
+ if ( in_array($format, $selected) ) {
270
+ echo " checked=\"checked\"";
271
+ }
272
+ echo " /> " . ucwords($format) . "</label><br />\r\n";
273
+ }
274
+ $i++;
275
+ }
276
+ echo "</td></tr>\r\n";
277
+ echo "</table>\r\n";
278
+ } // end display_format_form()
279
+
280
+ /**
281
+ Display a table of authors with checkboxes
282
+ Optionally pre-select those authors specified
283
+ */
284
+ function display_author_form($selected = array()) {
285
+ $all_authors = $this->get_authors();
286
+
287
+ $half = (count($all_authors) / 2);
288
+ $i = 0;
289
+ $j = 0;
290
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
291
+ echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
292
+ echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_author\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
293
+ echo "</td></tr>\r\n";
294
+ echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
295
+ foreach ( $all_authors as $author ) {
296
+ if ( $i >= $half && 0 == $j ) {
297
+ echo "</td><td width=\"50%\" align=\"left\">\r\n";
298
+ $j++;
299
+ }
300
+ if ( 0 == $j ) {
301
+ echo "<label><input class=\"checkall_author\" type=\"checkbox\" name=\"author[]\" value=\"" . $author->ID . "\"";
302
+ if ( in_array($author->ID, $selected) ) {
303
+ echo " checked=\"checked\"";
304
+ }
305
+ echo " /> " . $author->display_name . "</label><br />\r\n";
306
+ } else {
307
+ echo "<label><input class=\"checkall_author\" type=\"checkbox\" name=\"author[]\" value=\"" . $author->ID . "\"";
308
+ if ( in_array($author->ID, $selected) ) {
309
+ echo " checked=\"checked\"";
310
+ }
311
+ echo " /> " . $author->display_name . "</label><br />\r\n";
312
+ $i++;
313
+ }
314
+ }
315
+ echo "</td></tr>\r\n";
316
+ echo "</table>\r\n";
317
+ } // end display_author_form()
318
+
319
+ /**
320
+ Collect an array of all author level users and above
321
+ */
322
+ function get_authors() {
323
+ if ( '' == $this->all_authors ) {
324
+ $role = array('fields' => array('ID', 'display_name'), 'role' => 'administrator');
325
+ $administrators = get_users( $role );
326
+ $role = array('fields' => array('ID', 'display_name'), 'role' => 'editor');
327
+ $editors = get_users( $role );
328
+ $role = array('fields' => array('ID', 'display_name'), 'role' => 'author');
329
+ $authors = get_users( $role );
330
+
331
+ $this->all_authors = array_merge($administrators, $editors, $authors);
332
+ }
333
+ return apply_filters('s2_authors', $this->all_authors);
334
+ } // end get_authors()
335
+
336
+ /**
337
+ Display a drop-down form to select subscribers
338
+ $selected is the option to select
339
+ $submit is the text to use on the Submit button
340
+ */
341
+ function display_subscriber_dropdown($selected = 'registered', $submit = '', $exclude = array()) {
342
+ global $wpdb;
343
+
344
+ $who = array('all' => __('All Users and Subscribers', 'subscribe2'),
345
+ 'public' => __('Public Subscribers', 'subscribe2'),
346
+ 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
347
+ 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
348
+ 'all_users' => __('All Registered Users', 'subscribe2'),
349
+ 'registered' => __('Registered Subscribers', 'subscribe2'));
350
+
351
+ $all_cats = $this->all_cats(false);
352
+
353
+ // count the number of subscribers
354
+ $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
355
+ $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
356
+ if ( in_array('unconfirmed', $exclude) ) {
357
+ $count['public'] = $count['confirmed'];
358
+ } elseif ( in_array('confirmed', $exclude) ) {
359
+ $count['public'] = $count['unconfirmed'];
360
+ } else {
361
+ $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
362
+ }
363
+ if ( $this->s2_mu ) {
364
+ $count['all_users'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
365
+ } else {
366
+ $count['all_users'] = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
367
+ }
368
+ if ( $this->s2_mu ) {
369
+ $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities' AND meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
370
+ } else {
371
+ $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
372
+ }
373
+ $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
374
+ // get subscribers to individual categories but only if we are using per-post notifications
375
+ if ( $this->subscribe2_options['email_freq'] == 'never' ) {
376
+ if ( $this->s2_mu ) {
377
+ foreach ( $all_cats as $cat ) {
378
+ $count[$cat->name] = $wpdb->get_var("SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
379
+ }
380
+ } else {
381
+ foreach ( $all_cats as $cat ) {
382
+ $count[$cat->name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
383
+ }
384
+ }
385
+ }
386
+
387
+ // do have actually have some subscribers?
388
+ if ( 0 == $count['confirmed'] && 0 == $count['unconfirmed'] && 0 == $count['all_users'] ) {
389
+ // no? bail out
390
+ return;
391
+ }
392
+
393
+ echo "<select name=\"what\">\r\n";
394
+ foreach ( $who as $whom => $display ) {
395
+ if ( in_array($whom, $exclude) ) { continue; }
396
+ if ( 0 == $count[$whom] ) { continue; }
397
+
398
+ echo "<option value=\"" . $whom . "\"";
399
+ if ( $whom == $selected ) { echo " selected=\"selected\" "; }
400
+ echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
401
+ }
402
+
403
+ if ( $count['registered'] > 0 && $this->subscribe2_options['email_freq'] == 'never' ) {
404
+ foreach ( $all_cats as $cat ) {
405
+ if ( in_array($cat->term_id, $exclude) ) { continue; }
406
+ echo "<option value=\"" . $cat->term_id . "\"";
407
+ if ( $cat->term_id == $selected ) { echo " selected=\"selected\" "; }
408
+ echo "> &nbsp;&nbsp;" . $cat->name . "&nbsp;(" . $count[$cat->name] . ") </option>\r\n";
409
+ }
410
+ }
411
+ echo "</select>";
412
+ if ( false !== $submit ) {
413
+ echo "&nbsp;<input type=\"submit\" class=\"button-secondary\" value=\"$submit\" />\r\n";
414
+ }
415
+ } // end display_subscriber_dropdown()
416
+
417
+ /**
418
+ Display a drop down list of administrator level users and
419
+ optionally include a choice for Post Author
420
+ */
421
+ function admin_dropdown($inc_author = false) {
422
+ global $wpdb;
423
+
424
+ $args = array('fields' => array('ID', 'display_name'), 'role' => 'administrator');
425
+ $wp_user_query = get_users( $args );
426
+ foreach ($wp_user_query as $user) {
427
+ $admins[] = $user;
428
+ }
429
+
430
+ if ( $inc_author ) {
431
+ $author[] = (object)array('ID' => 'author', 'display_name' => __('Post Author', 'subscribe2'));
432
+ $author[] = (object)array('ID' => 'blogname', 'display_name' => html_entity_decode(get_option('blogname'), ENT_QUOTES));
433
+ $admins = array_merge($author, $admins);
434
+ }
435
+
436
+ echo "<select name=\"sender\">\r\n";
437
+ foreach ( $admins as $admin ) {
438
+ echo "<option value=\"" . $admin->ID . "\"";
439
+ if ( $admin->ID == $this->subscribe2_options['sender'] ) {
440
+ echo " selected=\"selected\"";
441
+ }
442
+ echo ">" . $admin->display_name . "</option>\r\n";
443
+ }
444
+ echo "</select>\r\n";
445
+ } // end admin_dropdown()
446
+
447
+ /**
448
+ Display a dropdown of choices for digest email frequency
449
+ and give user details of timings when event is scheduled
450
+ */
451
+ function display_digest_choices() {
452
+ global $wpdb;
453
+ $cron_file = ABSPATH . 'wp-cron.php';
454
+ if ( !is_readable($cron_file) ) {
455
+ echo "<strong><em style=\"color: red\">" . __('The WordPress cron functions may be disabled on this server. Digest notifications may not work.', 'subscribe2') . "</em></strong><br />\r\n";
456
+ }
457
+ $scheduled_time = wp_next_scheduled('s2_digest_cron');
458
+ $schedule = (array)wp_get_schedules();
459
+ $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('For each Post', 'subscribe2'))), $schedule);
460
+ $sort = array();
461
+ foreach ( (array)$schedule as $key => $value ) {
462
+ $sort[$key] = $value['interval'];
463
+ }
464
+ asort($sort);
465
+ $schedule_sorted = array();
466
+ foreach ( $sort as $key => $value ) {
467
+ $schedule_sorted[$key] = $schedule[$key];
468
+ }
469
+ foreach ( $schedule_sorted as $key => $value ) {
470
+ echo "<label><input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"" . checked($this->subscribe2_options['email_freq'], $key, false) . " />";
471
+ echo " " . $value['display'] . "</label><br />\r\n";
472
+ }
473
+ echo "<br />" . __('Send Digest Notification at', 'subscribe2') . ": \r\n";
474
+ $hours = array('12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am', '10am', '11am', '12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm');
475
+ echo "<select name=\"hour\">\r\n";
476
+ while ( $hour = current($hours) ) {
477
+ echo "<option value=\"" . key($hours) . "\"";
478
+ if ( key($hours) == date('H', $scheduled_time) && !empty($scheduled_time) ){
479
+ echo " selected=\"selected\"";
480
+ }
481
+ echo ">" . $hour . "</option>\r\n";
482
+ next($hours);
483
+ }
484
+ echo "</select>\r\n";
485
+ echo "<strong><em style=\"color: red\">" . __('This option will be ignored if the time selected is not in the future in relation to the current time', 'subscribe2') . "</em></strong>\r\n";
486
+ if ( $scheduled_time ) {
487
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
488
+ echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
489
+ echo "<strong>" . date_i18n($datetime, false, 'gmt') . "</strong></p>\r\n";
490
+ echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
491
+ echo "<strong>" . date_i18n($datetime) . "</strong></p>\r\n";
492
+ echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
493
+ echo "<strong>" . date_i18n($datetime, $scheduled_time) . "</strong></p>\r\n";
494
+ if ( !empty($this->subscribe2_options['previous_s2cron']) ) {
495
+ echo "<p>" . __('Attempt to resend the last Digest Notification email', 'subscribe2') . ": ";
496
+ echo "<input type=\"submit\" class=\"button-secondary\" name=\"resend\" value=\"" . __('Resend Digest', 'subscribe2') . "\" /></p>\r\n";
497
+ }
498
+ } else {
499
+ echo "<br />";
500
+ }
501
+ } // end display_digest_choices()
502
+
503
+ /**
504
+ Create and display a dropdown list of pages
505
+ */
506
+ function pages_dropdown($s2page) {
507
+ global $wpdb;
508
+ $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
509
+ $pages = $wpdb->get_results($sql);
510
+
511
+ if ( empty($pages) ) { return; }
512
+
513
+ $option = '';
514
+ foreach ( $pages as $page ) {
515
+ $option .= "<option value=\"" . $page->ID . "\"";
516
+ if ( $page->ID == $s2page ) {
517
+ $option .= " selected=\"selected\"";
518
+ }
519
+ $option .= ">" . $page->post_title . "</option>\r\n";
520
+ }
521
+
522
+ echo $option;
523
+ } // end pages_dropdown()
524
+
525
+ /**
526
+ Subscribe all registered users to category selected on Admin Manage Page
527
+ */
528
+ function subscribe_registered_users($emails = '', $cats = array()) {
529
+ if ( '' == $emails || '' == $cats ) { return false; }
530
+ global $wpdb;
531
+
532
+ $useremails = explode(",", $emails);
533
+ $useremails = implode("', '", $useremails);
534
+
535
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
536
+ $user_IDs = $wpdb->get_col($sql);
537
+
538
+ foreach ( $user_IDs as $user_ID ) {
539
+ $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
540
+ if ( !empty($old_cats) ) {
541
+ $old_cats = explode(',', $old_cats);
542
+ $newcats = array_unique(array_merge($cats, $old_cats));
543
+ } else {
544
+ $newcats = $cats;
545
+ }
546
+ if ( !empty($newcats) ) {
547
+ // add subscription to these cat IDs
548
+ foreach ( $newcats as $id ) {
549
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
550
+ }
551
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
552
+ }
553
+ unset($newcats);
554
+ }
555
+ } // end subscribe_registered_users()
556
+
557
+ /**
558
+ Unsubscribe all registered users to category selected on Admin Manage Page
559
+ */
560
+ function unsubscribe_registered_users($emails = '', $cats = array()) {
561
+ if ( '' == $emails || '' == $cats ) { return false; }
562
+ global $wpdb;
563
+
564
+ $useremails = explode(",", $emails);
565
+ $useremails = "'" . implode("', '", $useremails) . "'";
566
+
567
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
568
+ $user_IDs = $wpdb->get_col($sql);
569
+
570
+ foreach ( $user_IDs as $user_ID ) {
571
+ $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
572
+ $remain = array_diff($old_cats, $cats);
573
+ if ( !empty($remain) ) {
574
+ // remove subscription to these cat IDs and update s2_subscribed
575
+ foreach ( $cats as $id ) {
576
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
577
+ }
578
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
579
+ } else {
580
+ // remove subscription to these cat IDs and update s2_subscribed to ''
581
+ foreach ( $cats as $id ) {
582
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
583
+ }
584
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
585
+ }
586
+ unset($remain);
587
+ }
588
+ } // end unsubscribe_registered_users()
589
+
590
+ /**
591
+ Handles bulk changes to email format for Registered Subscribers
592
+ */
593
+ function format_change($format, $subscribers_string) {
594
+ if ( empty($format) ) { return; }
595
+
596
+ global $wpdb;
597
+ $subscribers = explode(',\r\n', $subscribers_string);
598
+ $emails = "'" . implode("', '", $subscribers) . "'";
599
+ $ids = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_email IN ($emails)");
600
+ $ids = implode(',', $ids);
601
+ $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname('s2_format') . "' AND user_id IN ($ids)";
602
+ $wpdb->get_results("UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname('s2_format') . "' AND user_id IN ($ids)");
603
+ } // end format_change()
604
+
605
+ /**
606
+ Handles bulk update to digest preferences
607
+ */
608
+ function digest_change($digest, $emails) {
609
+ if ( empty($digest) ) { return; }
610
+
611
+ global $wpdb;
612
+ $useremails = explode(",\r\n", $emails);
613
+ $useremails = "'" . implode("', '", $useremails) . "'";
614
+
615
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
616
+ $user_IDs = $wpdb->get_col($sql);
617
+
618
+ if ( $digest == 'digest' ) {
619
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
620
+ if ( !empty($exclude) ) {
621
+ $all_cats = $this->all_cats(true, 'ID');
622
+ } else {
623
+ $all_cats = $this->all_cats(false, 'ID');
624
+ }
625
+
626
+ $cats_string = '';
627
+ foreach ( $all_cats as $cat ) {
628
+ ('' == $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
629
+ }
630
+
631
+ foreach ( $user_IDs as $user_ID ) {
632
+ foreach ( $all_cats as $cat ) {
633
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
634
+ }
635
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats_string);
636
+ }
637
+ } elseif ( $digest == '-1' ) {
638
+ foreach ( $user_IDs as $user_ID ) {
639
+ $cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
640
+ foreach ( $cats as $id ) {
641
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
642
+ }
643
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
644
+ }
645
+ }
646
+ } // end digest_change()
647
+
648
+ /* ===== functions to handle addition and removal of WordPress categories ===== */
649
+ /**
650
+ Autosubscribe registered users to newly created categories
651
+ if registered user has selected this option
652
+ */
653
+ function new_category($new_category='') {
654
+ if ( 'no' == $this->subscribe2_options['show_autosub'] ) { return; }
655
+ // don't subscribe to individual new categories if we are doing digest emails
656
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) { return; }
657
+ global $wpdb;
658
+
659
+ if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
660
+ if ( $this->s2_mu ) {
661
+ $sql = "SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key='" . $this->get_usermeta_keyname('s2_autosub') . "' AND a.meta_value='yes' AND b.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'";
662
+ } else {
663
+ $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='" . $this->get_usermeta_keyname('s2_autosub') . "' AND $wpdb->usermeta.meta_value='yes'";
664
+ }
665
+ $user_IDs = $wpdb->get_col($sql);
666
+ if ( '' == $user_IDs ) { return; }
667
+
668
+ foreach ( $user_IDs as $user_ID ) {
669
+ $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
670
+ if ( empty($old_cats) ) {
671
+ $newcats = (array)$new_category;
672
+ } else {
673
+ $old_cats = explode(',', $old_cats);
674
+ $newcats = array_merge($old_cats, (array)$new_category);
675
+ }
676
+ // add subscription to these cat IDs
677
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $new_category, $new_category);
678
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
679
+ }
680
+ } elseif ( 'exclude' == $this->subscribe2_options['show_autosub'] ) {
681
+ $excluded_cats = explode(',', $this->subscribe2_options['exclude']);
682
+ $excluded_cats[] = $new_category;
683
+ $this->subscribe2_options['exclude'] = implode(',', $excluded_cats);
684
+ update_option('subscribe2_options', $this->subscribe2_options);
685
+ }
686
+ } // end new_category()
687
+
688
+ /**
689
+ Automatically delete subscriptions to a category when it is deleted
690
+ */
691
+ function delete_category($deleted_category='') {
692
+ global $wpdb;
693
+
694
+ if ( $this->s2_mu ) {
695
+ $sql = "SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$deleted_category' AND b.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'";
696
+ } else {
697
+ $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$deleted_category'";
698
+ }
699
+ $user_IDs = $wpdb->get_col($sql);
700
+ if ( '' == $user_IDs ) { return; }
701
+
702
+ foreach ( $user_IDs as $user_ID ) {
703
+ $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
704
+ if ( !is_array($old_cats) ) {
705
+ $old_cats = array($old_cats);
706
+ }
707
+ // add subscription to these cat IDs
708
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $deleted_category);
709
+ $remain = array_diff($old_cats, (array)$deleted_category);
710
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
711
+ }
712
+ } // end delete_category()
713
+
714
+ /* ===== functions to show & handle one-click subscription ===== */
715
+ /**
716
+ Show form for one-click subscription on user profile page
717
+ */
718
+ function one_click_profile_form($user) {
719
+ echo "<h3>" . __('Email subscription', 'subscribe2') . "</h3>\r\n";
720
+ echo "<table class=\"form-table\">\r\n";
721
+ echo "<tr><th scope=\"row\">" . __('Subscribe / Unsubscribe', 'subscribe2') . "</th>\r\n";
722
+ echo "<td><label><input type=\"checkbox\" name=\"sub2-one-click-subscribe\" value=\"1\" " . checked( ! get_user_meta($user->ID, $this->get_usermeta_keyname('s2_subscribed'), true), false, false ) . " /> " . __('Receive notifications', 'subscribe2') . "</label><br />\r\n";
723
+ echo "<span class=\"description\">" . __('Check if you want to receive email notification when new posts are published', 'subscribe2') . "</span>\r\n";
724
+ echo "</td></tr></table>\r\n";
725
+ } // end one_click_profile_form()
726
+
727
+ /**
728
+ Handle submission from profile one-click subscription
729
+ */
730
+ function one_click_profile_form_save($user_ID) {
731
+ if ( !current_user_can( 'edit_user', $user_ID ) ) {
732
+ return false;
733
+ }
734
+
735
+ if ( isset( $_POST['sub2-one-click-subscribe'] ) && 1 == $_POST['sub2-one-click-subscribe'] ) {
736
+ // Subscribe
737
+ $this->one_click_handler($user_ID, 'subscribe');
738
+ } else {
739
+ // Unsubscribe
740
+ $this->one_click_handler($user_ID, 'unsubscribe');
741
+ }
742
+ } // end one_click_profile_form_save()
743
+ }
744
+ ?>
classes/class-s2-core.php ADDED
@@ -0,0 +1,1812 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class s2class {
3
+ // variables and constructor are declared at the end
4
+ /**
5
+ Load all our strings
6
+ */
7
+ function load_strings() {
8
+ // adjust the output of Subscribe2 here
9
+
10
+ $this->please_log_in = "<p class=\"s2_message\">" . __('To manage your subscription options please', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-login.php\">" . __('login', 'subscribe2') . "</a>.</p>";
11
+
12
+ $this->profile = "<p class=\"s2_message\">" . __('You may manage your subscription options from your', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-admin/admin.php?page=s2\">" . __('profile', 'subscribe2') . "</a>.</p>";
13
+ if ( $this->s2_mu === true ) {
14
+ global $blog_id, $user_ID;
15
+ if ( !is_blog_user($blog_id) ) {
16
+ // if we are on multisite and the user is not a member of this blog change the link
17
+ $this->use_profile_admin = "<p class=\"s2_message\"><a href=\"" . get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id . "\">" . __('Subscribe', 'subscribe2') . "</a> " . __('to email notifications when this blog posts new content', 'subscribe2') . ".</p>";
18
+ }
19
+ }
20
+
21
+ $this->confirmation_sent = "<p class=\"s2_message\">" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
22
+
23
+ $this->already_subscribed = "<p class=\"s2_error\">" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
24
+
25
+ $this->not_subscribed = "<p class=\"s2_error\">" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
26
+
27
+ $this->not_an_email = "<p class=\"s2_error\">" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
28
+
29
+ $this->barred_domain = "<p class=\"s2_error\">" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
30
+
31
+ $this->error = "<p class=\"s2_error\">" . __('Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2') . "</p>";
32
+
33
+ $this->no_page = "<p class=\"s2_error\">" . __('You must to create a WordPress page for this plugin to work correctly.', 'subscribe2') . "</p>";
34
+
35
+ $this->mail_sent = "<p class=\"s2_message\">" . __('Message sent!', 'subscribe2') . "</p>";
36
+
37
+ $this->mail_failed = "<p class=\"s2_error\">" . __('Message failed! Check your settings and check with your hosting provider', 'subscribe2') . "</p>";
38
+
39
+ // confirmation messages
40
+ $this->no_such_email = "<p class=\"s2_error\">" . __('No such email address is registered.', 'subscribe2') . "</p>";
41
+
42
+ $this->added = "<p class=\"s2_message\">" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
43
+
44
+ $this->deleted = "<p class=\"s2_message\">" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
45
+
46
+ $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
47
+
48
+ $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
49
+
50
+ // menu strings
51
+ $this->options_saved = __('Options saved!', 'subscribe2');
52
+ $this->options_reset = __('Options reset!', 'subscribe2');
53
+ } // end load_strings()
54
+
55
+ /* ===== Install, upgrade, reset ===== */
56
+ /**
57
+ Install our table
58
+ */
59
+ function install() {
60
+ // include upgrade-functions for maybe_create_table;
61
+ if ( !function_exists('maybe_create_table') ) {
62
+ require_once(ABSPATH . 'wp-admin/install-helper.php');
63
+ }
64
+ $date = date('Y-m-d');
65
+ $sql = "CREATE TABLE $this->public (
66
+ id int(11) NOT NULL auto_increment,
67
+ email varchar(64) NOT NULL default '',
68
+ active tinyint(1) default 0,
69
+ date DATE default '$date' NOT NULL,
70
+ ip char(64) NOT NULL default 'admin',
71
+ PRIMARY KEY (id) )";
72
+
73
+ // create the table, as needed
74
+ maybe_create_table($this->public, $sql);
75
+
76
+ // safety check if options exist and if not create them
77
+ if ( !is_array($this->subscribe2_options) ) {
78
+ $this->reset();
79
+ }
80
+ } // end install()
81
+
82
+ /**
83
+ Upgrade function for the database and settings
84
+ */
85
+ function upgrade() {
86
+ global $wpdb, $wp_version, $wpmu_version;
87
+ // include upgrade-functions for maybe_add_column;
88
+ if ( !function_exists('maybe_add_column') ) {
89
+ require_once(ABSPATH . 'wp-admin/install-helper.php');
90
+ }
91
+ $date = date('Y-m-d');
92
+ maybe_add_column($this->public, 'date', "ALTER TABLE $this->public ADD date DATE DEFAULT '$date' NOT NULL AFTER active");
93
+ maybe_add_column($this->public, 'ip', "ALTER TABLE $this->public ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date");
94
+
95
+ // let's take the time to check process registered users
96
+ // existing public subscribers are subscribed to all categories
97
+ $users = $this->get_all_registered('ID');
98
+ if ( !empty($users) ) {
99
+ foreach ( $users as $user_ID ) {
100
+ $check_format = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true);
101
+ // if user is already registered update format remove 's2_excerpt' field and update 's2_format'
102
+ if ( 'html' == $check_format ) {
103
+ delete_user_meta($user_ID, 's2_excerpt');
104
+ } elseif ( 'text' == $check_format ) {
105
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), get_user_meta($user_ID, 's2_excerpt'));
106
+ delete_user_meta($user_ID, 's2_excerpt');
107
+ } elseif ( empty($check_format) ) {
108
+ // no prior settings so create them
109
+ $this->register($user_ID);
110
+ }
111
+ $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
112
+ if ( strstr($subscribed, '-1') ) {
113
+ // make sure we remove '-1' from any settings
114
+ $old_cats = explode(',', $subscribed);
115
+ $pos = array_search('-1', $old_cats);
116
+ unset($old_cats[$pos]);
117
+ $cats = implode(',', $old_cats);
118
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
119
+ }
120
+ $check_authors = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), true);
121
+ if ( empty($check_authors) ) {
122
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
123
+ }
124
+ }
125
+ }
126
+ // update the options table to serialized format
127
+ $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
128
+
129
+ if ( !empty($old_options) ) {
130
+ foreach ( $old_options as $option ) {
131
+ $value = get_option($option);
132
+ $option_array = substr($option, 3);
133
+ $this->subscribe2_options[$option_array] = $value;
134
+ delete_option($option);
135
+ }
136
+ }
137
+ $this->subscribe2_options['version'] = S2VERSION;
138
+ // ensure that the options are in the database
139
+ require(S2PATH . "include/options.php");
140
+ // correct autoformat to upgrade from pre 5.6
141
+ if ( $this->subscribe2_options['autoformat'] == 'text' ) {
142
+ $this->subscribe2_options['autoformat'] = 'excerpt';
143
+ }
144
+ if ( $this->subscribe2_options['autoformat'] == 'full' ) {
145
+ $this->subscribe2_options['autoformat'] = 'post';
146
+ }
147
+ // change old CAPITALISED keywords to those in {PARENTHESES}; since version 6.4
148
+ $keywords = array('BLOGNAME', 'BLOGLINK', 'TITLE', 'POST', 'POSTTIME', 'TABLE', 'TABLELINKS', 'PERMALINK', 'TINYLINK', 'DATE', 'TIME', 'MYNAME', 'EMAIL', 'AUTHORNAME', 'LINK', 'CATS', 'TAGS', 'COUNT', 'ACTION');
149
+ $keyword = implode('|', $keywords);
150
+ $regex = '/(?<!\{)\b('.$keyword.')\b(?!\{)/xm';
151
+ $replace = '{\1}';
152
+ $this->subscribe2_options['mailtext'] = preg_replace($regex, $replace, $this->subscribe2_options['mailtext']);
153
+ $this->subscribe2_options['notification_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['notification_subject']);
154
+ $this->subscribe2_options['confirm_email'] = preg_replace($regex, $replace, $this->subscribe2_options['confirm_email']);
155
+ $this->subscribe2_options['confirm_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['confirm_subject']);
156
+ $this->subscribe2_options['remind_email'] = preg_replace($regex, $replace, $this->subscribe2_options['remind_email']);
157
+ $this->subscribe2_options['remind_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['remind_subject']);
158
+ update_option('subscribe2_options', $this->subscribe2_options);
159
+
160
+ // upgrade old wpmu user meta data to new
161
+ if ( $this->s2_mu === true ) {
162
+ $s2class_multisite->namechange_subscribe2_widget();
163
+ // loop through all users
164
+ foreach ( $users as $user_ID ) {
165
+ // get categories which the user is subscribed to (old ones)
166
+ $categories = get_user_meta($user_ID, 's2_subscribed', true);
167
+ $categories = explode(',', $categories);
168
+ $format = get_user_meta($user_ID, 's2_format', true);
169
+ $autosub = get_user_meta($user_ID, 's2_autosub', true);
170
+
171
+ // load blogs of user (only if we need them)
172
+ $blogs = array();
173
+ if ( count($categories) > 0 && !in_array('-1', $categories) ) {
174
+ $blogs = get_blogs_of_user($user_ID, true);
175
+ }
176
+
177
+ foreach ( $blogs as $blog ) {
178
+ switch_to_blog($blog->userblog_id);
179
+
180
+ $blog_categories = (array)$wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category'");
181
+ $subscribed_categories = array_intersect($categories, $blog_categories);
182
+ if ( !empty($subscribed_categories) ) {
183
+ foreach ( $subscribed_categories as $subscribed_category ) {
184
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category);
185
+ }
186
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories));
187
+ }
188
+ if ( !empty($format) ) {
189
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $format);
190
+ }
191
+ if ( !empty($autosub) ) {
192
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $autosub);
193
+ }
194
+ restore_current_blog();
195
+ }
196
+
197
+ // delete old user meta keys
198
+ delete_user_meta($user_ID, 's2_subscribed');
199
+ delete_user_meta($user_ID, 's2_format');
200
+ delete_user_meta($user_ID, 's2_autosub');
201
+ foreach ( $categories as $cat ) {
202
+ delete_user_meta($user_ID, 's2_cat' . $cat);
203
+ }
204
+ }
205
+ }
206
+
207
+ // ensure existing public subscriber emails are all sanitized
208
+ $confirmed = $this->get_public();
209
+ $unconfirmed = $this->get_public(0);
210
+ $public_subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
211
+
212
+ foreach ( $public_subscribers as $email ) {
213
+ $new_email = $this->sanitize_email($email);
214
+ if ( $email !== $new_email ) {
215
+ $wpdb->get_results("UPDATE $this->public SET email='$new_email' WHERE CAST(email as binary)='$email'");
216
+ }
217
+ }
218
+ return;
219
+ } // end upgrade()
220
+
221
+ /**
222
+ Reset our options
223
+ */
224
+ function reset() {
225
+ delete_option('subscribe2_options');
226
+ wp_clear_scheduled_hook('s2_digest_cron');
227
+ unset($this->subscribe2_options);
228
+ require(S2PATH . "include/options.php");
229
+ update_option('subscribe2_options', $this->subscribe2_options);
230
+ } // end reset()
231
+
232
+ /* ===== mail handling ===== */
233
+ /**
234
+ Performs string substitutions for subscribe2 mail tags
235
+ */
236
+ function substitute($string = '') {
237
+ if ( '' == $string ) {
238
+ return;
239
+ }
240
+ $string = str_replace("{BLOGNAME}", html_entity_decode(get_option('blogname'), ENT_QUOTES), $string);
241
+ $string = str_replace("{BLOGLINK}", get_option('home'), $string);
242
+ $string = str_replace("{TITLE}", stripslashes($this->post_title), $string);
243
+ $link = "<a href=\"" . $this->get_tracking_link($this->permalink) . "\">" . $this->get_tracking_link($this->permalink) . "</a>";
244
+ $string = str_replace("{PERMALINK}", $link, $string);
245
+ if ( strstr($string, "{TINYLINK}") ) {
246
+ $tinylink = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode($this->get_tracking_link($this->permalink)));
247
+ if ( $tinylink !== 'Error' || $tinylink != false ) {
248
+ $tlink = "<a href=\"" . $tinylink . "\">" . $tinylink . "</a>";
249
+ $string = str_replace("{TINYLINK}", $tlink, $string);
250
+ } else {
251
+ $string = str_replace("{TINYLINK}", $link, $string);
252
+ }
253
+ }
254
+ $string = str_replace("{DATE}", $this->post_date, $string);
255
+ $string = str_replace("{TIME}", $this->post_time, $string);
256
+ $string = str_replace("{MYNAME}", stripslashes($this->myname), $string);
257
+ $string = str_replace("{EMAIL}", $this->myemail, $string);
258
+ $string = str_replace("{AUTHORNAME}", stripslashes($this->authorname), $string);
259
+ $string = str_replace("{CATS}", $this->post_cat_names, $string);
260
+ $string = str_replace("{TAGS}", $this->post_tag_names, $string);
261
+ $string = str_replace("{COUNT}", $this->post_count, $string);
262
+
263
+ return $string;
264
+ } // end substitute()
265
+
266
+ /**
267
+ Delivers email to recipients in HTML or plaintext
268
+ */
269
+ function mail($recipients = array(), $subject = '', $message = '', $type='text') {
270
+ if ( empty($recipients) || '' == $message ) { return; }
271
+
272
+ if ( 'html' == $type ) {
273
+ $headers = $this->headers('html');
274
+ if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
275
+ $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title><link rel=\"stylesheet\" href=\"" . get_stylesheet_uri() . "\" type=\"text/css\" media=\"screen\" /></head><body>" . $message . "</body></html>", $subject, $message);
276
+ } else {
277
+ $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>", $subject, $message);
278
+ }
279
+ } else {
280
+ $headers = $this->headers();
281
+ $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
282
+ $message = preg_replace('|&amp;|', '&', $message);
283
+ $message = wordwrap(strip_tags($message), 80, "\n");
284
+ $mailtext = apply_filters('s2_plain_email', $message);
285
+ }
286
+
287
+ // Replace any escaped html symbols in subject then apply filter
288
+ $subject = html_entity_decode($subject, ENT_QUOTES);
289
+ $subject = apply_filters('s2_email_subject', $subject);
290
+
291
+ // Construct BCC headers for sending or send individual emails
292
+ $bcc = '';
293
+ natcasesort($recipients);
294
+ if ( function_exists('wpmq_mail') || $this->subscribe2_options['bcclimit'] == 1 || count($recipients) == 1 ) {
295
+ // BCCLimit is 1 so send individual emails or we only have 1 recipient
296
+ foreach ( $recipients as $recipient ) {
297
+ $recipient = trim($recipient);
298
+ // sanity check -- make sure we have a valid email
299
+ if ( !is_email($recipient) || empty($recipient) ) { continue; }
300
+ // Use the mail queue provided we are not sending a preview
301
+ if ( function_exists('wpmq_mail') && !$this->preview_email ) {
302
+ @wp_mail($recipient, $subject, $mailtext, $headers, '', 0);
303
+ } else {
304
+ @wp_mail($recipient, $subject, $mailtext, $headers);
305
+ }
306
+ }
307
+ return true;
308
+ } elseif ( $this->subscribe2_options['bcclimit'] == 0 ) {
309
+ // we're not using BCCLimit
310
+ foreach ( $recipients as $recipient ) {
311
+ $recipient = trim($recipient);
312
+ // sanity check -- make sure we have a valid email
313
+ if ( !is_email($recipient) ) { continue; }
314
+ // and NOT the sender's email, since they'll get a copy anyway
315
+ if ( !empty($recipient) && $this->myemail != $recipient ) {
316
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
317
+ // Bcc Headers now constructed by phpmailer class
318
+ }
319
+ }
320
+ $headers .= "$bcc\n";
321
+ } else {
322
+ // we're using BCCLimit
323
+ $count = 1;
324
+ $batch = array();
325
+ foreach ( $recipients as $recipient ) {
326
+ $recipient = trim($recipient);
327
+ // sanity check -- make sure we have a valid email
328
+ if ( !is_email($recipient) ) { continue; }
329
+ // and NOT the sender's email, since they'll get a copy anyway
330
+ if ( !empty($recipient) && $this->myemail != $recipient ) {
331
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
332
+ // Bcc Headers now constructed by phpmailer class
333
+ }
334
+ if ( $this->subscribe2_options['bcclimit'] == $count ) {
335
+ $count = 0;
336
+ $batch[] = $bcc;
337
+ $bcc = '';
338
+ }
339
+ $count++;
340
+ }
341
+ // add any partially completed batches to our batch array
342
+ if ( '' != $bcc ) {
343
+ $batch[] = $bcc;
344
+ }
345
+ }
346
+ // rewind the array, just to be safe
347
+ reset($recipients);
348
+
349
+ // actually send mail
350
+ if ( isset($batch) && !empty($batch) ) {
351
+ foreach ( $batch as $bcc ) {
352
+ $newheaders = $headers . "$bcc\n";
353
+ $status = @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
354
+ }
355
+ } else {
356
+ $status = @wp_mail($this->myemail, $subject, $mailtext, $headers);
357
+ }
358
+ return $status;
359
+ } // end mail()
360
+
361
+ /**
362
+ Construct standard set of email headers
363
+ */
364
+ function headers($type='text') {
365
+ if ( empty($this->myname) || empty($this->myemail) ) {
366
+ if ( $this->subscribe2_options['sender'] == 'blogname' ) {
367
+ $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
368
+ $this->myemail = get_option('admin_email');
369
+ } else {
370
+ $admin = $this->get_userdata($this->subscribe2_options['sender']);
371
+ $this->myname = html_entity_decode($admin->display_name, ENT_QUOTES);
372
+ $this->myemail = $admin->user_email;
373
+ // fail safe to ensure sender details are not empty
374
+ if ( empty($this->myname) ) {
375
+ $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
376
+ }
377
+ if ( empty($this->myemail) ) {
378
+ // Get the site domain and get rid of www.
379
+ $sitename = strtolower( $_SERVER['SERVER_NAME'] );
380
+ if ( substr( $sitename, 0, 4 ) == 'www.' ) {
381
+ $sitename = substr( $sitename, 4 );
382
+ }
383
+ $this->myemail = 'wordpress@' . $sitename;
384
+ }
385
+ }
386
+ }
387
+
388
+ $header['From'] = $this->myname . " <" . $this->myemail . ">";
389
+ $header['Reply-To'] = $this->myname . " <" . $this->myemail . ">";
390
+ $header['Return-path'] = "<" . $this->myemail . ">";
391
+ $header['Precedence'] = "list\nList-Id: " . html_entity_decode(get_option('blogname'), ENT_QUOTES) . "";
392
+ if ( $type == 'html' ) {
393
+ // To send HTML mail, the Content-Type header must be set
394
+ $header['Content-Type'] = get_option('html_type') . "; charset=\"". get_option('blog_charset') . "\"";
395
+ } else {
396
+ $header['Content-Type'] = "text/plain; charset=\"". get_option('blog_charset') . "\"";
397
+ }
398
+
399
+ // apply header filter to allow on-the-fly amendments
400
+ $header = apply_filters('s2_email_headers', $header);
401
+ // collapse the headers using $key as the header name
402
+ foreach ( $header as $key => $value ) {
403
+ $headers[$key] = $key . ": " . $value;
404
+ }
405
+ $headers = implode("\n", $headers);
406
+ $headers .= "\n";
407
+
408
+ return $headers;
409
+ } // end headers()
410
+
411
+ /**
412
+ Function to add UTM tracking details to links
413
+ */
414
+ function get_tracking_link($link) {
415
+ if ( !empty($this->subscribe2_options['tracking']) ) {
416
+ $delimiter = '?';
417
+ if ( strpos($link, $delimiter) > 0 ) { $delimiter = '&'; }
418
+ return $link . $delimiter . $this->subscribe2_options['tracking'];
419
+ } else {
420
+ return $link;
421
+ }
422
+ } // end get_tracking_link()
423
+
424
+ /**
425
+ Sends an email notification of a new post
426
+ */
427
+ function publish($post = 0, $preview = '') {
428
+ if ( !$post ) { return $post; }
429
+
430
+ if ( $this->s2_mu ) {
431
+ global $switched;
432
+ if ( $switched ) { return; }
433
+ }
434
+
435
+ if ( $preview == '' ) {
436
+ // we aren't sending a Preview to the current user so carry out checks
437
+ $s2mail = get_post_meta($post->ID, 's2mail', true);
438
+ if ( (isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no') || strtolower(trim($s2mail)) == 'no' ) { return $post; }
439
+
440
+ // are we doing daily digests? If so, don't send anything now
441
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) { return $post; }
442
+
443
+ // is the current post of a type that should generate a notification email?
444
+ // uses s2_post_types filter to allow for custom post types in WP 3.0
445
+ if ( $this->subscribe2_options['pages'] == 'yes' ) {
446
+ $s2_post_types = array('page', 'post');
447
+ } else {
448
+ $s2_post_types = array('post');
449
+ }
450
+ $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
451
+ if ( !in_array($post->post_type, $s2_post_types) ) {
452
+ return $post;
453
+ }
454
+
455
+ // Are we sending notifications for password protected posts?
456
+ if ( $this->subscribe2_options['password'] == "no" && $post->post_password != '' ) {
457
+ return $post;
458
+ }
459
+
460
+ // Is the post assigned to a format for which we should not be sending posts
461
+ $post_format = get_post_format($post->ID);
462
+ $excluded_formats = explode(',', $this->subscribe2_options['exclude_formats']);
463
+ if ( $post_format !== false && in_array($post_format, $excluded_formats) ) {
464
+ return $post;
465
+ }
466
+
467
+ $post_cats = wp_get_post_categories($post->ID);
468
+ $check = false;
469
+ // is the current post assigned to any categories
470
+ // which should not generate a notification email?
471
+ foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
472
+ if ( in_array($cat, $post_cats) ) {
473
+ $check = true;
474
+ }
475
+ }
476
+
477
+ if ( $check ) {
478
+ // hang on -- can registered users subscribe to
479
+ // excluded categories?
480
+ if ( '0' == $this->subscribe2_options['reg_override'] ) {
481
+ // nope? okay, let's leave
482
+ return $post;
483
+ }
484
+ }
485
+
486
+ // Are we sending notifications for Private posts?
487
+ // Action is added if we are, but double check option and post status
488
+ if ( $this->subscribe2_options['private'] == "yes" && $post->post_status == 'private' ) {
489
+ // don't send notification to public users
490
+ $check = true;
491
+ }
492
+
493
+ // lets collect our subscribers
494
+ if ( !$check ) {
495
+ // if this post is assigned to an excluded
496
+ // category, or is a private post then
497
+ // don't send public subscribers a notification
498
+ $public = $this->get_public();
499
+ }
500
+ if ( $post->post_type == 'page' ) {
501
+ $post_cats_string = get_all_category_ids();
502
+ } else {
503
+ $post_cats_string = implode(',', $post_cats);
504
+ }
505
+ $registered = $this->get_registered("cats=$post_cats_string");
506
+
507
+ // do we have subscribers?
508
+ if ( empty($public) && empty($registered) ) {
509
+ // if not, no sense doing anything else
510
+ return $post;
511
+ }
512
+ }
513
+
514
+ // we set these class variables so that we can avoid
515
+ // passing them in function calls a little later
516
+ $this->post_title = "<a href=\"" . get_permalink($post->ID) . "\">" . html_entity_decode($post->post_title, ENT_QUOTES) . "</a>";
517
+ $this->permalink = get_permalink($post->ID);
518
+ $this->post_date = get_the_time(get_option('date_format'));
519
+ $this->post_time = get_the_time();
520
+
521
+ $author = get_userdata($post->post_author);
522
+ $this->authorname = $author->display_name;
523
+
524
+ // do we send as admin, or post author?
525
+ if ( 'author' == $this->subscribe2_options['sender'] ) {
526
+ // get author details
527
+ $user = &$author;
528
+ $this->myemail = $user->user_email;
529
+ $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
530
+ } elseif ( 'blogname' == $this->subscribe2_options['sender'] ) {
531
+ $this->myemail = get_option('admin_email');
532
+ $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
533
+ } else {
534
+ // get admin details
535
+ $user = $this->get_userdata($this->subscribe2_options['sender']);
536
+ $this->myemail = $user->user_email;
537
+ $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
538
+ }
539
+
540
+ $this->post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
541
+ $this->post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
542
+
543
+ // Get email subject
544
+ $subject = stripslashes(strip_tags($this->substitute($this->subscribe2_options['notification_subject'])));
545
+ // Get the message template
546
+ $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
547
+ $mailtext = stripslashes($this->substitute($mailtext));
548
+
549
+ $plaintext = $post->post_content;
550
+ if ( function_exists('strip_shortcodes') ) {
551
+ $plaintext = strip_shortcodes($plaintext);
552
+ }
553
+ $plaintext = preg_replace('|<s*>(.*)<\/s>|','', $plaintext);
554
+ $plaintext = preg_replace('|<strike*>(.*)<\/strike>|','', $plaintext);
555
+ $plaintext = preg_replace('|<del*>(.*)<\/del>|','', $plaintext);
556
+
557
+ $gallid = '[gallery id="' . $post->ID . '"';
558
+ $content = str_replace('[gallery', $gallid, $post->post_content);
559
+ $content = apply_filters('the_content', $content);
560
+ $content = str_replace("]]>", "]]&gt", $content);
561
+
562
+ $excerpt = $post->post_excerpt;
563
+ if ( '' == $excerpt ) {
564
+ // no excerpt, is there a <!--more--> ?
565
+ if ( false !== strpos($plaintext, '<!--more-->') ) {
566
+ list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
567
+ // strip leading and trailing whitespace
568
+ $excerpt = strip_tags($excerpt);
569
+ $excerpt = trim($excerpt);
570
+ } else {
571
+ // no <!--more-->, so grab the first 55 words
572
+ $excerpt = strip_tags($plaintext);
573
+ $words = explode(' ', $excerpt, $this->excerpt_length + 1);
574
+ if (count($words) > $this->excerpt_length) {
575
+ array_pop($words);
576
+ array_push($words, '[...]');
577
+ $excerpt = implode(' ', $words);
578
+ }
579
+ }
580
+ }
581
+ $html_excerpt = $post->post_excerpt;
582
+ if ( '' == $html_excerpt ) {
583
+ // no excerpt, is there a <!--more--> ?
584
+ if ( false !== strpos($content, '<!--more-->') ) {
585
+ list($html_excerpt, $more) = explode('<!--more-->', $content, 2);
586
+ // balance HTML tags and then strip leading and trailing whitespace
587
+ $html_excerpt = trim(balanceTags($html_excerpt, true));
588
+ } else {
589
+ // no <!--more-->, so grab the first 55 words
590
+ $words = explode(' ', $content, $this->excerpt_length + 1);
591
+ if (count($words) > $this->excerpt_length) {
592
+ array_pop($words);
593
+ array_push($words, '[...]');
594
+ $html_excerpt = implode(' ', $words);
595
+ // balance HTML tags and then strip leading and trailing whitespace
596
+ $html_excerpt = trim(balanceTags($html_excerpt, true));
597
+ } else {
598
+ $html_excerpt = $content;
599
+ }
600
+ }
601
+ }
602
+
603
+ // remove excess white space from with $excerpt and $plaintext
604
+ $excerpt = preg_replace('|[ ]+|', ' ', $excerpt);
605
+ $plaintext = preg_replace('|[ ]+|', ' ', $plaintext);
606
+
607
+ // prepare mail body texts
608
+ $excerpt_body = str_replace("{POST}", $excerpt, $mailtext);
609
+ $full_body = str_replace("{POST}", strip_tags($plaintext), $mailtext);
610
+ $html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
611
+ $html_body = str_replace("{POST}", $content, $html_body);
612
+ $html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
613
+ $html_excerpt_body = str_replace("{POST}", $html_excerpt, $html_excerpt_body);
614
+
615
+ if ( $preview != '' ) {
616
+ $this->myemail = $preview;
617
+ $this->myname = __('Plain Text Excerpt Preview', 'subscribe2');
618
+ $this->mail(array($preview), $subject, $excerpt_body);
619
+ $this->myname = __('Plain Text Full Preview', 'subscribe2');
620
+ $this->mail(array($preview), $subject, $full_body);
621
+ $this->myname = __('HTML Excerpt Preview', 'subscribe2');
622
+ $this->mail(array($preview), $subject, $html_excerpt_body, 'html');
623
+ $this->myname = __('HTML Full Preview', 'subscribe2');
624
+ $this->mail(array($preview), $subject, $html_body, 'html');
625
+ } else {
626
+ // first we send plaintext summary emails
627
+ $registered = $this->get_registered("cats=$post_cats_string&format=excerpt&author=$post->post_author");
628
+ if ( empty($registered) ) {
629
+ $recipients = (array)$public;
630
+ } elseif ( empty($public) ) {
631
+ $recipients = (array)$registered;
632
+ } else {
633
+ $recipients = array_merge((array)$public, (array)$registered);
634
+ }
635
+ $recipients = apply_filters('s2_send_plain_excerpt_suscribers', $recipients, $post->ID);
636
+ $this->mail($recipients, $subject, $excerpt_body);
637
+
638
+ // next we send plaintext full content emails
639
+ $recipients = $this->get_registered("cats=$post_cats_string&format=post&author=$post->post_author");
640
+ $recipients = apply_filters('s2_send_plain_fullcontent_suscribers', $recipients, $post->ID);
641
+ $this->mail($recipients, $subject, $full_body);
642
+
643
+ // next we send html excerpt content emails
644
+ $recipients = $this->get_registered("cats=$post_cats_string&format=html_excerpt&author=$post->post_author");
645
+ $recipients = apply_filters('s2_send_html_excerpt_suscribers', $recipients, $post->ID);
646
+ $this->mail($recipients, $subject, $html_excerpt_body, 'html');
647
+
648
+ // finally we send html full content emails
649
+ $recipients = $this->get_registered("cats=$post_cats_string&format=html&author=$post->post_author");
650
+ $recipients = apply_filters('s2_send_html_fullcontent_suscribers', $recipients, $post->ID);
651
+ $this->mail($recipients, $subject, $html_body, 'html');
652
+ }
653
+ } // end publish()
654
+
655
+ /**
656
+ Send confirmation email to a public subscriber
657
+ */
658
+ function send_confirm($what = '', $is_remind = false) {
659
+ if ( $this->filtered == 1 ) { return true; }
660
+ if ( !$this->email || !$what ) { return false; }
661
+ $id = $this->get_id($this->email);
662
+ if ( !$id ) {
663
+ return false;
664
+ }
665
+
666
+ // generate the URL "?s2=ACTION+HASH+ID"
667
+ // ACTION = 1 to subscribe, 0 to unsubscribe
668
+ // HASH = md5 hash of email address
669
+ // ID = user's ID in the subscribe2 table
670
+ // use home instead of siteurl incase index.php is not in core wordpress directory
671
+ $link = get_option('home') . "/?s2=";
672
+
673
+ if ( 'add' == $what ) {
674
+ $link .= '1';
675
+ } elseif ( 'del' == $what ) {
676
+ $link .= '0';
677
+ }
678
+ $link .= md5($this->email);
679
+ $link .= $id;
680
+
681
+ // sort the headers now so we have all substitute information
682
+ $mailheaders = $this->headers();
683
+
684
+ if ( $is_remind == true ) {
685
+ $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
686
+ $subject = $this->substitute(stripslashes($this->subscribe2_options['remind_subject']));
687
+ } else {
688
+ $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
689
+ if ( 'add' == $what ) {
690
+ $body = str_replace("{ACTION}", $this->subscribe, $body);
691
+ $subject = str_replace("{ACTION}", $this->subscribe, $this->subscribe2_options['confirm_subject']);
692
+ } elseif ( 'del' == $what ) {
693
+ $body = str_replace("{ACTION}", $this->unsubscribe, $body);
694
+ $subject = str_replace("{ACTION}", $this->unsubscribe, $this->subscribe2_options['confirm_subject']);
695
+ }
696
+ $subject = html_entity_decode($this->substitute(stripslashes($subject)), ENT_QUOTES);
697
+ }
698
+
699
+ $body = str_replace("{LINK}", $link, $body);
700
+
701
+ if ( $is_remind == true && function_exists('wpmq_mail') ) {
702
+ // could be sending lots of reminders so queue them if wpmq is enabled
703
+ @wp_mail($this->email, $subject, $body, $mailheaders, '', 0);
704
+ } else {
705
+ return @wp_mail($this->email, $subject, $body, $mailheaders);
706
+ }
707
+ } // end send_confirm()
708
+
709
+ /* ===== Public Subscriber functions ===== */
710
+ /**
711
+ Return an array of all the public subscribers
712
+ */
713
+ function get_public($confirmed = 1) {
714
+ global $wpdb;
715
+ if ( 1 == $confirmed ) {
716
+ if ( '' == $this->all_public ) {
717
+ $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
718
+ }
719
+ return $this->all_public;
720
+ } else {
721
+ if ( '' == $this->all_unconfirmed ) {
722
+ $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
723
+ }
724
+ return $this->all_unconfirmed;
725
+ }
726
+ } // end get_public()
727
+
728
+ /**
729
+ Given a public subscriber ID, returns the email address
730
+ */
731
+ function get_email($id = 0) {
732
+ global $wpdb;
733
+
734
+ if ( !$id ) {
735
+ return false;
736
+ }
737
+ return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
738
+ } // end get_email()
739
+
740
+ /**
741
+ Given a public subscriber email, returns the subscriber ID
742
+ */
743
+ function get_id($email = '') {
744
+ global $wpdb;
745
+
746
+ if ( !$email ) {
747
+ return false;
748
+ }
749
+ return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
750
+ } // end get_id()
751
+
752
+ /**
753
+ Add an public subscriber to the subscriber table
754
+ If added by admin it is immediately confirmed, otherwise as unconfirmed
755
+ */
756
+ function add($email = '', $confirm = false) {
757
+ if ( $this->filtered == 1 ) { return; }
758
+ global $wpdb;
759
+
760
+ if ( !is_email($email) ) { return false; }
761
+
762
+ if ( false !== $this->is_public($email) ) {
763
+ // is this an email for a registered user
764
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
765
+ if ( $check ) { return; }
766
+ if ( $confirm ) {
767
+ $wpdb->get_results("UPDATE $this->public SET active='1', ip='$this->ip' WHERE CAST(email as binary)='$email'");
768
+ } else {
769
+ $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE CAST(email as binary)='$email'");
770
+ }
771
+ } else {
772
+ if ( $confirm ) {
773
+ global $current_user;
774
+ $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 1, $current_user->user_login));
775
+ } else {
776
+ $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 0, $this->ip));
777
+ }
778
+ }
779
+ } // end add()
780
+
781
+ /**
782
+ Remove a public subscriber user from the subscription table
783
+ */
784
+ function delete($email = '') {
785
+ global $wpdb;
786
+
787
+ if ( !is_email($email) ) { return false; }
788
+ $wpdb->get_results("DELETE FROM $this->public WHERE CAST(email as binary)='$email'");
789
+ } // end delete()
790
+
791
+ /**
792
+ Toggle a public subscriber's status
793
+ */
794
+ function toggle($email = '') {
795
+ global $wpdb;
796
+
797
+ if ( '' == $email || !is_email($email) ) { return false; }
798
+
799
+ // let's see if this is a public user
800
+ $status = $this->is_public($email);
801
+ if ( false === $status ) { return false; }
802
+
803
+ if ( '0' == $status ) {
804
+ $wpdb->get_results("UPDATE $this->public SET active='1' WHERE CAST(email as binary)='$email'");
805
+ } else {
806
+ $wpdb->get_results("UPDATE $this->public SET active='0' WHERE CAST(email as binary)='$email'");
807
+ }
808
+ } // end toggle()
809
+
810
+ /**
811
+ Send reminder email to unconfirmed public subscribers
812
+ */
813
+ function remind($emails = '') {
814
+ if ( '' == $emails ) { return false; }
815
+
816
+ $recipients = explode(",", $emails);
817
+ if ( !is_array($recipients) ) { $recipients = (array)$recipients; }
818
+ foreach ( $recipients as $recipient ) {
819
+ $this->email = $recipient;
820
+ $this->send_confirm('add', true);
821
+ }
822
+ } //end remind()
823
+
824
+ /**
825
+ Check email is not from a barred domain
826
+ */
827
+ function is_barred($email='') {
828
+ $barred_option = $this->subscribe2_options['barred'];
829
+ list($user, $domain) = explode('@', $email, 2);
830
+ $bar_check = stristr($barred_option, $domain);
831
+
832
+ if ( !empty($bar_check) ) {
833
+ return true;
834
+ } else {
835
+ return false;
836
+ }
837
+ } // end is_barred()
838
+
839
+ /**
840
+ Is the supplied email address a public subscriber?
841
+ */
842
+ function is_public($email = '') {
843
+ global $wpdb;
844
+
845
+ if ( '' == $email ) { return false; }
846
+
847
+ // run the query and force case sensitivity
848
+ $check = $wpdb->get_var("SELECT active FROM $this->public WHERE CAST(email as binary)='$email'");
849
+ if ( '0' == $check || '1' == $check ) {
850
+ return $check;
851
+ } else {
852
+ return false;
853
+ }
854
+ } // end is_public()
855
+
856
+ /**
857
+ Collects the signup date for all public subscribers
858
+ */
859
+ function signup_date($email = '') {
860
+ if ( '' == $email ) { return false; }
861
+
862
+ global $wpdb;
863
+ if ( !empty($this->signup_dates) ) {
864
+ return $this->signup_dates[$email];
865
+ } else {
866
+ $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
867
+ foreach ( $results as $result ) {
868
+ $this->signup_dates[$result[0]] = $result[1];
869
+ }
870
+ return $this->signup_dates[$email];
871
+ }
872
+ } // end signup_date()
873
+
874
+ /**
875
+ Collects the ip address for all public subscribers
876
+ */
877
+ function signup_ip($email = '') {
878
+ if ( '' == $email ) {return false; }
879
+
880
+ global $wpdb;
881
+ if ( !empty($this->signup_ips) ) {
882
+ return $this->signup_ips[$email];
883
+ } else {
884
+ $results = $wpdb->get_results("SELECT email, ip FROM $this->public", ARRAY_N);
885
+ foreach ( $results as $result ) {
886
+ $this->signup_ips[$result[0]] = $result[1];
887
+ }
888
+ return $this->signup_ips[$email];
889
+ }
890
+ } // end signup_ip()
891
+
892
+ /* ===== Registered User and Subscriber functions ===== */
893
+ /**
894
+ Is the supplied email address a registered user of the blog?
895
+ */
896
+ function is_registered($email = '') {
897
+ global $wpdb;
898
+
899
+ if ( '' == $email ) { return false; }
900
+
901
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$email'");
902
+ if ( $check ) {
903
+ return true;
904
+ } else {
905
+ return false;
906
+ }
907
+ } // end is_registered()
908
+
909
+ /**
910
+ Return Registered User ID from email
911
+ */
912
+ function get_user_id($email = '') {
913
+ global $wpdb;
914
+
915
+ if ( '' == $email ) { return false; }
916
+
917
+ $id = $wpdb->get_var("SELECT id FROM $wpdb->users WHERE user_email='$email'");
918
+
919
+ return $id;
920
+ } // end get_user_id()
921
+
922
+ /**
923
+ Return an array of all subscribers emails or IDs
924
+ */
925
+ function get_all_registered($return = 'email') {
926
+ global $wpdb;
927
+
928
+ if ( $this->s2_mu ) {
929
+ if ( $return === 'ID' ) {
930
+ return $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
931
+ } else {
932
+ return $wpdb->get_col("SELECT a.user_email FROM $wpdb->users AS a INNER JOIN $wpdb->usermeta AS b ON a.ID = b.user_id WHERE b.meta_key='" . $wpdb->prefix . "capabilities'");
933
+ }
934
+ } else {
935
+ if ( $return === 'ID' ) {
936
+ return $wpdb->get_col("SELECT ID FROM $wpdb->users");
937
+ } else {
938
+ return $wpdb->get_col("SELECT user_email FROM $wpdb->users");
939
+ }
940
+ }
941
+ } // end get_all_registered()
942
+
943
+ /**
944
+ Return an array of registered subscribers
945
+ Collect all the registered users of the blog who are subscribed to the specified categories
946
+ */
947
+ function get_registered($args = '') {
948
+ global $wpdb;
949
+
950
+ $format = '';
951
+ $cats = '';
952
+ $authors = '';
953
+ $subscribers = array();
954
+
955
+ parse_str($args, $r);
956
+ if ( !isset($r['format']) )
957
+ $r['format'] = 'all';
958
+ if ( !isset($r['cats']) )
959
+ $r['cats'] = '';
960
+ if ( !isset($r['author']) )
961
+ $r['author'] = '';
962
+
963
+ $JOIN = ''; $AND = '';
964
+ // text or HTML subscribers
965
+ if ( 'all' != $r['format'] ) {
966
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
967
+ $AND .= " AND b.meta_key='" . $this->get_usermeta_keyname('s2_format') . "' AND b.meta_value=";
968
+ if ( 'html' == $r['format'] ) {
969
+ $AND .= "'html'";
970
+ } elseif ( 'html_excerpt' == $r['format'] ) {
971
+ $AND .= "'html_excerpt'";
972
+ } elseif ( 'post' == $r['format'] ) {
973
+ $AND .= "'post'";
974
+ } elseif ( 'excerpt' == $r['format'] ) {
975
+ $AND .= "'excerpt'";
976
+ }
977
+ }
978
+
979
+ // specific category subscribers
980
+ if ( '' != $r['cats'] ) {
981
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
982
+ $and = '';
983
+ foreach ( explode(',', $r['cats']) as $cat ) {
984
+ ('' == $and) ? $and = "c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'" : $and .= " OR c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'";
985
+ }
986
+ $AND .= " AND ($and)";
987
+ }
988
+
989
+ // specific authors
990
+ if ( '' != $r['author'] ) {
991
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
992
+ $AND .= " AND (d.meta_key='" . $this->get_usermeta_keyname('s2_authors') . "' AND NOT FIND_IN_SET(" . $r['author'] . ", d.meta_value))";
993
+ }
994
+
995
+ if ( $this->s2_mu ) {
996
+ $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities'" . $AND;
997
+ } else {
998
+ $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'" . $AND;
999
+ }
1000
+ $result = $wpdb->get_col($sql);
1001
+ if ( $result ) {
1002
+ $ids = implode(',', $result);
1003
+ $registered = $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
1004
+ }
1005
+
1006
+ if ( empty($registered) ) { return array(); }
1007
+
1008
+ // apply filter to registered users to add or remove additional addresses, pass args too for additional control
1009
+ $registered = apply_filters('s2_registered_subscribers', $registered, $args);
1010
+ return $registered;
1011
+ } // end get_registered()
1012
+
1013
+ /**
1014
+ Function to ensure email is compliant with internet messaging standards
1015
+ */
1016
+ function sanitize_email($email) {
1017
+ if ( !is_email($email) ) { return; }
1018
+
1019
+ // ensure that domain is in lowercase as per internet email standards
1020
+ list($name, $domain) = explode('@', $email, 2);
1021
+ return $name . "@" . strtolower($domain);
1022
+ } // end sanitize_email()
1023
+
1024
+ /**
1025
+ Create the appropriate usermeta values when a user registers
1026
+ If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
1027
+ */
1028
+ function register($user_ID = 0, $consent = false) {
1029
+ global $wpdb;
1030
+
1031
+ if ( 0 == $user_ID ) { return $user_ID; }
1032
+ $user = get_userdata($user_ID);
1033
+
1034
+ // Subscribe registered users to categories obeying excluded categories
1035
+ if ( 0 == $this->subscribe2_options['reg_override'] || 'no' == $this->subscribe2_options['newreg_override'] ) {
1036
+ $all_cats = $this->all_cats(true, 'ID');
1037
+ } else {
1038
+ $all_cats = $this->all_cats(false, 'ID');
1039
+ }
1040
+
1041
+ $cats = '';
1042
+ foreach ( $all_cats as $cat ) {
1043
+ ('' == $cats) ? $cats = "$cat->term_id" : $cats .= ",$cat->term_id";
1044
+ }
1045
+
1046
+ if ( '' == $cats ) {
1047
+ // sanity check, might occur if all cats excluded and reg_override = 0
1048
+ return $user_ID;
1049
+ }
1050
+
1051
+ // has this user previously signed up for email notification?
1052
+ if ( false !== $this->is_public($this->sanitize_email($user->user_email)) ) {
1053
+ // delete this user from the public table, and subscribe them to all the categories
1054
+ $this->delete($user->user_email);
1055
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1056
+ foreach ( explode(',', $cats) as $cat ) {
1057
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, $cat);
1058
+ }
1059
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
1060
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $this->subscribe2_options['autosub_def']);
1061
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
1062
+ } else {
1063
+ // create post format entries for all users
1064
+ if ( in_array($this->subscribe2_options['autoformat'], array('html', 'html_excerpt', 'post', 'excerpt')) ) {
1065
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $this->subscribe2_options['autoformat']);
1066
+ } else {
1067
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
1068
+ }
1069
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $this->subscribe2_options['autosub_def']);
1070
+ // if the are no existing subscriptions, create them if we have consent
1071
+ if ( true === $consent ) {
1072
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1073
+ foreach ( explode(',', $cats) as $cat ) {
1074
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, $cat);
1075
+ }
1076
+ }
1077
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
1078
+ }
1079
+ return $user_ID;
1080
+ } // end register()
1081
+
1082
+ /**
1083
+ Get admin data from record 1 or first user with admin rights
1084
+ */
1085
+ function get_userdata($admin_id) {
1086
+ global $wpdb, $userdata;
1087
+
1088
+ if ( is_numeric($admin_id) ) {
1089
+ $admin = get_userdata($admin_id);
1090
+ } elseif ( $admin_id == 'admin' ) {
1091
+ //ensure compatibility with < 4.16
1092
+ $admin = get_userdata('1');
1093
+ } else {
1094
+ $admin = &$userdata;
1095
+ }
1096
+
1097
+ if ( empty($admin) || $admin->ID == 0 ) {
1098
+ $role = array('role' => 'administrator');
1099
+ $wp_user_query = get_users( $role );
1100
+ $admin = $wp_user_query[0];
1101
+ }
1102
+
1103
+ return $admin;
1104
+ } //end get_userdata()
1105
+
1106
+ /**
1107
+ Subscribe/unsubscribe user from one-click submission
1108
+ */
1109
+ function one_click_handler($user_ID, $action) {
1110
+ if ( !isset($user_ID) || !isset($action) ) { return; }
1111
+
1112
+ $all_cats = $this->all_cats(true);
1113
+
1114
+ if ( 'subscribe' == $action ) {
1115
+ // Subscribe
1116
+ $new_cats = array();
1117
+ foreach ( $all_cats as $cat ) {
1118
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
1119
+ $new_cats[] = $cat->term_id;
1120
+ }
1121
+
1122
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $new_cats));
1123
+
1124
+ if ( 'yes' == $this->subscribe2_options['show_autosub'] && 'no' != get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
1125
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes');
1126
+ }
1127
+ } elseif ( 'unsubscribe' == $action ) {
1128
+ // Unsubscribe
1129
+ foreach ( $all_cats as $cat ) {
1130
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id);
1131
+ }
1132
+
1133
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1134
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'));
1135
+ }
1136
+ } //end one_click_handler()
1137
+
1138
+ /* ===== helper functions: forms and stuff ===== */
1139
+ /**
1140
+ Get an object of all categories, include default and custom type
1141
+ */
1142
+ function all_cats($exclude = false, $orderby = 'slug') {
1143
+ $all_cats = array();
1144
+ $s2_taxonomies = array('category');
1145
+ $s2_taxonomies = apply_filters('s2_taxonomies', $s2_taxonomies);
1146
+
1147
+ foreach( $s2_taxonomies as $taxonomy ) {
1148
+ if ( taxonomy_exists($taxonomy) ) {
1149
+ $all_cats = array_merge($all_cats, get_categories(array('hide_empty' => false, 'orderby' => $orderby, 'taxonomy' => $taxonomy)));
1150
+ }
1151
+ }
1152
+
1153
+ if ( $exclude === true ) {
1154
+ // remove excluded categories from the returned object
1155
+ $excluded = explode(',', $this->subscribe2_options['exclude']);
1156
+
1157
+ // need to use $id like this as this is a mixed array / object
1158
+ $id = 0;
1159
+ foreach ( $all_cats as $cat) {
1160
+ if ( in_array($cat->term_id, $excluded) ) {
1161
+ unset($all_cats[$id]);
1162
+ }
1163
+ $id++;
1164
+ }
1165
+ }
1166
+
1167
+ return $all_cats;
1168
+ } // end all_cats()
1169
+
1170
+ /**
1171
+ Export subscriber emails and other details to CSV
1172
+ */
1173
+ function prepare_export( $what ) {
1174
+ $confirmed = $this->get_public();
1175
+ $unconfirmed = $this->get_public(0);
1176
+ if ( 'all' == $what ) {
1177
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$this->get_all_registered());
1178
+ } elseif ( 'public' == $what ) {
1179
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1180
+ } elseif ( 'confirmed' == $what ) {
1181
+ $subscribers = $confirmed;
1182
+ } elseif ( 'unconfirmed' == $what ) {
1183
+ $subscribers = $unconfirmed;
1184
+ } elseif ( is_numeric($what) ) {
1185
+ $subscribers = $this->get_registered("cats=$what");
1186
+ } elseif ( 'registered' == $what ) {
1187
+ $subscribers = $this->get_registered();
1188
+ } elseif ( 'all_users' == $what ) {
1189
+ $subscribers = $this->get_all_registered();
1190
+ }
1191
+
1192
+ natcasesort($subscribers);
1193
+
1194
+ $exportcsv = "User Email,User Name";
1195
+ $all_cats = $this->all_cats(false, 'ID');
1196
+
1197
+ foreach ($all_cats as $cat) {
1198
+ $exportcsv .= "," . $cat->cat_name;
1199
+ $cat_ids[] = $cat->term_id;
1200
+ }
1201
+ $exportcsv .= "\r\n";
1202
+
1203
+ foreach ( $subscribers as $subscriber ) {
1204
+ if ( $this->is_registered($subscriber) ) {
1205
+ $user_ID = $this->get_user_id( $subscriber );
1206
+ $user_info = get_userdata($user_ID);
1207
+
1208
+ $cats = explode(',', get_user_meta($user_info->ID, $this->get_usermeta_keyname('s2_subscribed'), true));
1209
+ $subscribed_cats = '';
1210
+ foreach ( $cat_ids as $cat ) {
1211
+ (in_array($cat, $cats)) ? $subscribed_cats .= ",Yes" : $subscribed_cats .= ",No";
1212
+ }
1213
+
1214
+ $exportcsv .= $user_info->user_email . ',';
1215
+ $exportcsv .= $user_info->display_name;
1216
+ $exportcsv .= $subscribed_cats . "\r\n";
1217
+ } else {
1218
+ if ( in_array($subscriber, $confirmed) ) {
1219
+ $exportcsv .= $subscriber . ',' . __('Confirmed Public Subscriber', 'subscribe2') . "\r\n";
1220
+ } elseif ( in_array($subscriber, $unconfirmed) ) {
1221
+ $exportcsv .= $subscriber . ',' . __('Unconfirmed Public Subscriber', 'subscribe2') . "\r\n";
1222
+ }
1223
+ }
1224
+ }
1225
+
1226
+ return $exportcsv;
1227
+ } // end prepare_export()
1228
+
1229
+ /**
1230
+ Filter for usermeta table key names to adjust them if needed for WPMU blogs
1231
+ */
1232
+ function get_usermeta_keyname($metaname) {
1233
+ global $wpdb;
1234
+
1235
+ // Is this WordPressMU or not?
1236
+ if ( $this->s2_mu === true ) {
1237
+ switch( $metaname ) {
1238
+ case 's2_subscribed':
1239
+ case 's2_cat':
1240
+ case 's2_format':
1241
+ case 's2_autosub':
1242
+ case 's2_authors':
1243
+ return $wpdb->prefix . $metaname;
1244
+ break;
1245
+ }
1246
+ }
1247
+ // Not MU or not a prefixed option name
1248
+ return $metaname;
1249
+ } // end get_usermeta_keyname()
1250
+
1251
+ /**
1252
+ Adds information to the WordPress registration screen for new users
1253
+ */
1254
+ function register_form() {
1255
+ if ( 'no' == $this->subscribe2_options['autosub'] ) { return; }
1256
+ if ( 'wpreg' == $this->subscribe2_options['autosub'] ) {
1257
+ echo "<p>\r\n<label>";
1258
+ echo __('Check here to Subscribe to email notifications for new posts', 'subscribe2') . ":<br />\r\n";
1259
+ echo "<input type=\"checkbox\" name=\"reg_subscribe\"" . checked($this->subscribe2_options['wpregdef'], 'yes', false) . " />";
1260
+ echo "</label>\r\n";
1261
+ echo "</p>\r\n";
1262
+ } elseif ( 'yes' == $this->subscribe2_options['autosub'] ) {
1263
+ echo "<p>\r\n<center>\r\n";
1264
+ echo __('By registering with this blog you are also agreeing to receive email notifications for new posts but you can unsubscribe at anytime', 'subscribe2') . ".<br />\r\n";
1265
+ echo "</center></p>\r\n";
1266
+ }
1267
+ } // end register_form()
1268
+
1269
+ /**
1270
+ Process function to add action if user selects to subscribe to posts during registration
1271
+ */
1272
+ function register_post($user_ID = 0) {
1273
+ global $_POST;
1274
+ if ( 0 == $user_ID ) { return; }
1275
+ if ( 'yes' == $this->subscribe2_options['autosub'] || ( 'on' == $_POST['reg_subscribe'] && 'wpreg' == $this->subscribe2_options['autosub'] ) ) {
1276
+ $this->register($user_ID, true);
1277
+ } else {
1278
+ $this->register($user_ID, false);
1279
+ }
1280
+ } // end register_post()
1281
+
1282
+ /* ===== comment subscriber functions ===== */
1283
+ /**
1284
+ Display check box on comment page
1285
+ */
1286
+ function s2_comment_meta_form() {
1287
+ if ( is_user_logged_in() ) {
1288
+ echo $this->profile;
1289
+ } else {
1290
+ echo "<label><input type=\"checkbox\" name=\"s2_comment_request\" value=\"1\" />" . __('Check here to Subscribe to notifications for new posts', 'subscribe2') . "</label>";
1291
+ }
1292
+ } // end s2_comment_meta_form()
1293
+
1294
+ /**
1295
+ Process comment meta data
1296
+ */
1297
+ function s2_comment_meta($comment_ID, $approved = 0) {
1298
+ if ( $_POST['s2_comment_request'] == '1' ) {
1299
+ switch ($approved) {
1300
+ case '0':
1301
+ // Unapproved so hold in meta data pending moderation
1302
+ add_comment_meta($comment_ID, 's2_comment_request', $_POST['s2_comment_request']);
1303
+ break;
1304
+ case '1':
1305
+ // Approved so add
1306
+ $is_public = $this->is_public($comment->comment_author_email);
1307
+ if ( $is_public == 0 ) {
1308
+ $this->toggle($comment->comment_author_email);
1309
+ }
1310
+ $is_registered = $this->is_registered($comment->comment_author_email);
1311
+ if ( !$is_public && !$is_registered ) {
1312
+ $this->add($comment->comment_author_email, true);
1313
+ }
1314
+ break;
1315
+ default :
1316
+ break;
1317
+ }
1318
+ }
1319
+ } // end s2_comment_meta()
1320
+
1321
+ /**
1322
+ Action subscribe requests made on comment forms when comments are approved
1323
+ */
1324
+ function comment_status($comment_ID = 0){
1325
+ global $wpdb;
1326
+
1327
+ // get meta data
1328
+ $subscribe = get_comment_meta($comment_ID, 's2_comment_request', true);
1329
+ if ( $subscribe != '1' ) { return $comment_ID; }
1330
+
1331
+ // Retrieve the information about the comment
1332
+ $sql = "SELECT comment_author_email, comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_ID' LIMIT 1";
1333
+ $comment = $wpdb->get_row($sql, OBJECT);
1334
+ if ( empty($comment) ) { return $comment_ID; }
1335
+
1336
+ switch ($comment->comment_approved) {
1337
+ case '0': // Unapproved
1338
+ break;
1339
+ case '1': // Approved
1340
+ $is_public = $this->is_public($comment->comment_author_email);
1341
+ if ( $is_public == 0 ) {
1342
+ $this->toggle($comment->comment_author_email);
1343
+ }
1344
+ $is_registered = $this->is_registered($comment->comment_author_email);
1345
+ if ( !$is_public && !$is_registered ) {
1346
+ $this->add($comment->comment_author_email, true);
1347
+ }
1348
+ delete_comment_meta($comment_ID, 's2_comment_request');
1349
+ break;
1350
+ default: // post is trash, spam or deleted
1351
+ delete_comment_meta($comment_ID, 's2_comment_request');
1352
+ break;
1353
+ }
1354
+
1355
+ return $comment_ID;
1356
+ } // end comment_status()
1357
+
1358
+ /* ===== widget functions ===== */
1359
+ /**
1360
+ Register the form widget
1361
+ */
1362
+ function subscribe2_widget() {
1363
+ require_once( S2PATH . 'include/widget.php');
1364
+ register_widget('S2_Form_widget');
1365
+ } // end subscribe2_widget()
1366
+
1367
+ /**
1368
+ Register the counter widget
1369
+ */
1370
+ function counter_widget() {
1371
+ require_once( S2PATH . 'include/counterwidget.php');
1372
+ register_widget('S2_Counter_widget');
1373
+ } // end counter_widget()
1374
+
1375
+ /* ===== wp-cron functions ===== */
1376
+ /**
1377
+ Add a weekly event to cron
1378
+ */
1379
+ function add_weekly_sched($sched) {
1380
+ $sched['weekly'] = array('interval' => 604800, 'display' => __('Weekly', 'subscribe2'));
1381
+ return $sched;
1382
+ } // end add_weekly_sched()
1383
+
1384
+ /**
1385
+ Send a daily digest of today's new posts
1386
+ */
1387
+ function subscribe2_cron($preview = '', $resend = '') {
1388
+ if ( defined('DOING_S2_CRON') && DOING_S2_CRON ) { return; }
1389
+ define( 'DOING_S2_CRON', true );
1390
+ global $wpdb;
1391
+
1392
+ if ( '' == $preview ) {
1393
+ // update last_s2cron execution time before completing or bailing
1394
+ $now = current_time('mysql');
1395
+ $prev = $this->subscribe2_options['last_s2cron'];
1396
+ $last = $this->subscribe2_options['previous_s2cron'];
1397
+ $this->subscribe2_options['last_s2cron'] = $now;
1398
+ $this->subscribe2_options['previous_s2cron'] = $prev;
1399
+ if ( '' == $resend ) {
1400
+ // update sending times provided this is not a resend
1401
+ update_option('subscribe2_options', $this->subscribe2_options);
1402
+ }
1403
+
1404
+ // set up SQL query based on options
1405
+ if ( $this->subscribe2_options['private'] == 'yes' ) {
1406
+ $status = "'publish', 'private'";
1407
+ } else {
1408
+ $status = "'publish'";
1409
+ }
1410
+
1411
+ // send notifications for allowed post type (defaults for posts and pages)
1412
+ // uses s2_post_types filter to allow for custom post types in WP 3.0
1413
+ if ( $this->subscribe2_options['pages'] == 'yes' ) {
1414
+ $s2_post_types = array('page', 'post');
1415
+ } else {
1416
+ $s2_post_types = array('post');
1417
+ }
1418
+ $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
1419
+ foreach( $s2_post_types as $post_type ) {
1420
+ ('' == $type) ? $type = "'$post_type'" : $type .= ", '$post_type'";
1421
+ }
1422
+
1423
+ // collect posts
1424
+ if ( $resend == 'resend' ) {
1425
+ if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
1426
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
1427
+ } else {
1428
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
1429
+ }
1430
+ } else {
1431
+ if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
1432
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
1433
+ } else {
1434
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
1435
+ }
1436
+ }
1437
+ } else {
1438
+ // we are sending a preview
1439
+ $posts = get_posts('numberposts=1');
1440
+ }
1441
+
1442
+ // do we have any posts?
1443
+ if ( empty($posts) && !has_filter('s2_digest_email') ) { return false; }
1444
+ $this->post_count = count($posts);
1445
+
1446
+ // if we have posts, let's prepare the digest
1447
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
1448
+ $all_post_cats = array();
1449
+ $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
1450
+ $table = '';
1451
+ $tablelinks = '';
1452
+ $message_post= '';
1453
+ $message_posttime = '';
1454
+ foreach ( $posts as $post ) {
1455
+ $post_cats = wp_get_post_categories($post->ID);
1456
+ $post_cats_string = implode(',', $post_cats);
1457
+ $all_post_cats = array_unique(array_merge($all_post_cats, $post_cats));
1458
+ $check = false;
1459
+ // Pages are put into category 1 so make sure we don't exclude
1460
+ // pages if category 1 is excluded
1461
+ if ( $post->post_type != 'page' ) {
1462
+ // is the current post assigned to any categories
1463
+ // which should not generate a notification email?
1464
+ foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
1465
+ if ( in_array($cat, $post_cats) ) {
1466
+ $check = true;
1467
+ }
1468
+ }
1469
+ }
1470
+ // is the current post set by the user to
1471
+ // not generate a notification email?
1472
+ $s2mail = get_post_meta($post->ID, 's2mail', true);
1473
+ if ( strtolower(trim($s2mail)) == 'no' ) {
1474
+ $check = true;
1475
+ }
1476
+ // is the current post private
1477
+ // and should this not generate a notification email?
1478
+ if ( $this->subscribe2_options['password'] == 'no' && $post->post_password != '' ) {
1479
+ $check = true;
1480
+ }
1481
+ // is the post assigned a format that should
1482
+ // not be included in the notification email?
1483
+ $post_format = get_post_format($post->ID);
1484
+ $excluded_formats = explode(',', $this->subscribe2_options['exclude_formats']);
1485
+ if ( $post_format !== false && in_array($post_format, $excluded_formats) ) {
1486
+ $check = true;
1487
+ }
1488
+ // if this post is excluded
1489
+ // don't include it in the digest
1490
+ if ( $check ) {
1491
+ continue;
1492
+ }
1493
+ $post_title = html_entity_decode($post->post_title, ENT_QUOTES);
1494
+ ('' == $table) ? $table .= "* " . $post_title : $table .= "\r\n* " . $post_title;
1495
+ ('' == $tablelinks) ? $tablelinks .= "* " . $post_title : $tablelinks .= "\r\n* " . $post_title;
1496
+ $message_post .= $post_title;
1497
+ $message_posttime .= $post_title;
1498
+ if ( strstr($mailtext, "{AUTHORNAME}") ) {
1499
+ $author = get_userdata($post->post_author);
1500
+ if ( $author->display_name != '' ) {
1501
+ $message_post .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
1502
+ $message_posttime .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
1503
+ }
1504
+ }
1505
+ $message_post .= "\r\n";
1506
+ $message_posttime .= "\r\n";
1507
+
1508
+ $tablelinks .= "\r\n" . $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
1509
+ $message_post .= $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
1510
+ $message_posttime .= __('Posted on', 'subscribe2') . ": " . mysql2date($datetime, $post->post_date) . "\r\n";
1511
+ $message_posttime .= $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
1512
+ if ( strstr($mailtext, "{CATS}") ) {
1513
+ $post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
1514
+ $message_post .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
1515
+ $message_posttime .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
1516
+ }
1517
+ if ( strstr($mailtext, "{TAGS}") ) {
1518
+ $post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
1519
+ if ( $post_tag_names != '' ) {
1520
+ $message_post .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
1521
+ $message_posttime .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
1522
+ }
1523
+ }
1524
+ $message_post .= "\r\n";
1525
+ $message_posttime .= "\r\n";
1526
+
1527
+ $excerpt = $post->post_excerpt;
1528
+ if ( '' == $excerpt ) {
1529
+ // no excerpt, is there a <!--more--> ?
1530
+ if ( false !== strpos($post->post_content, '<!--more-->') ) {
1531
+ list($excerpt, $more) = explode('<!--more-->', $post->post_content, 2);
1532
+ $excerpt = strip_tags($excerpt);
1533
+ if ( function_exists('strip_shortcodes') ) {
1534
+ $excerpt = strip_shortcodes($excerpt);
1535
+ }
1536
+ } else {
1537
+ $excerpt = strip_tags($post->post_content);
1538
+ if ( function_exists('strip_shortcodes') ) {
1539
+ $excerpt = strip_shortcodes($excerpt);
1540
+ }
1541
+ $words = explode(' ', $excerpt, $this->excerpt_length + 1);
1542
+ if ( count($words) > $this->excerpt_length ) {
1543
+ array_pop($words);
1544
+ array_push($words, '[...]');
1545
+ $excerpt = implode(' ', $words);
1546
+ }
1547
+ }
1548
+ // strip leading and trailing whitespace
1549
+ $excerpt = trim($excerpt);
1550
+ }
1551
+ $message_post .= $excerpt . "\r\n\r\n";
1552
+ $message_posttime .= $excerpt . "\r\n\r\n";
1553
+ }
1554
+
1555
+ // we add a blank line after each post excerpt now trim white space that occurs for the last post
1556
+ $message_post = trim($message_post);
1557
+ $message_posttime = trim($message_posttime);
1558
+ // remove excess white space from within $message_post and $message_posttime
1559
+ $message_post = preg_replace('|[ ]+|', ' ', $message_post);
1560
+ $message_posttime = preg_replace('|[ ]+|', ' ', $message_posttime);
1561
+
1562
+ // apply filter to allow external content to be inserted or content manipulated
1563
+ $message_post = apply_filters('s2_digest_email', $message_post, $now, $prev, $last, $this->subscribe2_options['cron_order']);
1564
+ $message_posttime = apply_filters('s2_digest_email', $message_posttime, $now, $prev, $last, $this->subscribe2_options['cron_order']);
1565
+
1566
+ //sanity check - don't send a mail if the content is empty
1567
+ if ( !$message_post && !$message_posttime && !$table && !$tablelinks ) {
1568
+ return;
1569
+ }
1570
+
1571
+ // get sender details
1572
+ if ( $this->subscribe2_options['sender'] == 'blogname' ) {
1573
+ $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
1574
+ $this->myemail = get_bloginfo('admin_email');
1575
+ } else {
1576
+ $user = $this->get_userdata($this->subscribe2_options['sender']);
1577
+ $this->myemail = $user->user_email;
1578
+ $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
1579
+ }
1580
+
1581
+ $scheds = (array)wp_get_schedules();
1582
+ $email_freq = $this->subscribe2_options['email_freq'];
1583
+ $display = $scheds[$email_freq]['display'];
1584
+ ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
1585
+ $subject .= $display . " " . __('Digest Email', 'subscribe2');
1586
+ $mailtext = str_replace("{TABLELINKS}", $tablelinks, $mailtext);
1587
+ $mailtext = str_replace("{TABLE}", $table, $mailtext);
1588
+ $mailtext = str_replace("{POSTTIME}", $message_posttime, $mailtext);
1589
+ $mailtext = str_replace("{POST}", $message_post, $mailtext);
1590
+ $mailtext = stripslashes($this->substitute($mailtext));
1591
+
1592
+ // prepare recipients
1593
+ if ( $preview != '' ) {
1594
+ $this->myemail = $preview;
1595
+ $this->myname = __('Digest Preview', 'subscribe2');
1596
+ $this->mail(array($preview), $subject, $mailtext);
1597
+ } else {
1598
+ $public = $this->get_public();
1599
+ $all_post_cats_string = implode(',', $all_post_cats);
1600
+ $registered = $this->get_registered("cats=$all_post_cats_string");
1601
+ $recipients = array_merge((array)$public, (array)$registered);
1602
+ $this->mail($recipients, $subject, $mailtext);
1603
+ }
1604
+ } // end subscribe2_cron()
1605
+
1606
+ /* ===== Our constructor ===== */
1607
+ /**
1608
+ Subscribe2 constructor
1609
+ */
1610
+ function s2init() {
1611
+ global $wpdb, $table_prefix, $wp_version, $wpmu_version;
1612
+ // load the options
1613
+ $this->subscribe2_options = get_option('subscribe2_options');
1614
+ // if SCRIPT_DEBUG is true, use dev scripts
1615
+ $this->script_debug = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '.dev' : '';
1616
+
1617
+ // get the WordPress release number for in code version comparisons
1618
+ $tmp = explode('-', $wp_version, 2);
1619
+ $this->wp_release = $tmp[0];
1620
+
1621
+ load_plugin_textdomain('subscribe2', false, S2DIR);
1622
+
1623
+ // do we need to install anything?
1624
+ $this->public = $table_prefix . "subscribe2";
1625
+ if ( $wpdb->get_var("SHOW TABLES LIKE '{$this->public}'") != $this->public ) { $this->install(); }
1626
+ //do we need to upgrade anything?
1627
+ if ( is_array($this->subscribe2_options) && $this->subscribe2_options['version'] !== S2VERSION ) {
1628
+ add_action('shutdown', array(&$this, 'upgrade'));
1629
+ }
1630
+
1631
+ // add core actions
1632
+ add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
1633
+ // add actions for automatic subscription based on option settings
1634
+ add_action('register_form', array(&$this, 'register_form'));
1635
+ add_action('user_register', array(&$this, 'register_post'));
1636
+ if ( $this->s2_mu ) {
1637
+ add_action('add_user_to_blog', array(&$s2class_multisite, 'wpmu_add_user'), 10);
1638
+ add_action('remove_user_from_blog', array(&$s2class_multisite, 'wpmu_remove_user'), 10);
1639
+ }
1640
+ // add actions for processing posts based on per-post or cron email settings
1641
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) {
1642
+ add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
1643
+ } else {
1644
+ add_action('new_to_publish', array(&$this, 'publish'));
1645
+ add_action('draft_to_publish', array(&$this, 'publish'));
1646
+ add_action('auto-draft_to_publish', array(&$this, 'publish'));
1647
+ add_action('pending_to_publish', array(&$this, 'publish'));
1648
+ add_action('private_to_publish', array(&$this, 'publish'));
1649
+ add_action('future_to_publish', array(&$this, 'publish'));
1650
+ if ( $this->subscribe2_options['private'] == 'yes' ) {
1651
+ add_action('new_to_private', array(&$this, 'publish'));
1652
+ add_action('draft_to_private', array(&$this, 'publish'));
1653
+ add_action('auto-draft_to_private', array(&$this, 'publish'));
1654
+ add_action('pending_to_private', array(&$this, 'publish'));
1655
+ }
1656
+ }
1657
+ // add actions for comment subscribers
1658
+ if ( 'no' != $this->subscribe2_options['comment_subs'] ) {
1659
+ if ( 'before' == $this->subscribe2_options['comment_subs'] ) {
1660
+ add_action('comment_form_after_fields', array(&$this, 's2_comment_meta_form'));
1661
+ } else {
1662
+ add_action('comment_form', array(&$this, 's2_comment_meta_form'));
1663
+ }
1664
+ add_action('comment_post', array(&$this, 's2_comment_meta'), 1, 2);
1665
+ add_action('wp_set_comment_status', array(&$this, 'comment_status'));
1666
+ }
1667
+ // add action to display widget if option is enabled
1668
+ if ( '1' == $this->subscribe2_options['widget'] ) {
1669
+ add_action('widgets_init', array(&$this, 'subscribe2_widget'));
1670
+ }
1671
+ // add action to display counter widget if option is enabled
1672
+ if ( '1' == $this->subscribe2_options['counterwidget'] ) {
1673
+ add_action('widgets_init', array(&$this, 'counter_widget'));
1674
+ }
1675
+
1676
+ // Add actions specific to admin or frontend
1677
+ if ( is_admin() ) {
1678
+ //add menu, authoring and category admin actions
1679
+ add_action('admin_menu', array($this, 'admin_menu'));
1680
+ add_action('admin_menu', array(&$this, 's2_meta_init'));
1681
+ add_action('save_post', array(&$this, 's2_meta_handler'));
1682
+ add_action('create_category', array(&$this, 'new_category'));
1683
+ add_action('delete_category', array(&$this, 'delete_category'));
1684
+
1685
+ // Add filters for Ozh Admin Menu
1686
+ if ( function_exists('wp_ozh_adminmenu') ) {
1687
+ add_filter('ozh_adminmenu_icon_s2_posts', array(&$this, 'ozh_s2_icon'));
1688
+ add_filter('ozh_adminmenu_icon_s2_users', array(&$this, 'ozh_s2_icon'));
1689
+ add_filter('ozh_adminmenu_icon_s2_tools', array(&$this, 'ozh_s2_icon'));
1690
+ add_filter('ozh_adminmenu_icon_s2_settings', array(&$this, 'ozh_s2_icon'));
1691
+ }
1692
+
1693
+ // add write button
1694
+ if ( '1' == $this->subscribe2_options['show_button'] ) {
1695
+ add_action('admin_init', array(&$this, 'button_init'));
1696
+ }
1697
+
1698
+ // add counterwidget css and js
1699
+ if ( '1' == $this->subscribe2_options['counterwidget'] ) {
1700
+ add_action('admin_init', array(&$this, 'widget_s2counter_css_and_js'));
1701
+ }
1702
+
1703
+ // add one-click handlers
1704
+ if ( 'yes' == $this->subscribe2_options['one_click_profile'] ) {
1705
+ add_action( 'show_user_profile', array(&$this, 'one_click_profile_form') );
1706
+ add_action( 'edit_user_profile', array(&$this, 'one_click_profile_form') );
1707
+ add_action( 'personal_options_update', array(&$this, 'one_click_profile_form_save') );
1708
+ add_action( 'edit_user_profile_update', array(&$this, 'one_click_profile_form_save') );
1709
+ }
1710
+
1711
+ // capture CSV export
1712
+ if ( isset($_POST['s2_admin']) && $_POST['csv'] ) {
1713
+ $date = date('Y-m-d');
1714
+ header("Content-Description: File Transfer");
1715
+ header("Content-type: application/octet-stream");
1716
+ header("Content-Disposition: attachment; filename=subscribe2_users_$date.csv");
1717
+ header("Pragma: no-cache");
1718
+ header("Expires: 0");
1719
+ echo $this->prepare_export($_POST['exportcsv']);
1720
+ exit(0);
1721
+ }
1722
+ } else {
1723
+ if ( isset($_GET['s2']) ) {
1724
+ // someone is confirming a request
1725
+ if ( defined('DOING_S2_CONFIRM') && DOING_S2_CONFIRM ) { return; }
1726
+ define( 'DOING_S2_CONFIRM', true );
1727
+ add_filter('query_string', array(&$this, 'query_filter'));
1728
+ add_filter('the_title', array(&$this, 'title_filter'));
1729
+ add_filter('the_content', array(&$this, 'confirm'));
1730
+ }
1731
+
1732
+ // add the frontend filters
1733
+ add_shortcode('subscribe2', array(&$this, 'shortcode'));
1734
+ add_filter('the_content', array(&$this, 'filter'), 10);
1735
+
1736
+ // add actions for other plugins
1737
+ if ( '1' == $this->subscribe2_options['show_meta'] ) {
1738
+ add_action('wp_meta', array(&$this, 'add_minimeta'), 0);
1739
+ }
1740
+
1741
+ // add actions for ajax form if enabled
1742
+ if ( '1' == $this->subscribe2_options['ajax'] ) {
1743
+ add_action('wp_enqueue_scripts', array(&$this, 'add_ajax'));
1744
+ add_action('wp_head', array(&$this, 'add_s2_ajax'));
1745
+ }
1746
+ }
1747
+
1748
+ // load our strings
1749
+ $this->load_strings();
1750
+
1751
+ // Is this WordPressMU or not?
1752
+ $this->s2_mu = false;
1753
+ if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
1754
+ $this->s2_mu = true;
1755
+ }
1756
+ if ( function_exists('is_multisite') && is_multisite() ) {
1757
+ $this->s2_mu = true;
1758
+ }
1759
+
1760
+ // add action to handle WPMU subscriptions and unsubscriptions
1761
+ if ( $this->s2_mu === true || isset($_GET['s2mu_subscribe']) || isset($_GET['s2mu_unsubscribe']) ) {
1762
+ require_once(S2PATH . "classes/class-s2_multisite.php");
1763
+ $s2class_multisite = new s2_multisite;
1764
+ add_action('init', array(&$s2class_multisite, 'wpmu_subscribe'));
1765
+ }
1766
+ } // end s2init()
1767
+
1768
+ /* ===== our variables ===== */
1769
+ // cache variables
1770
+ var $subscribe2_options = array();
1771
+ var $all_public = '';
1772
+ var $all_unconfirmed = '';
1773
+ var $all_authors = '';
1774
+ var $excluded_cats = '';
1775
+ var $post_title = '';
1776
+ var $permalink = '';
1777
+ var $post_date = '';
1778
+ var $post_time = '';
1779
+ var $myname = '';
1780
+ var $myemail = '';
1781
+ var $signup_dates = array();
1782
+ var $filtered = 0;
1783
+ var $preview_email = false;
1784
+
1785
+ // state variables used to affect processing
1786
+ var $action = '';
1787
+ var $email = '';
1788
+ var $message = '';
1789
+ var $excerpt_length = 55;
1790
+
1791
+ // some messages
1792
+ var $please_log_in = '';
1793
+ var $profile = '';
1794
+ var $confirmation_sent = '';
1795
+ var $already_subscribed = '';
1796
+ var $not_subscribed ='';
1797
+ var $not_an_email = '';
1798
+ var $barred_domain = '';
1799
+ var $error = '';
1800
+ var $mail_sent = '';
1801
+ var $mail_failed = '';
1802
+ var $form = '';
1803
+ var $no_such_email = '';
1804
+ var $added = '';
1805
+ var $deleted = '';
1806
+ var $subscribe = '';
1807
+ var $unsubscribe = '';
1808
+ var $confirm_subject = '';
1809
+ var $options_saved = '';
1810
+ var $options_reset = '';
1811
+ } // end class subscribe2
1812
+ ?>
classes/class-s2-frontend.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class s2_frontend extends s2class {
3
+ /* ===== template and filter functions ===== */
4
+ /**
5
+ Display our form; also handles (un)subscribe requests
6
+ */
7
+ function shortcode($atts) {
8
+ extract(shortcode_atts(array(
9
+ 'hide' => '',
10
+ 'id' => '',
11
+ 'url' => '',
12
+ 'nojs' => 'false',
13
+ 'link' => '',
14
+ 'size' => 20
15
+ ), $atts));
16
+
17
+ // if link is true return a link to the page with the ajax class
18
+ if ( $link !== '' && !is_user_logged_in() ) {
19
+ $this->s2form = "<a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\" class=\"s2popup\">" . $link . "</a>\r\n";
20
+ return $this->s2form;
21
+ }
22
+
23
+ // if a button is hidden, show only other
24
+ if ( $hide == 'subscribe' ) {
25
+ $this->input_form_action = "<input type=\"submit\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" />";
26
+ } elseif ( $hide == 'unsubscribe' ) {
27
+ $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
28
+ } else {
29
+ // both form input actions
30
+ $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />&nbsp;<input type=\"submit\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" />";
31
+ }
32
+ // if ID is provided, get permalink
33
+ if ( $id ) {
34
+ $url = get_permalink( $id );
35
+ } elseif ( $this->subscribe2_options['s2page'] > 0 ) {
36
+ $url = get_permalink( $this->subscribe2_options['s2page'] );
37
+ } else {
38
+ $url = get_site_url();
39
+ }
40
+ // build default form
41
+ if ( $nojs == 'true' ) {
42
+ $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"\" size=\"" . $size . "\" /></p><p>" . $this->input_form_action . "</p></form>";
43
+ } else {
44
+ $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . __('Enter email address...', 'subscribe2') . "\" size=\"" . $size . "\" onfocus=\"if (this.value == '" . __('Enter email address...', 'subscribe2') . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . __('Enter email address...', 'subscribe2') . "';}\" /></p><p>" . $this->input_form_action . "</p></form>\r\n";
45
+ }
46
+ $this->s2form = $this->form;
47
+
48
+ global $user_ID;
49
+ get_currentuserinfo();
50
+ if ( $user_ID ) {
51
+ $this->s2form = $this->profile;
52
+ }
53
+ if ( isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) {
54
+ global $wpdb, $user_email;
55
+ if ( !is_email($_POST['email']) ) {
56
+ $this->s2form = $this->form . $this->not_an_email;
57
+ } elseif ( $this->is_barred($_POST['email']) ) {
58
+ $this->s2form = $this->form . $this->barred_domain;
59
+ } else {
60
+ $this->email = $this->sanitize_email($_POST['email']);
61
+ $this->ip = $_POST['ip'];
62
+ // does the supplied email belong to a registered user?
63
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
64
+ if ( '' != $check ) {
65
+ // this is a registered email
66
+ $this->s2form = $this->please_log_in;
67
+ } else {
68
+ // this is not a registered email
69
+ // what should we do?
70
+ if ( isset($_POST['subscribe']) ) {
71
+ // someone is trying to subscribe
72
+ // lets see if they've tried to subscribe previously
73
+ if ( '1' !== $this->is_public($this->email) ) {
74
+ // the user is unknown or inactive
75
+ $this->add($this->email);
76
+ $status = $this->send_confirm('add');
77
+ // set a variable to denote that we've already run, and shouldn't run again
78
+ $this->filtered = 1;
79
+ if ( $status ) {
80
+ $this->s2form = $this->confirmation_sent;
81
+ } else {
82
+ $this->s2form = $this->error;
83
+ }
84
+ } else {
85
+ // they're already subscribed
86
+ $this->s2form = $this->already_subscribed;
87
+ }
88
+ $this->action = 'subscribe';
89
+ } elseif ( isset($_POST['unsubscribe']) ) {
90
+ // is this email a subscriber?
91
+ if ( false == $this->is_public($this->email) ) {
92
+ $this->s2form = $this->form . $this->not_subscribed;
93
+ } else {
94
+ $status = $this->send_confirm('del');
95
+ // set a variable to denote that we've already run, and shouldn't run again
96
+ $this->filtered = 1;
97
+ if ( $status ) {
98
+ $this->s2form = $this->confirmation_sent;
99
+ } else {
100
+ $this->s2form = $this->error;
101
+ }
102
+ }
103
+ $this->action='unsubscribe';
104
+ }
105
+ }
106
+ }
107
+ }
108
+ return $this->s2form;
109
+ } // end shortcode()
110
+
111
+ /**
112
+ Display form when deprecated <!--subscribe2--> is used
113
+ */
114
+ function filter($content = '') {
115
+ if ( '' == $content || !strstr($content, '<!--subscribe2-->') ) { return $content; }
116
+
117
+ return preg_replace('|(<p>)?(\n)*<!--subscribe2-->(\n)*(</p>)?|', do_shortcode( '[subscribe2]' ), $content);
118
+ } // end filter()
119
+
120
+ /**
121
+ Overrides the default query when handling a (un)subscription confirmation
122
+ This is basically a trick: if the s2 variable is in the query string, just grab the first
123
+ static page and override it's contents later with title_filter()
124
+ */
125
+ function query_filter() {
126
+ // don't interfere if we've already done our thing
127
+ if ( 1 == $this->filtered ) { return; }
128
+
129
+ global $wpdb;
130
+
131
+ if ( 0 != $this->subscribe2_options['s2page'] ) {
132
+ return "page_id=" . $this->subscribe2_options['s2page'];
133
+ } else {
134
+ $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
135
+ if ( $id ) {
136
+ return "page_id=$id";
137
+ } else {
138
+ return "showposts=1";
139
+ }
140
+ }
141
+ } // end query_filter()
142
+
143
+ /**
144
+ Overrides the page title
145
+ */
146
+ function title_filter($title) {
147
+ // don't interfere if we've already done our thing
148
+ if ( in_the_loop() ) {
149
+ return __('Subscription Confirmation', 'subscribe2');
150
+ } else {
151
+ return $title;
152
+ }
153
+ } // end title_filter()
154
+
155
+ /**
156
+ Confirm request from the link emailed to the user and email the admin
157
+ */
158
+ function confirm($content = '') {
159
+ global $wpdb;
160
+
161
+ if ( 1 == $this->filtered ) { return $content; }
162
+
163
+ $code = $_GET['s2'];
164
+ $action = intval(substr($code, 0, 1));
165
+ $hash = substr($code, 1, 32);
166
+ $id = intval(substr($code, 33));
167
+ if ( $id ) {
168
+ $this->email = $this->sanitize_email($this->get_email($id));
169
+ if ( !$this->email || $hash !== md5($this->email) ) {
170
+ return $this->no_such_email;
171
+ }
172
+ } else {
173
+ return $this->no_such_email;
174
+ }
175
+
176
+ // get current status of email so messages are only sent once per emailed link
177
+ $current = $this->is_public($this->email);
178
+
179
+ if ( '1' == $action ) {
180
+ // make this subscription active
181
+ $this->message = $this->added;
182
+ if ( '1' != $current ) {
183
+ $this->ip = $_SERVER['REMOTE_ADDR'];
184
+ $this->toggle($this->email);
185
+ if ( $this->subscribe2_options['admin_email'] == 'subs' || $this->subscribe2_options['admin_email'] == 'both' ) {
186
+ ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
187
+ $subject .= __('New Subscription', 'subscribe2');
188
+ $subject = html_entity_decode($subject, ENT_QUOTES);
189
+ $message = $this->email . " " . __('subscribed to email notifications!', 'subscribe2');
190
+ $role = array('fields' => array('user_email'), 'role' => 'administrator');
191
+ $wp_user_query = get_users( $role );
192
+ foreach ($wp_user_query as $user) {
193
+ $recipients[] = $user->user_email;
194
+ }
195
+ $headers = $this->headers();
196
+ // send individual emails so we don't reveal admin emails to each other
197
+ foreach ( $recipients as $recipient ) {
198
+ @wp_mail($recipient, $subject, $message, $headers);
199
+ }
200
+ }
201
+ }
202
+ $this->filtered = 1;
203
+ } elseif ( '0' == $action ) {
204
+ // remove this subscriber
205
+ $this->message = $this->deleted;
206
+ if ( '0' != $current ) {
207
+ $this->delete($this->email);
208
+ if ( $this->subscribe2_options['admin_email'] == 'unsubs' || $this->subscribe2_options['admin_email'] == 'both' ) {
209
+ ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
210
+ $subject .= __('New Unsubscription', 'subscribe2');
211
+ $subject = html_entity_decode($subject, ENT_QUOTES);
212
+ $message = $this->email . " " . __('unsubscribed from email notifications!', 'subscribe2');
213
+ $role = array('fields' => array('user_email'), 'role' => 'administrator');
214
+ $wp_user_query = get_users( $role );
215
+ foreach ($wp_user_query as $user) {
216
+ $recipients[] = $user->user_email;
217
+ }
218
+ $headers = $this->headers();
219
+ // send individual emails so we don't reveal admin emails to each other
220
+ foreach ( $recipients as $recipient ) {
221
+ @wp_mail($recipient, $subject, $message, $headers);
222
+ }
223
+ }
224
+ }
225
+ $this->filtered = 1;
226
+ }
227
+
228
+ if ( '' != $this->message ) {
229
+ return $this->message;
230
+ }
231
+ } // end confirm()
232
+
233
+ /**
234
+ Add hook for Minimeta Widget plugin
235
+ */
236
+ function add_minimeta() {
237
+ if ( $this->subscribe2_options['s2page'] != 0 ) {
238
+ echo "<li><a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\">" . __('[Un]Subscribe to Posts', 'subscribe2') . "</a></li>\r\n";
239
+ }
240
+ } // end add_minimeta()
241
+
242
+ /**
243
+ Add jQuery code and CSS to front pages for ajax form
244
+ */
245
+ function add_ajax() {
246
+ // enqueue the jQuery script we need and let WordPress handle the dependencies
247
+ wp_enqueue_script('jquery-ui-dialog');
248
+ wp_register_style('jquery-ui-style', apply_filters('s2_jqueryui_css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-darkness/jquery-ui.css'));
249
+ wp_enqueue_style('jquery-ui-style');
250
+ } // end add_ajax()
251
+
252
+ /**
253
+ Write Subscribe2 form js code dynamically so we can pull WordPress functions
254
+ */
255
+ function add_s2_ajax() {
256
+ echo "<script type=\"text/javascript\">\r\n";
257
+ echo "//<![CDATA[\r\n";
258
+ echo "jQuery(document).ready(function() {\r\n";
259
+ echo " var dialog = jQuery('<div></div>')\r\n";
260
+ echo " .html('" . do_shortcode('[subscribe2 nojs="true"]') . "')\r\n";
261
+ if ( $this->s2form != $this->form && !is_user_logged_in() ) {
262
+ echo " .dialog({modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
263
+ } else {
264
+ echo " .dialog({autoOpen: false, modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
265
+ }
266
+ echo " jQuery('a.s2popup').click(function(){\r\n";
267
+ echo " dialog.dialog('open');\r\n";
268
+ echo " return false;\r\n";
269
+ echo " });\r\n";
270
+ echo "});\r\n";
271
+ echo "//]]>\r\n";
272
+ echo "</script>\r\n";
273
+ } // end add_s2_ajax()
274
+ }
275
+ ?>
classes/class-s2_multisite.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class s2_multisite {
3
+ /* === WP Multisite specific functions === */
4
+ /**
5
+ Handles subscriptions and unsubscriptions for different blogs on WPMU installs
6
+ */
7
+ function wpmu_subscribe() {
8
+ // subscribe to new blog
9
+ if ( !empty($_GET['s2mu_subscribe']) ) {
10
+ $sub_id = intval($_GET['s2mu_subscribe']);
11
+ if ( $sub_id >= 0 ) {
12
+ switch_to_blog($sub_id);
13
+
14
+ $user_ID = get_current_user_id();
15
+
16
+ // if user is not a user of the current blog
17
+ if ( !is_blog_user($sub_id) ) {
18
+ // add user to current blog as subscriber
19
+ add_user_to_blog($sub_id, $user_ID, 'subscriber');
20
+ // add an action hook for external manipulation of blog and user data
21
+ do_action_ref_array('subscribe2_wpmu_subscribe', array($user_ID, $sub_id));
22
+ }
23
+
24
+ // get categories, remove excluded ones if override is off
25
+ if ( 0 == $this->subscribe2_options['reg_override'] ) {
26
+ $all_cats = $this->all_cats(true, 'ID');
27
+ } else {
28
+ $all_cats = $this->all_cats(false, 'ID');
29
+ }
30
+
31
+ $cats_string = '';
32
+ foreach ( $all_cats as $cat ) {
33
+ ('' == $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
34
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
35
+ }
36
+ if ( empty($cats_string) ) {
37
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
38
+ } else {
39
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats_string);
40
+ }
41
+ }
42
+ } elseif ( !empty($_GET['s2mu_unsubscribe']) ) {
43
+ // unsubscribe from a blog
44
+ $unsub_id = intval($_GET['s2mu_unsubscribe']);
45
+ if ( $unsub_id >= 0 ) {
46
+ switch_to_blog($unsub_id);
47
+
48
+ $user_ID = get_current_user_id();
49
+
50
+ // delete subscription to all categories on that blog
51
+ $cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
52
+ $cats = explode(',', $cats);
53
+ if ( !is_array($cats) ) {
54
+ $cats = array($cats);
55
+ }
56
+
57
+ foreach ( $cats as $id ) {
58
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
59
+ }
60
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
61
+
62
+ // add an action hook for external manipulation of blog and user data
63
+ do_action_ref_array('subscribe2_wpmu_unsubscribe', array($user_ID, $unsub_id));
64
+
65
+ restore_current_blog();
66
+ }
67
+ }
68
+
69
+ if ( !is_user_member_of_blog($user_ID) ) {
70
+ $user_blogs = get_active_blog_for_user($user_ID);
71
+ if ( is_array($user_blogs) ) {
72
+ switch_to_blog(key($user_blogs));
73
+ } else {
74
+ // no longer a member of a blog
75
+ wp_redirect(get_option('siteurl')); // redirect to front page
76
+ exit(0);
77
+ }
78
+ }
79
+
80
+ // redirect to profile page
81
+ if ( current_user_can('manage_options') ) {
82
+ $url = get_option('siteurl') . '/wp-admin/users.php?page=s2_users';
83
+ wp_redirect($url);
84
+ exit(0);
85
+ } else {
86
+ $url = get_option('siteurl') . '/wp-admin/profile.php?page=s2_users';
87
+ wp_redirect($url);
88
+ exit(0);
89
+ }
90
+ } // end wpmu_subscribe()
91
+
92
+ /**
93
+ Obtain a list of current WordPress multiuser blogs
94
+ Note this may affect performance but there is no alternative
95
+ */
96
+ function get_mu_blog_list() {
97
+ global $wpdb;
98
+ $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
99
+
100
+ foreach ( $blogs as $details ) {
101
+ //reindex the array so the key is the same as the blog_id
102
+ $blog_list[$details['blog_id']] = $details;
103
+ }
104
+
105
+ if ( false == is_array( $blog_list ) ) {
106
+ return array();
107
+ }
108
+
109
+ return $blog_list;
110
+ } // end get_mu_blog_list()
111
+
112
+ /**
113
+ Register user details when new user is added to a multisite blog
114
+ */
115
+ function wpmu_add_user($user_ID = 0) {
116
+ if ( 0 == $user_ID ) { return; }
117
+ if ( 'yes' == $this->subscribe2_options['autosub'] ) {
118
+ $this->register($user_ID, true);
119
+ } else {
120
+ $this->register($user_ID, false);
121
+ }
122
+ } // end wpmu_add_user()
123
+
124
+ /**
125
+ Delete user details when a user is removed from a multisite blog
126
+ */
127
+ function wpmu_remove_user($user_ID) {
128
+ if ( 0 == $user_ID ) { return; }
129
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'));
130
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'));
131
+ $cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
132
+ if ( !empty($cats) ) {
133
+ $cats = explode(',', $cats);
134
+ foreach ( $cats as $cat ) {
135
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat);
136
+ }
137
+ }
138
+ delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
139
+ } // end wpmu_remove_user()
140
+
141
+ /**
142
+ Rename WPMU widgets on upgrade without requiring user to re-enable
143
+ */
144
+ function namechange_subscribe2_widget() {
145
+ global $wpdb;
146
+ $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
147
+
148
+ foreach ( $blogs as $blog ) {
149
+ switch_to_blog($blog);
150
+
151
+ $sidebars = get_option('sidebars_widgets');
152
+ if ( empty($sidebars) || !is_array($sidebars) ) { return; }
153
+ $changed = false;
154
+ foreach ( $sidebars as $s =>$sidebar ) {
155
+ if ( empty($sidebar) || !is_array($sidebar) ) { break; }
156
+ foreach ( $sidebar as $w => $widget ) {
157
+ if ( $widget == 'subscribe2widget' ) {
158
+ $sidebars[$s][$w] = 'subscribe2';
159
+ $changed = true;
160
+ }
161
+ }
162
+ }
163
+ if ( $changed ) {
164
+ update_option('sidebar_widgets', $sidebars);
165
+ }
166
+ }
167
+ restore_current_blog();
168
+ } // end namechange_subscribe2_widget()
169
+ }
170
+ ?>
include/counterwidget.php CHANGED
@@ -4,7 +4,7 @@ class S2_Counter_widget extends WP_Widget {
4
  Declares the S2_Counter_widget class.
5
  */
6
  function S2_Counter_widget() {
7
- $widget_options = array('classname' => 's2_counter', 'description' => __('Subscriber Counter widget for the Subscribe2 plugin', 'subscribe2') );
8
  $control_options = array('width' => 250, 'height' => 500);
9
  $this->WP_Widget('s2_counter', __('Subscribe2 Counter', 'subscribe2'), $widget_options, $control_options);
10
  }
4
  Declares the S2_Counter_widget class.
5
  */
6
  function S2_Counter_widget() {
7
+ $widget_options = array('classname' => 's2_counter', 'description' => __('Subscriber Counter widget for Subscribe2', 'subscribe2') );
8
  $control_options = array('width' => 250, 'height' => 500);
9
  $this->WP_Widget('s2_counter', __('Subscribe2 Counter', 'subscribe2'), $widget_options, $control_options);
10
  }
include/options.php CHANGED
@@ -30,8 +30,12 @@ if (!isset($this->subscribe2_options['comment_subs'])) {
30
  $this->subscribe2_options['comment_subs'] = "no";
31
  } // option for commenters to subscribe as public subscribers
32
 
 
 
 
 
33
  if(!isset($this->subscribe2_options['bcclimit'])) {
34
- $this->subscribe2_options['bcclimit'] = 0;
35
  } // option for default bcc limit on email notifications
36
 
37
  if (!isset($this->subscribe2_options['admin_email'])) {
@@ -75,7 +79,7 @@ if (!isset($this->subscribe2_options['exclude'])) {
75
  } // option for excluded categories
76
 
77
  if (!isset($this->subscribe2_options['sender'])) {
78
- $this->subscribe2_options['sender'] = "author";
79
  } // option for email notification sender
80
 
81
  if (!isset($this->subscribe2_options['reg_override'])) {
30
  $this->subscribe2_options['comment_subs'] = "no";
31
  } // option for commenters to subscribe as public subscribers
32
 
33
+ if (!isset($this->subscribe2_options['one_click_profile'])) {
34
+ $this->subscribe2_options['one_click_profile'] = "no";
35
+ } // option for displaying 'one-click' option on profile page
36
+
37
  if(!isset($this->subscribe2_options['bcclimit'])) {
38
+ $this->subscribe2_options['bcclimit'] = 1;
39
  } // option for default bcc limit on email notifications
40
 
41
  if (!isset($this->subscribe2_options['admin_email'])) {
79
  } // option for excluded categories
80
 
81
  if (!isset($this->subscribe2_options['sender'])) {
82
+ $this->subscribe2_options['sender'] = "blogname";
83
  } // option for email notification sender
84
 
85
  if (!isset($this->subscribe2_options['reg_override'])) {
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file
subscribe2.php CHANGED
@@ -3,9 +3,10 @@
3
  Plugin Name: Subscribe2
4
  Plugin URI: http://subscribe2.wordpress.com
5
  Description: Notifies an email list when new entries are posted.
6
- Version: 7.2
7
  Author: Matthew Robinson
8
  Author URI: http://subscribe2.wordpress.com
 
9
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904
10
  */
11
 
@@ -30,15 +31,19 @@ You should have received a copy of the GNU General Public License
30
  along with Subscribe2. If not, see <http://www.gnu.org/licenses/>.
31
  */
32
 
33
- if ( version_compare($GLOBALS['wp_version'], '3.1', '<') ) {
34
- // Subscribe2 needs WordPress 3.1 or above, exit if not on a compatible version
35
- $exit_msg = sprintf(__('This version of Subscribe2 requires WordPress 3.1 or greater. Please update %1$s or use an older version of %2$s.', 'subscribe2'), '<a href="http://codex.wordpress.org/Updating_WordPress">Wordpress</a>', '<a href="http://wordpress.org/extend/plugins/subscribe2/download/">Subscribe2</a>');
 
 
 
 
36
  exit($exit_msg);
37
  }
38
 
39
  // our version number. Don't touch this or any line below
40
  // unless you know exactly what you are doing
41
- define( 'S2VERSION', '7.2' );
42
  define( 'S2PATH', trailingslashit(dirname(__FILE__)) );
43
  define( 'S2DIR', trailingslashit(dirname(plugin_basename(__FILE__))) );
44
  define( 'S2URL', plugin_dir_url(dirname(__FILE__)) . S2DIR );
@@ -49,4048 +54,14 @@ if ( !in_array(ini_get('safe_mode'), $safe_mode) && ini_get('max_execution_time'
49
  @ini_set('max_execution_time', 300);
50
  }
51
 
52
- $mysubscribe2 = new s2class;
53
- $mysubscribe2->s2init();
54
-
55
- // start our class
56
- class s2class {
57
- // variables and constructor are declared at the end
58
-
59
- /**
60
- Load all our strings
61
- */
62
- function load_strings() {
63
- // adjust the output of Subscribe2 here
64
-
65
- $this->please_log_in = "<p class=\"s2_message\">" . __('To manage your subscription options please', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-login.php\">" . __('login', 'subscribe2') . "</a>.</p>";
66
-
67
- $this->profile = "<p class=\"s2_message\">" . __('You may manage your subscription options from your', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-admin/admin.php?page=s2\">" . __('profile', 'subscribe2') . "</a>.</p>";
68
- if ( $this->s2_mu === true ) {
69
- global $blog_id, $user_ID;
70
- if ( !is_blog_user($blog_id) ) {
71
- // if we are on multisite and the user is not a member of this blog change the link
72
- $this->use_profile_admin = "<p class=\"s2_message\"><a href=\"" . get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id . "\">" . __('Subscribe', 'subscribe2') . "</a> " . __('to email notifications when this blog posts new content', 'subscribe2') . ".</p>";
73
- }
74
- }
75
-
76
- $this->confirmation_sent = "<p class=\"s2_message\">" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
77
-
78
- $this->already_subscribed = "<p class=\"s2_error\">" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
79
-
80
- $this->not_subscribed = "<p class=\"s2_error\">" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
81
-
82
- $this->not_an_email = "<p class=\"s2_error\">" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
83
-
84
- $this->barred_domain = "<p class=\"s2_error\">" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
85
-
86
- $this->error = "<p class=\"s2_error\">" . __('Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2') . "</p>";
87
-
88
- $this->no_page = "<p class=\"s2_error\">" . __('You must to create a WordPress page for this plugin to work correctly.', 'subscribe2') . "</p>";
89
-
90
- $this->mail_sent = "<p class=\"s2_message\">" . __('Message sent!', 'subscribe2') . "</p>";
91
-
92
- $this->mail_failed = "<p class=\"s2_error\">" . __('Message failed! Check your settings and check with your hosting provider', 'subscribe2') . "</p>";
93
-
94
- // confirmation messages
95
- $this->no_such_email = "<p class=\"s2_error\">" . __('No such email address is registered.', 'subscribe2') . "</p>";
96
-
97
- $this->added = "<p class=\"s2_message\">" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
98
-
99
- $this->deleted = "<p class=\"s2_message\">" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
100
-
101
- $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
102
-
103
- $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
104
-
105
- // menu strings
106
- $this->options_saved = __('Options saved!', 'subscribe2');
107
- $this->options_reset = __('Options reset!', 'subscribe2');
108
- } // end load_strings()
109
-
110
- /* ===== WordPress menu registration and scripts ===== */
111
- /**
112
- Hook the menu
113
- */
114
- function admin_menu() {
115
- add_menu_page (__('Subscribe2', 'subscribe2'), __('Subscribe2', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', NULL, S2URL . 'include/email_edit.png');
116
-
117
- $s2user = add_submenu_page('s2', __('Your Subscriptions', 'subscribe2'), __('Your Subscriptions', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', array(&$this, 'user_menu'), S2URL . 'include/email_edit.png');
118
- add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
119
- add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
120
-
121
- $s2management = add_submenu_page('s2', __('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'manage'), 's2_tools', array(&$this, 'manage_menu'));
122
- add_action("admin_print_scripts-$s2management", array(&$this, 'checkbox_form_js'));
123
-
124
- $s2options = add_submenu_page('s2', __('Settings', 'subscribe2'), __('Settings', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'settings'), 's2_settings', array(&$this, 'options_menu'));
125
- add_action("admin_print_scripts-$s2options", array(&$this, 'checkbox_form_js'));
126
- add_action("admin_print_scripts-$s2options", array(&$this, 'option_form_js'));
127
- add_filter('plugin_row_meta', array(&$this, 'plugin_links'), 10, 2);
128
-
129
- add_submenu_page('s2', __('Send Email', 'subscribe2'), __('Send Email', 'subscribe2'), apply_filters('s2_capability', "publish_posts", 'send'), 's2_posts', array(&$this, 'write_menu'));
130
-
131
- $s2nonce = md5('subscribe2');
132
- } // end admin_menu()
133
-
134
- /**
135
- Hook for Admin Drop Down Icons
136
- */
137
- function ozh_s2_icon() {
138
- return S2URL . 'include/email_edit.png';
139
- } // end ozh_s2_icon()
140
-
141
- /**
142
- Insert Javascript and CSS into admin_header
143
- */
144
- function checkbox_form_js() {
145
- wp_register_script('s2_checkbox', S2URL . 'include/s2_checkbox' . $this->script_debug . '.js', array('jquery'), '1.1');
146
- wp_enqueue_script('s2_checkbox');
147
- } //end checkbox_form_js()
148
-
149
- function user_admin_css() {
150
- wp_register_style('s2_user_admin', S2URL . 'include/s2_user_admin.css', array(), '1.0');
151
- wp_enqueue_script('s2_user_admin');
152
- } // end user_admin_css()
153
-
154
- function option_form_js() {
155
- wp_register_script('s2_edit', S2URL . 'include/s2_edit' . $this->script_debug . '.js', array('jquery'), '1.0');
156
- wp_enqueue_script('s2_edit');
157
- } // end option_form_js()
158
-
159
- /* ===== Install, upgrade, reset ===== */
160
- /**
161
- Install our table
162
- */
163
- function install() {
164
- // include upgrade-functions for maybe_create_table;
165
- if ( !function_exists('maybe_create_table') ) {
166
- require_once(ABSPATH . 'wp-admin/install-helper.php');
167
- }
168
- $date = date('Y-m-d');
169
- $sql = "CREATE TABLE $this->public (
170
- id int(11) NOT NULL auto_increment,
171
- email varchar(64) NOT NULL default '',
172
- active tinyint(1) default 0,
173
- date DATE default '$date' NOT NULL,
174
- ip char(64) NOT NULL default 'admin',
175
- PRIMARY KEY (id) )";
176
-
177
- // create the table, as needed
178
- maybe_create_table($this->public, $sql);
179
-
180
- // safety check if options exist and if not create them
181
- if ( !is_array($this->subscribe2_options) ) {
182
- $this->reset();
183
- }
184
- } // end install()
185
-
186
- /**
187
- Upgrade function for the database and settings
188
- */
189
- function upgrade() {
190
- global $wpdb, $wp_version, $wpmu_version;
191
- // include upgrade-functions for maybe_add_column;
192
- if ( !function_exists('maybe_add_column') ) {
193
- require_once(ABSPATH . 'wp-admin/install-helper.php');
194
- }
195
- $date = date('Y-m-d');
196
- maybe_add_column($this->public, 'date', "ALTER TABLE $this->public ADD date DATE DEFAULT '$date' NOT NULL AFTER active");
197
- maybe_add_column($this->public, 'ip', "ALTER TABLE $this->public ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date");
198
-
199
- // let's take the time to check process registered users
200
- // existing public subscribers are subscribed to all categories
201
- $users = $this->get_all_registered('ID');
202
- if ( !empty($users) ) {
203
- foreach ( $users as $user_ID ) {
204
- $check_format = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true);
205
- // if user is already registered update format remove 's2_excerpt' field and update 's2_format'
206
- if ( 'html' == $check_format ) {
207
- delete_user_meta($user_ID, 's2_excerpt');
208
- } elseif ( 'text' == $check_format ) {
209
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), get_user_meta($user_ID, 's2_excerpt'));
210
- delete_user_meta($user_ID, 's2_excerpt');
211
- } elseif ( empty($check_format) ) {
212
- // no prior settings so create them
213
- $this->register($user_ID);
214
- }
215
- $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
216
- if ( strstr($subscribed, '-1') ) {
217
- // make sure we remove '-1' from any settings
218
- $old_cats = explode(',', $subscribed);
219
- $pos = array_search('-1', $old_cats);
220
- unset($old_cats[$pos]);
221
- $cats = implode(',', $old_cats);
222
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
223
- }
224
- $check_authors = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), true);
225
- if ( empty($check_authors) ) {
226
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
227
- }
228
- }
229
- }
230
- // update the options table to serialized format
231
- $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
232
-
233
- if ( !empty($old_options) ) {
234
- foreach ( $old_options as $option ) {
235
- $value = get_option($option);
236
- $option_array = substr($option, 3);
237
- $this->subscribe2_options[$option_array] = $value;
238
- delete_option($option);
239
- }
240
- }
241
- $this->subscribe2_options['version'] = S2VERSION;
242
- // ensure that the options are in the database
243
- require(S2PATH . "include/options.php");
244
- // correct autoformat to upgrade from pre 5.6
245
- if ( $this->subscribe2_options['autoformat'] == 'text' ) {
246
- $this->subscribe2_options['autoformat'] = 'excerpt';
247
- }
248
- if ( $this->subscribe2_options['autoformat'] == 'full' ) {
249
- $this->subscribe2_options['autoformat'] = 'post';
250
- }
251
- // change old CAPITALISED keywords to those in {PARENTHESES}; since version 6.4
252
- $keywords = array('BLOGNAME', 'BLOGLINK', 'TITLE', 'POST', 'POSTTIME', 'TABLE', 'TABLELINKS', 'PERMALINK', 'TINYLINK', 'DATE', 'TIME', 'MYNAME', 'EMAIL', 'AUTHORNAME', 'LINK', 'CATS', 'TAGS', 'COUNT', 'ACTION');
253
- $keyword = implode('|', $keywords);
254
- $regex = '/(?<!\{)\b('.$keyword.')\b(?!\{)/xm';
255
- $replace = '{\1}';
256
- $this->subscribe2_options['mailtext'] = preg_replace($regex, $replace, $this->subscribe2_options['mailtext']);
257
- $this->subscribe2_options['notification_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['notification_subject']);
258
- $this->subscribe2_options['confirm_email'] = preg_replace($regex, $replace, $this->subscribe2_options['confirm_email']);
259
- $this->subscribe2_options['confirm_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['confirm_subject']);
260
- $this->subscribe2_options['remind_email'] = preg_replace($regex, $replace, $this->subscribe2_options['remind_email']);
261
- $this->subscribe2_options['remind_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['remind_subject']);
262
- update_option('subscribe2_options', $this->subscribe2_options);
263
-
264
- // upgrade old wpmu user meta data to new
265
- if ( $this->s2_mu === true ) {
266
- $this->namechange_subscribe2_widget();
267
- // loop through all users
268
- foreach ( $users as $user_ID ) {
269
- // get categories which the user is subscribed to (old ones)
270
- $categories = get_user_meta($user_ID, 's2_subscribed', true);
271
- $categories = explode(',', $categories);
272
- $format = get_user_meta($user_ID, 's2_format', true);
273
- $autosub = get_user_meta($user_ID, 's2_autosub', true);
274
-
275
- // load blogs of user (only if we need them)
276
- $blogs = array();
277
- if ( count($categories) > 0 && !in_array('-1', $categories) ) {
278
- $blogs = get_blogs_of_user($user_ID, true);
279
- }
280
-
281
- foreach ( $blogs as $blog ) {
282
- switch_to_blog($blog->userblog_id);
283
-
284
- $blog_categories = (array)$wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category'");
285
- $subscribed_categories = array_intersect($categories, $blog_categories);
286
- if ( !empty($subscribed_categories) ) {
287
- foreach ( $subscribed_categories as $subscribed_category ) {
288
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category);
289
- }
290
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories));
291
- }
292
- if ( !empty($format) ) {
293
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $format);
294
- }
295
- if ( !empty($autosub) ) {
296
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $autosub);
297
- }
298
- restore_current_blog();
299
- }
300
-
301
- // delete old user meta keys
302
- delete_user_meta($user_ID, 's2_subscribed');
303
- delete_user_meta($user_ID, 's2_format');
304
- delete_user_meta($user_ID, 's2_autosub');
305
- foreach ( $categories as $cat ) {
306
- delete_user_meta($user_ID, 's2_cat' . $cat);
307
- }
308
- }
309
- }
310
-
311
- // ensure existing public subscriber emails are all sanitized
312
- $confirmed = $this->get_public();
313
- $unconfirmed = $this->get_public(0);
314
- $public_subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
315
-
316
- foreach ( $public_subscribers as $email ) {
317
- $new_email = $this->sanitize_email($email);
318
- if ( $email !== $new_email ) {
319
- $wpdb->get_results("UPDATE $this->public SET email='$new_email' WHERE CAST(email as binary)='$email'");
320
- }
321
- }
322
- return;
323
- } // end upgrade()
324
-
325
- /**
326
- Reset our options
327
- */
328
- function reset() {
329
- delete_option('subscribe2_options');
330
- wp_clear_scheduled_hook('s2_digest_cron');
331
- unset($this->subscribe2_options);
332
- require(S2PATH . "include/options.php");
333
- update_option('subscribe2_options', $this->subscribe2_options);
334
- } // end reset()
335
-
336
- /* ===== mail handling ===== */
337
- /**
338
- Performs string substitutions for subscribe2 mail tags
339
- */
340
- function substitute($string = '') {
341
- if ( '' == $string ) {
342
- return;
343
- }
344
- $string = str_replace("{BLOGNAME}", html_entity_decode(get_option('blogname'), ENT_QUOTES), $string);
345
- $string = str_replace("{BLOGLINK}", get_option('home'), $string);
346
- $string = str_replace("{TITLE}", stripslashes($this->post_title), $string);
347
- $link = "<a href=\"" . $this->get_tracking_link($this->permalink) . "\">" . $this->get_tracking_link($this->permalink) . "</a>";
348
- $string = str_replace("{PERMALINK}", $link, $string);
349
- if ( strstr($string, "{TINYLINK}") ) {
350
- $tinylink = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode($this->get_tracking_link($this->permalink)));
351
- if ( $tinylink !== 'Error' || $tinylink != false ) {
352
- $tlink = "<a href=\"" . $tinylink . "\">" . $tinylink . "</a>";
353
- $string = str_replace("{TINYLINK}", $tlink, $string);
354
- } else {
355
- $string = str_replace("{TINYLINK}", $link, $string);
356
- }
357
- }
358
- $string = str_replace("{DATE}", $this->post_date, $string);
359
- $string = str_replace("{TIME}", $this->post_time, $string);
360
- $string = str_replace("{MYNAME}", stripslashes($this->myname), $string);
361
- $string = str_replace("{EMAIL}", $this->myemail, $string);
362
- $string = str_replace("{AUTHORNAME}", stripslashes($this->authorname), $string);
363
- $string = str_replace("{CATS}", $this->post_cat_names, $string);
364
- $string = str_replace("{TAGS}", $this->post_tag_names, $string);
365
- $string = str_replace("{COUNT}", $this->post_count, $string);
366
-
367
- return $string;
368
- } // end substitute()
369
-
370
- /**
371
- Delivers email to recipients in HTML or plaintext
372
- */
373
- function mail($recipients = array(), $subject = '', $message = '', $type='text') {
374
- if ( empty($recipients) || '' == $message ) { return; }
375
-
376
- if ( 'html' == $type ) {
377
- $headers = $this->headers('html');
378
- if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
379
- $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title><link rel=\"stylesheet\" href=\"" . get_stylesheet_uri() . "\" type=\"text/css\" media=\"screen\" /></head><body>" . $message . "</body></html>", $subject, $message);
380
- } else {
381
- $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>", $subject, $message);
382
- }
383
- } else {
384
- $headers = $this->headers();
385
- $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
386
- $message = preg_replace('|&amp;|', '&', $message);
387
- $message = wordwrap(strip_tags($message), 80, "\n");
388
- $mailtext = apply_filters('s2_plain_email', $message);
389
- }
390
-
391
- // Replace any escaped html symbols in subject then apply filter
392
- $subject = html_entity_decode($subject, ENT_QUOTES);
393
- $subject = apply_filters('s2_email_subject', $subject);
394
-
395
- // Construct BCC headers for sending or send individual emails
396
- $bcc = '';
397
- natcasesort($recipients);
398
- if ( function_exists('wpmq_mail') || $this->subscribe2_options['bcclimit'] == 1 || count($recipients) == 1 ) {
399
- // BCCLimit is 1 so send individual emails or we only have 1 recipient
400
- foreach ( $recipients as $recipient ) {
401
- $recipient = trim($recipient);
402
- // sanity check -- make sure we have a valid email
403
- if ( !is_email($recipient) || empty($recipient) ) { continue; }
404
- // Use the mail queue provided we are not sending a preview
405
- if ( function_exists('wpmq_mail') && !$this->preview_email ) {
406
- @wp_mail($recipient, $subject, $mailtext, $headers, '', 0);
407
- } else {
408
- @wp_mail($recipient, $subject, $mailtext, $headers);
409
- }
410
- }
411
- return true;
412
- } elseif ( $this->subscribe2_options['bcclimit'] == 0 ) {
413
- // we're not using BCCLimit
414
- foreach ( $recipients as $recipient ) {
415
- $recipient = trim($recipient);
416
- // sanity check -- make sure we have a valid email
417
- if ( !is_email($recipient) ) { continue; }
418
- // and NOT the sender's email, since they'll get a copy anyway
419
- if ( !empty($recipient) && $this->myemail != $recipient ) {
420
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
421
- // Bcc Headers now constructed by phpmailer class
422
- }
423
- }
424
- $headers .= "$bcc\n";
425
- } else {
426
- // we're using BCCLimit
427
- $count = 1;
428
- $batch = array();
429
- foreach ( $recipients as $recipient ) {
430
- $recipient = trim($recipient);
431
- // sanity check -- make sure we have a valid email
432
- if ( !is_email($recipient) ) { continue; }
433
- // and NOT the sender's email, since they'll get a copy anyway
434
- if ( !empty($recipient) && $this->myemail != $recipient ) {
435
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
436
- // Bcc Headers now constructed by phpmailer class
437
- }
438
- if ( $this->subscribe2_options['bcclimit'] == $count ) {
439
- $count = 0;
440
- $batch[] = $bcc;
441
- $bcc = '';
442
- }
443
- $count++;
444
- }
445
- // add any partially completed batches to our batch array
446
- if ( '' != $bcc ) {
447
- $batch[] = $bcc;
448
- }
449
- }
450
- // rewind the array, just to be safe
451
- reset($recipients);
452
-
453
- // actually send mail
454
- if ( isset($batch) && !empty($batch) ) {
455
- foreach ( $batch as $bcc ) {
456
- $newheaders = $headers . "$bcc\n";
457
- $status = @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
458
- }
459
- } else {
460
- $status = @wp_mail($this->myemail, $subject, $mailtext, $headers);
461
- }
462
- return $status;
463
- } // end mail()
464
-
465
- /**
466
- Construct standard set of email headers
467
- */
468
- function headers($type='text') {
469
- if ( empty($this->myname) || empty($this->myemail) ) {
470
- if ( $this->subscribe2_options['sender'] == 'blogname' ) {
471
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
472
- $this->myemail = get_option('admin_email');
473
- } else {
474
- $admin = $this->get_userdata($this->subscribe2_options['sender']);
475
- $this->myname = html_entity_decode($admin->display_name, ENT_QUOTES);
476
- $this->myemail = $admin->user_email;
477
- // fail safe to ensure sender details are not empty
478
- if ( empty($this->myname) ) {
479
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
480
- }
481
- if ( empty($this->myemail) ) {
482
- // Get the site domain and get rid of www.
483
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
484
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
485
- $sitename = substr( $sitename, 4 );
486
- }
487
- $this->myemail = 'wordpress@' . $sitename;
488
- }
489
- }
490
- }
491
-
492
- $header['From'] = $this->myname . " <" . $this->myemail . ">";
493
- $header['Reply-To'] = $this->myname . " <" . $this->myemail . ">";
494
- $header['Return-path'] = "<" . $this->myemail . ">";
495
- $header['Precedence'] = "list\nList-Id: " . html_entity_decode(get_option('blogname'), ENT_QUOTES) . "";
496
- if ( $type == 'html' ) {
497
- // To send HTML mail, the Content-Type header must be set
498
- $header['Content-Type'] = get_option('html_type') . "; charset=\"". get_option('blog_charset') . "\"";
499
- } else {
500
- $header['Content-Type'] = "text/plain; charset=\"". get_option('blog_charset') . "\"";
501
- }
502
-
503
- // apply header filter to allow on-the-fly amendments
504
- $header = apply_filters('s2_email_headers', $header);
505
- // collapse the headers using $key as the header name
506
- foreach ( $header as $key => $value ) {
507
- $headers[$key] = $key . ": " . $value;
508
- }
509
- $headers = implode("\n", $headers);
510
- $headers .= "\n";
511
-
512
- return $headers;
513
- } // end headers()
514
-
515
- /**
516
- Function to add UTM tracking details to links
517
- */
518
- function get_tracking_link($link) {
519
- if ( !empty($this->subscribe2_options['tracking']) ) {
520
- $delimiter = '?';
521
- if ( strpos($link, $delimiter) > 0 ) { $delimiter = '&'; }
522
- return $link . $delimiter . $this->subscribe2_options['tracking'];
523
- } else {
524
- return $link;
525
- }
526
- } // end get_tracking_link()
527
-
528
- /**
529
- Sends an email notification of a new post
530
- */
531
- function publish($post = 0, $preview = '') {
532
- if ( !$post ) { return $post; }
533
-
534
- if ( $this->s2_mu ) {
535
- global $switched;
536
- if ( $switched ) { return; }
537
- }
538
-
539
- if ( $preview == '' ) {
540
- // we aren't sending a Preview to the current user so carry out checks
541
- $s2mail = get_post_meta($post->ID, 's2mail', true);
542
- if ( (isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no') || strtolower(trim($s2mail)) == 'no' ) { return $post; }
543
-
544
- // are we doing daily digests? If so, don't send anything now
545
- if ( $this->subscribe2_options['email_freq'] != 'never' ) { return $post; }
546
-
547
- // is the current post of a type that should generate a notification email?
548
- // uses s2_post_types filter to allow for custom post types in WP 3.0
549
- if ( $this->subscribe2_options['pages'] == 'yes' ) {
550
- $s2_post_types = array('page', 'post');
551
- } else {
552
- $s2_post_types = array('post');
553
- }
554
- $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
555
- if ( !in_array($post->post_type, $s2_post_types) ) {
556
- return $post;
557
- }
558
-
559
- // Are we sending notifications for password protected posts?
560
- if ( $this->subscribe2_options['password'] == "no" && $post->post_password != '' ) {
561
- return $post;
562
- }
563
-
564
- // Is the post assigned to a format for which we should not be sending posts
565
- $post_format = get_post_format($post->ID);
566
- $excluded_formats = explode(',', $this->subscribe2_options['exclude_formats']);
567
- if ( $post_format !== false && in_array($post_format, $excluded_formats) ) {
568
- return $post;
569
- }
570
-
571
- $post_cats = wp_get_post_categories($post->ID);
572
- $check = false;
573
- // is the current post assigned to any categories
574
- // which should not generate a notification email?
575
- foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
576
- if ( in_array($cat, $post_cats) ) {
577
- $check = true;
578
- }
579
- }
580
-
581
- if ( $check ) {
582
- // hang on -- can registered users subscribe to
583
- // excluded categories?
584
- if ( '0' == $this->subscribe2_options['reg_override'] ) {
585
- // nope? okay, let's leave
586
- return $post;
587
- }
588
- }
589
-
590
- // Are we sending notifications for Private posts?
591
- // Action is added if we are, but double check option and post status
592
- if ( $this->subscribe2_options['private'] == "yes" && $post->post_status == 'private' ) {
593
- // don't send notification to public users
594
- $check = true;
595
- }
596
-
597
- // lets collect our subscribers
598
- if ( !$check ) {
599
- // if this post is assigned to an excluded
600
- // category, or is a private post then
601
- // don't send public subscribers a notification
602
- $public = $this->get_public();
603
- }
604
- $post_cats_string = implode(',', $post_cats);
605
- $registered = $this->get_registered("cats=$post_cats_string");
606
-
607
- // do we have subscribers?
608
- if ( empty($public) && empty($registered) ) {
609
- // if not, no sense doing anything else
610
- return $post;
611
- }
612
- }
613
-
614
- // we set these class variables so that we can avoid
615
- // passing them in function calls a little later
616
- $this->post_title = "<a href=\"" . get_permalink($post->ID) . "\">" . html_entity_decode($post->post_title, ENT_QUOTES) . "</a>";
617
- $this->permalink = get_permalink($post->ID);
618
- $this->post_date = get_the_time(get_option('date_format'));
619
- $this->post_time = get_the_time();
620
-
621
- $author = get_userdata($post->post_author);
622
- $this->authorname = $author->display_name;
623
-
624
- // do we send as admin, or post author?
625
- if ( 'author' == $this->subscribe2_options['sender'] ) {
626
- // get author details
627
- $user = &$author;
628
- $this->myemail = $user->user_email;
629
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
630
- } elseif ( 'blogname' == $this->subscribe2_options['sender'] ) {
631
- $this->myemail = get_option('admin_email');
632
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
633
- } else {
634
- // get admin details
635
- $user = $this->get_userdata($this->subscribe2_options['sender']);
636
- $this->myemail = $user->user_email;
637
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
638
- }
639
-
640
- $this->post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
641
- $this->post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
642
-
643
- // Get email subject
644
- $subject = stripslashes(strip_tags($this->substitute($this->subscribe2_options['notification_subject'])));
645
- // Get the message template
646
- $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
647
- $mailtext = stripslashes($this->substitute($mailtext));
648
-
649
- $plaintext = $post->post_content;
650
- if ( function_exists('strip_shortcodes') ) {
651
- $plaintext = strip_shortcodes($plaintext);
652
- }
653
- $plaintext = preg_replace('|<s*>(.*)<\/s>|','', $plaintext);
654
- $plaintext = preg_replace('|<strike*>(.*)<\/strike>|','', $plaintext);
655
- $plaintext = preg_replace('|<del*>(.*)<\/del>|','', $plaintext);
656
-
657
- $gallid = '[gallery id="' . $post->ID . '"';
658
- $content = str_replace('[gallery', $gallid, $post->post_content);
659
- $content = apply_filters('the_content', $content);
660
- $content = str_replace("]]>", "]]&gt", $content);
661
-
662
- $excerpt = $post->post_excerpt;
663
- if ( '' == $excerpt ) {
664
- // no excerpt, is there a <!--more--> ?
665
- if ( false !== strpos($plaintext, '<!--more-->') ) {
666
- list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
667
- // strip leading and trailing whitespace
668
- $excerpt = strip_tags($excerpt);
669
- $excerpt = trim($excerpt);
670
- } else {
671
- // no <!--more-->, so grab the first 55 words
672
- $excerpt = strip_tags($plaintext);
673
- $words = explode(' ', $excerpt, $this->excerpt_length + 1);
674
- if (count($words) > $this->excerpt_length) {
675
- array_pop($words);
676
- array_push($words, '[...]');
677
- $excerpt = implode(' ', $words);
678
- }
679
- }
680
- }
681
- $html_excerpt = $post->post_excerpt;
682
- if ( '' == $html_excerpt ) {
683
- // no excerpt, is there a <!--more--> ?
684
- if ( false !== strpos($content, '<!--more-->') ) {
685
- list($html_excerpt, $more) = explode('<!--more-->', $content, 2);
686
- // balance HTML tags and then strip leading and trailing whitespace
687
- $html_excerpt = trim(balanceTags($html_excerpt, true));
688
- } else {
689
- // no <!--more-->, so grab the first 55 words
690
- $words = explode(' ', $content, $this->excerpt_length + 1);
691
- if (count($words) > $this->excerpt_length) {
692
- array_pop($words);
693
- array_push($words, '[...]');
694
- $html_excerpt = implode(' ', $words);
695
- // balance HTML tags and then strip leading and trailing whitespace
696
- $html_excerpt = trim(balanceTags($html_excerpt, true));
697
- } else {
698
- $html_excerpt = $content;
699
- }
700
- }
701
- }
702
-
703
- // remove excess white space from with $excerpt and $plaintext
704
- $excerpt = preg_replace('|\s+|', ' ', $excerpt);
705
- $plaintext = preg_replace('|\s+|', ' ', $plaintext);
706
-
707
- // prepare mail body texts
708
- $excerpt_body = str_replace("{POST}", $excerpt, $mailtext);
709
- $full_body = str_replace("{POST}", strip_tags($plaintext), $mailtext);
710
- $html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
711
- $html_body = str_replace("{POST}", $content, $html_body);
712
- $html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
713
- $html_excerpt_body = str_replace("{POST}", $html_excerpt, $html_excerpt_body);
714
-
715
- if ( $preview != '' ) {
716
- $this->myemail = $preview;
717
- $this->myname = __('Plain Text Excerpt Preview', 'subscribe2');
718
- $this->mail(array($preview), $subject, $excerpt_body);
719
- $this->myname = __('Plain Text Full Preview', 'subscribe2');
720
- $this->mail(array($preview), $subject, $full_body);
721
- $this->myname = __('HTML Excerpt Preview', 'subscribe2');
722
- $this->mail(array($preview), $subject, $html_excerpt_body, 'html');
723
- $this->myname = __('HTML Full Preview', 'subscribe2');
724
- $this->mail(array($preview), $subject, $html_body, 'html');
725
- } else {
726
- // first we send plaintext summary emails
727
- $registered = $this->get_registered("cats=$post_cats_string&format=excerpt&author=$post->post_author");
728
- if ( empty($registered) ) {
729
- $recipients = (array)$public;
730
- } elseif ( empty($public) ) {
731
- $recipients = (array)$registered;
732
- } else {
733
- $recipients = array_merge((array)$public, (array)$registered);
734
- }
735
- $this->mail($recipients, $subject, $excerpt_body);
736
-
737
- // next we send plaintext full content emails
738
- $this->mail($this->get_registered("cats=$post_cats_string&format=post&author=$post->post_author"), $subject, $full_body);
739
-
740
- // next we send html excerpt content emails
741
- $this->mail($this->get_registered("cats=$post_cats_string&format=html_excerpt&author=$post->post_author"), $subject, $html_excerpt_body, 'html');
742
-
743
- // finally we send html full content emails
744
- $this->mail($this->get_registered("cats=$post_cats_string&format=html&author=$post->post_author"), $subject, $html_body, 'html');
745
- }
746
- } // end publish()
747
-
748
- /**
749
- Send confirmation email to a public subscriber
750
- */
751
- function send_confirm($what = '', $is_remind = false) {
752
- if ( $this->filtered == 1 ) { return true; }
753
- if ( !$this->email || !$what ) { return false; }
754
- $id = $this->get_id($this->email);
755
- if ( !$id ) {
756
- return false;
757
- }
758
-
759
- // generate the URL "?s2=ACTION+HASH+ID"
760
- // ACTION = 1 to subscribe, 0 to unsubscribe
761
- // HASH = md5 hash of email address
762
- // ID = user's ID in the subscribe2 table
763
- // use home instead of siteurl incase index.php is not in core wordpress directory
764
- $link = get_option('home') . "/?s2=";
765
-
766
- if ( 'add' == $what ) {
767
- $link .= '1';
768
- } elseif ( 'del' == $what ) {
769
- $link .= '0';
770
- }
771
- $link .= md5($this->email);
772
- $link .= $id;
773
-
774
- // sort the headers now so we have all substitute information
775
- $mailheaders = $this->headers();
776
-
777
- if ( $is_remind == true ) {
778
- $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
779
- $subject = $this->substitute(stripslashes($this->subscribe2_options['remind_subject']));
780
- } else {
781
- $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
782
- if ( 'add' == $what ) {
783
- $body = str_replace("{ACTION}", $this->subscribe, $body);
784
- $subject = str_replace("{ACTION}", $this->subscribe, $this->subscribe2_options['confirm_subject']);
785
- } elseif ( 'del' == $what ) {
786
- $body = str_replace("{ACTION}", $this->unsubscribe, $body);
787
- $subject = str_replace("{ACTION}", $this->unsubscribe, $this->subscribe2_options['confirm_subject']);
788
- }
789
- $subject = html_entity_decode($this->substitute(stripslashes($subject)), ENT_QUOTES);
790
- }
791
-
792
- $body = str_replace("{LINK}", $link, $body);
793
-
794
- if ( $is_remind == true && function_exists('wpmq_mail') ) {
795
- // could be sending lots of reminders so queue them if wpmq is enabled
796
- @wp_mail($this->email, $subject, $body, $mailheaders, '', 0);
797
- } else {
798
- return @wp_mail($this->email, $subject, $body, $mailheaders);
799
- }
800
- } // end send_confirm()
801
-
802
- /* ===== Subscriber functions ===== */
803
- /**
804
- Given a public subscriber ID, returns the email address
805
- */
806
- function get_email($id = 0) {
807
- global $wpdb;
808
-
809
- if ( !$id ) {
810
- return false;
811
- }
812
- return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
813
- } // end get_email()
814
-
815
- /**
816
- Given a public subscriber email, returns the subscriber ID
817
- */
818
- function get_id($email = '') {
819
- global $wpdb;
820
-
821
- if ( !$email ) {
822
- return false;
823
- }
824
- return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
825
- } // end get_id()
826
-
827
- /**
828
- Activate an public subscriber email address
829
- If the address is not already present, it will be added
830
- */
831
- function activate($email = '') {
832
- global $wpdb;
833
-
834
- if ( false !== $this->is_public($email) ) {
835
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
836
- if ( $check ) { return; }
837
- $wpdb->get_results("UPDATE $this->public SET active='1', ip='$this->ip' WHERE CAST(email as binary)='$email'");
838
- } else {
839
- global $current_user;
840
- $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 1, $current_user->user_login));
841
- }
842
- } // end activate()
843
-
844
- /**
845
- Add an public subscriber to the subscriber table as unconfirmed
846
- */
847
- function add($email = '') {
848
- if ( $this->filtered == 1 ) { return; }
849
- global $wpdb;
850
-
851
- if ( !is_email($email) ) { return false; }
852
-
853
- if ( false !== $this->is_public($email) ) {
854
- $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE CAST(email as binary)='$email'");
855
- } else {
856
- $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 0, $this->ip));
857
- }
858
- } // end add()
859
-
860
- /**
861
- Remove a public subscriber user from the subscription table
862
- */
863
- function delete($email = '') {
864
- if ( $this->filtered == 1 ) { return; }
865
- global $wpdb;
866
-
867
- if ( !is_email($email) ) { return false; }
868
- $wpdb->get_results("DELETE FROM $this->public WHERE CAST(email as binary)='$email'");
869
- } // end delete()
870
-
871
- /**
872
- Toggle a public subscriber's status
873
- */
874
- function toggle($email = '') {
875
- global $wpdb;
876
-
877
- if ( '' == $email || ! is_email($email) ) { return false; }
878
-
879
- // let's see if this is a public user
880
- $status = $this->is_public($email);
881
- if ( false === $status ) { return false; }
882
-
883
- if ( '0' == $status ) {
884
- $wpdb->get_results("UPDATE $this->public SET active='1' WHERE CAST(email as binary)='$email'");
885
- } else {
886
- $wpdb->get_results("UPDATE $this->public SET active='0' WHERE CAST(email as binary)='$email'");
887
- }
888
- } // end toggle()
889
-
890
- /**
891
- Send reminder email to unconfirmed public subscribers
892
- */
893
- function remind($emails = '') {
894
- if ( '' == $emails ) { return false; }
895
-
896
- $recipients = explode(",", $emails);
897
- if ( !is_array($recipients) ) { $recipients = (array)$recipients; }
898
- foreach ( $recipients as $recipient ) {
899
- $this->email = $recipient;
900
- $this->send_confirm('add', true);
901
- }
902
- } //end remind()
903
-
904
- /**
905
- Check email is not from a barred domain
906
- */
907
- function is_barred($email='') {
908
- $barred_option = $this->subscribe2_options['barred'];
909
- list($user, $domain) = explode('@', $email, 2);
910
- $bar_check = stristr($barred_option, $domain);
911
-
912
- if ( !empty($bar_check) ) {
913
- return true;
914
- } else {
915
- return false;
916
- }
917
- } // end is_barred()
918
-
919
- /**
920
- Confirm request from the link emailed to the user and email the admin
921
- */
922
- function confirm($content = '') {
923
- global $wpdb;
924
-
925
- if ( 1 == $this->filtered ) { return $content; }
926
-
927
- $code = $_GET['s2'];
928
- $action = intval(substr($code, 0, 1));
929
- $hash = substr($code, 1, 32);
930
- $id = intval(substr($code, 33));
931
- if ( $id ) {
932
- $this->email = $this->sanitize_email($this->get_email($id));
933
- if ( !$this->email || $hash !== md5($this->email) ) {
934
- return $this->no_such_email;
935
- }
936
- } else {
937
- return $this->no_such_email;
938
- }
939
-
940
- // get current status of email so messages are only sent once per emailed link
941
- $current = $this->is_public($this->email);
942
-
943
- if ( '1' == $action ) {
944
- // make this subscription active
945
- $this->message = $this->added;
946
- if ( '1' != $current ) {
947
- $this->ip = $_SERVER['REMOTE_ADDR'];
948
- $this->activate($this->email);
949
- if ( $this->subscribe2_options['admin_email'] == 'subs' || $this->subscribe2_options['admin_email'] == 'both' ) {
950
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
951
- $subject .= __('New Subscription', 'subscribe2');
952
- $subject = html_entity_decode($subject, ENT_QUOTES);
953
- $message = $this->email . " " . __('subscribed to email notifications!', 'subscribe2');
954
- $role = array('fields' => array('user_email'), 'role' => 'administrator');
955
- $wp_user_query = get_users( $role );
956
- foreach ($wp_user_query as $user) {
957
- $recipients[] = $user->user_email;
958
- }
959
- $headers = $this->headers();
960
- // send individual emails so we don't reveal admin emails to each other
961
- foreach ( $recipients as $recipient ) {
962
- @wp_mail($recipient, $subject, $message, $headers);
963
- }
964
- }
965
- }
966
- $this->filtered = 1;
967
- } elseif ( '0' == $action ) {
968
- // remove this subscriber
969
- $this->message = $this->deleted;
970
- if ( '0' != $current ) {
971
- $this->delete($this->email);
972
- if ( $this->subscribe2_options['admin_email'] == 'unsubs' || $this->subscribe2_options['admin_email'] == 'both' ) {
973
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
974
- $subject .= __('New Unsubscription', 'subscribe2');
975
- $subject = html_entity_decode($subject, ENT_QUOTES);
976
- $message = $this->email . " " . __('unsubscribed from email notifications!', 'subscribe2');
977
- $role = array('fields' => array('user_email'), 'role' => 'administrator');
978
- $wp_user_query = get_users( $role );
979
- foreach ($wp_user_query as $user) {
980
- $recipients[] = $user->user_email;
981
- }
982
- $headers = $this->headers();
983
- // send individual emails so we don't reveal admin emails to each other
984
- foreach ( $recipients as $recipient ) {
985
- @wp_mail($recipient, $subject, $message, $headers);
986
- }
987
- }
988
- }
989
- $this->filtered = 1;
990
- }
991
-
992
- if ( '' != $this->message ) {
993
- return $this->message;
994
- }
995
- } // end confirm()
996
-
997
- /**
998
- Is the supplied email address a public subscriber?
999
- */
1000
- function is_public($email = '') {
1001
- global $wpdb;
1002
-
1003
- if ( '' == $email ) { return false; }
1004
-
1005
- // run the query and force case sensitivity
1006
- $check = $wpdb->get_var("SELECT active FROM $this->public WHERE CAST(email as binary)='$email'");
1007
- if ( '0' == $check || '1' == $check ) {
1008
- return $check;
1009
- } else {
1010
- return false;
1011
- }
1012
- } // end is_public()
1013
-
1014
- /**
1015
- Is the supplied email address a registered user of the blog?
1016
- */
1017
- function is_registered($email = '') {
1018
- global $wpdb;
1019
-
1020
- if ( '' == $email ) { return false; }
1021
-
1022
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$email'");
1023
- if ( $check ) {
1024
- return true;
1025
- } else {
1026
- return false;
1027
- }
1028
- } // end is_registered()
1029
-
1030
- /**
1031
- Return Registered User ID from email
1032
- */
1033
- function get_user_id($email = '') {
1034
- global $wpdb;
1035
-
1036
- if ( '' == $email ) { return false; }
1037
-
1038
- $id = $wpdb->get_var("SELECT id FROM $wpdb->users WHERE user_email='$email'");
1039
-
1040
- return $id;
1041
- } // end get_user_id()
1042
-
1043
- /**
1044
- Return an array of all the public subscribers
1045
- */
1046
- function get_public($confirmed = 1) {
1047
- global $wpdb;
1048
- if ( 1 == $confirmed ) {
1049
- if ( '' == $this->all_public ) {
1050
- $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
1051
- }
1052
- return $this->all_public;
1053
- } else {
1054
- if ( '' == $this->all_unconfirmed ) {
1055
- $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
1056
- }
1057
- return $this->all_unconfirmed;
1058
- }
1059
- } // end get_public()
1060
-
1061
- /**
1062
- Collect an array of all author level users and above
1063
- */
1064
- function get_authors() {
1065
- if ( '' == $this->all_authors ) {
1066
- $role = array('fields' => array('ID', 'display_name'), 'role' => 'administrator');
1067
- $administrators = get_users( $role );
1068
- $role = array('fields' => array('ID', 'display_name'), 'role' => 'editor');
1069
- $editors = get_users( $role );
1070
- $role = array('fields' => array('ID', 'display_name'), 'role' => 'author');
1071
- $authors = get_users( $role );
1072
-
1073
- $this->all_authors = array_merge($administrators, $editors, $authors);
1074
- }
1075
- return $this->all_authors;
1076
- } // end get_authors()
1077
-
1078
- /**
1079
- Return an array of all subscribers emails or IDs
1080
- */
1081
- function get_all_registered($return = 'email') {
1082
- global $wpdb;
1083
-
1084
- if ( $this->s2_mu ) {
1085
- if ( $return === 'ID' ) {
1086
- return $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
1087
- } else {
1088
- return $wpdb->get_col("SELECT a.user_email FROM $wpdb->users AS a INNER JOIN $wpdb->usermeta AS b ON a.ID = b.user_id WHERE b.meta_key='" . $wpdb->prefix . "capabilities'");
1089
- }
1090
- } else {
1091
- if ( $return === 'ID' ) {
1092
- return $wpdb->get_col("SELECT ID FROM $wpdb->users");
1093
- } else {
1094
- return $wpdb->get_col("SELECT user_email FROM $wpdb->users");
1095
- }
1096
- }
1097
- } // end get_all_registered()
1098
-
1099
- /**
1100
- Return an array of registered subscribers
1101
- Collect all the registered users of the blog who are subscribed to the specified categories
1102
- */
1103
- function get_registered($args = '') {
1104
- global $wpdb;
1105
-
1106
- $format = '';
1107
- $cats = '';
1108
- $authors = '';
1109
- $subscribers = array();
1110
-
1111
- parse_str($args, $r);
1112
- if ( !isset($r['format']) )
1113
- $r['format'] = 'all';
1114
- if ( !isset($r['cats']) )
1115
- $r['cats'] = '';
1116
- if ( !isset($r['author']) )
1117
- $r['author'] = '';
1118
-
1119
- $JOIN = ''; $AND = '';
1120
- // text or HTML subscribers
1121
- if ( 'all' != $r['format'] ) {
1122
- $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
1123
- $AND .= " AND b.meta_key='" . $this->get_usermeta_keyname('s2_format') . "' AND b.meta_value=";
1124
- if ( 'html' == $r['format'] ) {
1125
- $AND .= "'html'";
1126
- } elseif ( 'html_excerpt' == $r['format'] ) {
1127
- $AND .= "'html_excerpt'";
1128
- } elseif ( 'post' == $r['format'] ) {
1129
- $AND .= "'post'";
1130
- } elseif ( 'excerpt' == $r['format'] ) {
1131
- $AND .= "'excerpt'";
1132
- }
1133
- }
1134
-
1135
- // specific category subscribers
1136
- if ( '' != $r['cats'] ) {
1137
- $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
1138
- $and = '';
1139
- foreach ( explode(',', $r['cats']) as $cat ) {
1140
- ('' == $and) ? $and = "c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'" : $and .= " OR c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'";
1141
- }
1142
- $AND .= " AND ($and)";
1143
- }
1144
-
1145
- // specific authors
1146
- if ( '' != $r['author'] ) {
1147
- $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
1148
- $AND .= " AND (d.meta_key='" . $this->get_usermeta_keyname('s2_authors') . "' AND NOT FIND_IN_SET(" . $r['author'] . ", d.meta_value))";
1149
- }
1150
-
1151
- if ( $this->s2_mu ) {
1152
- $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities'" . $AND;
1153
- } else {
1154
- $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'" . $AND;
1155
- }
1156
- $result = $wpdb->get_col($sql);
1157
- if ( $result ) {
1158
- $ids = implode(',', $result);
1159
- $registered = $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
1160
- }
1161
-
1162
- if ( empty($registered) ) { return array(); }
1163
-
1164
- // apply filter to registered users to add or remove additional addresses, pass args too for additional control
1165
- $registered = apply_filters('s2_registered_subscribers', $registered, $args);
1166
- return $registered;
1167
- } // end get_registered()
1168
-
1169
- /**
1170
- Collects the signup date for all public subscribers
1171
- */
1172
- function signup_date($email = '') {
1173
- if ( '' == $email ) { return false; }
1174
-
1175
- global $wpdb;
1176
- if ( !empty($this->signup_dates) ) {
1177
- return $this->signup_dates[$email];
1178
- } else {
1179
- $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
1180
- foreach ( $results as $result ) {
1181
- $this->signup_dates[$result[0]] = $result[1];
1182
- }
1183
- return $this->signup_dates[$email];
1184
- }
1185
- } // end signup_date()
1186
-
1187
- /**
1188
- Collects the ip address for all public subscribers
1189
- */
1190
- function signup_ip($email = '') {
1191
- if ( '' == $email ) {return false; }
1192
-
1193
- global $wpdb;
1194
- if ( !empty($this->signup_ips) ) {
1195
- return $this->signup_ips[$email];
1196
- } else {
1197
- $results = $wpdb->get_results("SELECT email, ip FROM $this->public", ARRAY_N);
1198
- foreach ( $results as $result ) {
1199
- $this->signup_ips[$result[0]] = $result[1];
1200
- }
1201
- return $this->signup_ips[$email];
1202
- }
1203
- } // end signup_ip()
1204
-
1205
- /**
1206
- Function to ensure email is compliant with internet messaging standards
1207
- */
1208
- function sanitize_email($email) {
1209
- if ( !is_email($email) ) { return; }
1210
-
1211
- // ensure that domain is in lowercase as per internet email standards
1212
- list($name, $domain) = explode('@', $email, 2);
1213
- return $name . "@" . strtolower($domain);
1214
- } // end sanitize_email()
1215
-
1216
- /**
1217
- Create the appropriate usermeta values when a user registers
1218
- If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
1219
- */
1220
- function register($user_ID = 0, $consent = false) {
1221
- global $wpdb;
1222
-
1223
- if ( 0 == $user_ID ) { return $user_ID; }
1224
- $user = get_userdata($user_ID);
1225
-
1226
- // Subscribe registered users to categories obeying excluded categories
1227
- if ( 0 == $this->subscribe2_options['reg_override'] || 'no' == $this->subscribe2_options['newreg_override'] ) {
1228
- $all_cats = $this->all_cats(true, 'ID');
1229
- } else {
1230
- $all_cats = $this->all_cats(false, 'ID');
1231
- }
1232
-
1233
- $cats = '';
1234
- foreach ( $all_cats as $cat ) {
1235
- ('' == $cats) ? $cats = "$cat->term_id" : $cats .= ",$cat->term_id";
1236
- }
1237
-
1238
- if ( '' == $cats ) {
1239
- // sanity check, might occur if all cats excluded and reg_override = 0
1240
- return $user_ID;
1241
- }
1242
-
1243
- // has this user previously signed up for email notification?
1244
- if ( false !== $this->is_public($this->sanitize_email($user->user_email)) ) {
1245
- // delete this user from the public table, and subscribe them to all the categories
1246
- $this->delete($user->user_email);
1247
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1248
- foreach ( explode(',', $cats) as $cat ) {
1249
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, $cat);
1250
- }
1251
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
1252
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $this->subscribe2_options['autosub_def']);
1253
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
1254
- } else {
1255
- // create post format entries for all users
1256
- if ( in_array($this->subscribe2_options['autoformat'], array('html', 'html_excerpt', 'post', 'excerpt')) ) {
1257
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $this->subscribe2_options['autoformat']);
1258
- } else {
1259
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
1260
- }
1261
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $this->subscribe2_options['autosub_def']);
1262
- // if the are no existing subscriptions, create them if we have consent
1263
- if ( true === $consent ) {
1264
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1265
- foreach ( explode(',', $cats) as $cat ) {
1266
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, $cat);
1267
- }
1268
- }
1269
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
1270
- }
1271
- return $user_ID;
1272
- } // end register()
1273
-
1274
- /**
1275
- Subscribe all registered users to category selected on Admin Manage Page
1276
- */
1277
- function subscribe_registered_users($emails = '', $cats = array()) {
1278
- if ( '' == $emails || '' == $cats ) { return false; }
1279
- global $wpdb;
1280
-
1281
- $useremails = explode(",", $emails);
1282
- $useremails = implode("', '", $useremails);
1283
-
1284
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
1285
- $user_IDs = $wpdb->get_col($sql);
1286
-
1287
- foreach ( $user_IDs as $user_ID ) {
1288
- $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
1289
- if ( !empty($old_cats) ) {
1290
- $old_cats = explode(',', $old_cats);
1291
- $newcats = array_unique(array_merge($cats, $old_cats));
1292
- } else {
1293
- $newcats = $cats;
1294
- }
1295
- if ( !empty($newcats) ) {
1296
- // add subscription to these cat IDs
1297
- foreach ( $newcats as $id ) {
1298
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
1299
- }
1300
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
1301
- }
1302
- unset($newcats);
1303
- }
1304
- } // end subscribe_registered_users()
1305
-
1306
- /**
1307
- Unsubscribe all registered users to category selected on Admin Manage Page
1308
- */
1309
- function unsubscribe_registered_users($emails = '', $cats = array()) {
1310
- if ( '' == $emails || '' == $cats ) { return false; }
1311
- global $wpdb;
1312
-
1313
- $useremails = explode(",", $emails);
1314
- $useremails = "'" . implode("', '", $useremails) . "'";
1315
-
1316
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
1317
- $user_IDs = $wpdb->get_col($sql);
1318
-
1319
- foreach ( $user_IDs as $user_ID ) {
1320
- $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
1321
- $remain = array_diff($old_cats, $cats);
1322
- if ( !empty($remain) ) {
1323
- // remove subscription to these cat IDs and update s2_subscribed
1324
- foreach ( $cats as $id ) {
1325
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1326
- }
1327
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
1328
- } else {
1329
- // remove subscription to these cat IDs and update s2_subscribed to ''
1330
- foreach ( $cats as $id ) {
1331
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1332
- }
1333
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1334
- }
1335
- unset($remain);
1336
- }
1337
- } // end unsubscribe_registered_users()
1338
-
1339
- /**
1340
- Handles bulk changes to email format for Registered Subscribers
1341
- */
1342
- function format_change($format, $subscribers_string) {
1343
- if ( empty($format) ) { return; }
1344
-
1345
- global $wpdb;
1346
- $subscribers = explode(',', $subscribers_string);
1347
- $emails = "'" . implode("', '", $subscribers) . "'";
1348
- $ids = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_email IN ($emails)");
1349
- $ids = implode(',', $ids);
1350
- $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname('s2_format') . "' AND user_id IN ($ids)";
1351
- $wpdb->get_results("UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname('s2_format') . "' AND user_id IN ($ids)");
1352
- } // end format_change()
1353
-
1354
- /**
1355
- Handles bulk update to digest preferences
1356
- */
1357
- function digest_change($digest, $emails) {
1358
- if ( empty($digest) ) { return; }
1359
-
1360
- global $wpdb;
1361
- $useremails = explode(",", $emails);
1362
- $useremails = "'" . implode("', '", $useremails) . "'";
1363
-
1364
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
1365
- $user_IDs = $wpdb->get_col($sql);
1366
-
1367
- if ( $digest == 'digest' ) {
1368
- $exclude = explode(',', $this->subscribe2_options['exclude']);
1369
- if ( !empty($exclude) ) {
1370
- $all_cats = $this->all_cats(true, 'ID');
1371
- } else {
1372
- $all_cats = $this->all_cats(false, 'ID');
1373
- }
1374
-
1375
- $cats_string = '';
1376
- foreach ( $all_cats as $cat ) {
1377
- ('' == $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
1378
- }
1379
-
1380
- foreach ( $user_IDs as $user_ID ) {
1381
- foreach ( $all_cats as $cat ) {
1382
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
1383
- }
1384
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats_string);
1385
- }
1386
- } elseif ( $digest == '-1' ) {
1387
- foreach ( $user_IDs as $user_ID ) {
1388
- $cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
1389
- foreach ( $cats as $id ) {
1390
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1391
- }
1392
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1393
- }
1394
- }
1395
- } // end digest_change()
1396
-
1397
- /**
1398
- Handles subscriptions and unsubscriptions for different blogs on WPMU installs
1399
- */
1400
- function wpmu_subscribe() {
1401
- // subscribe to new blog
1402
- if ( !empty($_GET['s2mu_subscribe']) ) {
1403
- $sub_id = intval($_GET['s2mu_subscribe']);
1404
- if ( $sub_id >= 0 ) {
1405
- switch_to_blog($sub_id);
1406
-
1407
- $user_ID = get_current_user_id();
1408
-
1409
- // if user is not a user of the current blog
1410
- if ( !is_blog_user($sub_id) ) {
1411
- // add user to current blog as subscriber
1412
- add_user_to_blog($sub_id, $user_ID, 'subscriber');
1413
- // add an action hook for external manipulation of blog and user data
1414
- do_action_ref_array('subscribe2_wpmu_subscribe', array($user_ID, $sub_id));
1415
- }
1416
-
1417
- // get categories, remove excluded ones if override is off
1418
- if ( 0 == $this->subscribe2_options['reg_override'] ) {
1419
- $all_cats = $this->all_cats(true, 'ID');
1420
- } else {
1421
- $all_cats = $this->all_cats(false, 'ID');
1422
- }
1423
-
1424
- $cats_string = '';
1425
- foreach ( $all_cats as $cat ) {
1426
- ('' == $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
1427
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
1428
- }
1429
- if ( empty($cats_string) ) {
1430
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1431
- } else {
1432
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats_string);
1433
- }
1434
- }
1435
- } elseif ( !empty($_GET['s2mu_unsubscribe']) ) {
1436
- // unsubscribe from a blog
1437
- $unsub_id = intval($_GET['s2mu_unsubscribe']);
1438
- if ( $unsub_id >= 0 ) {
1439
- switch_to_blog($unsub_id);
1440
-
1441
- $user_ID = get_current_user_id();
1442
-
1443
- // delete subscription to all categories on that blog
1444
- $cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
1445
- $cats = explode(',', $cats);
1446
- if ( !is_array($cats) ) {
1447
- $cats = array($cats);
1448
- }
1449
-
1450
- foreach ( $cats as $id ) {
1451
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1452
- }
1453
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1454
-
1455
- // add an action hook for external manipulation of blog and user data
1456
- do_action_ref_array('subscribe2_wpmu_unsubscribe', array($user_ID, $unsub_id));
1457
-
1458
- restore_current_blog();
1459
- }
1460
- }
1461
-
1462
- if ( !is_user_member_of_blog($user_ID) ) {
1463
- $user_blogs = get_active_blog_for_user($user_ID);
1464
- if ( is_array($user_blogs) ) {
1465
- switch_to_blog(key($user_blogs));
1466
- } else {
1467
- // no longer a member of a blog
1468
- wp_redirect(get_option('siteurl')); // redirect to front page
1469
- exit(0);
1470
- }
1471
- }
1472
-
1473
- // redirect to profile page
1474
- if ( current_user_can('manage_options') ) {
1475
- $url = get_option('siteurl') . '/wp-admin/users.php?page=s2_users';
1476
- wp_redirect($url);
1477
- exit(0);
1478
- } else {
1479
- $url = get_option('siteurl') . '/wp-admin/profile.php?page=s2_users';
1480
- wp_redirect($url);
1481
- exit(0);
1482
- }
1483
- } // end wpmu_subscribe()
1484
-
1485
- /**
1486
- Autosubscribe registered users to newly created categories
1487
- if registered user has selected this option
1488
- */
1489
- function new_category($new_category='') {
1490
- if ( 'no' == $this->subscribe2_options['show_autosub'] ) { return; }
1491
- // don't subscribe to individual new categories if we are doing digest emails
1492
- if ( $this->subscribe2_options['email_freq'] != 'never' ) { return; }
1493
- global $wpdb;
1494
-
1495
- if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
1496
- if ( $this->s2_mu ) {
1497
- $sql = "SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key='" . $this->get_usermeta_keyname('s2_autosub') . "' AND a.meta_value='yes' AND b.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'";
1498
- } else {
1499
- $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='" . $this->get_usermeta_keyname('s2_autosub') . "' AND $wpdb->usermeta.meta_value='yes'";
1500
- }
1501
- $user_IDs = $wpdb->get_col($sql);
1502
- if ( '' == $user_IDs ) { return; }
1503
-
1504
- foreach ( $user_IDs as $user_ID ) {
1505
- $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
1506
- if ( empty($old_cats) ) {
1507
- $newcats = (array)$new_category;
1508
- } else {
1509
- $old_cats = explode(',', $old_cats);
1510
- $newcats = array_merge($old_cats, (array)$new_category);
1511
- }
1512
- // add subscription to these cat IDs
1513
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $new_category, $new_category);
1514
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
1515
- }
1516
- } elseif ( 'exclude' == $this->subscribe2_options['show_autosub'] ) {
1517
- $excluded_cats = explode(',', $this->subscribe2_options['exclude']);
1518
- $excluded_cats[] = $new_category;
1519
- $this->subscribe2_options['exclude'] = implode(',', $excluded_cats);
1520
- update_option('subscribe2_options', $this->subscribe2_options);
1521
- }
1522
- } // end new_category()
1523
-
1524
- function delete_category($deleted_category='') {
1525
- global $wpdb;
1526
-
1527
- if ( $this->s2_mu ) {
1528
- $sql = "SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$deleted_category' AND b.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'";
1529
- } else {
1530
- $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$deleted_category'";
1531
- }
1532
- $user_IDs = $wpdb->get_col($sql);
1533
- if ( '' == $user_IDs ) { return; }
1534
-
1535
- foreach ( $user_IDs as $user_ID ) {
1536
- $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
1537
- if ( !is_array($old_cats) ) {
1538
- $old_cats = array($old_cats);
1539
- }
1540
- // add subscription to these cat IDs
1541
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $deleted_category);
1542
- $remain = array_diff($old_cats, (array)$deleted_category);
1543
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
1544
- }
1545
- } // end delete_category()
1546
-
1547
- /**
1548
- Get admin data from record 1 or first user with admin rights
1549
- */
1550
- function get_userdata($admin_id) {
1551
- global $wpdb, $userdata;
1552
-
1553
- if ( is_numeric($admin_id) ) {
1554
- $admin = get_userdata($admin_id);
1555
- } elseif ( $admin_id == 'admin' ) {
1556
- //ensure compatibility with < 4.16
1557
- $admin = get_userdata('1');
1558
- } else {
1559
- $admin = &$userdata;
1560
- }
1561
-
1562
- if ( empty($admin) || $admin->ID == 0 ) {
1563
- $role = array('role' => 'administrator');
1564
- $wp_user_query = get_users( $role );
1565
- $admin = $wp_user_query[0];
1566
- }
1567
-
1568
- return $admin;
1569
- } //end get_userdata()
1570
-
1571
- /* ===== Menus ===== */
1572
- /**
1573
- Our management page
1574
- */
1575
- function manage_menu() {
1576
- global $wpdb, $s2nonce;
1577
-
1578
- //Get Registered Subscribers for bulk management
1579
- $registered = $this->get_registered();
1580
- $all_users = $this->get_all_registered();
1581
-
1582
- // was anything POSTed ?
1583
- if ( isset($_POST['s2_admin']) ) {
1584
- check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
1585
- if ( $_POST['addresses'] ) {
1586
- $sub_error = '';
1587
- $unsub_error = '';
1588
- foreach ( preg_split ("|[\s,]+|", $_POST['addresses']) as $email ) {
1589
- $email = $this->sanitize_email($email);
1590
- if ( is_email($email) && $_POST['subscribe'] ) {
1591
- if ( $this->is_public($email) !== false ) {
1592
- ('' == $sub_error) ? $sub_error = "$email" : $sub_error .= ", $email";
1593
- continue;
1594
- }
1595
- $this->activate($email);
1596
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) subscribed!', 'subscribe2') . "</strong></p></div>";
1597
- } elseif ( is_email($email) && $_POST['unsubscribe'] ) {
1598
- if ( $this->is_public($email) === false ) {
1599
- ('' == $unsub_error) ? $unsub_error = "$email" : $unsub_error .= ", $email";
1600
- continue;
1601
- }
1602
- $this->delete($email);
1603
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) unsubscribed!', 'subscribe2') . "</strong></p></div>";
1604
- }
1605
- }
1606
- if ( $sub_error != '' ) {
1607
- echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were already subscribed' , 'subscribe2') . ":<br />$sub_error</strong></p></div>";
1608
- }
1609
- if ( $unsub_error != '' ) {
1610
- echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were not in the database' , 'subscribe2') . ":<br />$unsub_error</strong></p></div>";
1611
- }
1612
- echo $message;
1613
- $_POST['what'] = 'confirmed';
1614
- } elseif ( $_POST['process'] ) {
1615
- if ( $_POST['delete'] ) {
1616
- foreach ( $_POST['delete'] as $address ) {
1617
- $this->delete($address);
1618
- }
1619
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) deleted!', 'subscribe2') . "</strong></p></div>";
1620
- }
1621
- if ( $_POST['confirm'] ) {
1622
- foreach ( $_POST['confirm'] as $address ) {
1623
- $this->toggle($this->sanitize_email($address));
1624
- }
1625
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
1626
- }
1627
- if ( $_POST['unconfirm'] ) {
1628
- foreach ( $_POST['unconfirm'] as $address ) {
1629
- $this->toggle($this->sanitize_email($address));
1630
- }
1631
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
1632
- }
1633
- echo $message;
1634
- } elseif ( $_POST['searchterm'] ) {
1635
- $confirmed = $this->get_public();
1636
- $unconfirmed = $this->get_public(0);
1637
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1638
- foreach ( $subscribers as $subscriber ) {
1639
- if ( is_numeric(stripos($subscriber, $_POST['searchterm'])) ) {
1640
- $result[] = $subscriber;
1641
- }
1642
- }
1643
- } elseif ( $_POST['remind'] ) {
1644
- $this->remind($_POST['reminderemails']);
1645
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Reminder Email(s) Sent!', 'subscribe2') . "</strong></p></div>";
1646
- } elseif ( $_POST['sub_categories'] && 'subscribe' == $_POST['manage'] ) {
1647
- $this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1648
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Subscribed!', 'subscribe2') . "</strong></p></div>";
1649
- } elseif ( $_POST['sub_categories'] && 'unsubscribe' == $_POST['manage'] ) {
1650
- $this->unsubscribe_registered_users($_POST['emails'], $_POST['category']);
1651
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Unsubscribed!', 'subscribe2') . "</strong></p></div>";
1652
- } elseif ( $_POST['sub_format'] ) {
1653
- $this->format_change( $_POST['format'], $_POST['emails'] );
1654
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Format updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
1655
- } elseif ( $_POST['sub_digest'] ) {
1656
- $this->digest_change( $_POST['sub_category'], $_POST['emails'] );
1657
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Digest Subscription updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
1658
- }
1659
- }
1660
-
1661
- //Get Public Subscribers once for filter
1662
- $confirmed = $this->get_public();
1663
- $unconfirmed = $this->get_public(0);
1664
- // safety check for our arrays
1665
- if ( '' == $confirmed ) { $confirmed = array(); }
1666
- if ( '' == $unconfirmed ) { $unconfirmed = array(); }
1667
- if ( '' == $registered ) { $registered = array(); }
1668
- if ( '' == $all_users ) { $all_users = array(); }
1669
-
1670
- $reminderform = false;
1671
- $urlpath = str_replace("\\", "/", S2PATH);
1672
- $urlpath = trailingslashit(get_option('siteurl')) . substr($urlpath,strpos($urlpath, "wp-content/"));
1673
- if ( isset($_GET['s2page']) ) {
1674
- $page = (int) $_GET['s2page'];
1675
- } else {
1676
- $page = 1;
1677
- }
1678
-
1679
- if ( isset($_POST['what']) ) {
1680
- $page = 1;
1681
- if ( 'all' == $_POST['what'] ) {
1682
- $what = 'all';
1683
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1684
- } elseif ( 'public' == $_POST['what'] ) {
1685
- $what = 'public';
1686
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1687
- } elseif ( 'confirmed' == $_POST['what'] ) {
1688
- $what = 'confirmed';
1689
- $subscribers = $confirmed;
1690
- } elseif ( 'unconfirmed' == $_POST['what'] ) {
1691
- $what = 'unconfirmed';
1692
- $subscribers = $unconfirmed;
1693
- if ( !empty($subscribers) ) {
1694
- $reminderemails = implode(",", $subscribers);
1695
- $reminderform = true;
1696
- }
1697
- } elseif ( is_numeric($_POST['what']) ) {
1698
- $what = intval($_POST['what']);
1699
- $subscribers = $this->get_registered("cats=$what");
1700
- } elseif ( 'registered' == $_POST['what'] ) {
1701
- $what = 'registered';
1702
- $subscribers = $registered;
1703
- } elseif ( 'all_users' == $_POST['what'] ) {
1704
- $what = 'all_users';
1705
- $subscribers = $all_users;
1706
- }
1707
- } elseif ( isset($_GET['what']) ) {
1708
- if ( 'all' == $_GET['what'] ) {
1709
- $what = 'all';
1710
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1711
- } elseif ( 'public' == $_GET['what'] ) {
1712
- $what = 'public';
1713
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1714
- } elseif ( 'confirmed' == $_GET['what'] ) {
1715
- $what = 'confirmed';
1716
- $subscribers = $confirmed;
1717
- } elseif ( 'unconfirmed' == $_GET['what'] ) {
1718
- $what = 'unconfirmed';
1719
- $subscribers = $unconfirmed;
1720
- if ( !empty($subscribers) ) {
1721
- $reminderemails = implode(",", $subscribers);
1722
- $reminderform = true;
1723
- }
1724
- } elseif ( is_numeric($_GET['what']) ) {
1725
- $what = intval($_GET['what']);
1726
- $subscribers = $this->get_registered("cats=$what");
1727
- } elseif ( 'registered' == $_GET['what'] ) {
1728
- $what = 'registered';
1729
- $subscribers = $registered;
1730
- } elseif ( 'all_users' == $_GET['what'] ) {
1731
- $what = 'all_users';
1732
- $subscribers = $all_users;
1733
- }
1734
- } else {
1735
- $what = 'all';
1736
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1737
- }
1738
- if ( $_POST['searchterm'] ) {
1739
- $subscribers = &$result;
1740
- $what = 'public';
1741
- }
1742
-
1743
- if ( !empty($subscribers) ) {
1744
- natcasesort($subscribers);
1745
- // Displays a page number strip - adapted from code in Akismet
1746
- $args['what'] = $what;
1747
- $total_subscribers = count($subscribers);
1748
- $total_pages = ceil($total_subscribers / $this->subscribe2_options['entries']);
1749
- $strip = '';
1750
- if ( $page > 1 ) {
1751
- $args['s2page'] = $page - 1;
1752
- $strip .= '<a class="prev" href="' . clean_url(add_query_arg($args)) . '">&laquo; '. __('Previous Page', 'subscribe2') .'</a>' . "\n";
1753
- }
1754
- if ( $total_pages > 1 ) {
1755
- for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) {
1756
- if ( $page == $page_num ) {
1757
- $strip .= "<strong>Page " . $page_num . "</strong>\n";
1758
- } else {
1759
- if ( $page_num < 3 || ( $page_num >= $page - 2 && $page_num <= $page + 2 ) || $page_num > $total_pages - 2 ) {
1760
- $args['s2page'] = $page_num;
1761
- $strip .= "<a class=\"page-numbers\" href=\"" . clean_url(add_query_arg($args)) . "\">" . $page_num . "</a>\n";
1762
- $trunc = true;
1763
- } elseif ( $trunc == true ) {
1764
- $strip .= "...\n";
1765
- $trunc = false;
1766
- }
1767
- }
1768
- }
1769
- }
1770
- if ( ( $page ) * $this->subscribe2_options['entries'] < $total_subscribers ) {
1771
- $args['s2page'] = $page + 1;
1772
- $strip .= "<a class=\"next\" href=\"" . clean_url(add_query_arg($args)) . "\">". __('Next Page', 'subscribe2') . " &raquo;</a>\n";
1773
- }
1774
- }
1775
-
1776
- // show our form
1777
- echo "<div class=\"wrap\">";
1778
- echo "<div id=\"icon-tools\" class=\"icon32\"></div>";
1779
- echo "<h2>" . __('Manage Subscribers', 'subscribe2') . "</h2>\r\n";
1780
- echo "<form method=\"post\" action=\"\">\r\n";
1781
- if ( function_exists('wp_nonce_field') ) {
1782
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1783
- }
1784
- echo "<div class=\"s2_admin\" id=\"s2_add_subscribers\">\r\n";
1785
- echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
1786
- echo "<p>" . __('Enter addresses, one per line or comma-separated', 'subscribe2') . "<br />\r\n";
1787
- echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea></p>\r\n";
1788
- echo "<input type=\"hidden\" name=\"s2_admin\" />\r\n";
1789
- echo "<p class=\"submit\" style=\"border-top: none;\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
1790
- echo "&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" /></p>\r\n";
1791
- echo "</div>\r\n";
1792
-
1793
- // subscriber lists
1794
- echo "<div class=\"s2_admin\" id=\"s2_current_subscribers\">\r\n";
1795
- echo "<h2>" . __('Current Subscribers', 'subscribe2') . "</h2>\r\n";
1796
- echo "<br />";
1797
- $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1798
- echo "<br /><br />";
1799
- // show the selected subscribers
1800
- $alternate = 'alternate';
1801
- echo "<table class=\"widefat\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">";
1802
- $searchterm = ( $_POST['searchterm'] ) ? $_POST['searchterm'] : '';
1803
- echo "<tr class=\"alternate\"><td colspan=\"3\"><input type=\"text\" name=\"searchterm\" value=\"" . $searchterm . "\" /></td>\r\n";
1804
- echo "<td><input type=\"submit\" class=\"button-secondary\" name=\"search\" value=\"" . __('Search Subscribers', 'subscribe2') . "\" /></td>\r\n";
1805
- if ( $reminderform ) {
1806
- echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"reminderemails\" value=\"" . $reminderemails . "\" />\r\n";
1807
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"remind\" value=\"" . __('Send Reminder Email', 'subscribe2') . "\" /></td>\r\n";
1808
- } else {
1809
- echo "<td width=\"25%\"></td>";
1810
- }
1811
- if ( !empty($subscribers) ) {
1812
- $exportcsv = implode(",\r\n", $subscribers);
1813
- echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"exportcsv\" value=\"" . $what . "\" />\r\n";
1814
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"csv\" value=\"" . __('Save Emails to CSV File', 'subscribe2') . "\" /></td>\r\n";
1815
- } else {
1816
- echo "<td width=\"25%\"></td>";
1817
- }
1818
- echo "</tr>";
1819
-
1820
- if ( !empty($subscribers) ) {
1821
- echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
1822
- echo "<td colspan=\"3\" align=\"right\">" . $strip . "</td></tr>\r\n";
1823
- }
1824
- if ( !empty($subscribers) ) {
1825
- if ( is_int($this->subscribe2_options['entries']) ) {
1826
- $subscriber_chunks = array_chunk($subscribers, $this->subscribe2_options['entries']);
1827
- } else {
1828
- $subscriber_chunks = array_chunk($subscribers, 25);
1829
- }
1830
- $chunk = $page - 1;
1831
- $subscribers = $subscriber_chunks[$chunk];
1832
- echo "<tr class=\"alternate\" style=\"height:1.5em;\">\r\n";
1833
- echo "<td width=\"4%\" align=\"center\">";
1834
- echo "<img src=\"" . $urlpath . "include/accept.png\" alt=\"&lt;\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" /></td>\r\n";
1835
- echo "<td width=\"4%\" align=\"center\">";
1836
- echo "<img src=\"" . $urlpath . "include/exclamation.png\" alt=\"&gt;\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" /></td>\r\n";
1837
- echo "<td width=\"4%\" align=\"center\">";
1838
- echo "<img src=\"" . $urlpath . "include/cross.png\" alt=\"X\" title=\"" . __('Delete this email address', 'subscribe2') . "\" /></td><td colspan=\"3\"></td></tr>\r\n";
1839
- echo "<tr class=\"\"><td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"confirm_checkall\" /></td>\r\n";
1840
- echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"unconfirm_checkall\" /></td>\r\n";
1841
- echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"delete_checkall\" /></td>\r\n";
1842
- echo "<td colspan =\"3\" align=\"left\"><strong>" . __('Select / Unselect All', 'subscribe2') . "</strong></td></tr>\r\n";
1843
-
1844
- foreach ( $subscribers as $subscriber ) {
1845
- echo "<tr class=\"$alternate\" style=\"height:1.5em;\">";
1846
- echo "<td align=\"center\">\r\n";
1847
- if ( in_array($subscriber, $confirmed) ) {
1848
- echo "</td><td align=\"center\">\r\n";
1849
- echo "<input class=\"unconfirm_checkall\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"unconfirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
1850
- echo "<td align=\"center\">\r\n";
1851
- echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
1852
- echo "</td>\r\n";
1853
- echo "<td colspan=\"3\"><span style=\"color:#006600\">&#x221A;&nbsp;&nbsp;</span><abbr title=\"" . $this->signup_ip($subscriber) . "\"><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a></abbr>\r\n";
1854
- echo "(<span style=\"color:#006600\">" . $this->signup_date($subscriber) . "</span>)\r\n";
1855
- } elseif ( in_array($subscriber, $unconfirmed) ) {
1856
- echo "<input class=\"confirm_checkall\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"confirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
1857
- echo "<td align=\"center\"></td>\r\n";
1858
- echo "<td align=\"center\">\r\n";
1859
- echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
1860
- echo "</td>\r\n";
1861
- echo "<td colspan=\"3\"><span style=\"color:#FF0000\">&nbsp;!&nbsp;&nbsp;&nbsp;</span><abbr title=\"" . $this->signup_ip($subscriber) . "\"><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a></abbr>\r\n";
1862
- echo "(<span style=\"color:#FF0000\">" . $this->signup_date($subscriber) . "</span>)\r\n";
1863
- } elseif ( in_array($subscriber, $all_users) ) {
1864
- $user_info = get_user_by('email', $subscriber);
1865
- echo "</td><td align=\"center\"></td><td align=\"center\"></td>\r\n";
1866
- echo "<td colspan=\"3\"><span style=\"color:#006600\">&reg;&nbsp;&nbsp;</span><abbr title=\"" . $user_info->user_login . "\"><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a></abbr>\r\n";
1867
- echo "(<a href=\"" . get_option('siteurl') . "/wp-admin/admin.php?page=s2&amp;email=" . urlencode($subscriber) . "\">" . __('edit', 'subscribe2') . "</a>)\r\n";
1868
- }
1869
- echo "</td></tr>\r\n";
1870
- ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1871
- }
1872
- } else {
1873
- if ( $_POST['searchterm'] ) {
1874
- echo "<tr><td colspan=\"6\" align=\"center\"><b>" . __('No matching subscribers found', 'subscribe2') . "</b></td></tr>\r\n";
1875
- } else {
1876
- echo "<tr><td colspan=\"6\" align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1877
- }
1878
- }
1879
- if ( !empty($subscribers) ) {
1880
- echo "<tr class=\"$alternate\"><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
1881
- echo "<td colspan=\"3\" align=\"right\">" . $strip . "</td></tr>\r\n";
1882
- }
1883
- echo "</table>\r\n";
1884
- echo "</div>\r\n";
1885
-
1886
- // show bulk managment form if filtered in some Registered Users
1887
- if ( in_array($what, array('registered', 'all_users')) || is_numeric($what) ) {
1888
- $subscribers_string = implode(',', $subscribers);
1889
- echo "<div class=\"s2_admin\" id=\"s2_bulk_manage\">\r\n";
1890
- echo "<h2>" . __('Bulk Management', 'subscribe2') . "</h2>\r\n";
1891
- if ( $this->subscribe2_options['email_freq'] == 'never' ) {
1892
- echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
1893
- echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1894
- echo "<br />" . __('Action to perform', 'subscribe2') . ":\r\n";
1895
- echo "<label><input type=\"radio\" name=\"manage\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1896
- echo "<label><input type=\"radio\" name=\"manage\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . "</label><br /><br />\r\n";
1897
- echo "<input type=\"hidden\" name=\"emails\" value=\"$subscribers_string\" />\r\n";
1898
- $this->display_category_form();
1899
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_categories\" value=\"" . __('Bulk Update Categories', 'subscribe2') . "\" /></p>";
1900
-
1901
- echo "<br />" . __('Send email as', 'subscribe2') . ":\r\n";
1902
- echo "<label><input type=\"radio\" name=\"format\" value=\"html\" /> " . __('HTML - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1903
- echo "<label><input type=\"radio\" name=\"format\" value=\"html_excerpt\" /> " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1904
- echo "<label><input type=\"radio\" name=\"format\" value=\"post\" /> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1905
- echo "<label><input type=\"radio\" name=\"format\" value=\"excerpt\" checked=\"checked\" /> " . __('Plain Text - Excerpt', 'subscribe2') . "</label>\r\n";
1906
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_format\" value=\"" . __('Bulk Update Format', 'subscribe2') . "\" /></p>";
1907
- } else {
1908
- echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
1909
- echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1910
- echo "<br />" . __('Subscribe Selected Users to recieve a periodic digest notification', 'subscribe2') . ":\r\n";
1911
- echo "<label><input type=\"radio\" name=\"sub_category\" value=\"digest\" checked=\"checked\" /> ";
1912
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1913
- echo "<label><input type=\"radio\" name=\"sub_category\" value=\"-1\" /> ";
1914
- echo __('No', 'subscribe2') . "</label>";
1915
- echo "<input type=\"hidden\" name=\"emails\" value=\"$subscribers_string\" />\r\n";
1916
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_digest\" value=\"" . __('Bulk Update Digest Subscription', 'subscribe2') . "\" /></p>";
1917
- }
1918
- echo "</div>\r\n";
1919
- }
1920
- echo "</form></div>\r\n";
1921
-
1922
- include(ABSPATH . 'wp-admin/admin-footer.php');
1923
- // just to be sure
1924
- die;
1925
- } // end manage_menu()
1926
-
1927
- /**
1928
- Our options page
1929
- */
1930
- function options_menu() {
1931
- global $s2nonce, $wpdb, $wp_version;
1932
-
1933
- // send error message if no WordPress page exists
1934
- $sql = "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1";
1935
- $id = $wpdb->get_var($sql);
1936
- if ( empty($id) ) {
1937
- echo "<div id=\"message\" class=\"error\"><p><strong>$this->no_page</strong></p></div>";
1938
- }
1939
-
1940
- // was anything POSTed?
1941
- if ( isset( $_POST['s2_admin']) ) {
1942
- check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
1943
- if ( $_POST['reset'] ) {
1944
- $this->reset();
1945
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_reset</strong></p></div>";
1946
- } elseif ( $_POST['preview'] ) {
1947
- global $user_email;
1948
- $this->preview_email = true;
1949
- if ( 'never' == $this->subscribe2_options['email_freq'] ) {
1950
- $post = get_posts('numberposts=1');
1951
- $this->publish($post[0], $user_email);
1952
- } else {
1953
- $this->subscribe2_cron($user_email);
1954
- }
1955
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Preview message(s) sent to logged in user', 'subscribe2') . "</strong></p></div>";
1956
- } elseif ( $_POST['resend'] ) {
1957
- $status = $this->subscribe2_cron('', 'resend');
1958
- if ( $status === false ) {
1959
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('The Digest Notification email contained no post information. No email was sent', 'subscribe2') . "</strong></p></div>";
1960
- } else {
1961
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Attempt made to resend the Digest Notification email', 'subscribe2') . "</strong></p></div>";
1962
- }
1963
- } elseif ( $_POST['submit'] ) {
1964
- // BCClimit
1965
- if ( is_numeric($_POST['bcc']) && $_POST['bcc'] >= 0 ) {
1966
- $this->subscribe2_options['bcclimit'] = $_POST['bcc'];
1967
- }
1968
- // admin_email
1969
- $this->subscribe2_options['admin_email'] = $_POST['admin_email'];
1970
-
1971
- // send as blogname, author or admin?
1972
- if ( is_numeric($_POST['sender']) ) {
1973
- $sender = $_POST['sender'];
1974
- } elseif ($_POST['sender'] == 'author') {
1975
- $sender = 'author';
1976
- } else {
1977
- $sender = 'blogname';
1978
- }
1979
- $this->subscribe2_options['sender'] = $sender;
1980
-
1981
- // send email for pages, private and password protected posts
1982
- $this->subscribe2_options['stylesheet'] = $_POST['stylesheet'];
1983
- $this->subscribe2_options['pages'] = $_POST['pages'];
1984
- $this->subscribe2_options['password'] = $_POST['password'];
1985
- $this->subscribe2_options['private'] = $_POST['private'];
1986
- $this->subscribe2_options['cron_order'] = $_POST['cron_order'];
1987
- $this->subscribe2_options['tracking'] = $_POST['tracking'];
1988
-
1989
- // send per-post or digest emails
1990
- $email_freq = $_POST['email_freq'];
1991
- $scheduled_time = wp_next_scheduled('s2_digest_cron');
1992
- if ( $email_freq != $this->subscribe2_options['email_freq'] || $_POST['hour'] != date('H', $scheduled_time) ) {
1993
- // make sure the timezone strings are right
1994
- if ( function_exists('date_default_timezone_get') && date_default_timezone_get() != get_option('timezone_string') ) {
1995
- date_default_timezone_set(get_option('timezone_string'));
1996
- }
1997
- $this->subscribe2_options['email_freq'] = $email_freq;
1998
- wp_clear_scheduled_hook('s2_digest_cron');
1999
- $scheds = (array)wp_get_schedules();
2000
- $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
2001
- if ( $interval == 0 ) {
2002
- // if we are on per-post emails remove last_cron entry
2003
- unset($this->subscribe2_options['last_s2cron']);
2004
- unset($this->subscribe2_options['previous_s2cron']);
2005
- } else {
2006
- // if we are using digest schedule the event and prime last_cron as now
2007
- $time = time() + $interval;
2008
- if ( $interval < 86400 ) {
2009
- // Schedule CRON events occurring less than daily starting now and periodically thereafter
2010
- $maybe_time = mktime($_POST['hour'], 0, 0, date('m', time()), date('d', time()), date('Y', time()));
2011
- // is maybe_time in the future
2012
- $offset = $maybe_time - time();
2013
- // is maybe_time + $interval in the future
2014
- $offset2 = ($maybe_time + $interval) - time();
2015
- if ( $offset < 0 ) {
2016
- if ( $offset2 < 0 ) {
2017
- $timestamp = &$time;
2018
- } else {
2019
- $timestamp = $maybe_time + $interval;
2020
- }
2021
- } else {
2022
- $timestamp = &$maybe_time;
2023
- }
2024
- } else {
2025
- // Schedule other CRON events starting at user defined hour and periodically thereafter
2026
- $timestamp = mktime($_POST['hour'], 0, 0, date('m', $time), date('d', $time), date('Y', $time));
2027
- }
2028
- wp_schedule_event($timestamp, $email_freq, 's2_digest_cron');
2029
- if ( !isset($this->subscribe2_options['last_s2cron']) ) {
2030
- $this->subscribe2_options['last_s2cron'] = current_time('mysql');
2031
- }
2032
- }
2033
- }
2034
-
2035
- // email subject and body templates
2036
- // ensure that are not empty before updating
2037
- if ( !empty($_POST['notification_subject']) ) {
2038
- $this->subscribe2_options['notification_subject'] = $_POST['notification_subject'];
2039
- }
2040
- if ( !empty($_POST['mailtext']) ) {
2041
- $this->subscribe2_options['mailtext'] = $_POST['mailtext'];
2042
- }
2043
- if ( !empty($_POST['confirm_subject']) ) {
2044
- $this->subscribe2_options['confirm_subject'] = $_POST['confirm_subject'];
2045
- }
2046
- if ( !empty($_POST['confirm_email']) ) {
2047
- $this->subscribe2_options['confirm_email'] = $_POST['confirm_email'];
2048
- }
2049
- if ( !empty($_POST['remind_subject']) ) {
2050
- $this->subscribe2_options['remind_subject'] = $_POST['remind_subject'];
2051
- }
2052
- if ( !empty($_POST['remind_email']) ) {
2053
- $this->subscribe2_options['remind_email'] = $_POST['remind_email'];
2054
- }
2055
-
2056
- // excluded categories
2057
- if ( !empty($_POST['category']) ) {
2058
- sort($_POST['category']);
2059
- $exclude_cats = implode(',', $_POST['category']);
2060
- } else {
2061
- $exclude_cats = '';
2062
- }
2063
- $this->subscribe2_options['exclude'] = $exclude_cats;
2064
- // allow override?
2065
- ( isset($_POST['reg_override']) ) ? $override = '1' : $override = '0';
2066
- $this->subscribe2_options['reg_override'] = $override;
2067
-
2068
- // excluded formats
2069
- if ( !empty($_POST['format']) ) {
2070
- $exclude_formats = implode(',', $_POST['format']);
2071
- } else {
2072
- $exclude_formats = '';
2073
- }
2074
- $this->subscribe2_options['exclude_formats'] = $exclude_formats;
2075
-
2076
- // default WordPress page where Subscribe2 token is placed
2077
- if ( is_numeric($_POST['page']) && $_POST['page'] >= 0 ) {
2078
- $this->subscribe2_options['s2page'] = $_POST['page'];
2079
- }
2080
-
2081
- // Number of subscriber per page
2082
- if ( is_numeric($_POST['entries']) && $_POST['entries'] > 0 ) {
2083
- $this->subscribe2_options['entries'] = (int)$_POST['entries'];
2084
- }
2085
-
2086
- // show meta link?
2087
- ( $_POST['show_meta'] == '1' ) ? $showmeta = '1' : $showmeta = '0';
2088
- $this->subscribe2_options['show_meta'] = $showmeta;
2089
-
2090
- // show button?
2091
- ( $_POST['show_button'] == '1' ) ? $showbutton = '1' : $showbutton = '0';
2092
- $this->subscribe2_options['show_button'] = $showbutton;
2093
-
2094
- // enable AJAX style form
2095
- ( $_POST['ajax'] == '1' ) ? $ajax = '1' : $ajax = '0';
2096
- $this->subscribe2_options['ajax'] = $ajax;
2097
-
2098
- // show widget in Presentation->Widgets
2099
- ( $_POST['widget'] == '1' ) ? $showwidget = '1' : $showwidget = '0';
2100
- $this->subscribe2_options['widget'] = $showwidget;
2101
-
2102
- // show counterwidget in Presentation->Widgets
2103
- ( $_POST['counterwidget'] == '1' ) ? $showcounterwidget = '1' : $showcounterwidget = '0';
2104
- $this->subscribe2_options['counterwidget'] = $showcounterwidget;
2105
-
2106
- // Subscribe2 over ride postmeta checked by default
2107
- ( $_POST['s2meta_default'] == '1' ) ? $s2meta_default = '1' : $s2meta_default = '0';
2108
- $this->subscribe2_options['s2meta_default'] = $s2meta_default;
2109
-
2110
- //automatic subscription
2111
- $this->subscribe2_options['autosub'] = $_POST['autosub'];
2112
- $this->subscribe2_options['newreg_override'] = $_POST['newreg_override'];
2113
- $this->subscribe2_options['wpregdef'] = $_POST['wpregdef'];
2114
- $this->subscribe2_options['autoformat'] = $_POST['autoformat'];
2115
- $this->subscribe2_options['show_autosub'] = $_POST['show_autosub'];
2116
- $this->subscribe2_options['autosub_def'] = $_POST['autosub_def'];
2117
- $this->subscribe2_options['comment_subs'] = $_POST['comment_subs'];
2118
-
2119
- //barred domains
2120
- $this->subscribe2_options['barred'] = $_POST['barred'];
2121
-
2122
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_saved</strong></p></div>";
2123
- update_option('subscribe2_options', $this->subscribe2_options);
2124
- }
2125
- }
2126
- // show our form
2127
- echo "<div class=\"wrap\">";
2128
- echo "<div id=\"icon-options-general\" class=\"icon32\"></div>";
2129
- echo "<h2>" . __('Subscribe2 Settings', 'subscribe2') . "</h2>\r\n";
2130
- echo "<a href=\"http://subscribe2.wordpress.com/\">" . __('Plugin Blog', 'subscribe2') . "</a> | ";
2131
- echo "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904\">" . __('Make a donation via PayPal', 'subscribe2') . "</a>";
2132
- echo "<form method=\"post\" action=\"\">\r\n";
2133
- if ( function_exists('wp_nonce_field') ) {
2134
- wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
2135
- }
2136
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
2137
- echo "<input type=\"hidden\" id=\"jsbcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" />";
2138
- echo "<input type=\"hidden\" id=\"jspage\" value=\"" . $this->subscribe2_options['s2page'] . "\" />";
2139
- echo "<input type=\"hidden\" id=\"jsentries\" value=\"" . $this->subscribe2_options['entries'] . "\" />";
2140
-
2141
- // settings for outgoing emails
2142
- echo "<div class=\"s2_admin\" id=\"s2_notification_settings\">\r\n";
2143
- echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
2144
- echo __('Restrict the number of recipients per email to (0 for unlimited)', 'subscribe2') . ': ';
2145
- echo "<span id=\"s2bcc_1\"><span id=\"s2bcc\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['bcclimit'] . "</span> ";
2146
- echo "<a href=\"#\" onclick=\"s2_show('bcc'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
2147
- echo "<span id=\"s2bcc_2\">\r\n";
2148
- echo "<input type=\"text\" name=\"bcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" size=\"3\" />\r\n";
2149
- echo "<a href=\"#\" onclick=\"s2_update('bcc'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
2150
- echo "<a href=\"#\" onclick=\"s2_revert('bcc'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
2151
-
2152
- echo "<br /><br />" . __('Send Admins notifications for new', 'subscribe2') . ': ';
2153
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"subs\"" . checked($this->subscribe2_options['admin_email'], 'subs', false) . " />\r\n";
2154
- echo __('Subscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
2155
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"unsubs\"" . checked($this->subscribe2_options['admin_email'], 'unsubs', false) . " />\r\n";
2156
- echo __('Unsubscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
2157
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"both\"" . checked($this->subscribe2_options['admin_email'], 'both', false) . " />\r\n";
2158
- echo __('Both', 'subscribe2') . "</label>&nbsp;&nbsp;";
2159
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"none\"" . checked($this->subscribe2_options['admin_email'], 'none', false) . " />\r\n";
2160
- echo __('Neither', 'subscribe2') . "</label><br /><br />\r\n";
2161
-
2162
- echo __('Include theme CSS stylesheet in HTML notifications', 'subscribe2') . ': ';
2163
- echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"yes\"" . checked($this->subscribe2_options['stylesheet'], 'yes', false) . " /> ";
2164
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2165
- echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"no\"" . checked($this->subscribe2_options['stylesheet'], 'no', false) . " /> ";
2166
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
2167
-
2168
- echo __('Send Emails for Pages', 'subscribe2') . ': ';
2169
- echo "<label><input type=\"radio\" name=\"pages\" value=\"yes\"" . checked($this->subscribe2_options['pages'], 'yes', false) . " /> ";
2170
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2171
- echo "<label><input type=\"radio\" name=\"pages\" value=\"no\"" . checked($this->subscribe2_options['pages'], 'no', false) . " /> ";
2172
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
2173
- $s2_post_types = apply_filters('s2_post_types', NULL);
2174
- if ( !empty($s2_post_types) ) {
2175
- $types = '';
2176
- echo __('Subscribe2 will send email notifications for the following custom post types', 'subscribe2') . ': <strong>';
2177
- foreach ($s2_post_types as $type) {
2178
- ('' == $types) ? $types = ucwords($type) : $types .= ", " . ucwords($type);
2179
- }
2180
- echo $types . "</strong><br /><br />\r\n";
2181
- }
2182
- echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
2183
- echo "<label><input type=\"radio\" name=\"password\" value=\"yes\"" . checked($this->subscribe2_options['password'], 'yes', false) . " /> ";
2184
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2185
- echo "<label><input type=\"radio\" name=\"password\" value=\"no\"" . checked($this->subscribe2_options['password'], 'no', false) . " /> ";
2186
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
2187
- echo __('Send Emails for Private Posts', 'subscribe2') . ': ';
2188
- echo "<label><input type=\"radio\" name=\"private\" value=\"yes\"" . checked($this->subscribe2_options['private'], 'yes', false) . " /> ";
2189
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2190
- echo "<label><input type=\"radio\" name=\"private\" value=\"no\"" . checked($this->subscribe2_options['private'], 'no', false) . " /> ";
2191
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
2192
- echo __('Send Email From', 'subscribe2') . ': ';
2193
- echo "<label>\r\n";
2194
- $this->admin_dropdown(true);
2195
- echo "</label><br /><br />\r\n";
2196
- if ( function_exists('wp_schedule_event') ) {
2197
- echo __('Send Emails', 'subscribe2') . ": <br /><br />\r\n";
2198
- $this->display_digest_choices();
2199
- echo __('For digest notifications, date order for posts is', 'subscribe2') . ": \r\n";
2200
- echo "<label><input type=\"radio\" name=\"cron_order\" value=\"desc\"" . checked($this->subscribe2_options['cron_order'], 'desc', false) . " /> ";
2201
- echo __('Descending', 'subscribe2') . "</label>&nbsp;&nbsp;";
2202
- echo "<label><input type=\"radio\" name=\"cron_order\" value=\"asc\"" . checked($this->subscribe2_options['cron_order'], 'asc', false) . " /> ";
2203
- echo __('Ascending', 'subscribe2') . "</label><br /><br />\r\n";
2204
- }
2205
- echo __('Add Tracking Parameters to the Permalink', 'subscribe2') . ": ";
2206
- echo "<input type=\"text\" name=\"tracking\" value=\"" . stripslashes($this->subscribe2_options['tracking']) . "\" size=\"50\" /> ";
2207
- echo "<br />" . __('eg. utm_source=subscribe2&utm_medium=email&utm_campaign=postnotify', 'subscribe2') . "<br /><br />\r\n";
2208
- echo "</div>\r\n";
2209
-
2210
- // email templates
2211
- echo "<div class=\"s2_admin\" id=\"s2_templates\">\r\n";
2212
- echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
2213
- echo "<br />";
2214
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
2215
- echo "<tr><td>";
2216
- echo __('New Post email (must not be empty)', 'subscribe2') . ":<br />\r\n";
2217
- echo __('Subject Line', 'subscribe2') . ": ";
2218
- echo "<input type=\"text\" name=\"notification_subject\" value=\"" . stripslashes($this->subscribe2_options['notification_subject']) . "\" size=\"30\" />";
2219
- echo "<br />\r\n";
2220
- echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
2221
- echo "</td><td valign=\"top\" rowspan=\"3\">";
2222
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Send Email Preview', 'subscribe2') . "\" /></p>\r\n";
2223
- echo "<h3>" . __('Message substitutions', 'subscribe2') . "</h3>\r\n";
2224
- echo "<dl>";
2225
- echo "<dt><b><em style=\"color: red\">" . __('IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED' ,'subscribe2') . "</em></b></dt><dd></dd>\r\n";
2226
- echo "<dt><b>{BLOGNAME}</b></dt><dd>" . get_option('blogname') . "</dd>\r\n";
2227
- echo "<dt><b>{BLOGLINK}</b></dt><dd>" . get_option('home') . "</dd>\r\n";
2228
- echo "<dt><b>{TITLE}</b></dt><dd>" . __("the post's title<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2229
- echo "<dt><b>{POST}</b></dt><dd>" . __("the excerpt or the entire post<br />(<i>based on the subscriber's preferences</i>)", 'subscribe2') . "</dd>\r\n";
2230
- echo "<dt><b>{POSTTIME}</b></dt><dd>" . __("the excerpt of the post and the time it was posted<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2231
- echo "<dt><b>{TABLE}</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2232
- echo "<dt><b>{TABLELINKS}</b></dt><dd>" . __("a list of post titles followed by links to the atricles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2233
- echo "<dt><b>{PERMALINK}</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2234
- echo "<dt><b>{TINYLINK}</b></dt><dd>" . __("the post's permalink after conversion by TinyURL<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2235
- echo "<dt><b>{DATE}</b></dt><dd>" . __("the date the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
2236
- echo "<dt><b>{TIME}</b></dt><dd>" . __("the time the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
2237
- echo "<dt><b>{MYNAME}</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
2238
- echo "<dt><b>{EMAIL}</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
2239
- echo "<dt><b>{AUTHORNAME}</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
2240
- echo "<dt><b>{LINK}</b></dt><dd>" . __("the generated link to confirm a request<br />(<i>only used in the confirmation email template</i>)", 'subscribe2') . "</dd>\r\n";
2241
- echo "<dt><b>{ACTION}</b></dt><dd>" . __("Action performed by LINK in confirmation email<br />(<i>only used in the confirmation email template</i>)", 'subscribe2') . "</dd>\r\n";
2242
- echo "<dt><b>{CATS}</b></dt><dd>" . __("the post's assigned categories", 'subscribe2') . "</dd>\r\n";
2243
- echo "<dt><b>{TAGS}</b></dt><dd>" . __("the post's assigned Tags", 'subscribe2') . "</dd>\r\n";
2244
- echo "<dt><b>{COUNT}</b></dt><dd>" . __("the number of posts included in the digest email<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2245
- echo "</dl></td></tr><tr><td>";
2246
- echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
2247
- echo __('Subject Line', 'subscribe2') . ": ";
2248
- echo "<input type=\"text\" name=\"confirm_subject\" value=\"" . stripslashes($this->subscribe2_options['confirm_subject']) . "\" size=\"30\" /><br />\r\n";
2249
- echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
2250
- echo "</td></tr><tr valign=\"top\"><td>";
2251
- echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
2252
- echo __('Subject Line', 'subscribe2') . ": ";
2253
- echo "<input type=\"text\" name=\"remind_subject\" value=\"" . stripslashes($this->subscribe2_options['remind_subject']) . "\" size=\"30\" /><br />\r\n";
2254
- echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
2255
- echo "</td></tr></table><br />\r\n";
2256
- echo "</div>\r\n";
2257
-
2258
- // excluded categories
2259
- echo "<div class=\"s2_admin\" id=\"s2_excluded_categories\">\r\n";
2260
- echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
2261
- echo "<p>";
2262
- echo "<strong><em style=\"color: red\">" . __('Posts assigned to any Excluded Category do not generate notifications and are not included in digest notifications', 'subscribe2') . "</em></strong><br />\r\n";
2263
- echo "</p>";
2264
- $this->display_category_form(explode(',', $this->subscribe2_options['exclude']));
2265
- echo "<center><label><input type=\"checkbox\" name=\"reg_override\" value=\"1\"" . checked($this->subscribe2_options['reg_override'], '1', false) . " /> ";
2266
- echo __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</label></center><br />\r\n";
2267
-
2268
- $formats = get_theme_support('post-formats');
2269
- if ( $formats !== false ) {
2270
- // excluded formats
2271
- echo "<h2>" . __('Excluded Formats', 'subscribe2') . "</h2>\r\n";
2272
- echo "<p>";
2273
- echo "<strong><em style=\"color: red\">" . __('Posts assigned to any Excluded Format do not generate notifications and are not included in digest notifications', 'subscribe2') . "</em></strong><br />\r\n";
2274
- echo "</p>";
2275
- $this->display_format_form($formats, explode(',', $this->subscribe2_options['exclude_formats']));
2276
- }
2277
- echo "</div>\r\n";
2278
-
2279
- // Appearance options
2280
- echo "<div class=\"s2_admin\" id=\"s2_appearance_settings\">\r\n";
2281
- echo "<h2>" . __('Appearance', 'subscribe2') . "</h2>\r\n";
2282
- echo "<p>";
2283
-
2284
- // WordPress page ID where subscribe2 token is used
2285
- echo __('Set default Subscribe2 page as ID', 'subscribe2') . ': ';
2286
- echo "<select name=\"page\">\r\n";
2287
- $this->pages_dropdown($this->subscribe2_options['s2page']);
2288
- echo "</select>\r\n";
2289
-
2290
- // Number of subscribers per page
2291
- echo "<br /><br />" . __('Set the number of Subscribers displayed per page', 'subscribe2') . ': ';
2292
- echo "<span id=\"s2entries_1\"><span id=\"s2entries\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['entries'] . "</span> ";
2293
- echo "<a href=\"#\" onclick=\"s2_show('entries'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
2294
- echo "<span id=\"s2entries_2\">\r\n";
2295
- echo "<input type=\"text\" name=\"entries\" value=\"" . $this->subscribe2_options['entries'] . "\" size=\"3\" />\r\n";
2296
- echo "<a href=\"#\" onclick=\"s2_update('entries'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
2297
- echo "<a href=\"#\" onclick=\"s2_revert('entries'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
2298
-
2299
- // show link to WordPress page in meta
2300
- echo "<br /><br /><label><input type=\"checkbox\" name=\"show_meta\" value=\"1\"" . checked($this->subscribe2_options['show_meta'], '1', false) . " /> ";
2301
- echo __('Show a link to your subscription page in "meta"?', 'subscribe2') . "</label><br /><br />\r\n";
2302
-
2303
- // show QuickTag button
2304
- echo "<label><input type=\"checkbox\" name=\"show_button\" value=\"1\"" . checked($this->subscribe2_options['show_button'], '1', false) . " /> ";
2305
- echo __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "</label><br /><br />\r\n";
2306
-
2307
- // enable AJAX style form
2308
- echo "<label><input type=\"checkbox\" name=\"ajax\" value=\"1\"" . checked($this->subscribe2_options['ajax'], '1', false) . " />";
2309
- echo __('Enable AJAX style subscription form?', 'subscribe2') . "</label><br /><br />\r\n";
2310
-
2311
- // show Widget
2312
- echo "<label><input type=\"checkbox\" name=\"widget\" value=\"1\"" . checked($this->subscribe2_options['widget'], '1', false) . " /> ";
2313
- echo __('Enable Subscribe2 Widget?', 'subscribe2') . "</label><br /><br />\r\n";
2314
-
2315
- // show Counter Widget
2316
- echo "<label><input type=\"checkbox\" name=\"counterwidget\" value=\"1\"" . checked($this->subscribe2_options['counterwidget'], '1', false) . " /> ";
2317
- echo __('Enable Subscribe2 Counter Widget?', 'subscribe2') . "</label><br /><br />\r\n";
2318
-
2319
- // s2_meta checked by default
2320
- echo "<label><input type =\"checkbox\" name=\"s2meta_default\" value=\"1\"" . checked($this->subscribe2_options['s2meta_default'], '1', false) . " /> ";
2321
- echo __('Disable email notifications is checked by default on authoring pages?', 'subscribe2') . "</label>\r\n";
2322
- echo "</p>";
2323
- echo "</div>\r\n";
2324
-
2325
- //Auto Subscription for new registrations
2326
- echo "<div class=\"s2_admin\" id=\"s2_autosubscribe_settings\">\r\n";
2327
- echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
2328
- echo "<p>";
2329
- echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
2330
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"yes\"" . checked($this->subscribe2_options['autosub'], 'yes', false) . " /> ";
2331
- echo __('Automatically', 'subscribe2') . "</label>&nbsp;&nbsp;";
2332
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"wpreg\"" . checked($this->subscribe2_options['autosub'], 'wpreg', false) . " /> ";
2333
- echo __('Display option on Registration Form', 'subscribe2') . "</label>&nbsp;&nbsp;";
2334
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"no\"" . checked($this->subscribe2_options['autosub'], 'no', false) . " /> ";
2335
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
2336
- echo __('Auto-subscribe includes any excluded categories', 'subscribe2') . ":<br />\r\n";
2337
- echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"yes\"" . checked($this->subscribe2_options['newreg_override'], 'yes', false) . " /> ";
2338
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2339
- echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"no\"" . checked($this->subscribe2_options['newreg_override'], 'no', false) . " /> ";
2340
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
2341
- echo __('Registration Form option is checked by default', 'subscribe2') . ":<br />\r\n";
2342
- echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"yes\"" . checked($this->subscribe2_options['wpregdef'], 'yes', false) . " /> ";
2343
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2344
- echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"no\"" . checked($this->subscribe2_options['wpregdef'], 'no', false) . " /> ";
2345
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
2346
- echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
2347
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html\"" . checked($this->subscribe2_options['autoformat'], 'html', false) . " /> ";
2348
- echo __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
2349
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html_excerpt\"" . checked($this->subscribe2_options['autoformat'], 'html_excerpt', false) . " /> ";
2350
- echo __('HTML - Excerpt', 'subscribe2') ."</label>&nbsp;&nbsp;";
2351
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"post\"" . checked($this->subscribe2_options['autoformat'], 'post', false) . " /> ";
2352
- echo __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
2353
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"excerpt\"" . checked($this->subscribe2_options['autoformat'], 'excerpt', false) . " /> ";
2354
- echo __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />";
2355
- echo __('Registered Users have the option to auto-subscribe to new categories', 'subscribe2') . ": <br />\r\n";
2356
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"yes\"" . checked($this->subscribe2_options['show_autosub'], 'yes', false) . " /> ";
2357
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2358
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"no\"" . checked($this->subscribe2_options['show_autosub'], 'no', false) . " /> ";
2359
- echo __('No', 'subscribe2') . "</label>&nbsp;&nbsp;";
2360
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"exclude\"" . checked($this->subscribe2_options['show_autosub'], 'exclude', false) . " /> ";
2361
- echo __('New categories are immediately excluded', 'subscribe2') . "</label><br /><br />";
2362
- echo __('Option for Registered Users to auto-subscribe to new categories is checked by default', 'subscribe2') . ": <br />\r\n";
2363
- echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"yes\"" . checked($this->subscribe2_options['autosub_def'], 'yes', false) . " /> ";
2364
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2365
- echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"no\"" . checked($this->subscribe2_options['autosub_def'], 'no', false) . " /> ";
2366
- echo __('No', 'subscribe2') . "</label><br /><br />";
2367
- echo __('Display checkbox to allow subscriptions from the comment form', 'subscribe2') . ": <br />\r\n";
2368
- echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"before\"" . checked($this->subscribe2_options['comment_subs'], 'before', false) . " /> ";
2369
- echo __('Before the Comment Submit button', 'subscribe2') . "</label>&nbsp;&nbsp;";
2370
- echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"after\"" . checked($this->subscribe2_options['comment_subs'], 'after', false) . " /> ";
2371
- echo __('After the Comment Submit button', 'subscribe2') . "</label>&nbsp;&nbsp;";
2372
- echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"no\"" . checked($this->subscribe2_options['comment_subs'], 'no', false) . " /> ";
2373
- echo __('No', 'subscribe2');
2374
- echo "</label></p>";
2375
- echo "</div>\r\n";
2376
-
2377
- //barred domains
2378
- echo "<div class=\"s2_admin\" id=\"s2_barred_domains\">\r\n";
2379
- echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
2380
- echo "<p>";
2381
- echo __('Enter domains to bar from public subscriptions: <br /> (Use a new line for each entry and omit the "@" symbol, for example email.com)', 'subscribe2');
2382
- echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
2383
- echo "</p>";
2384
- echo "</div>\r\n";
2385
-
2386
- // submit
2387
- echo "<p class=\"submit\" align=\"center\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p>";
2388
-
2389
- // reset
2390
- echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
2391
- echo "<p>" . __('Use this to reset all options to their defaults. This <strong><em>will not</em></strong> modify your list of subscribers.', 'subscribe2') . "</p>\r\n";
2392
- echo "<p class=\"submit\" align=\"center\">";
2393
- echo "<input type=\"submit\" id=\"deletepost\" name=\"reset\" value=\"" . __('RESET', 'subscribe2') .
2394
- "\" />";
2395
- echo "</p></form></div>\r\n";
2396
-
2397
- include(ABSPATH . 'wp-admin/admin-footer.php');
2398
- // just to be sure
2399
- die;
2400
- } // end options_menu()
2401
-
2402
- /**
2403
- Our profile menu
2404
- */
2405
- function user_menu() {
2406
- global $user_ID, $s2nonce;
2407
-
2408
- if ( isset($_GET['email']) ) {
2409
- global $wpdb;
2410
- $user_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . urldecode($_GET['email']) . "'");
2411
- } else {
2412
- get_currentuserinfo();
2413
- }
2414
-
2415
- // was anything POSTed?
2416
- if ( isset($_POST['s2_admin']) && 'user' == $_POST['s2_admin'] ) {
2417
- check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
2418
-
2419
- if ( isset($_POST['s2_format']) ) {
2420
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $_POST['s2_format']);
2421
- } else {
2422
- // value has not been set so use default
2423
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
2424
- }
2425
- if ( isset($_POST['new_category']) ) {
2426
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $_POST['new_category']);
2427
- } else {
2428
- // value has not been passed so use Settings defaults
2429
- if ( $this->subscribe2_options['show_autosub'] == 'yes' && $this->subscribe2_options['autosub_def'] == 'yes' ) {
2430
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes');
2431
- } else {
2432
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'no');
2433
- }
2434
- }
2435
-
2436
- $cats = $_POST['category'];
2437
-
2438
- if ( empty($cats) || $cats == '-1' ) {
2439
- $oldcats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
2440
- if ( $oldcats ) {
2441
- foreach ( $oldcats as $cat ) {
2442
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat);
2443
- }
2444
- }
2445
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
2446
- } elseif ( $cats == 'digest' ) {
2447
- $all_cats = $this->all_cats(false, 'ID');
2448
- foreach ( $all_cats as $cat ) {
2449
- ('' == $catids) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
2450
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
2451
- }
2452
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $catids);
2453
- } else {
2454
- if ( !is_array($cats) ) {
2455
- $cats = (array)$_POST['category'];
2456
- }
2457
- sort($cats);
2458
- $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
2459
- $remove = array_diff($old_cats, $cats);
2460
- $new = array_diff($cats, $old_cats);
2461
- if ( !empty($remove) ) {
2462
- // remove subscription to these cat IDs
2463
- foreach ( $remove as $id ) {
2464
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
2465
- }
2466
- }
2467
- if ( !empty($new) ) {
2468
- // add subscription to these cat IDs
2469
- foreach ( $new as $id ) {
2470
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
2471
- }
2472
- }
2473
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $cats));
2474
- }
2475
-
2476
- $authors = $_POST['author'];
2477
- if ( is_array($authors) ) {
2478
- $authors = implode(',', $authors);
2479
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), $authors);
2480
- } elseif ( empty($authors) ) {
2481
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
2482
- }
2483
-
2484
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
2485
- }
2486
-
2487
- // show our form
2488
- echo "<div class=\"wrap\">";
2489
- echo "<div id=\"icon-users\" class=\"icon32\"></div>";
2490
- echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
2491
- if ( isset($_GET['email']) ) {
2492
- $user = get_userdata($user_ID);
2493
- echo "<span style=\"color: red;line-height: 300%;\">" . __('Editing Subscribe2 preferences for user', 'subscribe2') . ": " . $user->display_name . "</span>";
2494
- }
2495
- echo "<form method=\"post\" action=\"\">";
2496
- echo "<p>";
2497
- if ( function_exists('wp_nonce_field') ) {
2498
- wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
2499
- }
2500
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
2501
- if ( $this->subscribe2_options['email_freq'] == 'never' ) {
2502
- echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
2503
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'html', false) . " />";
2504
- echo " " . __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
2505
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html_excerpt\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'html_excerpt', false) . " />";
2506
- echo " " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;";
2507
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"post\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'post', false) . " />";
2508
- echo " " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
2509
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"excerpt\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'excerpt', false) . " />";
2510
- echo " " . __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />\r\n";
2511
-
2512
- if ( $this->subscribe2_options['show_autosub'] == 'yes' ) {
2513
- echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
2514
- echo "<label><input type=\"radio\" name=\"new_category\" value=\"yes\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), true), 'yes', false) . " />";
2515
- echo " " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2516
- echo "<label><input type=\"radio\" name=\"new_category\" value=\"no\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), true), 'no', false) . " />";
2517
- echo " " . __('No', 'subscribe2') . "</label>";
2518
- echo "</p>";
2519
- }
2520
-
2521
- // subscribed categories
2522
- if ( $this->s2_mu ) {
2523
- global $blog_id;
2524
- $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
2525
- // if we are subscribed to the current blog display an "unsubscribe" link
2526
- if ( !empty($subscribed) ) {
2527
- $unsubscribe_link = esc_url( add_query_arg('s2mu_unsubscribe', $blog_id) );
2528
- echo "<p><a href=\"". $unsubscribe_link ."\" class=\"button\">" . __('Unsubscribe me from this blog', 'subscribe2') . "</a></p>";
2529
- } else {
2530
- // else we show a "subscribe" link
2531
- $subscribe_link = esc_url( add_query_arg('s2mu_subscribe', $blog_id) );
2532
- echo "<p><a href=\"". $subscribe_link ."\" class=\"button\">" . __('Subscribe to all categories', 'subscribe2') . "</a></p>";
2533
- }
2534
- echo "<h2>" . __('Subscribed Categories on', 'subscribe2') . " " . get_option('blogname') . " </h2>\r\n";
2535
- } else {
2536
- echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
2537
- }
2538
- $this->display_category_form(explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true)), $this->subscribe2_options['reg_override']);
2539
- } else {
2540
- // we're doing daily digests, so just show
2541
- // subscribe / unnsubscribe
2542
- echo __('Receive periodic summaries of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
2543
- echo "<label>";
2544
- echo "<input type=\"radio\" name=\"category\" value=\"digest\"";
2545
- if ( get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
2546
- echo " checked=\"checked\"";
2547
- }
2548
- echo " /> " . __('Yes', 'subscribe2') . "</label> <label><input type=\"radio\" name=\"category\" value=\"-1\" ";
2549
- if ( !get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
2550
- echo " checked=\"checked\"";
2551
- }
2552
- echo " /> " . __('No', 'subscribe2');
2553
- echo "</label></p>";
2554
- }
2555
-
2556
- if ( count($this->get_authors()) > 1 ) {
2557
- echo "<div class=\"s2_admin\" id=\"s2_authors\">\r\n";
2558
- echo "<h2>" . __('Do not send notifications for post made by these authors', 'subscribe2') . "</h2>\r\n";
2559
- $this->display_author_form(explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), true)));
2560
- echo "</div>\r\n";
2561
- }
2562
-
2563
- // submit
2564
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __("Update Preferences", 'subscribe2') . " &raquo;\" /></p>";
2565
- echo "</form>\r\n";
2566
-
2567
- // list of subscribed blogs on wordpress mu
2568
- if ( $this->s2_mu && !isset($_GET['email']) ) {
2569
- global $blog_id, $current_user;
2570
- $s2blog_id = $blog_id;
2571
- get_currentuserinfo();
2572
- $blogs = $this->get_mu_blog_list();
2573
-
2574
- $blogs_subscribed = array();
2575
- $blogs_notsubscribed = array();
2576
-
2577
- foreach ( $blogs as $blog ) {
2578
- // switch to blog
2579
- switch_to_blog($blog['blog_id']);
2580
-
2581
- // check that the Subscribe2 plugin is active on the current blog
2582
- $current_plugins = get_option('active_plugins');
2583
- if ( !is_array($current_plugins) ) {
2584
- $current_plugins = (array)$current_plugins;
2585
- }
2586
- if ( !in_array(S2DIR . 'subscribe2.php', $current_plugins) ) {
2587
- continue;
2588
- }
2589
-
2590
- // check if we're subscribed to the blog
2591
- $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
2592
-
2593
- $blogname = get_option('blogname');
2594
- if ( strlen($blogname) > 30 ) {
2595
- $blog['blogname'] = wp_html_excerpt($blogname, 30) . "..";
2596
- } else {
2597
- $blog['blogname'] = $blogname;
2598
- }
2599
- $blog['description'] = get_option('blogdescription');
2600
- $blog['blogurl'] = get_option('home');
2601
- $blog['subscribe_page'] = get_option('home') . "/wp-admin/users.php?page=s2_users";
2602
-
2603
- $key = strtolower($blog['blogname'] . "-" . $blog['blog_id']);
2604
- if ( !empty($subscribed) ) {
2605
- $blogs_subscribed[$key] = $blog;
2606
- } else {
2607
- $blogs_notsubscribed[$key] = $blog;
2608
- }
2609
- restore_current_blog();
2610
- }
2611
-
2612
- if ( !empty($blogs_subscribed) ) {
2613
- ksort($blogs_subscribed);
2614
- echo "<h2>" . __('Subscribed Blogs', 'subscribe2') . "</h2>\r\n";
2615
- echo "<ul class=\"s2_blogs\">\r\n";
2616
- foreach ( $blogs_subscribed as $blog ) {
2617
- echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
2618
- if ( $s2blog_id == $blog['blog_id'] ) {
2619
- echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
2620
- } else {
2621
- echo "<span class=\"buttons\">";
2622
- if ( is_user_member_of_blog($current_user->id, $blog['blog_id']) ) {
2623
- echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
2624
- }
2625
- echo "<a href=\"" . esc_url( add_query_arg('s2mu_unsubscribe', $blog['blog_id']) ) . "\">" . __('Unsubscribe', 'subscribe2') . "</a></span>\r\n";
2626
- }
2627
- echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
2628
- echo "</li>";
2629
- }
2630
- echo "</ul>\r\n";
2631
- }
2632
-
2633
- if ( !empty($blogs_notsubscribed) ) {
2634
- ksort($blogs_notsubscribed);
2635
- echo "<h2>" . __('Subscribe to new blogs', 'subscribe2') . "</h2>\r\n";
2636
- echo "<ul class=\"s2_blogs\">";
2637
- foreach ( $blogs_notsubscribed as $blog ) {
2638
- echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
2639
- if ( $s2blog_id == $blog['blog_id'] ) {
2640
- echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
2641
- } else {
2642
- echo "<span class=\"buttons\">";
2643
- if ( is_user_member_of_blog($current_user->id, $blog['blog_id']) ) {
2644
- echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
2645
- }
2646
- echo "<a href=\"" . esc_url( add_query_arg('s2mu_subscribe', $blog['blog_id']) ) . "\">" . __('Subscribe', 'subscribe2') . "</a></span>\r\n";
2647
- }
2648
- echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
2649
- echo "</li>";
2650
- }
2651
- echo "</ul>\r\n";
2652
- }
2653
- }
2654
-
2655
- echo "</div>\r\n";
2656
-
2657
- include(ABSPATH . 'wp-admin/admin-footer.php');
2658
- // just to be sure
2659
- die;
2660
- } // end user_menu()
2661
-
2662
- /**
2663
- Display the Write sub-menu
2664
- */
2665
- function write_menu() {
2666
- global $wpdb, $s2nonce, $current_user;
2667
-
2668
- // was anything POSTed?
2669
- if ( isset($_POST['s2_admin']) && 'mail' == $_POST['s2_admin'] ) {
2670
- check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
2671
- $subject = $this->substitute(stripslashes(strip_tags($_POST['subject'])));
2672
- $body = $this->substitute(stripslashes($_POST['content']));
2673
- if ( '' != $current_user->display_name || '' != $current_user->user_email ) {
2674
- $this->myname = html_entity_decode($current_user->display_name, ENT_QUOTES);
2675
- $this->myemail = $current_user->user_email;
2676
- }
2677
- if ( isset($_POST['send']) ) {
2678
- if ( 'confirmed' == $_POST['what'] ) {
2679
- $recipients = $this->get_public();
2680
- } elseif ( 'unconfirmed' == $_POST['what'] ) {
2681
- $recipients = $this->get_public(0);
2682
- } elseif ( 'public' == $_POST['what'] ) {
2683
- $confirmed = $this->get_public();
2684
- $unconfirmed = $this->get_public(0);
2685
- $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
2686
- } elseif ( is_numeric($_POST['what']) ) {
2687
- $cat = intval($_POST['what']);
2688
- $recipients = $this->get_registered("cats=$cat");
2689
- } elseif ( 'all_users' == $_POST['what'] ) {
2690
- $recipients = $this->get_all_registered();
2691
- } else {
2692
- $recipients = $this->get_registered();
2693
- }
2694
- } elseif ( isset($_POST['preview']) ) {
2695
- global $user_email;
2696
- $recipients[] = $user_email;
2697
- }
2698
- $status = $this->mail($recipients, $subject, $body, 'text');
2699
- if ( $status ) {
2700
- $message = $this->mail_sent;
2701
- } else {
2702
- global $phpmailer;
2703
- $message = $this->mail_failed . $phpmailer->ErrorInfo;
2704
- }
2705
- echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
2706
- }
2707
-
2708
- // show our form
2709
- echo "<div class=\"wrap\">";
2710
- echo "<div id=\"icon-edit\" class=\"icon32\"></div>";
2711
- echo "<h2>" . __('Send an email to subscribers', 'subscribe2') . "</h2>\r\n";
2712
- echo "<form method=\"post\" action=\"\">\r\n";
2713
- if ( function_exists('wp_nonce_field') ) {
2714
- wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
2715
- }
2716
- if ( isset($_POST['subject']) ) {
2717
- $subject = $_POST['subject'];
2718
- } else {
2719
- $subject = __('A message from', 'subscribe2') . " " . html_entity_decode(get_option('blogname'), ENT_QUOTES);
2720
- }
2721
- if ( !isset($_POST['content']) ) {
2722
- $body = '';
2723
- }
2724
- echo "<p>" . __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . $subject . "\" /> <br /><br />";
2725
- echo "<textarea rows=\"12\" cols=\"75\" name=\"content\">" . $body . "</textarea>";
2726
- echo "<br /><br />\r\n";
2727
- echo __('Recipients:', 'subscribe2') . " ";
2728
- $this->display_subscriber_dropdown('registered', false, array('all'));
2729
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
2730
- echo "</p>";
2731
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Preview', 'subscribe2') . "\" \><input type=\"submit\" class=\"button-primary\" name=\"send\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
2732
- echo "</form></div>\r\n";
2733
- echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
2734
-
2735
- include(ABSPATH . 'wp-admin/admin-footer.php');
2736
- // just to be sure
2737
- die;
2738
- } // end write_menu()
2739
-
2740
- /* ===== helper functions: forms and stuff ===== */
2741
- /**
2742
- Get an object of all categories, include default and custom type
2743
- */
2744
- function all_cats($exclude = false, $orderby = 'slug') {
2745
- $all_cats = array();
2746
- $s2_taxonomies = array('category');
2747
- $s2_taxonomies = apply_filters('s2_taxonomies', $s2_taxonomies);
2748
-
2749
- foreach( $s2_taxonomies as $taxonomy ) {
2750
- if ( taxonomy_exists($taxonomy) ) {
2751
- $all_cats = array_merge($all_cats, get_categories(array('hide_empty' => false, 'orderby' => $orderby, 'taxonomy' => $taxonomy)));
2752
- }
2753
- }
2754
-
2755
- if ( $exclude === true ) {
2756
- // remove excluded categories from the returned object
2757
- $excluded = explode(',', $this->subscribe2_options['exclude']);
2758
-
2759
- // need to use $id like this as this is a mixed array / object
2760
- $id = 0;
2761
- foreach ( $all_cats as $cat) {
2762
- if ( in_array($cat->term_id, $excluded) ) {
2763
- unset($all_cats[$id]);
2764
- }
2765
- $id++;
2766
- }
2767
- }
2768
-
2769
- return $all_cats;
2770
- } // end all_cats()
2771
-
2772
- /**
2773
- Display a table of categories with checkboxes
2774
- Optionally pre-select those categories specified
2775
- */
2776
- function display_category_form($selected = array(), $override = 1) {
2777
- global $wpdb;
2778
-
2779
- if ( $override == 0 ) {
2780
- $all_cats = $this->all_cats(true);
2781
- } else {
2782
- $all_cats = $this->all_cats(false);
2783
- }
2784
-
2785
- $half = (count($all_cats) / 2);
2786
- $i = 0;
2787
- $j = 0;
2788
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
2789
- echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
2790
- echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_cat\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
2791
- echo "</td></tr>\r\n";
2792
- echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
2793
- foreach ( $all_cats as $cat ) {
2794
- if ( $i >= $half && 0 == $j ){
2795
- echo "</td><td width=\"50%\" align=\"left\">\r\n";
2796
- $j++;
2797
- }
2798
- $catName = '';
2799
- $parents = array_reverse( get_ancestors($cat->term_id, $cat->taxonomy) );
2800
- if ( $parents ) {
2801
- foreach ( $parents as $parent ) {
2802
- $parent = get_term($parent, $cat->taxonomy);
2803
- $catName .= $parent->name . ' &raquo; ';
2804
- }
2805
- }
2806
- $catName .= $cat->name;
2807
-
2808
- if ( 0 == $j ) {
2809
- echo "<label><input class=\"checkall_cat\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
2810
- if ( in_array($cat->term_id, $selected) ) {
2811
- echo " checked=\"checked\"";
2812
- }
2813
- echo " /> <abbr title=\"" . $cat->slug . "\">" . $catName . "</abbr></label><br />\r\n";
2814
- } else {
2815
- echo "<label><input class=\"checkall_cat\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
2816
- if ( in_array($cat->term_id, $selected) ) {
2817
- echo " checked=\"checked\"";
2818
- }
2819
- echo " /> <abbr title=\"" . $cat->slug . "\">" . $catName . "</abbr></label><br />\r\n";
2820
- }
2821
- $i++;
2822
- }
2823
- echo "</td></tr>\r\n";
2824
- echo "</table>\r\n";
2825
- } // end display_category_form()
2826
-
2827
- /**
2828
- Display a table of post formats supported by the currently active theme
2829
- */
2830
- function display_format_form($formats, $selected = array()) {
2831
- $half = (count($formats[0]) / 2);
2832
- $i = 0;
2833
- $j = 0;
2834
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
2835
- echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
2836
- echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_format\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
2837
- echo "</td></tr>\r\n";
2838
- echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
2839
- foreach ( $formats[0] as $format ) {
2840
- if ( $i >= $half && 0 == $j ){
2841
- echo "</td><td width=\"50%\" align=\"left\">\r\n";
2842
- $j++;
2843
- }
2844
-
2845
- if ( 0 == $j ) {
2846
- echo "<label><input class=\"checkall_format\" type=\"checkbox\" name=\"format[]\" value=\"" . $format . "\"";
2847
- if ( in_array($format, $selected) ) {
2848
- echo " checked=\"checked\"";
2849
- }
2850
- echo " /> " . ucwords($format) . "</label><br />\r\n";
2851
- } else {
2852
- echo "<label><input class=\"checkall_format\" type=\"checkbox\" name=\"format[]\" value=\"" . $format . "\"";
2853
- if ( in_array($format, $selected) ) {
2854
- echo " checked=\"checked\"";
2855
- }
2856
- echo " /> " . ucwords($format) . "</label><br />\r\n";
2857
- }
2858
- $i++;
2859
- }
2860
- echo "</td></tr>\r\n";
2861
- echo "</table>\r\n";
2862
- } // end display_format_form()
2863
-
2864
- /**
2865
- Display a table of authors with checkboxes
2866
- Optionally pre-select those authors specified
2867
- */
2868
- function display_author_form($selected = array()) {
2869
- $all_authors = $this->get_authors();
2870
-
2871
- $half = (count($all_authors) / 2);
2872
- $i = 0;
2873
- $j = 0;
2874
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
2875
- echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
2876
- echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_author\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
2877
- echo "</td></tr>\r\n";
2878
- echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
2879
- foreach ( $all_authors as $author ) {
2880
- if ( $i >= $half && 0 == $j ) {
2881
- echo "</td><td width=\"50%\" align=\"left\">\r\n";
2882
- $j++;
2883
- }
2884
- if ( 0 == $j ) {
2885
- echo "<label><input class=\"checkall_author\" type=\"checkbox\" name=\"author[]\" value=\"" . $author->ID . "\"";
2886
- if ( in_array($author->ID, $selected) ) {
2887
- echo " checked=\"checked\"";
2888
- }
2889
- echo " /> " . $author->display_name . "</label><br />\r\n";
2890
- } else {
2891
- echo "<label><input class=\"checkall_author\" type=\"checkbox\" name=\"author[]\" value=\"" . $author->ID . "\"";
2892
- if ( in_array($author->ID, $selected) ) {
2893
- echo " checked=\"checked\"";
2894
- }
2895
- echo " /> " . $author->display_name . "</label><br />\r\n";
2896
- $i++;
2897
- }
2898
- }
2899
- echo "</td></tr>\r\n";
2900
- echo "</table>\r\n";
2901
- } // end display_author_form()
2902
-
2903
- /**
2904
- Display a drop-down form to select subscribers
2905
- $selected is the option to select
2906
- $submit is the text to use on the Submit button
2907
- */
2908
- function display_subscriber_dropdown($selected = 'registered', $submit = '', $exclude = array()) {
2909
- global $wpdb;
2910
-
2911
- $who = array('all' => __('All Users and Subscribers', 'subscribe2'),
2912
- 'public' => __('Public Subscribers', 'subscribe2'),
2913
- 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
2914
- 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
2915
- 'all_users' => __('All Registered Users', 'subscribe2'),
2916
- 'registered' => __('Registered Subscribers', 'subscribe2'));
2917
-
2918
- $all_cats = $this->all_cats(false);
2919
-
2920
- // count the number of subscribers
2921
- $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
2922
- $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
2923
- if ( in_array('unconfirmed', $exclude) ) {
2924
- $count['public'] = $count['confirmed'];
2925
- } elseif ( in_array('confirmed', $exclude) ) {
2926
- $count['public'] = $count['unconfirmed'];
2927
- } else {
2928
- $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
2929
- }
2930
- if ( $this->s2_mu ) {
2931
- $count['all_users'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
2932
- } else {
2933
- $count['all_users'] = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
2934
- }
2935
- if ( $this->s2_mu ) {
2936
- $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities' AND meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
2937
- } else {
2938
- $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
2939
- }
2940
- $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
2941
- if ( $this->s2_mu ) {
2942
- foreach ( $all_cats as $cat ) {
2943
- $count[$cat->name] = $wpdb->get_var("SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
2944
- }
2945
- } else {
2946
- foreach ( $all_cats as $cat ) {
2947
- $count[$cat->name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
2948
- }
2949
- }
2950
-
2951
- // do have actually have some subscribers?
2952
- if ( 0 == $count['confirmed'] && 0 == $count['unconfirmed'] && 0 == $count['all_users'] ) {
2953
- // no? bail out
2954
- return;
2955
- }
2956
-
2957
- echo "<select name=\"what\">\r\n";
2958
- foreach ( $who as $whom => $display ) {
2959
- if ( in_array($whom, $exclude) ) { continue; }
2960
- if ( 0 == $count[$whom] ) { continue; }
2961
-
2962
- echo "<option value=\"" . $whom . "\"";
2963
- if ( $whom == $selected ) { echo " selected=\"selected\" "; }
2964
- echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
2965
- }
2966
-
2967
- if ( $count['registered'] > 0 ) {
2968
- foreach ( $all_cats as $cat ) {
2969
- if ( in_array($cat->term_id, $exclude) ) { continue; }
2970
- echo "<option value=\"" . $cat->term_id . "\"";
2971
- if ( $cat->term_id == $selected ) { echo " selected=\"selected\" "; }
2972
- echo "> &nbsp;&nbsp;" . $cat->name . "&nbsp;(" . $count[$cat->name] . ") </option>\r\n";
2973
- }
2974
- }
2975
- echo "</select>";
2976
- if ( false !== $submit ) {
2977
- echo "&nbsp;<input type=\"submit\" class=\"button-secondary\" value=\"$submit\" />\r\n";
2978
- }
2979
- } // end display_subscriber_dropdown()
2980
-
2981
- /**
2982
- Display a drop down list of administrator level users and
2983
- optionally include a choice for Post Author
2984
- */
2985
- function admin_dropdown($inc_author = false) {
2986
- global $wpdb;
2987
-
2988
- $args = array('fields' => array('ID', 'display_name'), 'role' => 'administrator');
2989
- $wp_user_query = get_users( $args );
2990
- foreach ($wp_user_query as $user) {
2991
- $admins[] = $user;
2992
- }
2993
-
2994
- if ( $inc_author ) {
2995
- $author[] = (object)array('ID' => 'author', 'display_name' => __('Post Author', 'subscribe2'));
2996
- $author[] = (object)array('ID' => 'blogname', 'display_name' => html_entity_decode(get_option('blogname'), ENT_QUOTES));
2997
- $admins = array_merge($author, $admins);
2998
- }
2999
-
3000
- echo "<select name=\"sender\">\r\n";
3001
- foreach ( $admins as $admin ) {
3002
- echo "<option value=\"" . $admin->ID . "\"";
3003
- if ( $admin->ID == $this->subscribe2_options['sender'] ) {
3004
- echo " selected=\"selected\"";
3005
- }
3006
- echo ">" . $admin->display_name . "</option>\r\n";
3007
- }
3008
- echo "</select>\r\n";
3009
- } // end admin_dropdown()
3010
-
3011
- /**
3012
- Display a dropdown of choices for digest email frequency
3013
- and give user details of timings when event is scheduled
3014
- */
3015
- function display_digest_choices() {
3016
- global $wpdb;
3017
- $cron_file = ABSPATH . 'wp-cron.php';
3018
- if ( !is_readable($cron_file) ) {
3019
- echo "<strong><em style=\"color: red\">" . __('The WordPress cron functions may be disabled on this server. Digest notifications may not work.', 'subscribe2') . "</em></strong><br />\r\n";
3020
- }
3021
- $scheduled_time = wp_next_scheduled('s2_digest_cron');
3022
- $schedule = (array)wp_get_schedules();
3023
- $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('For each Post', 'subscribe2'))), $schedule);
3024
- $sort = array();
3025
- foreach ( (array)$schedule as $key => $value ) {
3026
- $sort[$key] = $value['interval'];
3027
- }
3028
- asort($sort);
3029
- $schedule_sorted = array();
3030
- foreach ( $sort as $key => $value ) {
3031
- $schedule_sorted[$key] = $schedule[$key];
3032
- }
3033
- foreach ( $schedule_sorted as $key => $value ) {
3034
- echo "<label><input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"" . checked($this->subscribe2_options['email_freq'], $key, false) . " />";
3035
- echo " " . $value['display'] . "</label><br />\r\n";
3036
- }
3037
- echo "<br />" . __('Send Digest Notification at', 'subscribe2') . ": \r\n";
3038
- $hours = array('12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am', '10am', '11am', '12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm');
3039
- echo "<select name=\"hour\">\r\n";
3040
- while ( $hour = current($hours) ) {
3041
- echo "<option value=\"" . key($hours) . "\"";
3042
- if ( key($hours) == date('H', $scheduled_time) && !empty($scheduled_time) ){
3043
- echo " selected=\"selected\"";
3044
- }
3045
- echo ">" . $hour . "</option>\r\n";
3046
- next($hours);
3047
- }
3048
- echo "</select>\r\n";
3049
- echo "<strong><em style=\"color: red\">" . __('This option will be ignored if the time selected is not in the future in relation to the current time', 'subscribe2') . "</em></strong>\r\n";
3050
- if ( $scheduled_time ) {
3051
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
3052
- echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
3053
- echo "<strong>" . date_i18n($datetime, false, 'gmt') . "</strong></p>\r\n";
3054
- echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
3055
- echo "<strong>" . date_i18n($datetime) . "</strong></p>\r\n";
3056
- echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
3057
- echo "<strong>" . date_i18n($datetime, $scheduled_time) . "</strong></p>\r\n";
3058
- if ( !empty($this->subscribe2_options['previous_s2cron']) ) {
3059
- echo "<p>" . __('Attempt to resend the last Digest Notification email', 'subscribe2') . ": ";
3060
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"resend\" value=\"" . __('Resend Digest', 'subscribe2') . "\" /></p>\r\n";
3061
- }
3062
- } else {
3063
- echo "<br />";
3064
- }
3065
- } // end display_digest_choices()
3066
-
3067
- /**
3068
- Create and display a dropdown list of pages
3069
- */
3070
- function pages_dropdown($s2page) {
3071
- global $wpdb;
3072
- $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
3073
- $pages = $wpdb->get_results($sql);
3074
-
3075
- if ( empty($pages) ) { return; }
3076
-
3077
- $option = '';
3078
- foreach ( $pages as $page ) {
3079
- $option .= "<option value=\"" . $page->ID . "\"";
3080
- if ( $page->ID == $s2page ) {
3081
- $option .= " selected=\"selected\"";
3082
- }
3083
- $option .= ">" . $page->post_title . "</option>\r\n";
3084
- }
3085
-
3086
- echo $option;
3087
- } // end pages_dropdown()
3088
-
3089
- /**
3090
- Export subscriber emails and other details to CSV
3091
- */
3092
- function prepare_export( $what ) {
3093
- $confirmed = $this->get_public();
3094
- $unconfirmed = $this->get_public(0);
3095
- if ( 'all' == $what ) {
3096
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$this->get_all_registered());
3097
- } elseif ( 'public' == $what ) {
3098
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
3099
- } elseif ( 'confirmed' == $what ) {
3100
- $subscribers = $confirmed;
3101
- } elseif ( 'unconfirmed' == $what ) {
3102
- $subscribers = $unconfirmed;
3103
- } elseif ( is_numeric($what) ) {
3104
- $subscribers = $this->get_registered("cats=$what");
3105
- } elseif ( 'registered' == $what ) {
3106
- $subscribers = $this->get_registered();
3107
- } elseif ( 'all_users' == $what ) {
3108
- $subscribers = $this->get_all_registered();
3109
- }
3110
-
3111
- natcasesort($subscribers);
3112
-
3113
- $exportcsv = "User Email,User Name";
3114
- $all_cats = $this->all_cats(false, 'ID');
3115
-
3116
- foreach ($all_cats as $cat) {
3117
- $exportcsv .= "," . $cat->cat_name;
3118
- $cat_ids[] = $cat->term_id;
3119
- }
3120
- $exportcsv .= "\r\n";
3121
-
3122
- foreach ( $subscribers as $subscriber ) {
3123
- if ( $this->is_registered($subscriber) ) {
3124
- $user_ID = $this->get_user_id( $subscriber );
3125
- $user_info = get_userdata($user_ID);
3126
-
3127
- $cats = explode(',', get_user_meta($user_info->ID, $this->get_usermeta_keyname('s2_subscribed'), true));
3128
- $subscribed_cats = '';
3129
- foreach ( $cat_ids as $cat ) {
3130
- (in_array($cat, $cats)) ? $subscribed_cats .= ",Yes" : $subscribed_cats .= ",No";
3131
- }
3132
-
3133
- $exportcsv .= $user_info->user_email . ',';
3134
- $exportcsv .= $user_info->display_name;
3135
- $exportcsv .= $subscribed_cats . "\r\n";
3136
- } else {
3137
- if ( in_array($subscriber, $confirmed) ) {
3138
- $exportcsv .= $subscriber . ',' . __('Confirmed Public Subscriber', 'subscribe2') . "\r\n";
3139
- } elseif ( in_array($subscriber, $unconfirmed) ) {
3140
- $exportcsv .= $subscriber . ',' . __('Unconfirmed Public Subscriber', 'subscribe2') . "\r\n";
3141
- }
3142
- }
3143
- }
3144
-
3145
- return $exportcsv;
3146
- } // end prepare_export()
3147
-
3148
- /**
3149
- Filter for usermeta table key names to adjust them if needed for WPMU blogs
3150
- */
3151
- function get_usermeta_keyname($metaname) {
3152
- global $wpdb;
3153
-
3154
- // Is this WordPressMU or not?
3155
- if ( $this->s2_mu === true ) {
3156
- switch( $metaname ) {
3157
- case 's2_subscribed':
3158
- case 's2_cat':
3159
- case 's2_format':
3160
- case 's2_autosub':
3161
- case 's2_authors':
3162
- return $wpdb->prefix . $metaname;
3163
- break;
3164
- }
3165
- }
3166
- // Not MU or not a prefixed option name
3167
- return $metaname;
3168
- } // end get_usermeta_keyname()
3169
-
3170
- /**
3171
- Obtain a list of current WordPress multiuser blogs
3172
- Note this may affect performance but there is no alternative
3173
- */
3174
- function get_mu_blog_list() {
3175
- global $wpdb;
3176
- $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
3177
-
3178
- foreach ( $blogs as $details ) {
3179
- //reindex the array so the key is the same as the blog_id
3180
- $blog_list[$details['blog_id']] = $details;
3181
- }
3182
-
3183
- if ( false == is_array( $blog_list ) ) {
3184
- return array();
3185
- }
3186
-
3187
- return $blog_list;
3188
- } // end get_mu_blog_list()
3189
-
3190
- /**
3191
- Adds a links directly to the settings page from the plugin page
3192
- */
3193
- function plugin_links($links, $file) {
3194
- if ( $file == S2DIR.'subscribe2.php' ) {
3195
- $links[] = "<a href='admin.php?page=s2_settings'>" . __('Settings', 'subscribe2') . "</a>";
3196
- $links[] = "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904'><b>" . __('Donate', 'subscribe2') . "</b></a>";
3197
- }
3198
- return $links;
3199
- } // end plugin_links()
3200
-
3201
- /**
3202
- Adds information to the WordPress registration screen for new users
3203
- */
3204
- function register_form() {
3205
- if ( 'no' == $this->subscribe2_options['autosub'] ) { return; }
3206
- if ( 'wpreg' == $this->subscribe2_options['autosub'] ) {
3207
- echo "<p>\r\n<label>";
3208
- echo __('Check here to Subscribe to email notifications for new posts', 'subscribe2') . ":<br />\r\n";
3209
- echo "<input type=\"checkbox\" name=\"reg_subscribe\"" . checked($this->subscribe2_options['wpregdef'], 'yes', false) . " />";
3210
- echo "</label>\r\n";
3211
- echo "</p>\r\n";
3212
- } elseif ( 'yes' == $this->subscribe2_options['autosub'] ) {
3213
- echo "<p>\r\n<center>\r\n";
3214
- echo __('By registering with this blog you are also agreeing to receive email notifications for new posts but you can unsubscribe at anytime', 'subscribe2') . ".<br />\r\n";
3215
- echo "</center></p>\r\n";
3216
- }
3217
- } // end register_form()
3218
-
3219
- /**
3220
- Process function to add action if user selects to subscribe to posts during registration
3221
- */
3222
- function register_post($user_ID = 0) {
3223
- global $_POST;
3224
- if ( 0 == $user_ID ) { return; }
3225
- if ( 'yes' == $this->subscribe2_options['autosub'] || ( 'on' == $_POST['reg_subscribe'] && 'wpreg' == $this->subscribe2_options['autosub'] ) ) {
3226
- $this->register($user_ID, true);
3227
- } else {
3228
- $this->register($user_ID, false);
3229
- }
3230
- } // end register_post()
3231
-
3232
- /**
3233
- Register user details when new user is added to a multisite blog
3234
- */
3235
- function wpmu_add_user($user_ID = 0) {
3236
- if ( 0 == $user_ID ) { return; }
3237
- if ( 'yes' == $this->subscribe2_options['autosub'] ) {
3238
- $this->register($user_ID, true);
3239
- } else {
3240
- $this->register($user_ID, false);
3241
- }
3242
- } // end wpmu_add_user()
3243
-
3244
- /**
3245
- Delete user details when a user is removed from a multisite blog
3246
- */
3247
- function wpmu_remove_user($user_ID) {
3248
- if ( 0 == $user_ID ) { return; }
3249
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'));
3250
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'));
3251
- $cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
3252
- if ( !empty($cats) ) {
3253
- $cats = explode(',', $cats);
3254
- foreach ( $cats as $cat ) {
3255
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat);
3256
- }
3257
- }
3258
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
3259
- } // end wpmu_remove_user()
3260
-
3261
- /**
3262
- Create meta box on write pages
3263
- */
3264
- function s2_meta_init() {
3265
- add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'post', 'advanced');
3266
- add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'page', 'advanced');
3267
- } // end s2_meta_init()
3268
-
3269
- /**
3270
- Meta box code
3271
- */
3272
- function s2_meta_box() {
3273
- global $post_ID;
3274
- $s2mail = get_post_meta($post_ID, 's2mail', true);
3275
- echo "<input type=\"hidden\" name=\"s2meta_nonce\" id=\"s2meta_nonce\" value=\"" . wp_create_nonce(md5(plugin_basename(__FILE__))) . "\" />";
3276
- echo __("Check here to disable sending of an email notification for this post/page", 'subscribe2');
3277
- echo "&nbsp;&nbsp;<input type=\"checkbox\" name=\"s2_meta_field\" value=\"no\"";
3278
- if ( $s2mail == 'no' || ($this->subscribe2_options['s2meta_default'] == "1" && $s2mail == "") ) {
3279
- echo " checked=\"checked\"";
3280
- }
3281
- echo " />";
3282
- } // end s2_meta_box()
3283
-
3284
- /**
3285
- Meta box form handler
3286
- */
3287
- function s2_meta_handler($post_id) {
3288
- if ( !isset($_POST['s2meta_nonce']) || !wp_verify_nonce($_POST['s2meta_nonce'], md5(plugin_basename(__FILE__))) ) { return $post_id; }
3289
-
3290
- if ( 'page' == $_POST['post_type'] ) {
3291
- if ( !current_user_can('edit_page', $post_id) ) { return $post_id; }
3292
- } else {
3293
- if ( !current_user_can('edit_post', $post_id) ) { return $post_id; }
3294
- }
3295
-
3296
- if ( isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no' ) {
3297
- update_post_meta($post_id, 's2mail', $_POST['s2_meta_field']);
3298
- } else {
3299
- update_post_meta($post_id, 's2mail', 'yes');
3300
- }
3301
- } // end s2_meta_box_handler()
3302
-
3303
- /* ===== comment subscriber functions ===== */
3304
- /**
3305
- Display check box on comment page
3306
- */
3307
- function s2_comment_meta_form() {
3308
- if ( is_user_logged_in() ) {
3309
- echo $this->profile;
3310
- } else {
3311
- echo "<label><input type=\"checkbox\" name=\"s2_comment_request\" value=\"1\" />" . __('Check here to Subscribe to notifications for new posts', 'subscribe2') . "</label>";
3312
- }
3313
- } // end s2_comment_meta_form()
3314
-
3315
- /**
3316
- Process comment meta data
3317
- */
3318
- function s2_comment_meta($comment_ID, $approved) {
3319
- if ( $_POST['s2_comment_request'] == '1' ) {
3320
- global $wpdb;
3321
- $sql = "SELECT comment_author_email, comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_ID' LIMIT 1";
3322
- $comment = $wpdb->get_row($sql, OBJECT);
3323
- if ( empty($comment) ) { return $comment_ID; }
3324
- switch ($approved) {
3325
- case '0':
3326
- // Unapproved so hold in meta data pending moderation
3327
- add_comment_meta($comment_ID, 's2_comment_request', $_POST['s2_comment_request']);
3328
- break;
3329
- case '1':
3330
- // Approved so add
3331
- $is_public = $this->is_public($comment->comment_author_email);
3332
- if ( $is_public == 0 ) {
3333
- $this->toggle($comment->comment_author_email);
3334
- }
3335
- $is_registered = $this->is_registered($comment->comment_author_email);
3336
- if ( !$is_public && !$is_registered ) {
3337
- $this->activate($comment->comment_author_email);
3338
- }
3339
- break;
3340
- default:
3341
- // post is trash, spam or deleted
3342
- break;
3343
- }
3344
- }
3345
- } // end s2_comment_meta()
3346
-
3347
- /**
3348
- Action subscribe requests made on comment forms when comments are approved
3349
- */
3350
- function comment_status($comment_ID = 0, $comment_status = 0){
3351
- global $wpdb;
3352
-
3353
- // get meta data
3354
- $subscribe = get_comment_meta($comment_ID, 's2_comment_request', true);
3355
- if ( $subscribe != '1' ) { return $comment_ID; }
3356
-
3357
- // Retrieve the information about the comment
3358
- $sql = "SELECT comment_author_email, comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_ID' LIMIT 1";
3359
- $comment = $wpdb->get_row($sql, OBJECT);
3360
- if ( empty($comment) ) { return $comment_ID; }
3361
-
3362
- switch ($comment->comment_approved){
3363
- case '0':
3364
- // Unapproved
3365
- break;
3366
- case '1':
3367
- // Approved
3368
- $is_public = $this->is_public($comment->comment_author_email);
3369
- if ( $is_public == 0 ) {
3370
- $this->toggle($comment->comment_author_email);
3371
- }
3372
- $is_registered = $this->is_registered($comment->comment_author_email);
3373
- if ( !$is_public && !$is_registered ) {
3374
- $this->activate($comment->comment_author_email);
3375
- }
3376
- delete_comment_meta($comment_ID, 's2_comment_request');
3377
- break;
3378
- default:
3379
- // post is trash, spam or deleted
3380
- delete_comment_meta($comment_ID, 's2_comment_request');
3381
- break;
3382
- }
3383
-
3384
- return $comment_ID;
3385
- } // end comment_status()
3386
-
3387
- /* ===== template and filter functions ===== */
3388
- /**
3389
- Display our form; also handles (un)subscribe requests
3390
- */
3391
- function shortcode($atts) {
3392
- extract(shortcode_atts(array(
3393
- 'hide' => '',
3394
- 'id' => '',
3395
- 'url' => '',
3396
- 'nojs' => 'false',
3397
- 'link' => '',
3398
- 'size' => 20
3399
- ), $atts));
3400
-
3401
- // if link is true return a link to the page with the ajax class
3402
- if ( $link !== '' && !is_user_logged_in() ) {
3403
- $this->s2form = "<a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\" class=\"s2popup\">" . $link . "</a>\r\n";
3404
- return $this->s2form;
3405
- }
3406
-
3407
- // if a button is hidden, show only other
3408
- if ( $hide == 'subscribe' ) {
3409
- $this->input_form_action = "<input type=\"submit\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" />";
3410
- } elseif ( $hide == 'unsubscribe' ) {
3411
- $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
3412
- } else {
3413
- // both form input actions
3414
- $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />&nbsp;<input type=\"submit\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" />";
3415
- }
3416
- // if ID is provided, get permalink
3417
- if ( $id ) {
3418
- $url = get_permalink( $id );
3419
- }
3420
- // build default form
3421
- if ( $nojs == 'true' ) {
3422
- $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"\" size=\"" . $size . "\" /></p><p>" . $this->input_form_action . "</p></form>";
3423
- } else {
3424
- $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . __('Enter email address...', 'subscribe2') . "\" size=\"" . $size . "\" onfocus=\"if (this.value == '" . __('Enter email address...', 'subscribe2') . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . __('Enter email address...', 'subscribe2') . "';}\" /></p><p>" . $this->input_form_action . "</p></form>\r\n";
3425
- }
3426
- $this->s2form = $this->form;
3427
-
3428
- global $user_ID;
3429
- get_currentuserinfo();
3430
- if ( $user_ID ) {
3431
- $this->s2form = $this->profile;
3432
- }
3433
- if ( isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) {
3434
- global $wpdb, $user_email;
3435
- if ( !is_email($_POST['email']) ) {
3436
- $this->s2form = $this->form . $this->not_an_email;
3437
- } elseif ( $this->is_barred($_POST['email']) ) {
3438
- $this->s2form = $this->form . $this->barred_domain;
3439
- } else {
3440
- $this->email = $this->sanitize_email($_POST['email']);
3441
- $this->ip = $_POST['ip'];
3442
- // does the supplied email belong to a registered user?
3443
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
3444
- if ( '' != $check ) {
3445
- // this is a registered email
3446
- $this->s2form = $this->please_log_in;
3447
- } else {
3448
- // this is not a registered email
3449
- // what should we do?
3450
- if ( isset($_POST['subscribe']) ) {
3451
- // someone is trying to subscribe
3452
- // lets see if they've tried to subscribe previously
3453
- if ( '1' !== $this->is_public($this->email) ) {
3454
- // the user is unknown or inactive
3455
- $this->add($this->email);
3456
- $status = $this->send_confirm('add');
3457
- // set a variable to denote that we've already run, and shouldn't run again
3458
- $this->filtered = 1;
3459
- if ( $status ) {
3460
- $this->s2form = $this->confirmation_sent;
3461
- } else {
3462
- $this->s2form = $this->error;
3463
- }
3464
- } else {
3465
- // they're already subscribed
3466
- $this->s2form = $this->already_subscribed;
3467
- }
3468
- $this->action = 'subscribe';
3469
- } elseif ( isset($_POST['unsubscribe']) ) {
3470
- // is this email a subscriber?
3471
- if ( false == $this->is_public($this->email) ) {
3472
- $this->s2form = $this->form . $this->not_subscribed;
3473
- } else {
3474
- $status = $this->send_confirm('del');
3475
- // set a variable to denote that we've already run, and shouldn't run again
3476
- $this->filtered = 1;
3477
- if ( $status ) {
3478
- $this->s2form = $this->confirmation_sent;
3479
- } else {
3480
- $this->s2form = $this->error;
3481
- }
3482
- }
3483
- $this->action='unsubscribe';
3484
- }
3485
- }
3486
- }
3487
- }
3488
- return $this->s2form;
3489
- } // end shortcode()
3490
-
3491
- /**
3492
- Display form when deprecated <!--subscribe2--> is used
3493
- */
3494
- function filter($content = '') {
3495
- if ( '' == $content || !strstr($content, '<!--subscribe2-->') ) { return $content; }
3496
-
3497
- return preg_replace('|(<p>)?(\n)*<!--subscribe2-->(\n)*(</p>)?|', do_shortcode( '[subscribe2]' ), $content);
3498
- } // end filter()
3499
-
3500
- /**
3501
- Overrides the default query when handling a (un)subscription confirmation
3502
- This is basically a trick: if the s2 variable is in the query string, just grab the first
3503
- static page and override it's contents later with title_filter()
3504
- */
3505
- function query_filter() {
3506
- // don't interfere if we've already done our thing
3507
- if ( 1 == $this->filtered ) { return; }
3508
-
3509
- global $wpdb;
3510
-
3511
- if ( 0 != $this->subscribe2_options['s2page'] ) {
3512
- return "page_id=" . $this->subscribe2_options['s2page'];
3513
- } else {
3514
- $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
3515
- if ( $id ) {
3516
- return "page_id=$id";
3517
- } else {
3518
- return "showposts=1";
3519
- }
3520
- }
3521
- } // end query_filter()
3522
-
3523
- /**
3524
- Overrides the page title
3525
- */
3526
- function title_filter($title) {
3527
- // don't interfere if we've already done our thing
3528
- if ( in_the_loop() ) {
3529
- return __('Subscription Confirmation', 'subscribe2');
3530
- } else {
3531
- return $title;
3532
- }
3533
- } // end title_filter()
3534
-
3535
- /* ===== widget functions ===== */
3536
- /**
3537
- Register the form widget
3538
- */
3539
- function subscribe2_widget() {
3540
- require_once( S2PATH . 'include/widget.php');
3541
- register_widget('S2_Form_widget');
3542
- } // end subscribe2_widget()
3543
-
3544
- /**
3545
- Register the counter widget
3546
- */
3547
- function counter_widget() {
3548
- require_once( S2PATH . 'include/counterwidget.php');
3549
- register_widget('S2_Counter_widget');
3550
- } // end counter_widget()
3551
-
3552
- /**
3553
- Function to add css and js files to admin header
3554
- */
3555
- function widget_s2counter_css_and_js() {
3556
- // ensure we only add colorpicker js to widgets page
3557
- if ( stripos($_SERVER['REQUEST_URI'], 'widgets.php' ) !== false ) {
3558
- wp_register_style('colorpicker', S2URL . 'include/colorpicker/css/colorpicker.css', '', '20090523'); // colorpicker css
3559
- wp_register_script('colorpicker_js', S2URL . 'include/colorpicker/js/colorpicker' . $this->script_debug . '.js', array('jquery'), '20090523'); // colorpicker js
3560
- wp_register_script('s2_colorpicker', S2URL . 'include/s2_colorpicker' . $this->script_debug . '.js', array('colorpicker_js'), '1.3'); //my js
3561
- wp_enqueue_style('colorpicker');
3562
- wp_enqueue_script('colorpicker_js');
3563
- wp_enqueue_script('s2_colorpicker');
3564
- }
3565
- } // end widget_s2_counter_css_and_js()
3566
-
3567
- /**
3568
- Rename WPMU widgets on upgrade without requiring user to re-enable
3569
- */
3570
- function namechange_subscribe2_widget() {
3571
- global $wpdb;
3572
- $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
3573
-
3574
- foreach ( $blogs as $blog ) {
3575
- switch_to_blog($blog);
3576
-
3577
- $sidebars = get_option('sidebars_widgets');
3578
- if ( empty($sidebars) || !is_array($sidebars) ) { return; }
3579
- $changed = false;
3580
- foreach ( $sidebars as $s =>$sidebar ) {
3581
- if ( empty($sidebar) || !is_array($sidebar) ) { break; }
3582
- foreach ( $sidebar as $w => $widget ) {
3583
- if ( $widget == 'subscribe2widget' ) {
3584
- $sidebars[$s][$w] = 'subscribe2';
3585
- $changed = true;
3586
- }
3587
- }
3588
- }
3589
- if ( $changed ) {
3590
- update_option('sidebar_widgets', $sidebars);
3591
- }
3592
- }
3593
- restore_current_blog();
3594
- } // end namechange_subscribe2_widget()
3595
-
3596
- /**
3597
- Add hook for Minimeta Widget plugin
3598
- */
3599
- function add_minimeta() {
3600
- if ( $this->subscribe2_options['s2page'] != 0 ) {
3601
- echo "<li><a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\">" . __('[Un]Subscribe to Posts', 'subscribe2') . "</a></li>\r\n";
3602
- }
3603
- } // end add_minimeta()
3604
-
3605
- /**
3606
- Add jQuery code and CSS to front pages for ajax form
3607
- */
3608
- function add_ajax() {
3609
- // enqueue the jQuery script we need and let WordPress handle the dependencies
3610
- wp_enqueue_script('jquery-ui-dialog');
3611
- wp_register_style('jquery-ui-style', apply_filters('s2_jqueryui_css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-darkness/jquery-ui.css'));
3612
- wp_enqueue_style('jquery-ui-style');
3613
- } // end add_ajax()
3614
-
3615
- /**
3616
- Write Subscribe2 form js code dynamically so we can pull WordPress functions
3617
- */
3618
- function add_s2_ajax() {
3619
- echo "<script type=\"text/javascript\">\r\n";
3620
- echo "//<![CDATA[\r\n";
3621
- echo "jQuery(document).ready(function() {\r\n";
3622
- echo " var dialog = jQuery('<div></div>')\r\n";
3623
- echo " .html('" . do_shortcode('[subscribe2 nojs="true"]') . "')\r\n";
3624
- if ( $this->s2form != $this->form && !is_user_logged_in() ) {
3625
- echo " .dialog({modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
3626
- } else {
3627
- echo " .dialog({autoOpen: false, modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
3628
- }
3629
- echo " jQuery('a.s2popup').click(function(){\r\n";
3630
- echo " dialog.dialog('open');\r\n";
3631
- echo " return false;\r\n";
3632
- echo " });\r\n";
3633
- echo "});\r\n";
3634
- echo "//]]>\r\n";
3635
- echo "</script>\r\n";
3636
- } // end add_s2_ajax()
3637
-
3638
- /* ===== Write Toolbar Button Functions ===== */
3639
- /**
3640
- Register our button in the QuickTags bar
3641
- */
3642
- function button_init() {
3643
- global $pagenow;
3644
- if ( !in_array($pagenow, array('post-new.php', 'post.php', 'page-new.php', 'page.php')) ) { return; }
3645
- if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) { return; }
3646
- if ( 'true' == get_user_option('rich_editing') ) {
3647
- // Hook into the rich text editor
3648
- add_filter('mce_external_plugins', array(&$this, 'mce3_plugin'));
3649
- add_filter('mce_buttons', array(&$this, 'mce3_button'));
3650
- } else {
3651
- if ( version_compare($this->wp_release, '3.3', '<') ) {
3652
- wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button' . $this->script_debug . '.js', array('quicktags'), '1.0' );
3653
- } else {
3654
- // use QTags.addButton for WordPress 3.3 and greater
3655
- wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button2' . $this->script_debug . '.js', array('quicktags'), '2.0' );
3656
- }
3657
- }
3658
- } // end button_init()
3659
-
3660
- /**
3661
- Add buttons for Rich Text Editor
3662
- */
3663
- function mce3_plugin($arr) {
3664
- $path = S2URL . 'tinymce3/editor_plugin' . $this->script_debug . '.js';
3665
- $arr['subscribe2'] = $path;
3666
- return $arr;
3667
- } // end mce3_plugin()
3668
-
3669
- function mce3_button($arr) {
3670
- $arr[] = 'subscribe2';
3671
- return $arr;
3672
- } // end mce3_button()
3673
-
3674
- /* ===== wp-cron functions ===== */
3675
- /**
3676
- Add a weekly event to cron
3677
- */
3678
- function add_weekly_sched($sched) {
3679
- $sched['weekly'] = array('interval' => 604800, 'display' => __('Weekly', 'subscribe2'));
3680
- return $sched;
3681
- } // end add_weekly_sched()
3682
-
3683
- /**
3684
- Send a daily digest of today's new posts
3685
- */
3686
- function subscribe2_cron($preview = '', $resend = '') {
3687
- if ( defined('DOING_S2_CRON') && DOING_S2_CRON ) { return; }
3688
- define( 'DOING_S2_CRON', true );
3689
- global $wpdb;
3690
-
3691
- if ( '' == $preview ) {
3692
- // update last_s2cron execution time before completing or bailing
3693
- $now = current_time('mysql');
3694
- $prev = $this->subscribe2_options['last_s2cron'];
3695
- $last = $this->subscribe2_options['previous_s2cron'];
3696
- $this->subscribe2_options['last_s2cron'] = $now;
3697
- $this->subscribe2_options['previous_s2cron'] = $prev;
3698
- if ( '' == $resend ) {
3699
- // update sending times provided this is not a resend
3700
- update_option('subscribe2_options', $this->subscribe2_options);
3701
- }
3702
-
3703
- // set up SQL query based on options
3704
- if ( $this->subscribe2_options['private'] == 'yes' ) {
3705
- $status = "'publish', 'private'";
3706
- } else {
3707
- $status = "'publish'";
3708
- }
3709
-
3710
- // send notifications for allowed post type (defaults for posts and pages)
3711
- // uses s2_post_types filter to allow for custom post types in WP 3.0
3712
- if ( $this->subscribe2_options['pages'] == 'yes' ) {
3713
- $s2_post_types = array('page', 'post');
3714
- } else {
3715
- $s2_post_types = array('post');
3716
- }
3717
- $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
3718
- foreach( $s2_post_types as $post_type ) {
3719
- ('' == $type) ? $type = "'$post_type'" : $type .= ", '$post_type'";
3720
- }
3721
-
3722
- // collect posts
3723
- if ( $resend == 'resend' ) {
3724
- if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
3725
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
3726
- } else {
3727
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
3728
- }
3729
- } else {
3730
- if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
3731
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
3732
- } else {
3733
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
3734
- }
3735
- }
3736
- } else {
3737
- // we are sending a preview
3738
- $posts = get_posts('numberposts=1');
3739
- }
3740
-
3741
- // do we have any posts?
3742
- if ( empty($posts) && !has_filter('s2_digest_email') ) { return false; }
3743
- $this->post_count = count($posts);
3744
-
3745
- // if we have posts, let's prepare the digest
3746
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
3747
- $all_post_cats = array();
3748
- $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
3749
- $table = '';
3750
- $tablelinks = '';
3751
- $message_post= '';
3752
- $message_posttime = '';
3753
- foreach ( $posts as $post ) {
3754
- $post_cats = wp_get_post_categories($post->ID);
3755
- $post_cats_string = implode(',', $post_cats);
3756
- $all_post_cats = array_unique(array_merge($all_post_cats, $post_cats));
3757
- $check = false;
3758
- // Pages are put into category 1 so make sure we don't exclude
3759
- // pages if category 1 is excluded
3760
- if ( $post->post_type != 'page' ) {
3761
- // is the current post assigned to any categories
3762
- // which should not generate a notification email?
3763
- foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
3764
- if ( in_array($cat, $post_cats) ) {
3765
- $check = true;
3766
- }
3767
- }
3768
- }
3769
- // is the current post set by the user to
3770
- // not generate a notification email?
3771
- $s2mail = get_post_meta($post->ID, 's2mail', true);
3772
- if ( strtolower(trim($s2mail)) == 'no' ) {
3773
- $check = true;
3774
- }
3775
- // is the current post private
3776
- // and should this not generate a notification email?
3777
- if ( $this->subscribe2_options['password'] == 'no' && $post->post_password != '' ) {
3778
- $check = true;
3779
- }
3780
- // is the post assigned a format that should
3781
- // not be included in the notification email?
3782
- $post_format = get_post_format($post->ID);
3783
- $excluded_formats = explode(',', $this->subscribe2_options['exclude_formats']);
3784
- if ( $post_format !== false && in_array($post_format, $excluded_formats) ) {
3785
- $check = true;
3786
- }
3787
- // if this post is excluded
3788
- // don't include it in the digest
3789
- if ( $check ) {
3790
- continue;
3791
- }
3792
- $post_title = html_entity_decode($post->post_title, ENT_QUOTES);
3793
- ('' == $table) ? $table .= "* " . $post_title : $table .= "\r\n* " . $post_title;
3794
- ('' == $tablelinks) ? $tablelinks .= "* " . $post_title : $tablelinks .= "\r\n* " . $post_title;
3795
- $message_post .= $post_title;
3796
- $message_posttime .= $post_title;
3797
- if ( strstr($mailtext, "{AUTHORNAME}") ) {
3798
- $author = get_userdata($post->post_author);
3799
- if ( $author->display_name != '' ) {
3800
- $message_post .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
3801
- $message_posttime .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
3802
- }
3803
- }
3804
- $message_post .= "\r\n";
3805
- $message_posttime .= "\r\n";
3806
-
3807
- $tablelinks .= "\r\n" . $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
3808
- $message_post .= $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
3809
- $message_posttime .= __('Posted on', 'subscribe2') . ": " . mysql2date($datetime, $post->post_date) . "\r\n";
3810
- $message_posttime .= $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
3811
- if ( strstr($mailtext, "{CATS}") ) {
3812
- $post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
3813
- $message_post .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
3814
- $message_posttime .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
3815
- }
3816
- if ( strstr($mailtext, "{TAGS}") ) {
3817
- $post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
3818
- if ( $post_tag_names != '' ) {
3819
- $message_post .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
3820
- $message_posttime .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
3821
- }
3822
- }
3823
- $message_post .= "\r\n";
3824
- $message_posttime .= "\r\n";
3825
-
3826
- $excerpt = $post->post_excerpt;
3827
- if ( '' == $excerpt ) {
3828
- // no excerpt, is there a <!--more--> ?
3829
- if ( false !== strpos($post->post_content, '<!--more-->') ) {
3830
- list($excerpt, $more) = explode('<!--more-->', $post->post_content, 2);
3831
- $excerpt = strip_tags($excerpt);
3832
- if ( function_exists('strip_shortcodes') ) {
3833
- $excerpt = strip_shortcodes($excerpt);
3834
- }
3835
- } else {
3836
- $excerpt = strip_tags($post->post_content);
3837
- if ( function_exists('strip_shortcodes') ) {
3838
- $excerpt = strip_shortcodes($excerpt);
3839
- }
3840
- $words = explode(' ', $excerpt, $this->excerpt_length + 1);
3841
- if ( count($words) > $this->excerpt_length ) {
3842
- array_pop($words);
3843
- array_push($words, '[...]');
3844
- $excerpt = implode(' ', $words);
3845
- }
3846
- }
3847
- // strip leading and trailing whitespace
3848
- $excerpt = trim($excerpt);
3849
- }
3850
- $message_post .= $excerpt . "\r\n\r\n";
3851
- $message_posttime .= $excerpt . "\r\n\r\n";
3852
- }
3853
-
3854
- // we add a blank line after each post excerpt now trim white space that occurs for the last post
3855
- $message_post = trim($message_post);
3856
- $message_posttime = trim($message_posttime);
3857
- // remove excess white space from within $message_post and $message_posttime
3858
- $message_post = preg_replace('|\s+|', ' ', $message_post);
3859
- $message_posttime = preg_replace('|\s+|', ' ', $message_posttime);
3860
-
3861
- // apply filter to allow external content to be inserted or content manipulated
3862
- $message_post = apply_filters('s2_digest_email', $message_post, $now, $prev, $last, $this->subscribe2_options['cron_order']);
3863
- $message_posttime = apply_filters('s2_digest_email', $message_posttime, $now, $prev, $last, $this->subscribe2_options['cron_order']);
3864
-
3865
- //sanity check - don't send a mail if the content is empty
3866
- if ( !$message_post && !$message_posttime && !$table && !$tablelinks ) {
3867
- return;
3868
- }
3869
-
3870
- // get sender details
3871
- if ( $this->subscribe2_options['sender'] == 'blogname' ) {
3872
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
3873
- $this->myemail = get_bloginfo('admin_email');
3874
- } else {
3875
- $user = $this->get_userdata($this->subscribe2_options['sender']);
3876
- $this->myemail = $user->user_email;
3877
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
3878
- }
3879
-
3880
- $scheds = (array)wp_get_schedules();
3881
- $email_freq = $this->subscribe2_options['email_freq'];
3882
- $display = $scheds[$email_freq]['display'];
3883
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
3884
- $subject .= $display . " " . __('Digest Email', 'subscribe2');
3885
- $mailtext = str_replace("{TABLELINKS}", $tablelinks, $mailtext);
3886
- $mailtext = str_replace("{TABLE}", $table, $mailtext);
3887
- $mailtext = str_replace("{POSTTIME}", $message_posttime, $mailtext);
3888
- $mailtext = str_replace("{POST}", $message_post, $mailtext);
3889
- $mailtext = stripslashes($this->substitute($mailtext));
3890
-
3891
- // prepare recipients
3892
- if ( $preview != '' ) {
3893
- $this->myemail = $preview;
3894
- $this->myname = __('Digest Preview', 'subscribe2');
3895
- $this->mail(array($preview), $subject, $mailtext);
3896
- } else {
3897
- $public = $this->get_public();
3898
- $all_post_cats_string = implode(',', $all_post_cats);
3899
- $registered = $this->get_registered("cats=$all_post_cats_string");
3900
- $recipients = array_merge((array)$public, (array)$registered);
3901
- $this->mail($recipients, $subject, $mailtext);
3902
- }
3903
- } // end subscribe2_cron()
3904
-
3905
- /* ===== Our constructor ===== */
3906
- /**
3907
- Subscribe2 constructor
3908
- */
3909
- function s2init() {
3910
- // load the options
3911
- $this->subscribe2_options = get_option('subscribe2_options');
3912
- // if SCRIPT_DEBUG is true, use dev scripts
3913
- $this->script_debug = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '.dev' : '';
3914
-
3915
- // get the WordPress release number for in code version comparisons
3916
- list($this->wp_release, $more) = explode('-', $GLOBALS['wp_version'], 2);
3917
-
3918
- add_action('init', array(&$this, 'subscribe2'));
3919
- if ( '1' == $this->subscribe2_options['show_button'] ) {
3920
- add_action('admin_init', array(&$this, 'button_init'));
3921
- }
3922
-
3923
- // add action to display widget if option is enabled
3924
- if ( '1' == $this->subscribe2_options['widget'] ) {
3925
- add_action('widgets_init', array(&$this, 'subscribe2_widget'));
3926
- }
3927
-
3928
- // add action to display counter widget if option is enabled
3929
- if ( '1' == $this->subscribe2_options['counterwidget'] ) {
3930
- add_action('admin_init', array(&$this, 'widget_s2counter_css_and_js'));
3931
- add_action('widgets_init', array(&$this, 'counter_widget'));
3932
- }
3933
-
3934
- // add action to handle WPMU subscriptions and unsubscriptions
3935
- if ( isset($_GET['s2mu_subscribe']) || isset($_GET['s2mu_unsubscribe']) ) {
3936
- add_action('init', array(&$this, 'wpmu_subscribe'));
3937
- }
3938
- } // end s2init()
3939
-
3940
- function subscribe2() {
3941
- global $wpdb, $table_prefix, $wp_version, $wpmu_version;
3942
-
3943
- load_plugin_textdomain('subscribe2', false, S2DIR);
3944
-
3945
- // Is this WordPressMU or not?
3946
- $this->s2_mu = false;
3947
- if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
3948
- $this->s2_mu = true;
3949
- }
3950
- if ( function_exists('is_multisite') && is_multisite() ) {
3951
- $this->s2_mu = true;
3952
- }
3953
-
3954
- // do we need to install anything?
3955
- $this->public = $table_prefix . "subscribe2";
3956
- if ( $wpdb->get_var("SHOW TABLES LIKE '{$this->public}'") != $this->public ) { $this->install(); }
3957
- //do we need to upgrade anything?
3958
- if ( is_array($this->subscribe2_options) && $this->subscribe2_options['version'] !== S2VERSION ) {
3959
- add_action('shutdown', array(&$this, 'upgrade'));
3960
- }
3961
-
3962
- if ( isset($_GET['s2']) ) {
3963
- // someone is confirming a request
3964
- if ( defined('DOING_S2_CONFIRM') && DOING_S2_CONFIRM ) { return; }
3965
- define( 'DOING_S2_CONFIRM', true );
3966
- add_filter('query_string', array(&$this, 'query_filter'));
3967
- add_filter('the_title', array(&$this, 'title_filter'));
3968
- add_filter('the_content', array(&$this, 'confirm'));
3969
- }
3970
-
3971
- if ( isset($_POST['s2_admin']) && $_POST['csv'] ) {
3972
- $date = date('Y-m-d');
3973
- header("Content-Description: File Transfer");
3974
- header("Content-type: application/octet-stream");
3975
- header("Content-Disposition: attachment; filename=subscribe2_users_$date.csv");
3976
- header("Pragma: no-cache");
3977
- header("Expires: 0");
3978
- echo $this->prepare_export($_POST['exportcsv']);
3979
- exit(0);
3980
- }
3981
-
3982
- //add regular actions and filters
3983
- add_action('admin_menu', array(&$this, 'admin_menu'));
3984
- add_action('admin_menu', array(&$this, 's2_meta_init'));
3985
- add_action('save_post', array(&$this, 's2_meta_handler'));
3986
- add_action('create_category', array(&$this, 'new_category'));
3987
- add_action('delete_category', array(&$this, 'delete_category'));
3988
- add_shortcode('subscribe2', array(&$this, 'shortcode'));
3989
- add_filter('the_content', array(&$this, 'filter'), 10);
3990
- add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
3991
-
3992
- // add actions for other plugins
3993
- if ( '1' == $this->subscribe2_options['show_meta'] ) {
3994
- add_action('wp_meta', array(&$this, 'add_minimeta'), 0);
3995
- }
3996
-
3997
- // add actions for ajax form if enabled
3998
- if ( '1' == $this->subscribe2_options['ajax'] ) {
3999
- add_action('wp_enqueue_scripts', array(&$this, 'add_ajax'));
4000
- add_action('wp_head', array(&$this, 'add_s2_ajax'));
4001
- }
4002
-
4003
- // Add filters for Ozh Admin Menu
4004
- if ( function_exists('wp_ozh_adminmenu') ) {
4005
- add_filter('ozh_adminmenu_icon_s2_posts', array(&$this, 'ozh_s2_icon'));
4006
- add_filter('ozh_adminmenu_icon_s2_users', array(&$this, 'ozh_s2_icon'));
4007
- add_filter('ozh_adminmenu_icon_s2_tools', array(&$this, 'ozh_s2_icon'));
4008
- add_filter('ozh_adminmenu_icon_s2_settings', array(&$this, 'ozh_s2_icon'));
4009
- }
4010
-
4011
- // add actions for automatic subscription based on option settings
4012
- add_action('register_form', array(&$this, 'register_form'));
4013
- add_action('user_register', array(&$this, 'register_post'));
4014
- if ( $this->s2_mu ) {
4015
- add_action('add_user_to_blog', array(&$this, 'wpmu_add_user'), 10);
4016
- add_action('remove_user_from_blog', array(&$this, 'wpmu_remove_user'), 10);
4017
- }
4018
-
4019
- // add actions for processing posts based on per-post or cron email settings
4020
- if ( $this->subscribe2_options['email_freq'] != 'never' ) {
4021
- add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
4022
- } else {
4023
- add_action('new_to_publish', array(&$this, 'publish'));
4024
- add_action('draft_to_publish', array(&$this, 'publish'));
4025
- add_action('auto-draft_to_publish', array(&$this, 'publish'));
4026
- add_action('pending_to_publish', array(&$this, 'publish'));
4027
- add_action('private_to_publish', array(&$this, 'publish'));
4028
- add_action('future_to_publish', array(&$this, 'publish'));
4029
- if ( $this->subscribe2_options['private'] == 'yes' ) {
4030
- add_action('new_to_private', array(&$this, 'publish'));
4031
- add_action('draft_to_private', array(&$this, 'publish'));
4032
- add_action('auto-draft_to_private', array(&$this, 'publish'));
4033
- add_action('pending_to_private', array(&$this, 'publish'));
4034
- }
4035
- }
4036
-
4037
- // add actions for comment subscribers
4038
- if ( 'no' != $this->subscribe2_options['comment_subs'] ) {
4039
- if ( 'before' == $this->subscribe2_options['comment_subs'] ) {
4040
- add_action('comment_form_after_fields', array(&$this, 's2_comment_meta_form'));
4041
- } else {
4042
- add_action('comment_form', array(&$this, 's2_comment_meta_form'));
4043
- }
4044
- add_action('comment_post', array(&$this, 's2_comment_meta'), 1, 2);
4045
- add_action('wp_set_comment_status', array(&$this, 'comment_status'));
4046
- }
4047
-
4048
- // load our strings
4049
- $this->load_strings();
4050
- } // end subscribe2()
4051
-
4052
- /* ===== our variables ===== */
4053
- // cache variables
4054
- var $subscribe2_options = array();
4055
- var $all_public = '';
4056
- var $all_unconfirmed = '';
4057
- var $all_authors = '';
4058
- var $excluded_cats = '';
4059
- var $post_title = '';
4060
- var $permalink = '';
4061
- var $post_date = '';
4062
- var $post_time = '';
4063
- var $myname = '';
4064
- var $myemail = '';
4065
- var $signup_dates = array();
4066
- var $filtered = 0;
4067
- var $preview_email = false;
4068
-
4069
- // state variables used to affect processing
4070
- var $action = '';
4071
- var $email = '';
4072
- var $message = '';
4073
- var $excerpt_length = 55;
4074
-
4075
- // some messages
4076
- var $please_log_in = '';
4077
- var $profile = '';
4078
- var $confirmation_sent = '';
4079
- var $already_subscribed = '';
4080
- var $not_subscribed ='';
4081
- var $not_an_email = '';
4082
- var $barred_domain = '';
4083
- var $error = '';
4084
- var $mail_sent = '';
4085
- var $mail_failed = '';
4086
- var $form = '';
4087
- var $no_such_email = '';
4088
- var $added = '';
4089
- var $deleted = '';
4090
- var $subscribe = '';
4091
- var $unsubscribe = '';
4092
- var $confirm_subject = '';
4093
- var $options_saved = '';
4094
- var $options_reset = '';
4095
- } // end class subscribe2
4096
  ?>
3
  Plugin Name: Subscribe2
4
  Plugin URI: http://subscribe2.wordpress.com
5
  Description: Notifies an email list when new entries are posted.
6
+ Version: 8.0
7
  Author: Matthew Robinson
8
  Author URI: http://subscribe2.wordpress.com
9
+ Licence: GPL3
10
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904
11
  */
12
 
31
  along with Subscribe2. If not, see <http://www.gnu.org/licenses/>.
32
  */
33
 
34
+ if ( version_compare($GLOBALS['wp_version'], '3.1', '<') || !function_exists( 'add_action' ) ) {
35
+ if ( !function_exists( 'add_action' ) ) {
36
+ $exit_msg = "I'm just a plugin, please don't call me directly";
37
+ } else {
38
+ // Subscribe2 needs WordPress 3.1 or above, exit if not on a compatible version
39
+ $exit_msg = sprintf(__('This version of Subscribe2 requires WordPress 3.1 or greater. Please update %1$s or use an older version of %2$s.', 'subscribe2'), '<a href="http://codex.wordpress.org/Updating_WordPress">Wordpress</a>', '<a href="http://wordpress.org/extend/plugins/subscribe2/download/">Subscribe2</a>');
40
+ }
41
  exit($exit_msg);
42
  }
43
 
44
  // our version number. Don't touch this or any line below
45
  // unless you know exactly what you are doing
46
+ define( 'S2VERSION', '8.0' );
47
  define( 'S2PATH', trailingslashit(dirname(__FILE__)) );
48
  define( 'S2DIR', trailingslashit(dirname(plugin_basename(__FILE__))) );
49
  define( 'S2URL', plugin_dir_url(dirname(__FILE__)) . S2DIR );
54
  @ini_set('max_execution_time', 300);
55
  }
56
 
57
+ require_once(S2PATH . 'classes/class-s2-core.php');
58
+ if ( is_admin() ) {
59
+ require_once(S2PATH . 'classes/class-s2-admin.php');
60
+ $mysubscribe2 = new s2_admin;
61
+ $mysubscribe2->s2init();
62
+ } else {
63
+ require_once(S2PATH . 'classes/class-s2-frontend.php');
64
+ $mysubscribe2 = new s2_frontend;
65
+ $mysubscribe2->s2init();
66
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  ?>
subscribe2.pot CHANGED
@@ -8,7 +8,7 @@ msgid ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2012-02-01 20:48+0000\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,957 +17,1031 @@ msgstr ""
17
  "Content-Type: text/plain; charset=CHARSET\n"
18
  "Content-Transfer-Encoding: 8bit\n"
19
 
20
- #: subscribe2.php:35
21
- #, php-format
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  msgid ""
23
- "This version of Subscribe2 requires WordPress 3.1 or greater. Please update "
24
- "%1$s or use an older version of %2$s."
25
  msgstr ""
26
 
27
- #: subscribe2.php:65
28
- msgid "To manage your subscription options please"
29
  msgstr ""
30
 
31
- #: subscribe2.php:65
32
- msgid "login"
33
  msgstr ""
34
 
35
- #: subscribe2.php:67
36
- msgid "You may manage your subscription options from your"
37
  msgstr ""
38
 
39
- #: subscribe2.php:67
40
- msgid "profile"
41
  msgstr ""
42
 
43
- #: subscribe2.php:72 subscribe2.php:1789 subscribe2.php:1895
44
- #: subscribe2.php:2646 subscribe2.php:3411 subscribe2.php:3414
45
- msgid "Subscribe"
46
  msgstr ""
47
 
48
- #: subscribe2.php:72
49
- msgid "to email notifications when this blog posts new content"
50
  msgstr ""
51
 
52
- #: subscribe2.php:76
53
- msgid "A confirmation message is on its way!"
54
  msgstr ""
55
 
56
- #: subscribe2.php:78
57
- msgid "That email address is already subscribed."
58
  msgstr ""
59
 
60
- #: subscribe2.php:80
61
- msgid "That email address is not subscribed."
62
  msgstr ""
63
 
64
- #: subscribe2.php:82
65
- msgid "Sorry, but that does not look like an email address to me."
66
  msgstr ""
67
 
68
- #: subscribe2.php:84
69
- msgid ""
70
- "Sorry, email addresses at that domain are currently barred due to spam, "
71
- "please use an alternative email address."
72
  msgstr ""
73
 
74
- #: subscribe2.php:86
75
- msgid ""
76
- "Sorry, there seems to be an error on the server. Please try again later."
77
  msgstr ""
78
 
79
- #: subscribe2.php:88
80
- msgid "You must to create a WordPress page for this plugin to work correctly."
81
  msgstr ""
82
 
83
- #: subscribe2.php:90
84
- msgid "Message sent!"
85
  msgstr ""
86
 
87
- #: subscribe2.php:92
88
- msgid ""
89
- "Message failed! Check your settings and check with your hosting provider"
90
  msgstr ""
91
 
92
- #: subscribe2.php:95
93
- msgid "No such email address is registered."
 
 
 
 
94
  msgstr ""
95
 
96
- #: subscribe2.php:97
97
- msgid "You have successfully subscribed!"
 
 
 
 
98
  msgstr ""
99
 
100
- #: subscribe2.php:99
101
- msgid "You have successfully unsubscribed."
102
  msgstr ""
103
 
104
- #: subscribe2.php:101
105
- msgid "subscribe"
 
106
  msgstr ""
107
 
108
- #: subscribe2.php:103
109
- msgid "unsubscribe"
110
  msgstr ""
111
 
112
- #: subscribe2.php:106
113
- msgid "Options saved!"
114
  msgstr ""
115
 
116
- #: subscribe2.php:107
117
- msgid "Options reset!"
118
  msgstr ""
119
 
120
- #: subscribe2.php:115 include/widget.php:17
121
- msgid "Subscribe2"
122
  msgstr ""
123
 
124
- #: subscribe2.php:117
125
- msgid "Your Subscriptions"
126
  msgstr ""
127
 
128
- #: subscribe2.php:121
129
- msgid "Subscribers"
130
  msgstr ""
131
 
132
- #: subscribe2.php:124 subscribe2.php:3195
133
- msgid "Settings"
134
  msgstr ""
135
 
136
- #: subscribe2.php:129
137
- msgid "Send Email"
138
  msgstr ""
139
 
140
- #: subscribe2.php:717
141
- msgid "Plain Text Excerpt Preview"
142
  msgstr ""
143
 
144
- #: subscribe2.php:719
145
- msgid "Plain Text Full Preview"
146
  msgstr ""
147
 
148
- #: subscribe2.php:721
149
- msgid "HTML Excerpt Preview"
150
  msgstr ""
151
 
152
- #: subscribe2.php:723
153
- msgid "HTML Full Preview"
154
  msgstr ""
155
 
156
- #: subscribe2.php:951
157
- msgid "New Subscription"
158
  msgstr ""
159
 
160
- #: subscribe2.php:953
161
- msgid "subscribed to email notifications!"
162
  msgstr ""
163
 
164
- #: subscribe2.php:974
165
- msgid "New Unsubscription"
 
166
  msgstr ""
167
 
168
- #: subscribe2.php:976
169
- msgid "unsubscribed from email notifications!"
170
  msgstr ""
171
 
172
- #: subscribe2.php:1596
173
- msgid "Address(es) subscribed!"
 
 
174
  msgstr ""
175
 
176
- #: subscribe2.php:1603
177
- msgid "Address(es) unsubscribed!"
 
 
178
  msgstr ""
179
 
180
- #: subscribe2.php:1607
181
- msgid "Some emails were not processed, the following were already subscribed"
182
  msgstr ""
183
 
184
- #: subscribe2.php:1610
185
- msgid "Some emails were not processed, the following were not in the database"
 
 
186
  msgstr ""
187
 
188
- #: subscribe2.php:1619
189
- msgid "Address(es) deleted!"
190
  msgstr ""
191
 
192
- #: subscribe2.php:1625 subscribe2.php:1631
193
- msgid "Status changed!"
 
 
194
  msgstr ""
195
 
196
- #: subscribe2.php:1645
197
- msgid "Reminder Email(s) Sent!"
198
  msgstr ""
199
 
200
- #: subscribe2.php:1648
201
- msgid "Registered Users Subscribed!"
202
  msgstr ""
203
 
204
- #: subscribe2.php:1651
205
- msgid "Registered Users Unsubscribed!"
206
  msgstr ""
207
 
208
- #: subscribe2.php:1654
209
- msgid "Format updated for Selected Registered Users!"
210
  msgstr ""
211
 
212
- #: subscribe2.php:1657
213
- msgid "Digest Subscription updated for Selected Registered Users!"
214
  msgstr ""
215
 
216
- #: subscribe2.php:1752
217
- msgid "Previous Page"
 
 
218
  msgstr ""
219
 
220
- #: subscribe2.php:1772
221
- msgid "Next Page"
 
 
222
  msgstr ""
223
 
224
- #: subscribe2.php:1779
225
- msgid "Manage Subscribers"
226
  msgstr ""
227
 
228
- #: subscribe2.php:1785
229
- msgid "Add/Remove Subscribers"
230
  msgstr ""
231
 
232
- #: subscribe2.php:1786
233
- msgid "Enter addresses, one per line or comma-separated"
 
 
234
  msgstr ""
235
 
236
- #: subscribe2.php:1790 subscribe2.php:1896 subscribe2.php:2625
237
- #: subscribe2.php:3409 subscribe2.php:3414
238
- msgid "Unsubscribe"
239
  msgstr ""
240
 
241
- #: subscribe2.php:1795
242
- msgid "Current Subscribers"
243
  msgstr ""
244
 
245
- #: subscribe2.php:1797
246
- msgid "Filter"
247
  msgstr ""
248
 
249
- #: subscribe2.php:1804
250
- msgid "Search Subscribers"
 
 
251
  msgstr ""
252
 
253
- #: subscribe2.php:1807
254
- msgid "Send Reminder Email"
255
  msgstr ""
256
 
257
- #: subscribe2.php:1814
258
- msgid "Save Emails to CSV File"
259
  msgstr ""
260
 
261
- #: subscribe2.php:1821 subscribe2.php:1880
262
- msgid "Process"
 
 
263
  msgstr ""
264
 
265
- #: subscribe2.php:1834 subscribe2.php:1856
266
- msgid "Confirm this email address"
267
  msgstr ""
268
 
269
- #: subscribe2.php:1836 subscribe2.php:1849
270
- msgid "Unconfirm this email address"
271
  msgstr ""
272
 
273
- #: subscribe2.php:1838 subscribe2.php:1851 subscribe2.php:1859
274
- msgid "Delete this email address"
275
  msgstr ""
276
 
277
- #: subscribe2.php:1842 subscribe2.php:2790 subscribe2.php:2836
278
- #: subscribe2.php:2876
279
- msgid "Select / Unselect All"
280
  msgstr ""
281
 
282
- #: subscribe2.php:1867
283
- msgid "edit"
284
  msgstr ""
285
 
286
- #: subscribe2.php:1874
287
- msgid "No matching subscribers found"
288
  msgstr ""
289
 
290
- #: subscribe2.php:1876
291
- msgid "NONE"
292
  msgstr ""
293
 
294
- #: subscribe2.php:1890
295
- msgid "Bulk Management"
296
  msgstr ""
297
 
298
- #: subscribe2.php:1892 subscribe2.php:1908
299
- msgid ""
300
- "Preferences for Registered Users selected in the filter above can be changed "
301
- "using this section."
302
  msgstr ""
303
 
304
- #: subscribe2.php:1893 subscribe2.php:1909
305
- msgid "Consider User Privacy as changes cannot be undone"
306
  msgstr ""
307
 
308
- #: subscribe2.php:1894
309
- msgid "Action to perform"
310
  msgstr ""
311
 
312
- #: subscribe2.php:1899
313
- msgid "Bulk Update Categories"
314
  msgstr ""
315
 
316
- #: subscribe2.php:1901
317
- msgid "Send email as"
318
  msgstr ""
319
 
320
- #: subscribe2.php:1902 subscribe2.php:2348 subscribe2.php:2504
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  msgid "HTML - Full"
322
  msgstr ""
323
 
324
- #: subscribe2.php:1903 subscribe2.php:2350 subscribe2.php:2506
 
325
  msgid "HTML - Excerpt"
326
  msgstr ""
327
 
328
- #: subscribe2.php:1904 subscribe2.php:2352 subscribe2.php:2508
 
329
  msgid "Plain Text - Full"
330
  msgstr ""
331
 
332
- #: subscribe2.php:1905 subscribe2.php:2354 subscribe2.php:2510
 
333
  msgid "Plain Text - Excerpt"
334
  msgstr ""
335
 
336
- #: subscribe2.php:1906
337
- msgid "Bulk Update Format"
338
  msgstr ""
339
 
340
- #: subscribe2.php:1910
341
- msgid "Subscribe Selected Users to recieve a periodic digest notification"
342
  msgstr ""
343
 
344
- #: subscribe2.php:1912 subscribe2.php:2164 subscribe2.php:2170
345
- #: subscribe2.php:2184 subscribe2.php:2189 subscribe2.php:2338
346
- #: subscribe2.php:2343 subscribe2.php:2357 subscribe2.php:2364
347
- #: subscribe2.php:2515 subscribe2.php:2548
348
- msgid "Yes"
349
  msgstr ""
350
 
351
- #: subscribe2.php:1914 subscribe2.php:2166 subscribe2.php:2172
352
- #: subscribe2.php:2186 subscribe2.php:2191 subscribe2.php:2335
353
- #: subscribe2.php:2340 subscribe2.php:2345 subscribe2.php:2359
354
- #: subscribe2.php:2366 subscribe2.php:2373 subscribe2.php:2517
355
- #: subscribe2.php:2552
356
- msgid "No"
357
  msgstr ""
358
 
359
- #: subscribe2.php:1916
360
- msgid "Bulk Update Digest Subscription"
361
  msgstr ""
362
 
363
- #: subscribe2.php:1955
364
- msgid "Preview message(s) sent to logged in user"
365
  msgstr ""
366
 
367
- #: subscribe2.php:1959
 
 
 
 
 
 
 
 
368
  msgid ""
369
- "The Digest Notification email contained no post information. No email was "
370
- "sent"
371
  msgstr ""
372
 
373
- #: subscribe2.php:1961
374
- msgid "Attempt made to resend the Digest Notification email"
375
  msgstr ""
376
 
377
- #: subscribe2.php:2129
378
- msgid "Subscribe2 Settings"
379
  msgstr ""
380
 
381
- #: subscribe2.php:2130
382
- msgid "Plugin Blog"
 
 
383
  msgstr ""
384
 
385
- #: subscribe2.php:2131
386
- msgid "Make a donation via PayPal"
387
  msgstr ""
388
 
389
- #: subscribe2.php:2143 subscribe2.php:2490
390
- msgid "Notification Settings"
391
  msgstr ""
392
 
393
- #: subscribe2.php:2144
394
- msgid "Restrict the number of recipients per email to (0 for unlimited)"
395
  msgstr ""
396
 
397
- #: subscribe2.php:2146 subscribe2.php:2293
398
- msgid "Edit"
399
  msgstr ""
400
 
401
- #: subscribe2.php:2149 subscribe2.php:2296
402
- msgid "Update"
403
  msgstr ""
404
 
405
- #: subscribe2.php:2150 subscribe2.php:2297
406
- msgid "Revert"
407
  msgstr ""
408
 
409
- #: subscribe2.php:2152
410
- msgid "Send Admins notifications for new"
411
  msgstr ""
412
 
413
- #: subscribe2.php:2154
414
- msgid "Subscriptions"
415
  msgstr ""
416
 
417
- #: subscribe2.php:2156
418
- msgid "Unsubscriptions"
419
  msgstr ""
420
 
421
- #: subscribe2.php:2158
422
- msgid "Both"
423
  msgstr ""
424
 
425
- #: subscribe2.php:2160
426
- msgid "Neither"
427
  msgstr ""
428
 
429
- #: subscribe2.php:2162
430
- msgid "Include theme CSS stylesheet in HTML notifications"
431
  msgstr ""
432
 
433
- #: subscribe2.php:2168
434
- msgid "Send Emails for Pages"
435
  msgstr ""
436
 
437
- #: subscribe2.php:2176
438
- msgid ""
439
- "Subscribe2 will send email notifications for the following custom post types"
440
  msgstr ""
441
 
442
- #: subscribe2.php:2182
443
- msgid "Send Emails for Password Protected Posts"
444
  msgstr ""
445
 
446
- #: subscribe2.php:2187
447
- msgid "Send Emails for Private Posts"
448
  msgstr ""
449
 
450
- #: subscribe2.php:2192
451
- msgid "Send Email From"
452
  msgstr ""
453
 
454
- #: subscribe2.php:2197
455
- msgid "Send Emails"
 
 
456
  msgstr ""
457
 
458
- #: subscribe2.php:2199
459
- msgid "For digest notifications, date order for posts is"
 
 
460
  msgstr ""
461
 
462
- #: subscribe2.php:2201
463
- msgid "Descending"
464
  msgstr ""
465
 
466
- #: subscribe2.php:2203
467
- msgid "Ascending"
468
  msgstr ""
469
 
470
- #: subscribe2.php:2205
471
- msgid "Add Tracking Parameters to the Permalink"
472
  msgstr ""
473
 
474
- #: subscribe2.php:2207
475
- msgid "eg. utm_source=subscribe2&utm_medium=email&utm_campaign=postnotify"
476
  msgstr ""
477
 
478
- #: subscribe2.php:2212
479
- msgid "Email Templates"
480
  msgstr ""
481
 
482
- #: subscribe2.php:2216
483
- msgid "New Post email (must not be empty)"
484
  msgstr ""
485
 
486
- #: subscribe2.php:2217 subscribe2.php:2247 subscribe2.php:2252
487
- msgid "Subject Line"
488
  msgstr ""
489
 
490
- #: subscribe2.php:2222
491
- msgid "Send Email Preview"
492
  msgstr ""
493
 
494
- #: subscribe2.php:2223
495
- msgid "Message substitutions"
 
496
  msgstr ""
497
 
498
- #: subscribe2.php:2225
499
- msgid ""
500
- "IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED"
501
  msgstr ""
502
 
503
- #: subscribe2.php:2228
504
- msgid "the post's title<br />(<i>for per-post emails only</i>)"
505
  msgstr ""
506
 
507
- #: subscribe2.php:2229
508
- msgid ""
509
- "the excerpt or the entire post<br />(<i>based on the subscriber's "
510
- "preferences</i>)"
511
  msgstr ""
512
 
513
- #: subscribe2.php:2230
514
- msgid ""
515
- "the excerpt of the post and the time it was posted<br />(<i>for digest "
516
- "emails only</i>)"
517
  msgstr ""
518
 
519
- #: subscribe2.php:2231
520
- msgid "a list of post titles<br />(<i>for digest emails only</i>)"
521
  msgstr ""
522
 
523
- #: subscribe2.php:2232
524
  msgid ""
525
- "a list of post titles followed by links to the atricles<br />(<i>for digest "
526
- "emails only</i>)"
527
  msgstr ""
528
 
529
- #: subscribe2.php:2233
530
- msgid "the post's permalink<br />(<i>for per-post emails only</i>)"
531
  msgstr ""
532
 
533
- #: subscribe2.php:2234
534
- msgid ""
535
- "the post's permalink after conversion by TinyURL<br />(<i>for per-post "
536
- "emails only</i>)"
537
  msgstr ""
538
 
539
- #: subscribe2.php:2235
540
- msgid "the date the post was made<br />(<i>for per-post emails only</i>)"
541
  msgstr ""
542
 
543
- #: subscribe2.php:2236
544
- msgid "the time the post was made<br />(<i>for per-post emails only</i>)"
545
  msgstr ""
546
 
547
- #: subscribe2.php:2237
548
- msgid "the admin or post author's name"
549
  msgstr ""
550
 
551
- #: subscribe2.php:2238
552
- msgid "the admin or post author's email"
553
  msgstr ""
554
 
555
- #: subscribe2.php:2239
556
- msgid "the post author's name"
557
  msgstr ""
558
 
559
- #: subscribe2.php:2240
560
- msgid ""
561
- "the generated link to confirm a request<br />(<i>only used in the "
562
- "confirmation email template</i>)"
563
  msgstr ""
564
 
565
- #: subscribe2.php:2241
566
- msgid ""
567
- "Action performed by LINK in confirmation email<br />(<i>only used in the "
568
- "confirmation email template</i>)"
569
  msgstr ""
570
 
571
- #: subscribe2.php:2242
572
- msgid "the post's assigned categories"
573
  msgstr ""
574
 
575
- #: subscribe2.php:2243
576
- msgid "the post's assigned Tags"
577
  msgstr ""
578
 
579
- #: subscribe2.php:2244
580
- msgid ""
581
- "the number of posts included in the digest email<br />(<i>for digest emails "
582
- "only</i>)"
583
  msgstr ""
584
 
585
- #: subscribe2.php:2246
586
- msgid "Subscribe / Unsubscribe confirmation email"
587
  msgstr ""
588
 
589
- #: subscribe2.php:2251
590
- msgid "Reminder email to Unconfirmed Subscribers"
591
  msgstr ""
592
 
593
- #: subscribe2.php:2260
594
- msgid "Excluded Categories"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595
  msgstr ""
596
 
597
- #: subscribe2.php:2262
598
- msgid ""
599
- "Posts assigned to any Excluded Category do not generate notifications and "
600
- "are not included in digest notifications"
601
  msgstr ""
602
 
603
- #: subscribe2.php:2266
604
- msgid "Allow registered users to subscribe to excluded categories?"
605
  msgstr ""
606
 
607
- #: subscribe2.php:2271
608
- msgid "Excluded Formats"
609
  msgstr ""
610
 
611
- #: subscribe2.php:2273
612
- msgid ""
613
- "Posts assigned to any Excluded Format do not generate notifications and are "
614
- "not included in digest notifications"
615
  msgstr ""
616
 
617
- #: subscribe2.php:2281
618
- msgid "Appearance"
619
  msgstr ""
620
 
621
- #: subscribe2.php:2285
622
- msgid "Set default Subscribe2 page as ID"
623
  msgstr ""
624
 
625
- #: subscribe2.php:2291
626
- msgid "Set the number of Subscribers displayed per page"
627
  msgstr ""
628
 
629
- #: subscribe2.php:2301
630
- msgid "Show a link to your subscription page in \"meta\"?"
631
  msgstr ""
632
 
633
- #: subscribe2.php:2305
634
- msgid "Show the Subscribe2 button on the Write toolbar?"
635
  msgstr ""
636
 
637
- #: subscribe2.php:2309
638
- msgid "Enable AJAX style subscription form?"
639
  msgstr ""
640
 
641
- #: subscribe2.php:2313
642
- msgid "Enable Subscribe2 Widget?"
643
  msgstr ""
644
 
645
- #: subscribe2.php:2317
646
- msgid "Enable Subscribe2 Counter Widget?"
 
647
  msgstr ""
648
 
649
- #: subscribe2.php:2321
650
- msgid "Disable email notifications is checked by default on authoring pages?"
651
  msgstr ""
652
 
653
- #: subscribe2.php:2327
654
- msgid "Auto Subscribe"
655
  msgstr ""
656
 
657
- #: subscribe2.php:2329
658
- msgid "Subscribe new users registering with your blog"
659
  msgstr ""
660
 
661
- #: subscribe2.php:2331
662
- msgid "Automatically"
663
  msgstr ""
664
 
665
- #: subscribe2.php:2333
666
- msgid "Display option on Registration Form"
667
  msgstr ""
668
 
669
- #: subscribe2.php:2336
670
- msgid "Auto-subscribe includes any excluded categories"
671
  msgstr ""
672
 
673
- #: subscribe2.php:2341
674
- msgid "Registration Form option is checked by default"
675
  msgstr ""
676
 
677
- #: subscribe2.php:2346
678
- msgid "Auto-subscribe users to receive email as"
 
 
679
  msgstr ""
680
 
681
- #: subscribe2.php:2355
682
- msgid "Registered Users have the option to auto-subscribe to new categories"
683
  msgstr ""
684
 
685
- #: subscribe2.php:2361
686
- msgid "New categories are immediately excluded"
687
  msgstr ""
688
 
689
- #: subscribe2.php:2362
690
  msgid ""
691
- "Option for Registered Users to auto-subscribe to new categories is checked "
692
- "by default"
693
  msgstr ""
694
 
695
- #: subscribe2.php:2367
696
- msgid "Display checkbox to allow subscriptions from the comment form"
697
  msgstr ""
698
 
699
- #: subscribe2.php:2369
700
- msgid "Before the Comment Submit button"
701
  msgstr ""
702
 
703
- #: subscribe2.php:2371
704
- msgid "After the Comment Submit button"
705
  msgstr ""
706
 
707
- #: subscribe2.php:2379
708
- msgid "Barred Domains"
709
  msgstr ""
710
 
711
- #: subscribe2.php:2381
712
- msgid ""
713
- "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
714
- "each entry and omit the \"@\" symbol, for example email.com)"
715
  msgstr ""
716
 
717
- #: subscribe2.php:2387
718
- msgid "Submit"
719
  msgstr ""
720
 
721
- #: subscribe2.php:2390
722
- msgid "Reset Default"
723
  msgstr ""
724
 
725
- #: subscribe2.php:2391
726
- msgid ""
727
- "Use this to reset all options to their defaults. This <strong><em>will not</"
728
- "em></strong> modify your list of subscribers."
729
  msgstr ""
730
 
731
- #: subscribe2.php:2393
732
- msgid "RESET"
 
733
  msgstr ""
734
 
735
- #: subscribe2.php:2484
736
- msgid "Subscription preferences updated."
737
  msgstr ""
738
 
739
- #: subscribe2.php:2493
740
- msgid "Editing Subscribe2 preferences for user"
741
  msgstr ""
742
 
743
- #: subscribe2.php:2502
744
- msgid "Receive email as"
745
  msgstr ""
746
 
747
- #: subscribe2.php:2513
748
- msgid "Automatically subscribe me to newly created categories"
749
  msgstr ""
750
 
751
- #: subscribe2.php:2528
752
- msgid "Unsubscribe me from this blog"
753
  msgstr ""
754
 
755
- #: subscribe2.php:2532
756
- msgid "Subscribe to all categories"
757
  msgstr ""
758
 
759
- #: subscribe2.php:2534
760
- msgid "Subscribed Categories on"
761
  msgstr ""
762
 
763
- #: subscribe2.php:2536
764
- msgid "Subscribed Categories"
765
  msgstr ""
766
 
767
- #: subscribe2.php:2542
768
- msgid "Receive periodic summaries of new posts?"
769
  msgstr ""
770
 
771
- #: subscribe2.php:2558
772
- msgid "Do not send notifications for post made by these authors"
 
 
773
  msgstr ""
774
 
775
- #: subscribe2.php:2564
776
- msgid "Update Preferences"
 
777
  msgstr ""
778
 
779
- #: subscribe2.php:2614
780
- msgid "Subscribed Blogs"
781
  msgstr ""
782
 
783
- #: subscribe2.php:2619 subscribe2.php:2640
784
- msgid "Viewing Settings Now"
785
  msgstr ""
786
 
787
- #: subscribe2.php:2623 subscribe2.php:2644
788
- msgid "View Settings"
 
789
  msgstr ""
790
 
791
- #: subscribe2.php:2635
792
- msgid "Subscribe to new blogs"
793
  msgstr ""
794
 
795
- #: subscribe2.php:2711
796
- msgid "Send an email to subscribers"
797
  msgstr ""
798
 
799
- #: subscribe2.php:2719
800
- msgid "A message from"
801
  msgstr ""
802
 
803
- #: subscribe2.php:2724
804
- msgid "Subject"
805
  msgstr ""
806
 
807
- #: subscribe2.php:2727
808
- msgid "Recipients:"
809
  msgstr ""
810
 
811
- #: subscribe2.php:2731
812
- msgid "Preview"
813
  msgstr ""
814
 
815
- #: subscribe2.php:2731
816
- msgid "Send"
817
  msgstr ""
818
 
819
- #: subscribe2.php:2911
820
- msgid "All Users and Subscribers"
821
  msgstr ""
822
 
823
- #: subscribe2.php:2912
824
- msgid "Public Subscribers"
825
  msgstr ""
826
 
827
- #: subscribe2.php:2913
828
- msgid "Confirmed"
829
  msgstr ""
830
 
831
- #: subscribe2.php:2914
832
- msgid "Unconfirmed"
833
  msgstr ""
834
 
835
- #: subscribe2.php:2915
836
- msgid "All Registered Users"
837
  msgstr ""
838
 
839
- #: subscribe2.php:2916
840
- msgid "Registered Subscribers"
841
  msgstr ""
842
 
843
- #: subscribe2.php:2995
844
- msgid "Post Author"
845
  msgstr ""
846
 
847
- #: subscribe2.php:3019
848
  msgid ""
849
- "The WordPress cron functions may be disabled on this server. Digest "
850
- "notifications may not work."
851
- msgstr ""
852
-
853
- #: subscribe2.php:3023
854
- msgid "For each Post"
855
  msgstr ""
856
 
857
- #: subscribe2.php:3037
858
- msgid "Send Digest Notification at"
859
  msgstr ""
860
 
861
- #: subscribe2.php:3049
862
- msgid ""
863
- "This option will be ignored if the time selected is not in the future in "
864
- "relation to the current time"
865
  msgstr ""
866
 
867
- #: subscribe2.php:3052
868
- msgid "Current UTC time is"
869
  msgstr ""
870
 
871
- #: subscribe2.php:3054
872
- msgid "Current blog time is"
873
  msgstr ""
874
 
875
- #: subscribe2.php:3056
876
- msgid "Next email notification will be sent when your blog time is after"
877
  msgstr ""
878
 
879
- #: subscribe2.php:3059
880
- msgid "Attempt to resend the last Digest Notification email"
881
  msgstr ""
882
 
883
- #: subscribe2.php:3060
884
- msgid "Resend Digest"
885
  msgstr ""
886
 
887
- #: subscribe2.php:3138
888
- msgid "Confirmed Public Subscriber"
889
  msgstr ""
890
 
891
- #: subscribe2.php:3140
892
- msgid "Unconfirmed Public Subscriber"
893
  msgstr ""
894
 
895
- #: subscribe2.php:3196
896
- msgid "Donate"
897
  msgstr ""
898
 
899
- #: subscribe2.php:3208
900
- msgid "Check here to Subscribe to email notifications for new posts"
901
  msgstr ""
902
 
903
- #: subscribe2.php:3214
904
- msgid ""
905
- "By registering with this blog you are also agreeing to receive email "
906
- "notifications for new posts but you can unsubscribe at anytime"
907
  msgstr ""
908
 
909
- #: subscribe2.php:3265 subscribe2.php:3266
910
- msgid "Subscribe2 Notification Override"
911
  msgstr ""
912
 
913
- #: subscribe2.php:3276
914
- msgid ""
915
- "Check here to disable sending of an email notification for this post/page"
916
  msgstr ""
917
 
918
- #: subscribe2.php:3311
919
- msgid "Check here to Subscribe to notifications for new posts"
920
  msgstr ""
921
 
922
- #: subscribe2.php:3422 subscribe2.php:3424
923
- msgid "Your email:"
924
  msgstr ""
925
 
926
- #: subscribe2.php:3424
927
- msgid "Enter email address..."
928
  msgstr ""
929
 
930
- #: subscribe2.php:3529
931
- msgid "Subscription Confirmation"
932
  msgstr ""
933
 
934
- #: subscribe2.php:3601
935
- msgid "[Un]Subscribe to Posts"
936
  msgstr ""
937
 
938
- #: subscribe2.php:3625 subscribe2.php:3627
939
- msgid "Subscribe to this blog"
940
  msgstr ""
941
 
942
- #: subscribe2.php:3679
943
- msgid "Weekly"
944
  msgstr ""
945
 
946
- #: subscribe2.php:3800 subscribe2.php:3801
947
- msgid "Author"
948
  msgstr ""
949
 
950
- #: subscribe2.php:3809
951
- msgid "Posted on"
952
  msgstr ""
953
 
954
- #: subscribe2.php:3813 subscribe2.php:3814
955
- msgid "Posted in"
956
  msgstr ""
957
 
958
- #: subscribe2.php:3819 subscribe2.php:3820
959
- msgid "Tagged as"
960
  msgstr ""
961
 
962
- #: subscribe2.php:3884
963
- msgid "Digest Email"
964
  msgstr ""
965
 
966
- #: subscribe2.php:3894
967
- msgid "Digest Preview"
968
  msgstr ""
969
 
970
- #: include/options.php:122
971
  msgid ""
972
  "{BLOGNAME} has posted a new item, '{TITLE}'\n"
973
  "\n"
@@ -983,7 +1057,7 @@ msgid ""
983
  "{EMAIL}"
984
  msgstr ""
985
 
986
- #: include/options.php:130
987
  msgid ""
988
  "{BLOGNAME} has received a request to {ACTION} for this email address. To "
989
  "complete your request please click on the link below:\n"
@@ -996,11 +1070,11 @@ msgid ""
996
  "{MYNAME}."
997
  msgstr ""
998
 
999
- #: include/options.php:134
1000
  msgid "Please confirm your request"
1001
  msgstr ""
1002
 
1003
- #: include/options.php:138
1004
  msgid ""
1005
  "This email address was subscribed for notifications at {BLOGNAME} "
1006
  "({BLOGLINK}) but the subscription remains incomplete.\n"
@@ -1016,7 +1090,7 @@ msgid ""
1016
  "{MYNAME}"
1017
  msgstr ""
1018
 
1019
- #: include/options.php:142
1020
  msgid "Subscription Reminder"
1021
  msgstr ""
1022
 
@@ -1080,42 +1154,9 @@ msgstr ""
1080
  msgid "Use Subscribe2 Default"
1081
  msgstr ""
1082
 
1083
- #: include/counterwidget.php:7
1084
- msgid "Subscriber Counter widget for the Subscribe2 plugin"
1085
- msgstr ""
1086
-
1087
- #: include/counterwidget.php:9
1088
- msgid "Subscribe2 Counter"
1089
- msgstr ""
1090
-
1091
- #: include/counterwidget.php:73
1092
- msgid "Widget Title"
1093
- msgstr ""
1094
-
1095
- #: include/counterwidget.php:78
1096
- msgid "Color Scheme"
1097
- msgstr ""
1098
-
1099
- #: include/counterwidget.php:80
1100
- msgid "Body"
1101
- msgstr ""
1102
-
1103
- #: include/counterwidget.php:82
1104
- msgid "Text"
1105
- msgstr ""
1106
-
1107
- #: include/counterwidget.php:86
1108
- msgid "Width, Height and Font Size"
1109
- msgstr ""
1110
-
1111
- #: include/counterwidget.php:88
1112
- msgid "Width"
1113
- msgstr ""
1114
-
1115
- #: include/counterwidget.php:90
1116
- msgid "Height"
1117
- msgstr ""
1118
-
1119
- #: include/counterwidget.php:92
1120
- msgid "Font"
1121
  msgstr ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2012-03-28 18:50+0100\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
17
  "Content-Type: text/plain; charset=CHARSET\n"
18
  "Content-Transfer-Encoding: 8bit\n"
19
 
20
+ #: admin/send_email.php:51
21
+ msgid "Send an email to subscribers"
22
+ msgstr ""
23
+
24
+ #: admin/send_email.php:59
25
+ msgid "A message from"
26
+ msgstr ""
27
+
28
+ #: admin/send_email.php:64
29
+ msgid "Subject"
30
+ msgstr ""
31
+
32
+ #: admin/send_email.php:67
33
+ msgid "Recipients:"
34
+ msgstr ""
35
+
36
+ #: admin/send_email.php:71
37
+ msgid "Preview"
38
+ msgstr ""
39
+
40
+ #: admin/send_email.php:71
41
+ msgid "Send"
42
+ msgstr ""
43
+
44
+ #: admin/settings.php:30
45
+ msgid "Preview message(s) sent to logged in user"
46
+ msgstr ""
47
+
48
+ #: admin/settings.php:34
49
  msgid ""
50
+ "The Digest Notification email contained no post information. No email was "
51
+ "sent"
52
  msgstr ""
53
 
54
+ #: admin/settings.php:36
55
+ msgid "Attempt made to resend the Digest Notification email"
56
  msgstr ""
57
 
58
+ #: admin/settings.php:205
59
+ msgid "Subscribe2 Settings"
60
  msgstr ""
61
 
62
+ #: admin/settings.php:206
63
+ msgid "Plugin Blog"
64
  msgstr ""
65
 
66
+ #: admin/settings.php:207
67
+ msgid "Make a donation via PayPal"
68
  msgstr ""
69
 
70
+ #: admin/settings.php:219 admin/your_subscriptions.php:96
71
+ msgid "Notification Settings"
 
72
  msgstr ""
73
 
74
+ #: admin/settings.php:220
75
+ msgid "Restrict the number of recipients per email to (0 for unlimited)"
76
  msgstr ""
77
 
78
+ #: admin/settings.php:222 admin/settings.php:370
79
+ msgid "Edit"
80
  msgstr ""
81
 
82
+ #: admin/settings.php:225 admin/settings.php:373
83
+ msgid "Update"
84
  msgstr ""
85
 
86
+ #: admin/settings.php:226 admin/settings.php:374
87
+ msgid "Revert"
88
  msgstr ""
89
 
90
+ #: admin/settings.php:228
91
+ msgid "Send Admins notifications for new"
92
  msgstr ""
93
 
94
+ #: admin/settings.php:230
95
+ msgid "Subscriptions"
 
 
96
  msgstr ""
97
 
98
+ #: admin/settings.php:232
99
+ msgid "Unsubscriptions"
 
100
  msgstr ""
101
 
102
+ #: admin/settings.php:234
103
+ msgid "Both"
104
  msgstr ""
105
 
106
+ #: admin/settings.php:236
107
+ msgid "Neither"
108
  msgstr ""
109
 
110
+ #: admin/settings.php:238
111
+ msgid "Include theme CSS stylesheet in HTML notifications"
 
112
  msgstr ""
113
 
114
+ #: admin/settings.php:240 admin/settings.php:246 admin/settings.php:260
115
+ #: admin/settings.php:265 admin/settings.php:415 admin/settings.php:420
116
+ #: admin/settings.php:434 admin/settings.php:441 admin/settings.php:453
117
+ #: admin/subscribers.php:339 admin/your_subscriptions.php:121
118
+ #: admin/your_subscriptions.php:159
119
+ msgid "Yes"
120
  msgstr ""
121
 
122
+ #: admin/settings.php:242 admin/settings.php:248 admin/settings.php:262
123
+ #: admin/settings.php:267 admin/settings.php:412 admin/settings.php:417
124
+ #: admin/settings.php:422 admin/settings.php:436 admin/settings.php:443
125
+ #: admin/settings.php:450 admin/settings.php:455 admin/subscribers.php:341
126
+ #: admin/your_subscriptions.php:123 admin/your_subscriptions.php:163
127
+ msgid "No"
128
  msgstr ""
129
 
130
+ #: admin/settings.php:244
131
+ msgid "Send Emails for Pages"
132
  msgstr ""
133
 
134
+ #: admin/settings.php:252
135
+ msgid ""
136
+ "Subscribe2 will send email notifications for the following custom post types"
137
  msgstr ""
138
 
139
+ #: admin/settings.php:258
140
+ msgid "Send Emails for Password Protected Posts"
141
  msgstr ""
142
 
143
+ #: admin/settings.php:263
144
+ msgid "Send Emails for Private Posts"
145
  msgstr ""
146
 
147
+ #: admin/settings.php:268
148
+ msgid "Send Email From"
149
  msgstr ""
150
 
151
+ #: admin/settings.php:273
152
+ msgid "Send Emails"
153
  msgstr ""
154
 
155
+ #: admin/settings.php:275
156
+ msgid "For digest notifications, date order for posts is"
157
  msgstr ""
158
 
159
+ #: admin/settings.php:277
160
+ msgid "Descending"
161
  msgstr ""
162
 
163
+ #: admin/settings.php:279
164
+ msgid "Ascending"
165
  msgstr ""
166
 
167
+ #: admin/settings.php:281
168
+ msgid "Add Tracking Parameters to the Permalink"
169
  msgstr ""
170
 
171
+ #: admin/settings.php:283
172
+ msgid "eg. utm_source=subscribe2&utm_medium=email&utm_campaign=postnotify"
173
  msgstr ""
174
 
175
+ #: admin/settings.php:288
176
+ msgid "Email Templates"
177
  msgstr ""
178
 
179
+ #: admin/settings.php:292
180
+ msgid "New Post email (must not be empty)"
181
  msgstr ""
182
 
183
+ #: admin/settings.php:293 admin/settings.php:323 admin/settings.php:328
184
+ msgid "Subject Line"
185
  msgstr ""
186
 
187
+ #: admin/settings.php:298
188
+ msgid "Send Email Preview"
189
  msgstr ""
190
 
191
+ #: admin/settings.php:299
192
+ msgid "Message substitutions"
193
  msgstr ""
194
 
195
+ #: admin/settings.php:301
196
+ msgid ""
197
+ "IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED"
198
  msgstr ""
199
 
200
+ #: admin/settings.php:304
201
+ msgid "the post's title<br />(<i>for per-post emails only</i>)"
202
  msgstr ""
203
 
204
+ #: admin/settings.php:305
205
+ msgid ""
206
+ "the excerpt or the entire post<br />(<i>based on the subscriber's "
207
+ "preferences</i>)"
208
  msgstr ""
209
 
210
+ #: admin/settings.php:306
211
+ msgid ""
212
+ "the excerpt of the post and the time it was posted<br />(<i>for digest "
213
+ "emails only</i>)"
214
  msgstr ""
215
 
216
+ #: admin/settings.php:307
217
+ msgid "a list of post titles<br />(<i>for digest emails only</i>)"
218
  msgstr ""
219
 
220
+ #: admin/settings.php:308
221
+ msgid ""
222
+ "a list of post titles followed by links to the atricles<br />(<i>for digest "
223
+ "emails only</i>)"
224
  msgstr ""
225
 
226
+ #: admin/settings.php:309
227
+ msgid "the post's permalink<br />(<i>for per-post emails only</i>)"
228
  msgstr ""
229
 
230
+ #: admin/settings.php:310
231
+ msgid ""
232
+ "the post's permalink after conversion by TinyURL<br />(<i>for per-post "
233
+ "emails only</i>)"
234
  msgstr ""
235
 
236
+ #: admin/settings.php:311
237
+ msgid "the date the post was made<br />(<i>for per-post emails only</i>)"
238
  msgstr ""
239
 
240
+ #: admin/settings.php:312
241
+ msgid "the time the post was made<br />(<i>for per-post emails only</i>)"
242
  msgstr ""
243
 
244
+ #: admin/settings.php:313
245
+ msgid "the admin or post author's name"
246
  msgstr ""
247
 
248
+ #: admin/settings.php:314
249
+ msgid "the admin or post author's email"
250
  msgstr ""
251
 
252
+ #: admin/settings.php:315
253
+ msgid "the post author's name"
254
  msgstr ""
255
 
256
+ #: admin/settings.php:316
257
+ msgid ""
258
+ "the generated link to confirm a request<br />(<i>only used in the "
259
+ "confirmation email template</i>)"
260
  msgstr ""
261
 
262
+ #: admin/settings.php:317
263
+ msgid ""
264
+ "Action performed by LINK in confirmation email<br />(<i>only used in the "
265
+ "confirmation email template</i>)"
266
  msgstr ""
267
 
268
+ #: admin/settings.php:318
269
+ msgid "the post's assigned categories"
270
  msgstr ""
271
 
272
+ #: admin/settings.php:319
273
+ msgid "the post's assigned Tags"
274
  msgstr ""
275
 
276
+ #: admin/settings.php:320
277
+ msgid ""
278
+ "the number of posts included in the digest email<br />(<i>for digest emails "
279
+ "only</i>)"
280
  msgstr ""
281
 
282
+ #: admin/settings.php:322
283
+ msgid "Subscribe / Unsubscribe confirmation email"
 
284
  msgstr ""
285
 
286
+ #: admin/settings.php:327
287
+ msgid "Reminder email to Unconfirmed Subscribers"
288
  msgstr ""
289
 
290
+ #: admin/settings.php:336
291
+ msgid "Excluded Categories"
292
  msgstr ""
293
 
294
+ #: admin/settings.php:338
295
+ msgid ""
296
+ "Posts assigned to any Excluded Category do not generate notifications and "
297
+ "are not included in digest notifications"
298
  msgstr ""
299
 
300
+ #: admin/settings.php:342
301
+ msgid "Allow registered users to subscribe to excluded categories?"
302
  msgstr ""
303
 
304
+ #: admin/settings.php:348
305
+ msgid "Excluded Formats"
306
  msgstr ""
307
 
308
+ #: admin/settings.php:350
309
+ msgid ""
310
+ "Posts assigned to any Excluded Format do not generate notifications and are "
311
+ "not included in digest notifications"
312
  msgstr ""
313
 
314
+ #: admin/settings.php:358
315
+ msgid "Appearance"
316
  msgstr ""
317
 
318
+ #: admin/settings.php:362
319
+ msgid "Set default Subscribe2 page as ID"
320
  msgstr ""
321
 
322
+ #: admin/settings.php:368
323
+ msgid "Set the number of Subscribers displayed per page"
324
  msgstr ""
325
 
326
+ #: admin/settings.php:378
327
+ msgid "Show a link to your subscription page in \"meta\"?"
 
328
  msgstr ""
329
 
330
+ #: admin/settings.php:382
331
+ msgid "Show the Subscribe2 button on the Write toolbar?"
332
  msgstr ""
333
 
334
+ #: admin/settings.php:386
335
+ msgid "Enable AJAX style subscription form?"
336
  msgstr ""
337
 
338
+ #: admin/settings.php:390
339
+ msgid "Enable Subscribe2 Widget?"
340
  msgstr ""
341
 
342
+ #: admin/settings.php:394
343
+ msgid "Enable Subscribe2 Counter Widget?"
344
  msgstr ""
345
 
346
+ #: admin/settings.php:398
347
+ msgid "Disable email notifications is checked by default on authoring pages?"
 
 
348
  msgstr ""
349
 
350
+ #: admin/settings.php:404
351
+ msgid "Auto Subscribe"
352
  msgstr ""
353
 
354
+ #: admin/settings.php:406
355
+ msgid "Subscribe new users registering with your blog"
356
  msgstr ""
357
 
358
+ #: admin/settings.php:408
359
+ msgid "Automatically"
360
  msgstr ""
361
 
362
+ #: admin/settings.php:410
363
+ msgid "Display option on Registration Form"
364
  msgstr ""
365
 
366
+ #: admin/settings.php:413
367
+ msgid "Auto-subscribe includes any excluded categories"
368
+ msgstr ""
369
+
370
+ #: admin/settings.php:418
371
+ msgid "Registration Form option is checked by default"
372
+ msgstr ""
373
+
374
+ #: admin/settings.php:423
375
+ msgid "Auto-subscribe users to receive email as"
376
+ msgstr ""
377
+
378
+ #: admin/settings.php:425 admin/subscribers.php:329
379
+ #: admin/your_subscriptions.php:110
380
  msgid "HTML - Full"
381
  msgstr ""
382
 
383
+ #: admin/settings.php:427 admin/subscribers.php:330
384
+ #: admin/your_subscriptions.php:112
385
  msgid "HTML - Excerpt"
386
  msgstr ""
387
 
388
+ #: admin/settings.php:429 admin/subscribers.php:331
389
+ #: admin/your_subscriptions.php:114
390
  msgid "Plain Text - Full"
391
  msgstr ""
392
 
393
+ #: admin/settings.php:431 admin/subscribers.php:332
394
+ #: admin/your_subscriptions.php:116
395
  msgid "Plain Text - Excerpt"
396
  msgstr ""
397
 
398
+ #: admin/settings.php:432
399
+ msgid "Registered Users have the option to auto-subscribe to new categories"
400
  msgstr ""
401
 
402
+ #: admin/settings.php:438
403
+ msgid "New categories are immediately excluded"
404
  msgstr ""
405
 
406
+ #: admin/settings.php:439
407
+ msgid ""
408
+ "Option for Registered Users to auto-subscribe to new categories is checked "
409
+ "by default"
 
410
  msgstr ""
411
 
412
+ #: admin/settings.php:444
413
+ msgid "Display checkbox to allow subscriptions from the comment form"
 
 
 
 
414
  msgstr ""
415
 
416
+ #: admin/settings.php:446
417
+ msgid "Before the Comment Submit button"
418
  msgstr ""
419
 
420
+ #: admin/settings.php:448
421
+ msgid "After the Comment Submit button"
422
  msgstr ""
423
 
424
+ #: admin/settings.php:451
425
+ msgid "Show one-click subscription on profile page"
426
+ msgstr ""
427
+
428
+ #: admin/settings.php:460
429
+ msgid "Barred Domains"
430
+ msgstr ""
431
+
432
+ #: admin/settings.php:462
433
  msgid ""
434
+ "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
435
+ "each entry and omit the \"@\" symbol, for example email.com)"
436
  msgstr ""
437
 
438
+ #: admin/settings.php:468
439
+ msgid "Submit"
440
  msgstr ""
441
 
442
+ #: admin/settings.php:471
443
+ msgid "Reset Default"
444
  msgstr ""
445
 
446
+ #: admin/settings.php:472
447
+ msgid ""
448
+ "Use this to reset all options to their defaults. This <strong><em>will not</"
449
+ "em></strong> modify your list of subscribers."
450
  msgstr ""
451
 
452
+ #: admin/settings.php:474
453
+ msgid "RESET"
454
  msgstr ""
455
 
456
+ #: admin/subscribers.php:26
457
+ msgid "Address(es) subscribed!"
458
  msgstr ""
459
 
460
+ #: admin/subscribers.php:33
461
+ msgid "Address(es) unsubscribed!"
462
  msgstr ""
463
 
464
+ #: admin/subscribers.php:37
465
+ msgid "Some emails were not processed, the following were already subscribed"
466
  msgstr ""
467
 
468
+ #: admin/subscribers.php:40
469
+ msgid "Some emails were not processed, the following were not in the database"
470
  msgstr ""
471
 
472
+ #: admin/subscribers.php:49
473
+ msgid "Address(es) deleted!"
474
  msgstr ""
475
 
476
+ #: admin/subscribers.php:55 admin/subscribers.php:61
477
+ msgid "Status changed!"
478
  msgstr ""
479
 
480
+ #: admin/subscribers.php:75
481
+ msgid "Reminder Email(s) Sent!"
482
  msgstr ""
483
 
484
+ #: admin/subscribers.php:78
485
+ msgid "Registered Users Subscribed!"
486
  msgstr ""
487
 
488
+ #: admin/subscribers.php:81
489
+ msgid "Registered Users Unsubscribed!"
490
  msgstr ""
491
 
492
+ #: admin/subscribers.php:84
493
+ msgid "Format updated for Selected Registered Users!"
494
  msgstr ""
495
 
496
+ #: admin/subscribers.php:87
497
+ msgid "Digest Subscription updated for Selected Registered Users!"
498
  msgstr ""
499
 
500
+ #: admin/subscribers.php:182
501
+ msgid "Previous Page"
502
  msgstr ""
503
 
504
+ #: admin/subscribers.php:202
505
+ msgid "Next Page"
 
506
  msgstr ""
507
 
508
+ #: admin/subscribers.php:209
509
+ msgid "Manage Subscribers"
510
  msgstr ""
511
 
512
+ #: admin/subscribers.php:215
513
+ msgid "Add/Remove Subscribers"
514
  msgstr ""
515
 
516
+ #: admin/subscribers.php:216
517
+ msgid "Enter addresses, one per line or comma-separated"
518
  msgstr ""
519
 
520
+ #: admin/subscribers.php:219 admin/subscribers.php:324
521
+ #: admin/your_subscriptions.php:257 classes/class-s2-core.php:17
522
+ #: classes/class-s2-frontend.php:27 classes/class-s2-frontend.php:30
523
+ msgid "Subscribe"
524
  msgstr ""
525
 
526
+ #: admin/subscribers.php:220 admin/subscribers.php:325
527
+ #: admin/your_subscriptions.php:236 classes/class-s2-frontend.php:25
528
+ #: classes/class-s2-frontend.php:30
529
+ msgid "Unsubscribe"
530
  msgstr ""
531
 
532
+ #: admin/subscribers.php:225
533
+ msgid "Current Subscribers"
534
  msgstr ""
535
 
536
+ #: admin/subscribers.php:227
537
+ msgid "Filter"
538
  msgstr ""
539
 
540
+ #: admin/subscribers.php:234
541
+ msgid "Search Subscribers"
542
  msgstr ""
543
 
544
+ #: admin/subscribers.php:237
545
+ msgid "Send Reminder Email"
546
  msgstr ""
547
 
548
+ #: admin/subscribers.php:244
549
+ msgid "Save Emails to CSV File"
550
  msgstr ""
551
 
552
+ #: admin/subscribers.php:251 admin/subscribers.php:310
553
+ msgid "Process"
554
  msgstr ""
555
 
556
+ #: admin/subscribers.php:264 admin/subscribers.php:286
557
+ msgid "Confirm this email address"
558
  msgstr ""
559
 
560
+ #: admin/subscribers.php:266 admin/subscribers.php:279
561
+ msgid "Unconfirm this email address"
562
  msgstr ""
563
 
564
+ #: admin/subscribers.php:268 admin/subscribers.php:281
565
+ #: admin/subscribers.php:289
566
+ msgid "Delete this email address"
567
  msgstr ""
568
 
569
+ #: admin/subscribers.php:272 classes/class-s2-admin.php:206
570
+ #: classes/class-s2-admin.php:252 classes/class-s2-admin.php:292
571
+ msgid "Select / Unselect All"
572
  msgstr ""
573
 
574
+ #: admin/subscribers.php:297
575
+ msgid "edit"
576
  msgstr ""
577
 
578
+ #: admin/subscribers.php:304
579
+ msgid "No matching subscribers found"
 
 
580
  msgstr ""
581
 
582
+ #: admin/subscribers.php:306
583
+ msgid "NONE"
 
 
584
  msgstr ""
585
 
586
+ #: admin/subscribers.php:319
587
+ msgid "Bulk Management"
588
  msgstr ""
589
 
590
+ #: admin/subscribers.php:321 admin/subscribers.php:335
591
  msgid ""
592
+ "Preferences for Registered Users selected in the filter above can be changed "
593
+ "using this section."
594
  msgstr ""
595
 
596
+ #: admin/subscribers.php:322 admin/subscribers.php:336
597
+ msgid "Consider User Privacy as changes cannot be undone"
598
  msgstr ""
599
 
600
+ #: admin/subscribers.php:323
601
+ msgid "Action to perform"
 
 
602
  msgstr ""
603
 
604
+ #: admin/subscribers.php:327
605
+ msgid "Bulk Update Categories"
606
  msgstr ""
607
 
608
+ #: admin/subscribers.php:328
609
+ msgid "Send email as"
610
  msgstr ""
611
 
612
+ #: admin/subscribers.php:333
613
+ msgid "Bulk Update Format"
614
  msgstr ""
615
 
616
+ #: admin/subscribers.php:337
617
+ msgid "Subscribe Selected Users to recieve a periodic digest notification"
618
  msgstr ""
619
 
620
+ #: admin/subscribers.php:342
621
+ msgid "Bulk Update Digest Subscription"
622
  msgstr ""
623
 
624
+ #: admin/your_subscriptions.php:90
625
+ msgid "Subscription preferences updated."
 
 
626
  msgstr ""
627
 
628
+ #: admin/your_subscriptions.php:99
629
+ msgid "Editing Subscribe2 preferences for user"
 
 
630
  msgstr ""
631
 
632
+ #: admin/your_subscriptions.php:108
633
+ msgid "Receive email as"
634
  msgstr ""
635
 
636
+ #: admin/your_subscriptions.php:119
637
+ msgid "Automatically subscribe me to newly created categories"
638
  msgstr ""
639
 
640
+ #: admin/your_subscriptions.php:128
641
+ msgid "One Click Subscription / Unsubscription"
 
 
642
  msgstr ""
643
 
644
+ #: admin/your_subscriptions.php:129
645
+ msgid "Subscribe to All"
646
  msgstr ""
647
 
648
+ #: admin/your_subscriptions.php:130
649
+ msgid "Unsubscribe from All"
650
  msgstr ""
651
 
652
+ #: admin/your_subscriptions.php:139
653
+ msgid "Unsubscribe me from this blog"
654
+ msgstr ""
655
+
656
+ #: admin/your_subscriptions.php:143
657
+ msgid "Subscribe to all categories"
658
+ msgstr ""
659
+
660
+ #: admin/your_subscriptions.php:145
661
+ msgid "Subscribed Categories on"
662
+ msgstr ""
663
+
664
+ #: admin/your_subscriptions.php:147
665
+ msgid "Subscribed Categories"
666
+ msgstr ""
667
+
668
+ #: admin/your_subscriptions.php:153
669
+ msgid "Receive periodic summaries of new posts?"
670
+ msgstr ""
671
+
672
+ #: admin/your_subscriptions.php:169
673
+ msgid "Do not send notifications for post made by these authors"
674
+ msgstr ""
675
+
676
+ #: admin/your_subscriptions.php:175
677
+ msgid "Update Preferences"
678
  msgstr ""
679
 
680
+ #: admin/your_subscriptions.php:225
681
+ msgid "Subscribed Blogs"
 
 
682
  msgstr ""
683
 
684
+ #: admin/your_subscriptions.php:230 admin/your_subscriptions.php:251
685
+ msgid "Viewing Settings Now"
686
  msgstr ""
687
 
688
+ #: admin/your_subscriptions.php:234 admin/your_subscriptions.php:255
689
+ msgid "View Settings"
690
  msgstr ""
691
 
692
+ #: admin/your_subscriptions.php:246
693
+ msgid "Subscribe to new blogs"
 
 
694
  msgstr ""
695
 
696
+ #: classes/class-s2-admin.php:8 include/widget.php:17
697
+ msgid "Subscribe2"
698
  msgstr ""
699
 
700
+ #: classes/class-s2-admin.php:10
701
+ msgid "Your Subscriptions"
702
  msgstr ""
703
 
704
+ #: classes/class-s2-admin.php:14
705
+ msgid "Subscribers"
706
  msgstr ""
707
 
708
+ #: classes/class-s2-admin.php:17 classes/class-s2-admin.php:57
709
+ msgid "Settings"
710
  msgstr ""
711
 
712
+ #: classes/class-s2-admin.php:22
713
+ msgid "Send Email"
714
  msgstr ""
715
 
716
+ #: classes/class-s2-admin.php:58
717
+ msgid "Donate"
718
  msgstr ""
719
 
720
+ #: classes/class-s2-admin.php:149 classes/class-s2-admin.php:150
721
+ msgid "Subscribe2 Notification Override"
722
  msgstr ""
723
 
724
+ #: classes/class-s2-admin.php:160
725
+ msgid ""
726
+ "Check here to disable sending of an email notification for this post/page"
727
  msgstr ""
728
 
729
+ #: classes/class-s2-admin.php:344
730
+ msgid "All Users and Subscribers"
731
  msgstr ""
732
 
733
+ #: classes/class-s2-admin.php:345
734
+ msgid "Public Subscribers"
735
  msgstr ""
736
 
737
+ #: classes/class-s2-admin.php:346
738
+ msgid "Confirmed"
739
  msgstr ""
740
 
741
+ #: classes/class-s2-admin.php:347
742
+ msgid "Unconfirmed"
743
  msgstr ""
744
 
745
+ #: classes/class-s2-admin.php:348
746
+ msgid "All Registered Users"
747
  msgstr ""
748
 
749
+ #: classes/class-s2-admin.php:349
750
+ msgid "Registered Subscribers"
751
  msgstr ""
752
 
753
+ #: classes/class-s2-admin.php:431
754
+ msgid "Post Author"
755
  msgstr ""
756
 
757
+ #: classes/class-s2-admin.php:455
758
+ msgid ""
759
+ "The WordPress cron functions may be disabled on this server. Digest "
760
+ "notifications may not work."
761
  msgstr ""
762
 
763
+ #: classes/class-s2-admin.php:459
764
+ msgid "For each Post"
765
  msgstr ""
766
 
767
+ #: classes/class-s2-admin.php:473
768
+ msgid "Send Digest Notification at"
769
  msgstr ""
770
 
771
+ #: classes/class-s2-admin.php:485
772
  msgid ""
773
+ "This option will be ignored if the time selected is not in the future in "
774
+ "relation to the current time"
775
  msgstr ""
776
 
777
+ #: classes/class-s2-admin.php:488
778
+ msgid "Current UTC time is"
779
  msgstr ""
780
 
781
+ #: classes/class-s2-admin.php:490
782
+ msgid "Current blog time is"
783
  msgstr ""
784
 
785
+ #: classes/class-s2-admin.php:492
786
+ msgid "Next email notification will be sent when your blog time is after"
787
  msgstr ""
788
 
789
+ #: classes/class-s2-admin.php:495
790
+ msgid "Attempt to resend the last Digest Notification email"
791
  msgstr ""
792
 
793
+ #: classes/class-s2-admin.php:496
794
+ msgid "Resend Digest"
 
 
795
  msgstr ""
796
 
797
+ #: classes/class-s2-admin.php:719
798
+ msgid "Email subscription"
799
  msgstr ""
800
 
801
+ #: classes/class-s2-admin.php:721
802
+ msgid "Subscribe / Unsubscribe"
803
  msgstr ""
804
 
805
+ #: classes/class-s2-admin.php:722
806
+ msgid "Receive notifications"
 
 
807
  msgstr ""
808
 
809
+ #: classes/class-s2-admin.php:723
810
+ msgid ""
811
+ "Check if you want to receive email notification when new posts are published"
812
  msgstr ""
813
 
814
+ #: classes/class-s2-core.php:10
815
+ msgid "To manage your subscription options please"
816
  msgstr ""
817
 
818
+ #: classes/class-s2-core.php:10
819
+ msgid "login"
820
  msgstr ""
821
 
822
+ #: classes/class-s2-core.php:12
823
+ msgid "You may manage your subscription options from your"
824
  msgstr ""
825
 
826
+ #: classes/class-s2-core.php:12
827
+ msgid "profile"
828
  msgstr ""
829
 
830
+ #: classes/class-s2-core.php:17
831
+ msgid "to email notifications when this blog posts new content"
832
  msgstr ""
833
 
834
+ #: classes/class-s2-core.php:21
835
+ msgid "A confirmation message is on its way!"
836
  msgstr ""
837
 
838
+ #: classes/class-s2-core.php:23
839
+ msgid "That email address is already subscribed."
840
  msgstr ""
841
 
842
+ #: classes/class-s2-core.php:25
843
+ msgid "That email address is not subscribed."
844
  msgstr ""
845
 
846
+ #: classes/class-s2-core.php:27
847
+ msgid "Sorry, but that does not look like an email address to me."
848
  msgstr ""
849
 
850
+ #: classes/class-s2-core.php:29
851
+ msgid ""
852
+ "Sorry, email addresses at that domain are currently barred due to spam, "
853
+ "please use an alternative email address."
854
  msgstr ""
855
 
856
+ #: classes/class-s2-core.php:31
857
+ msgid ""
858
+ "Sorry, there seems to be an error on the server. Please try again later."
859
  msgstr ""
860
 
861
+ #: classes/class-s2-core.php:33
862
+ msgid "You must to create a WordPress page for this plugin to work correctly."
863
  msgstr ""
864
 
865
+ #: classes/class-s2-core.php:35
866
+ msgid "Message sent!"
867
  msgstr ""
868
 
869
+ #: classes/class-s2-core.php:37
870
+ msgid ""
871
+ "Message failed! Check your settings and check with your hosting provider"
872
  msgstr ""
873
 
874
+ #: classes/class-s2-core.php:40
875
+ msgid "No such email address is registered."
876
  msgstr ""
877
 
878
+ #: classes/class-s2-core.php:42
879
+ msgid "You have successfully subscribed!"
880
  msgstr ""
881
 
882
+ #: classes/class-s2-core.php:44
883
+ msgid "You have successfully unsubscribed."
884
  msgstr ""
885
 
886
+ #: classes/class-s2-core.php:46
887
+ msgid "subscribe"
888
  msgstr ""
889
 
890
+ #: classes/class-s2-core.php:48
891
+ msgid "unsubscribe"
892
  msgstr ""
893
 
894
+ #: classes/class-s2-core.php:51
895
+ msgid "Options saved!"
896
  msgstr ""
897
 
898
+ #: classes/class-s2-core.php:52
899
+ msgid "Options reset!"
900
  msgstr ""
901
 
902
+ #: classes/class-s2-core.php:617
903
+ msgid "Plain Text Excerpt Preview"
904
  msgstr ""
905
 
906
+ #: classes/class-s2-core.php:619
907
+ msgid "Plain Text Full Preview"
908
  msgstr ""
909
 
910
+ #: classes/class-s2-core.php:621
911
+ msgid "HTML Excerpt Preview"
912
  msgstr ""
913
 
914
+ #: classes/class-s2-core.php:623
915
+ msgid "HTML Full Preview"
916
  msgstr ""
917
 
918
+ #: classes/class-s2-core.php:1219
919
+ msgid "Confirmed Public Subscriber"
920
  msgstr ""
921
 
922
+ #: classes/class-s2-core.php:1221
923
+ msgid "Unconfirmed Public Subscriber"
924
  msgstr ""
925
 
926
+ #: classes/class-s2-core.php:1258
927
+ msgid "Check here to Subscribe to email notifications for new posts"
928
  msgstr ""
929
 
930
+ #: classes/class-s2-core.php:1264
931
  msgid ""
932
+ "By registering with this blog you are also agreeing to receive email "
933
+ "notifications for new posts but you can unsubscribe at anytime"
 
 
 
 
934
  msgstr ""
935
 
936
+ #: classes/class-s2-core.php:1290
937
+ msgid "Check here to Subscribe to notifications for new posts"
938
  msgstr ""
939
 
940
+ #: classes/class-s2-core.php:1380
941
+ msgid "Weekly"
 
 
942
  msgstr ""
943
 
944
+ #: classes/class-s2-core.php:1501 classes/class-s2-core.php:1502
945
+ msgid "Author"
946
  msgstr ""
947
 
948
+ #: classes/class-s2-core.php:1510
949
+ msgid "Posted on"
950
  msgstr ""
951
 
952
+ #: classes/class-s2-core.php:1514 classes/class-s2-core.php:1515
953
+ msgid "Posted in"
954
  msgstr ""
955
 
956
+ #: classes/class-s2-core.php:1520 classes/class-s2-core.php:1521
957
+ msgid "Tagged as"
958
  msgstr ""
959
 
960
+ #: classes/class-s2-core.php:1585
961
+ msgid "Digest Email"
962
  msgstr ""
963
 
964
+ #: classes/class-s2-core.php:1595
965
+ msgid "Digest Preview"
966
  msgstr ""
967
 
968
+ #: classes/class-s2-frontend.php:42 classes/class-s2-frontend.php:44
969
+ msgid "Your email:"
970
  msgstr ""
971
 
972
+ #: classes/class-s2-frontend.php:44
973
+ msgid "Enter email address..."
974
  msgstr ""
975
 
976
+ #: classes/class-s2-frontend.php:149
977
+ msgid "Subscription Confirmation"
978
  msgstr ""
979
 
980
+ #: classes/class-s2-frontend.php:187
981
+ msgid "New Subscription"
 
 
982
  msgstr ""
983
 
984
+ #: classes/class-s2-frontend.php:189
985
+ msgid "subscribed to email notifications!"
986
  msgstr ""
987
 
988
+ #: classes/class-s2-frontend.php:210
989
+ msgid "New Unsubscription"
 
990
  msgstr ""
991
 
992
+ #: classes/class-s2-frontend.php:212
993
+ msgid "unsubscribed from email notifications!"
994
  msgstr ""
995
 
996
+ #: classes/class-s2-frontend.php:238
997
+ msgid "[Un]Subscribe to Posts"
998
  msgstr ""
999
 
1000
+ #: classes/class-s2-frontend.php:262 classes/class-s2-frontend.php:264
1001
+ msgid "Subscribe to this blog"
1002
  msgstr ""
1003
 
1004
+ #: include/counterwidget.php:7
1005
+ msgid "Subscriber Counter widget for Subscribe2"
1006
  msgstr ""
1007
 
1008
+ #: include/counterwidget.php:9
1009
+ msgid "Subscribe2 Counter"
1010
  msgstr ""
1011
 
1012
+ #: include/counterwidget.php:73
1013
+ msgid "Widget Title"
1014
  msgstr ""
1015
 
1016
+ #: include/counterwidget.php:78
1017
+ msgid "Color Scheme"
1018
  msgstr ""
1019
 
1020
+ #: include/counterwidget.php:80
1021
+ msgid "Body"
1022
  msgstr ""
1023
 
1024
+ #: include/counterwidget.php:82
1025
+ msgid "Text"
1026
  msgstr ""
1027
 
1028
+ #: include/counterwidget.php:86
1029
+ msgid "Width, Height and Font Size"
1030
  msgstr ""
1031
 
1032
+ #: include/counterwidget.php:88
1033
+ msgid "Width"
1034
  msgstr ""
1035
 
1036
+ #: include/counterwidget.php:90
1037
+ msgid "Height"
1038
  msgstr ""
1039
 
1040
+ #: include/counterwidget.php:92
1041
+ msgid "Font"
1042
  msgstr ""
1043
 
1044
+ #: include/options.php:126
1045
  msgid ""
1046
  "{BLOGNAME} has posted a new item, '{TITLE}'\n"
1047
  "\n"
1057
  "{EMAIL}"
1058
  msgstr ""
1059
 
1060
+ #: include/options.php:134
1061
  msgid ""
1062
  "{BLOGNAME} has received a request to {ACTION} for this email address. To "
1063
  "complete your request please click on the link below:\n"
1070
  "{MYNAME}."
1071
  msgstr ""
1072
 
1073
+ #: include/options.php:138
1074
  msgid "Please confirm your request"
1075
  msgstr ""
1076
 
1077
+ #: include/options.php:142
1078
  msgid ""
1079
  "This email address was subscribed for notifications at {BLOGNAME} "
1080
  "({BLOGLINK}) but the subscription remains incomplete.\n"
1090
  "{MYNAME}"
1091
  msgstr ""
1092
 
1093
+ #: include/options.php:146
1094
  msgid "Subscription Reminder"
1095
  msgstr ""
1096
 
1154
  msgid "Use Subscribe2 Default"
1155
  msgstr ""
1156
 
1157
+ #: subscribe2.php:39
1158
+ #, php-format
1159
+ msgid ""
1160
+ "This version of Subscribe2 requires WordPress 3.1 or greater. Please update "
1161
+ "%1$s or use an older version of %2$s."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1162
  msgstr ""