Subscribe2 - Version 3.6

Version Description

Download this release

Release Info

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

Code changes from version 2.10 to 3.6

ReadMe.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: MattyRob, Skippy, Ravan
3
  Donate link: http://subscribe2.wordpress.com/donate/
4
  Tags: posts, subscription, email
5
  Requires at least: 2.0.x
6
- Tested up to: 2.1
7
 
8
  Sends a list of subscribers an email notification when new posts are published to your blog
9
 
@@ -77,6 +77,101 @@ Batches will occur for each group of message as described above. A site on Drea
77
 
78
  == Version History ==
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  Version 2.10 by Matthew Robinson
81
  * Improved sign up process by double checking email address
82
  * Fix for submenu issues encountered in WP 2.0.6
3
  Donate link: http://subscribe2.wordpress.com/donate/
4
  Tags: posts, subscription, email
5
  Requires at least: 2.0.x
6
+ Tested up to: 2.2
7
 
8
  Sends a list of subscribers an email notification when new posts are published to your blog
9
 
77
 
78
  == Version History ==
79
 
80
+ Version 3.6 by Matthew Robinson
81
+
82
+ * Fixed a typo in Content-Type mail headers
83
+ * Fixed Auto Register functions to obey Excluded Categories
84
+ * Added option to check WP-Register checkbox by default
85
+
86
+ Version 3.5 by Matthew Robinson
87
+
88
+ * Fixed a bug in the upgrade function that was messing up the options settings
89
+ * Updated the include.php file to preset recently introduced option settings
90
+
91
+ Version 3.4 by Matthew Robinson
92
+
93
+ * QuickTag button now displays a Marker! (HUGE thanks to Raven!)
94
+ * Fix for excluded categories in User Menu
95
+ * BCCLIMIT typo corrected in Mail function
96
+ * Call to translation files moved to avoid call to undefined function
97
+ * Options added to send mails for pages and password protected posts
98
+ * Option added to display subscription checkbox in WordPress Register screen
99
+ * Small typo and layout amendments
100
+
101
+ Version 3.3 by Matthew Robinson
102
+
103
+ * QuickTag button added! Works with Visual and Standard Editor. __Look in Code for token addition if using RTE.__
104
+ * Current Server time displayed for Cron tasks
105
+ * Fixed bug so Registered users now identified correctly
106
+ * Upgrade function called via WordPress hook to prevent calls to undefined functions
107
+ * Fixed a bug affecting Registered Users not appearing in the drop down list
108
+ * Improved handling of the Subscribe2 option array
109
+
110
+ Version 3.2 by Matthew Robinson
111
+
112
+ * Fixed a bug affecting Registered Users not appearing in the drop down list
113
+ * Improved handling of the Subscribe2 option array
114
+
115
+ Version 3.1 by Matthew Robinson
116
+
117
+ * Amended code to use core cron functionality for future posts and digest notifications, no longer need WP-Cron
118
+ * Improved HTML code generated for admin pages
119
+ * Removed sending of emails for WordPress Pages
120
+ * Fixed display issues if S2PAGE is not defined
121
+
122
+ Version 3.0 by Matthew Robinson
123
+
124
+ * Updated for WordPress 2.1 Branch
125
+
126
+ Version 2.20 by Matthew Robinson
127
+
128
+ * Fixed a typo in Content-Type mail headers
129
+ * Fixed Auto Register functions to obey Excluded Categories
130
+
131
+ Version 2.19 by Matthew Robinson
132
+
133
+ * Fixed a bug in the upgrade function that was messing up the options settings
134
+
135
+ Version 2.18 by Matthew Robinson
136
+
137
+ * BCCLIMIT typo corrected in Mail function
138
+ * Call to translation files moved to avoid call to undefined function
139
+ * Small typo and layout amendments
140
+
141
+ Version 2.17 by Matthew Robinson
142
+
143
+ * Current Server time displayed for Cron tasks
144
+ * Fixed bug so Registered users now identified correctly
145
+ * Upgrade function called via WordPress hook to prevent calls to undefined functions
146
+
147
+ Version 2.16 by Matthew Robinson
148
+
149
+ * Fixed a bug affecting Registered Users not appearing in the drop down list
150
+ * Improved handling of the Subscribe2 option array
151
+
152
+ Version 2.15 by Matthew Robinson
153
+
154
+ * Improved HTML code generated for admin pages
155
+ * Fixed display issues if S2PAGE is not defined
156
+
157
+ Version 2.14 by Matthew Robinson
158
+
159
+ * Amended DREAMHOST setting to BCCLIMIT as more hosts are limiting emails
160
+ * Fixed oversight in upgrade() function
161
+
162
+ Version 2.13 by Matthew Robinson
163
+
164
+ * Added WordPress nonce functionality to improve admin security
165
+
166
+ Version 2.12 by Matthew Robinson
167
+
168
+ * Fix for missing Quicktags (probably since version 2.2.10)
169
+ * Fix for occasional email issue where excerpts are incomplete
170
+
171
+ Version 2.11 by Matthew Robinson
172
+ * Fixed bug that would cause all subscribers to get digest emails
173
+ * Added Select All check box to category listing
174
+
175
  Version 2.10 by Matthew Robinson
176
  * Improved sign up process by double checking email address
177
  * Fix for submenu issues encountered in WP 2.0.6
subscribe2/include.php CHANGED
@@ -6,10 +6,26 @@ if (!isset($this->subscribe2_options['autosub'])) {
6
  $this->subscribe2_options['autosub'] = "no";
7
  } // option to autosubscribe registered users to new categories
8
 
 
 
 
 
9
  if (!isset($this->subscribe2_options['autoformat'])) {
10
  $this->subscribe2_options['autoformat'] = "text";
11
  } // option for default auto-subscription email format
12
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  if (!isset($this->subscribe2_options['exclude'])) {
14
  $this->subscribe2_options['exclude'] = "";
15
  } // option for excluded categories
@@ -32,11 +48,11 @@ if (!isset($this->subscribe2_options['barred'])) {
32
  } // option containing domains barred from public registration
33
 
34
  if (!isset($this->subscribe2_options['mailtext'])) {
35
- $this->subscribe2_options['mailtext'] = "BLOGNAME has posted a new item, 'TITLE'\r\nPOST\r\nYou may view the latest post at\r\nPERMALINK\r\nYou received this e-mail because you asked to be notified when new updates are posted.\r\nBest regards,\r\nMYNAME\r\nEMAIL";
36
  } // Default notification email text
37
 
38
  if (!isset($this->subscribe2_options['confirm_email'])) {
39
- $this->subscribe2_options['confirm_email'] = "In order to confirm your request for BLOGNAME, please click on the link below:\n\nLINK\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\nMYNAME.";
40
  } // Default confirmation email text
41
 
42
  if (!isset($this->subscribe2_options['remind_email'])) {
6
  $this->subscribe2_options['autosub'] = "no";
7
  } // option to autosubscribe registered users to new categories
8
 
9
+ if (!isset($this->subscribe2_options['wpregdef'])) {
10
+ $this->subscribe2_options['wpregdef'] = "no";
11
+ } // option to
12
+
13
  if (!isset($this->subscribe2_options['autoformat'])) {
14
  $this->subscribe2_options['autoformat'] = "text";
15
  } // option for default auto-subscription email format
16
 
17
+ if (!isset($this->subscribe2_options['pages'])) {
18
+ $this->subscribe2_options['pages'] = "no";
19
+ } // option for sending notifications for WordPress pages
20
+
21
+ if (!isset($this->subscribe2_options['password'])) {
22
+ $this->subscribe2_options['password'] = "no";
23
+ } // option for sending notifications for posts that are password protected
24
+
25
+ if (!isset($this->subscribe2_options['email_freq'])) {
26
+ $this->subscribe2_options['email_freq'] = "never";
27
+ } // option for sending emails per-post or as a digest email on a cron schedule
28
+
29
  if (!isset($this->subscribe2_options['exclude'])) {
30
  $this->subscribe2_options['exclude'] = "";
31
  } // option for excluded categories
48
  } // option containing domains barred from public registration
49
 
50
  if (!isset($this->subscribe2_options['mailtext'])) {
51
+ $this->subscribe2_options['mailtext'] = "BLOGNAME has posted a new item, 'TITLE'\n\nPOST\n\nYou may view the latest post at\nPERMALINK\n\nYou received this e-mail because you asked to be notified when new updates are posted.\nBest regards,\nMYNAME\nEMAIL";
52
  } // Default notification email text
53
 
54
  if (!isset($this->subscribe2_options['confirm_email'])) {
55
+ $this->subscribe2_options['confirm_email'] = "BLOGNAME has received a request to ACTION for this email address. To complete your request please click on the link below:\n\nLINK\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\nMYNAME.";
56
  } // Default confirmation email text
57
 
58
  if (!isset($this->subscribe2_options['remind_email'])) {
subscribe2/spacer.gif ADDED
Binary file
subscribe2/subscribe2.php CHANGED
@@ -1,2001 +1,2210 @@
1
- <?php
2
- /*
3
- Plugin Name: Subscribe2
4
- Plugin URI: http://subscribe2.wordpress.com
5
- Description: Notifies an email list when new entries are posted.
6
- Version: 2.2.10
7
- Author: Matthew Robinson
8
- Author URI: http://subscribe2.wordpress.com
9
- */
10
-
11
- /*
12
- Copyright (C) 2006 Matthew Robinson
13
- Based on the Original Subscribe2 plugin by
14
- Copyright (C) 2005 Scott Merrill (skippy@skippy.net)
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
- http://www.gnu.org/licenses/gpl.html
30
- */
31
-
32
- // use Owen's excellent ButtonSnap library
33
- include(ABSPATH . '/wp-content/plugins/buttonsnap.php');
34
-
35
- // change this to TRUE if you're on Dreamhost
36
- // (or any other host that limits the number of recipients
37
- // permitted on each outgoing email message)
38
- define('DREAMHOST', false);
39
-
40
- // by default, subscribe2 grabs the first page from your database for use
41
- // when displaying the confirmation screen to public subscribers.
42
- // You can override this by specifying a page ID below.
43
- define('S2PAGE', '0');
44
-
45
- // change this to TRUE if you want a daily digest of the day's posts
46
- // send to your subscribers
47
- define('S2DIGEST', false);
48
-
49
- // our version number. Don't touch.
50
- define('S2VERSION', '2.2.10');
51
-
52
- // start our class
53
- class subscribe2 {
54
- // variables and constructor are declared at the end
55
-
56
- /**
57
- Load all our strings
58
- */
59
- function load_strings() {
60
- // adjust the output of Subscribe2 here
61
-
62
- $this->please_log_in = "<p>" . __('To manage your subscription options please ', 'subscribe2') . "<a href=\"" . get_settings('siteurl') . "/wp-login.php\">login</a>.</p>";
63
-
64
- $this->use_profile = "<p>" . __('You may manage your subscription options from your ', 'subscribe2') . "<a href=\"" . get_settings('siteurl') . "/wp-admin/profile.php?page=" . plugin_basename(__FILE__) . "\">profile</a>.</p>";
65
-
66
- $this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
67
-
68
- $this->already_subscribed = "<p>" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
69
-
70
- $this->not_subscribed = "<p>" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
71
-
72
- $this->not_an_email = "<p>" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
73
-
74
- $this->barred_domain = "<p>" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
75
-
76
- $this->mail_sent = "<p>" . __('Message sent!', 'subscribe2') . "</p>";
77
-
78
- $this->form = "<form method=\"post\" action=\"\">" . __('Your email:', 'subscribe2') . "&#160;<input type=\"text\" name=\"email\" value=\"\" size=\"20\" />&#160;<br /><input type=\"radio\" name=\"s2_action\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . " <input type=\"radio\" name=\"s2_action\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . " &#160;<input type=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></form>\r\n";
79
-
80
- // confirmation messages
81
- $this->no_such_email = "<p>" . __('No such email address is registered.', 'subscribe2') . "</p>";
82
-
83
- $this->added = "<p>" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
84
-
85
- $this->deleted = "<p>" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
86
-
87
- $this->confirm_subject = "[" . get_settings('blogname') . "] " . __('Please confirm your request', 'subscribe2');
88
-
89
- $this->remind_subject = "[" . get_settings('blogname') . "] " . __('Subscription Reminder', 'subscribe2');
90
-
91
- $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
92
-
93
- $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
94
-
95
- // menu strings
96
- $this->options_saved = __('Options saved!', 'subscribe2');
97
- $this->options_reset = __('Options reset!', 'subscribe2');
98
- } // end load_strings()
99
-
100
- /* ===== WordPress menu registration ===== */
101
- /**
102
- Hook the menu
103
- */
104
- function admin_menu() {
105
- add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", __FILE__, array(&$this, 'manage_menu'));
106
- add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2','subscribe2'), "manage_options", __FILE__, array(&$this, 'options_menu'));
107
- add_submenu_page('profile.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
108
- add_submenu_page('post.php', __('Mail Subscribers','subscribe2'), __('Mail Subscribers', 'subscribe2'),"manage_options", __FILE__, array(&$this, 'write_menu'));
109
- }
110
-
111
- /* ===== ButtonSnap configuration ===== */
112
- /**
113
- Register our button in the QuickTags bar
114
- */
115
- function s2_button_init() {
116
- $url = get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_button.png';
117
- buttonsnap_textbutton($url, 'Subscribe2', '<!--subscribe2-->');
118
- buttonsnap_register_marker('subscribe2', 's2_marker');
119
- }
120
-
121
- /**
122
- Style a marker in the Rich Text Editor for our tag
123
-
124
- By default, the RTE suppresses output of HTML comments, so this places a CSS style on our token in order to make it display
125
- */
126
- function subscribe2_css() {
127
- $marker_url = get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_marker.png';
128
- echo "
129
- .s2_marker {
130
- display: block;
131
- height: 45px;
132
- margin-top: 5px;
133
- background-image: url({$marker_url});
134
- background-repeat: no-repeat;
135
- background-position: center;
136
- }
137
- ";
138
- }
139
-
140
- /* ===== Install, upgrade, reset ===== */
141
- /**
142
- Install our table
143
- */
144
- function install() {
145
- // include upgrade-functions for maybe_create_table;
146
- if (! function_exists('maybe_create_table')) {
147
- require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
148
- }
149
- $date = date('Y-m-d');
150
- $sql = "CREATE TABLE $this->public (
151
- id int(11) NOT NULL auto_increment,
152
- email varchar(64) NOT NULL default '',
153
- active tinyint(1) default 0,
154
- date DATE default '$date' NOT NULL,
155
- PRIMARY KEY (id) )";
156
-
157
- // create the table, as needed
158
- maybe_create_table($this->public, $sql);
159
- $this->reset();
160
- } // end install()
161
-
162
- /**
163
- Upgrade the database
164
- */
165
- function upgrade() {
166
- global $wpdb;
167
-
168
- // include upgrade-functions for maybe_create_table;
169
- if (! function_exists('maybe_create_table')) {
170
- require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
171
- }
172
- $date = date('Y-m-d');
173
- maybe_add_column($this->public, 'date', "ALTER TABLE `$this->public` ADD `date` DATE DEFAULT '$date' NOT NULL AFTER `active`;");
174
-
175
- // let's take the time to check process registered users
176
- // existing public subscribers are subscribed to all categories
177
- $users = $wpdb->get_col("SELECT ID FROM $wpdb->users");
178
- if (! empty($users)) {
179
- foreach ($users as $user) {
180
- $this->register($user);
181
- }
182
- }
183
- // update the options table to serialized format
184
- // We'll deal with s2_future_posts another time
185
- // TODO: Fix s2_future posts
186
- $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
187
-
188
- if (!empty($old_options)) {
189
- foreach ($old_options as $option) {
190
- $value = get_option($option);
191
- $option_array = substr($option, 3);
192
- $this->subscribe2_options[$option_array] = $value;
193
- delete_option($option);
194
- }
195
- }
196
- $this->subscribe2_options['version'] = S2VERSION;
197
- update_option('subscribe2_options', $this->subscribe2_options);
198
- } // end upgrade()
199
-
200
- /**
201
- Reset our options
202
- */
203
- function reset() {
204
- delete_option('subscribe2_options');
205
- unset($this->subscribe2_options);
206
- require(ABSPATH . "/wp-content/plugins/subscribe2/include.php");
207
- } // end reset()
208
-
209
- /* ===== mail handling ===== */
210
- /**
211
- Performs string substitutions for subscribe2 mail texts
212
- */
213
- function substitute($string = '') {
214
- if ('' == $string) {
215
- return;
216
- }
217
- $string = str_replace('BLOGNAME', get_settings('blogname'), $string);
218
- $string = str_replace('BLOGLINK', get_bloginfo('url'), $string);
219
- $string = str_replace('TITLE', stripslashes($this->post_title), $string);
220
- $string = str_replace('PERMALINK', $this->permalink, $string);
221
- $string = str_replace('MYNAME', stripslashes($this->myname), $string);
222
- $string = str_replace('EMAIL', $this->myemail, $string);
223
- $string = str_replace('AUTHORNAME', $this->authorname, $string);
224
- return $string;
225
- } // end sustitute()
226
-
227
- /**
228
- Delivers email to recipients in HTML or plaintext
229
- */
230
- function mail ($recipients = array(), $subject = '', $message = '', $type='text') {
231
- if ( (empty($recipients)) || ('' == $message) ) { return; }
232
-
233
- // Set sender details
234
- if ('' == $this->myname) {
235
- $admin = get_userdata(1);
236
- $this->myname = $admin->display_name;
237
- $this->myemail = $admin->user_email;
238
- }
239
- $headers = "From: $this->myname <$this->myemail>\n";
240
- $headers .= "Return-Path: <$this->myemail>\n";
241
- $headers .= "X-Mailer:PHP" . phpversion() . "\n";
242
- $headers .= "Precedence: list\nList-Id: " . get_settings('blogname') . "\n";
243
-
244
- if ('html' == $type) {
245
- // To send HTML mail, the Content-type header must be set
246
- $headers .= "MIME-Version: 1.0\n";
247
- $headers .= "Content-type: " . get_bloginfo('html_type') . "; charset=\"". get_bloginfo('charset') . "\"\n";
248
- $mailtext = "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>";
249
- } else {
250
- $headers .= "MIME-Version: 1.0\n";
251
- $headers .= "Content-type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
252
- $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
253
- $message = preg_replace('|&amp;|', '&', $message);
254
- $mailtext = wordwrap(strip_tags($message), 80, "\n");
255
- }
256
-
257
- // BCC all recipients
258
- $bcc = '';
259
- if ( (defined('DREAMHOST') && true == DREAMHOST) &&
260
- (count($recipients) > 30) ) {
261
- // we're on Dreamhost, and have more than 30 susbcribers
262
- $count = 1;
263
- $batch = array();
264
- foreach ($recipients as $recipient) {
265
- // advance the array pointer by one, for use down below
266
- // the array pointer _is not_ advanced by the foreach() loop itself
267
- next($recipients);
268
- $recipient = trim($recipient);
269
- // sanity check -- make sure we have a valid email
270
- if (! is_email($recipient)) { continue; }
271
- // and NOT the sender's email, since they'll
272
- // get a copy anyway
273
- if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
274
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
275
- // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
276
- }
277
- if (30 == $count) {
278
- $count = 1;
279
- $batch[] = $bcc;
280
- $bcc = '';
281
- } else {
282
- if (false == current($recipients)) {
283
- // we've reached the end of the subscriber list
284
- // add what we have to the batch, and move on
285
- $batch[] = $bcc;
286
- break;
287
- } else {
288
- $count++;
289
- }
290
- }
291
- }
292
- // rewind the array, just to be safe
293
- reset($recipients);
294
- } else {
295
- // we're not on dreamhost, or have less than 30
296
- // subscribers, so do it normal
297
- foreach ($recipients as $recipient) {
298
- $recipient = trim($recipient);
299
- // sanity check -- make sure we have a valid email
300
- if (! is_email($recipient)) { continue; }
301
- // and NOT the sender's email, since they'll
302
- // get a copy anyway
303
- if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
304
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
305
- // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
306
- }
307
- }
308
- $headers .= "$bcc\r\n";
309
- }
310
- // actually send mail
311
- if ( (defined('DREAMHOST') && true == DREAMHOST) && (isset($batch)) ) {
312
- foreach ($batch as $bcc) {
313
- $newheaders = $headers . "$bcc\r\n";
314
- @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
315
- }
316
- } else {
317
- @wp_mail($this->myemail, $subject, $mailtext, $headers);
318
- }
319
- } // end mail()
320
-
321
- /**
322
- Sends an email notification of a new post
323
- */
324
- function publish($id = 0, $cron = 0) {
325
- if (! $id) { return $id; }
326
-
327
- // are we doing daily digests? If so, don't send anything now
328
- if ( defined('S2DIGEST') && true == S2DIGEST ) { return; }
329
-
330
- // we need to determine whether this is a new post, or an edit
331
- if (0 == $cron) {
332
- // we're not being called from WP-Cron
333
- if ($this->private) {
334
- // this post was published from draft status
335
- // OR is an edit of an existing post
336
- // so send no notification
337
- return $id;
338
- }
339
- }
340
-
341
- $post_cats = wp_get_post_cats('1', $id);
342
- $post_cats_string = implode(',', $post_cats);
343
- $check = false;
344
- // is the current post assigned to any categories
345
- // which should not generate a notification email?
346
- foreach (explode(',', $this->get_excluded_cats()) as $cat) {
347
- if (in_array($cat, $post_cats)) {
348
- $check = true;
349
- }
350
- }
351
- // if so, bail out
352
- if ($check) {
353
- // hang on -- can registered users subscribe to
354
- // excluded categories?
355
- if ('0' == $this->subscribe2_options['reg_override']) {
356
- // nope? okay, let's leave
357
- return $id;
358
- }
359
- }
360
-
361
- global $wpdb;
362
- $post = & get_post($id);
363
- // is this post set in the future?
364
- if ($post->post_date > current_time('mysql')) {
365
- // is wp-cron installed?
366
- if (function_exists('wp_cron_init')) {
367
- // are we doing daily digests?
368
- if ( defined('S2DIGEST') && false == S2DIGEST ) {
369
- // not doing daily digests, so
370
- // add this post to the list of
371
- // future posts
372
- $our_post = array('id' => $id, 'date' => $post->post_date);
373
- $future_posts = get_option('s2_future_posts');
374
- $future_posts[] = $our_post;
375
- update_option('s2_future_posts', $future_posts);
376
- }
377
- }
378
- // bail out
379
- return $id;
380
- }
381
-
382
- // lets collect our public subscribers
383
- // and all our registered subscribers for these categories
384
- if (! $check) {
385
- // if this post is assigned to an excluded
386
- // category, then this test will prevent
387
- // the public from receiving notification
388
- $public = $this->get_public();
389
- }
390
- $registered = $this->get_registered("cats=$post_cats_string");
391
-
392
- // do we have subscribers?
393
- if ( empty($public) && empty($registered) ) {
394
- // if not, no sense doing anything else
395
- return $id;
396
- }
397
- // we set these class variables so that we can avoid
398
- // passing them in function calls a little later
399
- $this->post_title = $post->post_title;
400
- $this->permalink = "<a href=\"" . get_permalink($id) . "\">" . get_permalink($id) . "</a>";
401
-
402
- $author = get_userdata($post->post_author);
403
- $this->authorname = $author->display_name;
404
-
405
- // do we send as admin, or post author?
406
- if ('author' == $this->subscribe2_options['sender']) {
407
- // get author details
408
- $user =& $author;
409
- } else {
410
- // get admin details
411
- $user = get_userdata(1);
412
- }
413
- $this->myemail = $user->user_email;
414
- $this->myname = $user->display_name;
415
- // Get email subject
416
- $subject = $this->substitute(stripslashes($this->s2_subject));
417
- // Get the message template
418
- $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
419
-
420
- $plaintext = $post->post_content;
421
- $content = apply_filters('the_content', $post->post_content);
422
- $content = str_replace(']]>', ']]&gt', $content);
423
- $excerpt = $post->post_excerpt;
424
- if ('' == $excerpt) {
425
- // no excerpt, is there a <!--more--> ?
426
- if (false !== strpos($plaintext, '<!--more-->')) {
427
- list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
428
- // strip leading and trailing whitespace
429
- $excerpt = strip_tags($excerpt);
430
- $excerpt = trim($excerpt);
431
- } else {
432
- // no <!--more-->, so grab the first 55 words
433
- $excerpt = strip_tags($plaintext);
434
- $excerpt_length = 55;
435
- $words = explode(' ', $plaintext, $excerpt_length + 1);
436
- if (count($words) > $excerpt_length) {
437
- array_pop($words);
438
- array_push($words, '[...]');
439
- $excerpt = implode(' ', $words);
440
- }
441
- }
442
-
443
- }
444
- // first we send plaintext summary emails
445
- $body = str_replace('POST', $excerpt, $mailtext);
446
- $registered = $this->get_registered("cats=$post_cats_string&format=text&amount=excerpt");
447
- if (empty($registered)) {
448
- $recipients = (array)$public;
449
- }
450
- elseif (empty($public)) {
451
- $recipients = (array)$registered;
452
- } else {
453
- $recipients = array_merge((array)$public, (array)$registered);
454
- }
455
- $this->mail($recipients, $subject, $body);
456
- // next we send plaintext full content emails
457
- $body = str_replace('POST', strip_tags($plaintext), $mailtext);
458
- $this->mail($this->get_registered("cats=$post_cats_string&format=text&amount=post"), $subject, $body);
459
- // finally we send html full content emails
460
- $body = str_replace("\r\n", "<br />\r\n", $mailtext);
461
- $body = str_replace('POST', $content, $body);
462
- $this->mail($this->get_registered("cats=$post_cats_string&format=html"), $subject, $body, 'html');
463
-
464
- return $id;
465
- } // end publish()
466
-
467
- /**
468
- Sends a notification when a draft post is published
469
- */
470
- function private2publish($id = 0) {
471
- if (0 == $id) { return $id; }
472
-
473
- $this->publish($id);
474
- $this->private = TRUE;
475
- return $id;
476
- } // end private2publish()
477
-
478
- /**
479
- Prevents notifications from being sent when editing posts
480
- */
481
- function edit($id = 0) {
482
- if (0 == $id) { return; }
483
-
484
- $this->private = TRUE;
485
- return $id;
486
- }
487
-
488
- /**
489
- Send confirmation email to the user
490
- */
491
- function send_confirm($what = '', $is_remind = FALSE) {
492
- if ($this->filtered == 1) { return; }
493
- if ( (! $this->email) || (! $what) ) {
494
- return false;
495
- }
496
- $id = $this->get_id($this->email);
497
- if (! $id) {
498
- return false;
499
- }
500
-
501
- // generate the URL "?s2=ACTION+HASH+ID"
502
- // ACTION = 1 to subscribe, 0 to unsubscribe
503
- // HASH = md5 hash of email address
504
- // ID = user's ID in the subscribe2 table
505
- $link = get_settings('siteurl') . "?s2=";
506
-
507
- if ('add' == $what) {
508
- $link .= '1';
509
- } elseif ('del' == $what) {
510
- $link .= '0';
511
- }
512
- $link .= md5($this->email);
513
- $link .= $id;
514
-
515
- $admin = get_userdata(1);
516
- $this->myname = $admin->display_name;
517
-
518
- if ($is_remind == TRUE) {
519
- $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
520
- $subject = stripslashes($this->remind_subject);
521
- } else {
522
- $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
523
- if ('add' == $what) {
524
- $body = str_replace("ACTION", $this->subscribe, $body);
525
- } elseif ('del' == $what) {
526
- $body = str_replace("ACTION", $this->unsubscribe, $body);
527
- }
528
- $subject = stripslashes($this->confirm_subject);
529
- }
530
-
531
- $body = str_replace("LINK", $link, $body);
532
-
533
- $mailheaders .= "From: $admin->display_name <$admin->user_email>\n";
534
- $mailheaders .= "Return-Path: <$admin->user_email>\n";
535
- $mailheaders .= "X-Mailer:PHP" . phpversion() . "\n";
536
- $mailheaders .= "Precedence: list\nList-Id: " . get_settings('blogname') . "\n";
537
- $mailheaders .= "MIME-Version: 1.0\n";
538
- $mailheaders .= "Content-type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
539
-
540
- @wp_mail ($this->email, $subject, $body, $mailheaders);
541
- } // end send_confirm()
542
-
543
- /* ===== Category functions ===== */
544
- /**
545
- Returns a comma-separated list of category IDs which should not generate notifications
546
- */
547
- function get_excluded_cats() {
548
- if ('' != $this->excluded_cats) {
549
- return $this->excluded_cats;
550
- } else {
551
- global $wpdb;
552
- $this->excluded_cats = $this->subscribe2_options['exclude'];
553
- return $this->excluded_cats;
554
- }
555
- } // end get_excluded_cats()
556
-
557
- /**
558
- Return either a comma-separated list of all the category IDs in the blog or an array of cat_ID => cat_name
559
- */
560
- function get_all_categories($select = 'id') {
561
- global $wpdb;
562
- if ('id' == $select) {
563
- return implode(',', $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"));
564
- } else {
565
- $cats = array();
566
- $result = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_N);
567
- foreach ($result as $result) {
568
- $cats[$result[0]] = $result[1];
569
- }
570
- return $cats;
571
- }
572
- } // end get_all_categories()
573
-
574
- /* ===== Subscriber functions ===== */
575
- /**
576
- Given a public subscriber ID, returns the email address
577
- */
578
- function get_email ($id = 0) {
579
- global $wpdb;
580
-
581
- if (! $id) {
582
- return false;
583
- }
584
- return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
585
- } // end get_email
586
-
587
- /**
588
- Given a public subscriber email, returns the subscriber ID
589
- */
590
- function get_id ($email = '') {
591
- global $wpdb;
592
-
593
- if (! $email) {
594
- return false;
595
- }
596
- return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
597
- } // end get_id()
598
-
599
- /**
600
- Activate an email address
601
- If the address is not already present, it will be added
602
- */
603
- function activate ($email = '') {
604
- global $wpdb;
605
-
606
- if ('' == $email) {
607
- if ('' != $this->email) {
608
- $email = $this->email;
609
- } else {
610
- return false;
611
- }
612
- }
613
-
614
- if (false !== $this->is_public($email)) {
615
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
616
- if ($check) { return; }
617
- $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
618
- } else {
619
- $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '1', NOW())");
620
- }
621
- } // end activate()
622
-
623
- /**
624
- Add an unconfirmed email address to the subscriber list
625
- */
626
- function add ($email = '') {
627
- if ($this->filtered ==1) { return; }
628
- global $wpdb;
629
-
630
- if ('' == $email) {
631
- if ('' != $this->email) {
632
- $email = $this->email;
633
- } else {
634
- return false;
635
- }
636
- }
637
-
638
- if (! is_email($email)) { return false; }
639
-
640
- if (false !== $this->is_public($email)) {
641
- $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE email='$email'");
642
- } else {
643
- $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '0', NOW())");
644
- }
645
- } // end add()
646
-
647
- /**
648
- Remove a user from the subscription table
649
- */
650
- function delete($email = '') {
651
- global $wpdb;
652
-
653
- if ('' == $email) {
654
- if ('' != $this->email) {
655
- $email = $this->email;
656
- } else {
657
- return false;
658
- }
659
- }
660
-
661
- if (! is_email($email)) { return false; }
662
- $wpdb->get_results("DELETE FROM $this->public WHERE email='$email'");
663
- } // end delete()
664
-
665
- /**
666
- Toggle a public subscriber's status
667
- */
668
- function toggle($email = '') {
669
- global $wpdb;
670
-
671
- if ( ('' == $email) || (! is_email($email)) ) { return false; }
672
-
673
- // let's see if this is a public user
674
- $status = $this->is_public($email);
675
- if (false === $status) { return false; }
676
-
677
- if ('0' == $status) {
678
- $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
679
- } else {
680
- $wpdb->get_results("UPDATE $this->public SET active='0' WHERE email='$email'");
681
- }
682
- } // end toggle()
683
-
684
- /**
685
- Send reminder email to unconfirmed public subscribers
686
- */
687
- function remind($emails = '') {
688
- if ('' == $emails) { return false; }
689
-
690
- $admin = get_userdata(1);
691
- $this->myname = $admin->display_name;
692
-
693
- $recipients = explode(",", $emails);
694
- if (! is_array($recipients)) { $recipients = array(); }
695
- foreach ($recipients as $recipient) {
696
- $this->email = $recipient;
697
- $this->send_confirm('add', TRUE);
698
- }
699
- } //end remind()
700
-
701
- /**
702
- Export email list to CSV download
703
- */
704
- function exportcsv($emails = '') {
705
- if ('' == $emails) {return false; }
706
-
707
- $f = fopen(ABSPATH . '/wp-content/email.csv', 'w');
708
- fwrite($f, $emails);
709
- fclose($f);
710
- } //end exportcsv
711
-
712
- /**
713
- Check email is not from a barred domain
714
- */
715
- function is_barred($email='') {
716
- $barred_option = $this->subscribe2_options['barred'];
717
- list($user, $domain) = split('@', $email);
718
- $bar_check = stristr($barred_option, $domain);
719
-
720
- if(!empty($bar_check)) {
721
- return true;
722
- } else {
723
- return false;
724
- }
725
- } //end is_barred()
726
-
727
- /**
728
- Confirm request from the link emailed to the user and email the admin
729
- */
730
- function confirm($content = '') {
731
- global $wpdb;
732
-
733
- if (1 == $this->filtered) { return $content; }
734
-
735
- $code = $_GET['s2'];
736
- $action = intval(substr($code, 0, 1));
737
- $hash = substr($code, 1, 32);
738
- $code = str_replace($hash, '', $code);
739
- $id = intval(substr($code, 1));
740
- if ($id) {
741
- $this->email = $this->get_email($id);
742
- if ( (!$this->email) || ($hash !== md5($this->email)) ) {
743
- return $this->no_such_email;
744
- }
745
- } else {
746
- return $this->no_such_email;
747
- }
748
-
749
- if ('1' == $action) {
750
- // make this subscription active
751
- $this->activate();
752
- $this->message = $this->added;
753
- $subject = '[' . get_settings('blogname') . '] ' . __('New subscriber', 'subscribe2');
754
- $message = "$this->email " . __('subscribed to email notifications!', 'subscribe2');
755
- $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='wp_user_level' AND $wpdb->usermeta.meta_value='10'");
756
- $this->mail($recipients, $subject, $message);
757
- $this->filtered = 1;
758
- } elseif ('0' == $action) {
759
- // remove this subscriber
760
- $this->delete();
761
- $this->message = $this->deleted;
762
- $this->filtered = 1;
763
- }
764
-
765
- if ('' != $this->message) {
766
- return $this->message;
767
- }
768
- } // end confirm
769
-
770
- /**
771
- Is the supplied email address a public subscriber?
772
- */
773
- function is_public($email = '') {
774
- global $wpdb;
775
-
776
- if ('' == $email) { return false; }
777
-
778
- $check = $wpdb->get_var("SELECT active FROM $this->public WHERE email='$email'");
779
- if ( ('0' == $check) || ('1' == $check) ) {
780
- return $check;
781
- } else {
782
- return false;
783
- }
784
- } // end is_public
785
-
786
- /**
787
- Is the supplied email address a registered user of the blog?
788
- */
789
- function is_registered($email = '') {
790
- global $wpdb;
791
-
792
- if ('' == $email) { return false; }
793
-
794
- $check = $wpdb->get_var("SELECT email FROM $wpdb->users WHERE user_email='$email'");
795
- if ($check) {
796
- return true;
797
- } else {
798
- return false;
799
- }
800
- }
801
-
802
- /**
803
- Return an array of all the public subscribers
804
- */
805
- function get_public ($confirmed = 1) {
806
- global $wpdb;
807
- if (1 == $confirmed) {
808
- if ('' == $this->all_public) {
809
- $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
810
- }
811
- return $this->all_public;
812
- } else {
813
- if ('' == $this->all_unconfirmed) {
814
- $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
815
- }
816
- return $this->all_unconfirmed;
817
- }
818
- } // end get_public()
819
-
820
- /**
821
- Return an array of registered subscribers
822
- Collect all the registered users of the blog who are subscribed to the specified categories
823
- */
824
- function get_registered ($args = '') {
825
- global $wpdb;
826
-
827
- $format = '';
828
- $amount = '';
829
- $cats = '';
830
- $subscribers = array();
831
-
832
- parse_str($args, $r);
833
- if (! isset($r['cats']))
834
- $r['cats'] = '';
835
- if (! isset($r['format']))
836
- $r['format'] = 'all';
837
- if (! isset($r['amount']))
838
- $r['amount'] = 'all';
839
-
840
- $JOIN = ''; $AND = '';
841
- // text or HTML subscribers
842
- if ('all' != $r['format']) {
843
- $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
844
- $AND .= " AND b.meta_key='s2_format' AND b.meta_value=";
845
- if ('html' == $r['format']) {
846
- $AND .= "'html'";
847
- } elseif ('text' == $r['format']) {
848
- $AND .= "'text'";
849
- }
850
- }
851
-
852
- // full post or excerpt subscribers
853
- if ('all' != $r['amount']) {
854
- $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
855
- $AND .= " AND c.meta_key='s2_excerpt' AND c.meta_value=";
856
- if ('excerpt' == $r['amount']) {
857
- $AND .= "'excerpt'";
858
- } elseif ('post' == $r['amount']) {
859
- $AND.= "'post'";
860
- }
861
- }
862
-
863
- // specific category subscribers
864
- if ('' != $r['cats']) {
865
- $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
866
- foreach (explode(',', $r['cats']) as $cat) {
867
- ('' == $and) ? $and = "d.meta_key='s2_cat$cat'" : $and .= " OR d.meta_key='s2_cat$cat'";
868
- }
869
- $AND .= "AND ($and)";
870
- }
871
-
872
- $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . " WHERE a.meta_key='s2_subscribed'" . $AND;
873
- $result = $wpdb->get_col($sql);
874
- if ($result) {
875
- $ids = implode(',', $result);
876
- return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
877
- }
878
- } // end get_registered()
879
-
880
- /**
881
- Collects the signup date for all public subscribers
882
- */
883
- function signup_date($email = '') {
884
- if ('' == $email) { return false; }
885
-
886
- global $wpdb;
887
- if (! empty($this->signup_dates)) {
888
- return $this->signup_dates[$email];
889
- } else {
890
- $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
891
- foreach ($results as $result) {
892
- $this->signup_dates[$result[0]] = $result[1];
893
- }
894
- return $this->signup_dates[$email];
895
- }
896
- } // end signup_date()
897
-
898
- /**
899
- Create the appropriate usermeta values when a user registers
900
- If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
901
- */
902
- function register ($user_id = 0) {
903
- global $wpdb;
904
-
905
- if (0 == $user_id) { return $user_id; }
906
- $user = get_userdata($user_id);
907
-
908
- // has this user previously signed up for email notification?
909
- if (false !== $this->is_public($user->user_email)) {
910
- // delete this user from the public table, and subscribe them to all the categories
911
- $this->delete($user->user_email);
912
- update_usermeta($user_id, 's2_subscribed', $this->get_all_categories());
913
- foreach(explode(',', $this->get_all_categories()) as $cat) {
914
- update_usermeta($user_id, 's2_cat' . $cat, "$cat");
915
- }
916
- update_usermeta($user_id, 's2_format', 'text');
917
- update_usermeta($user_id, 's2_excerpt', 'excerpt');
918
- } else {
919
- // add the usermeta for new registrations, but don't subscribe them
920
- $check = get_usermeta($user_id, 's2_subscribed');
921
- // ensure existing subscriptions are not overwritten on upgrade
922
- if (empty($check)) {
923
- if ('yes' == $this->subscribe2_options['s2_autosub']) {
924
- update_usermeta($user_id, 's2_subscribed', $this->get_all_categories());
925
- foreach(explode(',', $this->get_all_categories()) as $cat) {
926
- update_usermeta($user_id, 's2_cat' . $cat, "$cat");
927
- }
928
- if ('html' == $this->subscribe2_options['s2_autoformat']) {
929
- update_usermeta($user_id, 's2_format', 'html');
930
- update_usermeta($user_id, 's2_excerpt', 'post');
931
- } elseif ('fulltext' == $this->subscribe2_options['s2_autoformat']) {
932
- update_usermeta($user_id, 's2_format', 'text');
933
- update_usermeta($user_id, 's2_excerpt', 'post');
934
- } else {
935
- update_usermeta($user_id, 's2_format', 'text');
936
- update_usermeta($user_id, 's2_excerpt', 'excerpt');
937
- }
938
- } else {
939
- update_usermeta($user_id, 's2_subscribed', '');
940
- update_usermeta($user_id, 's2_format', 'text');
941
- update_usermeta($user_id, 's2_excerpt', 'excerpt');
942
- }
943
- }
944
- }
945
- return $user_id;
946
- } // end register()
947
-
948
- /**
949
- Subscribe all registered users to category selected on Admin Manage Page
950
- */
951
- function subscribe_registered_users ($emails = '', $cats = '') {
952
- if (('' == $emails) || ('' == $cats)) { return false; }
953
- global $wpdb;
954
-
955
- $useremails = explode(",", $emails);
956
- $useremails = implode("', '", $useremails);
957
-
958
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
959
- $user_IDs = $wpdb->get_col($sql);
960
- $cats = $_POST['category'];
961
- if (! is_array($cats)) {
962
- $cats = array($_POST['category']);
963
- }
964
-
965
- foreach ($user_IDs as $user_ID) {
966
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
967
- if (! is_array($old_cats)) {
968
- $old_cats = array($old_cats);
969
- }
970
- $new = array_diff($cats, $old_cats);
971
- if (! empty($new)) {
972
- // add subscription to these cat IDs
973
- foreach ($new as $id) {
974
- update_usermeta($user_ID, 's2_cat' . $id, "$id");
975
- }
976
- }
977
- $newcats = array_merge($cats, $old_cats);
978
- update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
979
- }
980
- } // end subscribe_registered_users
981
-
982
- /**
983
- Unsubscribe all registered users to category selected on Admin Manage Page
984
- */
985
- function unsubscribe_registered_users ($emails = '', $cats = '') {
986
- if (('' == $emails) || ('' == $cats)) { return false; }
987
- global $wpdb;
988
-
989
- $useremails = explode(",", $emails);
990
- $useremails = implode("', '", $useremails);
991
-
992
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
993
- $user_IDs = $wpdb->get_col($sql);
994
- $cats = $_POST['category'];
995
- if (! is_array($cats)) {
996
- $cats = array($_POST['category']);
997
- }
998
-
999
- foreach ($user_IDs as $user_ID) {
1000
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1001
- if (! is_array($old_cats)) {
1002
- $old_cats = array($old_cats);
1003
- }
1004
- $remain = array_diff($old_cats, $cats);
1005
- if (! empty($remain)) {
1006
- // remove subscription to these cat IDs and update s2_subscribed
1007
- foreach ($cats as $id) {
1008
- delete_usermeta($user_ID, 's2_cat' . $id, "$id");
1009
- }
1010
- update_usermeta($user_ID, 's2_subscribed', implode(',', $remain));
1011
- } else {
1012
- // remove subscription to these cat IDs and update s2_subscribed to ''
1013
- foreach ($cats as $id) {
1014
- delete_usermeta($user_ID, 's2_cat' . $id, "$id");
1015
- }
1016
- update_usermeta($user_ID, 's2_subscribed', '');
1017
- }
1018
- }
1019
- } // end unsubscribe_registered_users
1020
-
1021
- /**
1022
- Autosubscribe registered users to newly created categories
1023
- if registered user has selected this option
1024
- */
1025
- function autosub_new_category ($new_category='') {
1026
- global $wpdb;
1027
-
1028
- $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='s2_autosub' AND $wpdb->usermeta.meta_value='yes'";
1029
- $user_IDs = $wpdb->get_col($sql);
1030
- if ('' == $user_IDs) { return; }
1031
-
1032
- foreach ($user_IDs as $user_ID) {
1033
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1034
- if (! is_array($old_cats)) {
1035
- $old_cats = array($old_cats);
1036
- }
1037
- // add subscription to these cat IDs
1038
- update_usermeta($user_ID, 's2_cat' . $new_category, "$new_category");
1039
- $newcats = array_merge($old_cats, (array)$new_category);
1040
- update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
1041
- }
1042
- } // end autosub_new_category
1043
-
1044
- /* ===== Menus ===== */
1045
- /**
1046
- Our management page
1047
- */
1048
- function manage_menu() {
1049
- global $wpdb;
1050
-
1051
- //Get Registered Subscribers for bulk management
1052
- $registered = $this->get_registered();
1053
- if(!empty($registered)) {
1054
- $emails = implode(",", $registered);
1055
- }
1056
-
1057
- $what = '';
1058
- $reminderform = '';
1059
-
1060
- // was anything POSTed ?
1061
- if (isset($_POST['s2_admin'])) {
1062
- if ('subscribe' == $_POST['s2_admin']) {
1063
- foreach (preg_split ("/[\s,]+/", $_POST['addresses']) as $email) {
1064
- if (is_email($email)) {
1065
- $this->activate($email);
1066
- }
1067
- }
1068
- $_POST['what'] = 'confirmed';
1069
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Address(es) subscribed!', 'subscribe2') . "</p></strong></div>";
1070
- } elseif ('delete' == $_POST['s2_admin']) {
1071
- $this->delete($_POST['email']);
1072
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . $_POST['email'] . ' ' . __('deleted!', 'subscribe2') . "</p></strong></div>";
1073
- } elseif ('toggle' == $_POST['s2_admin']) {
1074
- $this->toggle($_POST['email']);
1075
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . $_POST['email'] . ' ' . __('status changed!', 'subscribe2') . "</p></strong></div>";
1076
- } elseif ('remind' == $_POST['s2_admin']) {
1077
- $this->remind($_POST['reminderemails']);
1078
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Reminder Email(s) Sent!','subscribe2') . "</p></strong></div>";
1079
- } elseif ('exportcsv' == $_POST['s2_admin']) {
1080
- $this->exportcsv($_POST['exportcsv']);
1081
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('CSV File Created in wp-content','subscribe2') . "</p></strong></div>";
1082
- } elseif ( ('register' == $_POST['s2_admin']) && ('Subscribe' == $_POST['submit']) ) {
1083
- $this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1084
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Subscribed!','subscribe2') . "</p></strong></div>";
1085
- } elseif ( ('register' == $_POST['s2_admin']) && ('Unsubscribe' == $_POST['submit']) ) {
1086
- $this->unsubscribe_registered_users($_POST['emails'], $_POST['category']);
1087
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Unsubscribed!','subscribe2') . "</p></strong></div>";
1088
- }
1089
- }
1090
-
1091
- if (isset($_POST['what'])) {
1092
- if ('all' == $_POST['what']) {
1093
- $what = 'all';
1094
- $confirmed = $this->get_public();
1095
- $unconfirmed = $this->get_public(0);
1096
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$registered);
1097
- } elseif ('public' == $_POST['what']) {
1098
- $what = 'public';
1099
- $confirmed = $this->get_public();
1100
- $unconfirmed = $this->get_public(0);
1101
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1102
- } elseif ('confirmed' == $_POST['what']) {
1103
- $what = 'confirmed';
1104
- $confirmed = $this->get_public();
1105
- $subscribers = $confirmed;
1106
- } elseif ('unconfirmed' == $_POST['what']) {
1107
- $what = 'unconfirmed';
1108
- $unconfirmed = $this->get_public(0);
1109
- $subscribers = $unconfirmed;
1110
- if (!empty($unconfirmed)) {
1111
- $reminderemails = implode(",", $unconfirmed);
1112
- $reminderform = "<span class=\"submit\"><form method=\"post\" action=\"\"><input type=\"hidden\" name=\"reminderemails\" value=\"$reminderemails\" /><input type=\"hidden\" name=\"s2_admin\" value=\"remind\" /><input type=\"submit\" name=\"submit\" value=\"" . __('Send Reminder Email','subscribe2') . "\" /></form></span>";
1113
- }
1114
- } elseif (is_numeric($_POST['what'])) {
1115
- $what = intval($_POST['what']);
1116
- $subscribers = $this->get_registered("cats=$what");
1117
- } elseif ('registered' == $_POST['what']) {
1118
- $what = 'registered';
1119
- $subscribers = $registered;
1120
- }
1121
- } elseif ('' == $what) {
1122
- $what = 'registered';
1123
- $subscribers = $registered;
1124
- $registermessage = '';
1125
- if (empty($subscribers)) {
1126
- $confirmed = $this->get_public();
1127
- $subscribers = $confirmed;
1128
- $what = 'confirmed';
1129
- if (empty ($subscribers)) {
1130
- $unconfirmed = $this->get_public(0);
1131
- $subscribers = $unconfirmed;
1132
- $what = 'unconfirmed';
1133
- if (empty($subscribers)) {
1134
- $what = 'all';
1135
- }
1136
- }
1137
- }
1138
- }
1139
- if (!empty($subscribers)) {
1140
- natcasesort($subscribers);
1141
- }
1142
- // safety check for our arrays
1143
- if ('' == $confirmed) { $confirmed = array(); }
1144
- if ('' == $unconfirmed) { $unconfirmed = array(); }
1145
- if ('' == $registered) { $registered = array(); }
1146
-
1147
- // show our form
1148
- echo "<div class=\"wrap\">";
1149
- echo "<h2>" . __('Subscribe Addresses', 'subscribe2') . "</h2>\r\n";
1150
- echo "<form method=\"post\" action=\"\">\r\n";
1151
- echo "<span style=\"align:left\">" . __('Enter addresses, one per line or comma-seperated', 'subscribe2') . "</span><br />\r\n";
1152
- echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea>";
1153
- echo "<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Subscribe', 'subscribe2') . "\"/>";
1154
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"subscribe\" /></span>";
1155
- echo "</form></div>";
1156
-
1157
- // subscriber lists
1158
- echo "<div class=\"wrap\"><h2>" . __('Subscribers', 'subscribe2') . "</h2>\r\n";
1159
-
1160
- $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1161
- // show the selected subscribers
1162
- $alternate = 'alternate';
1163
- if (!empty($subscribers)) {
1164
- echo "<p align=\"center\"><b>" . __('Registered on the left, confirmed in the middle, unconfirmed on the right', 'subscribe2') . "</b></p>";
1165
- if (is_writable(ABSPATH . '/wp-content')) {
1166
- $exportcsv = implode(",", $subscribers);
1167
- echo "<span class=\"submit\"><form method=\"post\" action=\"\"><input type=\"hidden\" name=\"exportcsv\" value=\"$exportcsv\" /><input type=\"hidden\" name=\"s2_admin\" value=\"exportcsv\" /><input type=\"submit\" name=\"submit\" value=\"" . __('Save Emails to CSV File','subscribe2') . "\" /></form></span>";
1168
- }
1169
- }
1170
- echo "<table cellpadding=\"2\" cellspacing=\"2\">";
1171
- if (!empty($subscribers)) {
1172
- foreach ($subscribers as $subscriber) {
1173
- echo "<tr class=\"$alternate\">";
1174
- echo "<td width=\"75%\"";
1175
- if (in_array($subscriber, $unconfirmed)) {
1176
- echo " align=\"right\">";
1177
- } elseif (in_array($subscriber, $confirmed)) {
1178
- echo "align=\"center\">";
1179
- } else {
1180
- echo "align=\"left\" colspan=\"3\">";
1181
- }
1182
- echo "<a href=\"mailto:$subscriber\">$subscriber</a>\r\n";
1183
- if (in_array($subscriber, $unconfirmed) || in_array($subscriber, $confirmed) ) {
1184
- echo "(" . $this->signup_date($subscriber) . ")</td>";
1185
- echo "<td width=\"5%\" align=\"center\"><form method=\"post\" action=\"\"><input type=\"hidden\" name=\"email\" value=\"$subscriber\" /><input type=\"hidden\" name=\"s2_admin\" value=\"toggle\" /><input type=\"hidden\" name=\"what\" value=\"$what\" /><input type=\"submit\" name=\"submit\" value=\"";
1186
- (in_array($subscriber, $unconfirmed)) ? $foo = '&lt;-' : $foo= '-&gt;';
1187
- echo "$foo\" /></form></td>";
1188
- echo "<td width=\"2%\" align=\"center\"><form method=\"post\" action=\"\"><span class=\"delete\"><input type=\"hidden\" name=\"email\" value=\"$subscriber\" /><input type=\"hidden\" name=\"s2_admin\" value=\"delete\" /><input type=\"hidden\" name=\"what\" value=\"$what\" /><input type=\"submit\" name=\"submit\" value=\"X\" /></span></form>";
1189
- }
1190
- echo "</td></tr>\r\n";
1191
- ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1192
- }
1193
- } else {
1194
- echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1195
- }
1196
- echo "</table>";
1197
- if (!empty($reminderform)) {echo $reminderform;}
1198
- echo "</div>\r\n";
1199
-
1200
- //show bulk managment form
1201
- echo "<div class=\"wrap\">";
1202
- echo "<h2 >" . __('Categories', 'subscribe2') . "</h2>\r\n";
1203
- echo __('Existing Registered Users can be automatically (un)subscribed to categories using this section.', 'subscribe2') . "<br />\r\n";
1204
- echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1205
- echo "<span class=\"submit\"><form method=\"post\" action=\"\"><input type=\"hidden\" name=\"emails\" value=\"$emails\" /><input type=\"hidden\" name=\"s2_admin\" value=\"register\" />";
1206
- $this->display_category_form(explode(',', $this->get_excluded_cats()));
1207
- echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Subscribe','subscribe2') . "\" />";
1208
- echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Unsubscribe','subscribe2') . "\" /></form></span>";
1209
-
1210
- echo "</div>\r\n";
1211
- echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1212
-
1213
- include(ABSPATH . '/wp-admin/admin-footer.php');
1214
- // just to be sure
1215
- die;
1216
- } // end manage_menu()
1217
-
1218
- /**
1219
- Our options page
1220
- */
1221
- function options_menu() {
1222
- // was anything POSTed?
1223
- if (isset($_POST['s2_admin'])) {
1224
- if ('RESET' == $_POST['s2_admin']) {
1225
- $this->reset();
1226
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_reset</p></strong></div>";
1227
- } elseif ('options' == $_POST['s2_admin']) {
1228
- // excluded categories
1229
- if (!empty($_POST['category'])) {
1230
- $exclude_cats = implode(',', $_POST['category']);
1231
- } else {
1232
- $exclude_cats = '';
1233
- }
1234
- $this->subscribe2_options['exclude'] = $exclude_cats;
1235
- // allow override?
1236
- (isset($_POST['reg_override'])) ? $override = '1' : $override = '0';
1237
- $this->subscribe2_options['reg_override'] = $override;
1238
-
1239
- // show button?
1240
- ($_POST['show_button'] == '1') ? $showbutton = '1' : $showbutton = '0';
1241
- $this->subscribe2_options['show_button'] = $showbutton;
1242
-
1243
- // send as author or admin?
1244
- $sender = 'author';
1245
- if ('admin' == $_POST['sender']) {
1246
- $sender = 'admin';
1247
- }
1248
- $this->subscribe2_options['sender'] = $sender;
1249
-
1250
- // email templates
1251
- $mailtext = $_POST['mailtext'];
1252
- $this->subscribe2_options['mailtext'] = $mailtext;
1253
- $confirm_email = $_POST['confirm_email'];
1254
- $this->subscribe2_options['confirm_email'] = $confirm_email;
1255
- $remind_email = $_POST['remind_email'];
1256
- $this->subscribe2_options['remind_email'] = $remind_email;
1257
-
1258
- //automatic subscription
1259
- $autosub_option = $_POST['autosub'];
1260
- $this->subscribe2_options['autosub']= $autosub_option;
1261
- $autosub_format_option = $_POST['autoformat'];
1262
- $this->subscribe2_options['autoformat']= $autosub_format_option;
1263
-
1264
- //barred domains
1265
- $barred_option = $_POST['barred'];
1266
- $this->subscribe2_options['barred'] = $barred_option;
1267
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_saved</p></strong></div>";
1268
- update_option( 'subscribe2_options', $this->subscribe2_options );
1269
- }
1270
- }
1271
- // show our form
1272
- echo "<div class=\"wrap\">";
1273
- echo "<form method=\"post\" action=\"\">";
1274
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />";
1275
- echo "<h2>" . __('Delivery Options', 'subscribe2') . ":</h2>";
1276
- echo __('Send Email From', 'subscribe2') . ': ';
1277
- echo "<input type=\"radio\" name=\"sender\" value=\"author\" ";
1278
- if ('author' == $this->subscribe2_options['sender']) {
1279
- echo "checked=\"checked\" ";
1280
- }
1281
- echo " /> " . __('Author of the post', 'subscribe2') . " &nbsp;&nbsp;";
1282
- echo "<input type=\"radio\" name=\"sender\" value=\"admin\" ";
1283
- if ('admin' == $this->subscribe2_options['sender']) {
1284
- echo "checked=\"checked\" ";
1285
- }
1286
- echo " /> " . __('Blog Admin', 'subscribe2') . "<br />\r\n";
1287
- echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
1288
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">";
1289
- echo "<tr><td>";
1290
- echo __('New Post email (must not be empty)', 'subscribe2') . ":";
1291
- echo "<br />\r\n";
1292
- echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><p>\r\n";
1293
- echo "</td><td valign=\"top\" rowspan=\"3\">";
1294
- echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
1295
- echo "<dl>";
1296
- echo "<dt><b>BLOGNAME</b></dt><dd>" . get_bloginfo('name') . "</dd>\r\n";
1297
- echo "<dt><b>BLOGLINK</b></dt><dd>" . get_bloginfo('url') . "</dd>\r\n";
1298
- echo "<dt><b>TITLE</b></dt><dd>" . __("the post's title", 'subscribe2') . "</dd>\r\n";
1299
- 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";
1300
- echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink", 'subscribe2') . "</dd>\r\n";
1301
- echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
1302
- echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
1303
- echo "<dt><b>AUTHORNAME</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
1304
- 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";
1305
- 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";
1306
- echo "</dl></td></tr><tr><td>";
1307
- echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
1308
- echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><p>";
1309
- echo "</td></tr><tr><td>";
1310
- echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
1311
- echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><p>";
1312
- echo "</td></tr></table>\r\n";
1313
-
1314
- // excluded categories
1315
- echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
1316
- $this->display_category_form(explode(',', $this->get_excluded_cats()));
1317
- echo "<p align=\"center\"><input type=\"checkbox\" name=\"reg_override\" value=\"1\"";
1318
- if ('1' == $this->subscribe2_options['reg_override']) {
1319
- echo "checked=\"checked\"";
1320
- }
1321
- echo "/> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</p>";
1322
- echo "<h2>" . __('Writing Options', 'subscribe2') . "</h2>\r\n";
1323
- echo "<p align=\"center\"><input type=\"checkbox\" name=\"show_button\" value=\"1\"";
1324
- if ('1' == $this->subscribe2_options['show_button']) {
1325
- echo "checked=\"checked\"";
1326
- }
1327
- echo "/> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "</p>";
1328
-
1329
- //Auto Subscription for new registrations
1330
- echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
1331
- echo __('Automatically subscribe new users registering with your blog.', 'subscribe2') . "<br />\r\n";
1332
- echo "<input type=\"radio\" name=\"autosub\" value=\"yes\" ";
1333
- if ('yes' == $this->subscribe2_options['autosub']) {
1334
- echo "checked=\"checked\" ";
1335
- }
1336
- echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1337
- echo "<input type=\"radio\" name=\"autosub\" value=\"no\" ";
1338
- if ('no' == $this->subscribe2_options['autosub']) {
1339
- echo "checked=\"checked\" ";
1340
- }
1341
- echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1342
- echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
1343
- echo "<input type=\"radio\" name=\"autoformat\" value=\"html\"";
1344
- if ('html' == $this->subscribe2_options['autoformat']) {
1345
- echo "checked=\"checked\" ";
1346
- }
1347
- echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1348
- echo "<input type=\"radio\" name=\"autoformat\" value=\"fulltext\" ";
1349
- if ('fulltext' == $this->subscribe2_options['autoformat']) {
1350
- echo "checked=\"checked\" ";
1351
- }
1352
- echo "/> " . __('Plain Text - Full', 'subscribe2') . " &nbsp;&nbsp;";
1353
- echo "<input type=\"radio\" name=\"autoformat\" value=\"text\" ";
1354
- if ('text' == $this->subscribe2_options['autoformat']) {
1355
- echo "checked=\"checked\" ";
1356
- }
1357
- echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . " &nbsp;&nbsp;";
1358
-
1359
- //barred domains
1360
- echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
1361
- 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');
1362
- echo "<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
1363
-
1364
- // submit
1365
- echo "<p align=\"center\"><span class=\"submit\"><input type=\"submit\" id=\"save\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></span></p>";
1366
- echo "</form>\r\n";
1367
- echo "</div><div class=\"wrap\">";
1368
-
1369
- // reset
1370
- echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
1371
- 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";
1372
- echo "<form method=\"post\" action=\"\">";
1373
- echo "<p align=\"center\"><span class=\"submit\">";
1374
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"RESET\" />";
1375
- echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('RESET', 'subscribe2') .
1376
- "\" />";
1377
- echo "</span></p></form></div>\r\n";
1378
-
1379
- include(ABSPATH . '/wp-admin/admin-footer.php');
1380
- // just to be sure
1381
- die;
1382
- } // end options_menu()
1383
-
1384
- /**
1385
- Our profile menu
1386
- */
1387
- function user_menu() {
1388
- global $user_ID;
1389
-
1390
- get_currentuserinfo();
1391
-
1392
- // was anything POSTed?
1393
- if ( (isset($_POST['s2_admin'])) && ('user' == $_POST['s2_admin']) ) {
1394
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
1395
- $format = 'text';
1396
- $post = 'post';
1397
- if ('html' == $_POST['s2_format']) {
1398
- $format = 'html';
1399
- }
1400
- if ('excerpt' == $_POST['s2_excerpt']) {
1401
- $post = 'excerpt';
1402
- }
1403
- update_usermeta($user_ID, 's2_excerpt', $post);
1404
- update_usermeta($user_ID, 's2_format', $format);
1405
- update_usermeta($user_ID, 's2_autosub', $_POST['new_category']);
1406
-
1407
- $cats = $_POST['category'];
1408
- if (empty($cats)) {
1409
- $cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1410
- if ($cats) {
1411
- foreach ($cats as $cat) {
1412
- delete_usermeta($user_ID, "s2_cat" . $cat);
1413
- }
1414
- }
1415
- update_usermeta($user_ID, 's2_subscribed', '');
1416
- } else {
1417
- if (! is_array($cats)) {
1418
- $cats = array($_POST['category']);
1419
- }
1420
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1421
- $remove = array_diff($old_cats, $cats);
1422
- $new = array_diff($cats, $old_cats);
1423
- if (! empty($remove)) {
1424
- // remove subscription to these cat IDs
1425
- foreach ($remove as $id) {
1426
- delete_usermeta($user_ID, "s2_cat" .$id);
1427
- }
1428
- }
1429
- if (! empty($new)) {
1430
- // add subscription to these cat IDs
1431
- foreach ($new as $id) {
1432
- update_usermeta($user_ID, 's2_cat' . $id, "$id");
1433
- }
1434
- }
1435
- update_usermeta($user_ID, 's2_subscribed', implode(',', $cats));
1436
- }
1437
- }
1438
-
1439
- // show our form
1440
- echo "<div class=\"wrap\">";
1441
- echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
1442
- echo "<form method=\"post\" action=\"\">";
1443
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
1444
- if ( defined('S2DIGEST') && FALSE == S2DIGEST ) {
1445
- echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
1446
- echo "<input type=\"radio\" name=\"s2_format\" value=\"html\"";
1447
- if ('html' == get_usermeta($user_ID, 's2_format')) {
1448
- echo "checked=\"checked\" ";
1449
- }
1450
- echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1451
- echo "<input type=\"radio\" name=\"s2_format\" value=\"text\" ";
1452
- if ('text' == get_usermeta($user_ID, 's2_format')) {
1453
- echo "checked=\"checked\" ";
1454
- }
1455
- echo "/> " . __('Plain Text', 'subscribe2') . "<br /><br />\r\n";
1456
-
1457
- echo __('Email contains', 'subscribe2') . ": &nbsp;&nbsp;";
1458
- $amount = array ('excerpt' => __('Excerpt Only', 'subscribe2'), 'post' => __('Full Post', 'subscribe2'));
1459
- foreach ($amount as $key => $value) {
1460
- echo "<input type=\"radio\" name=\"s2_excerpt\" value=\"" . $key . "\"";
1461
- if ($key == get_usermeta($user_ID, 's2_excerpt')) {
1462
- echo " checked=\"checked\"";
1463
- }
1464
- echo " /> $value ";
1465
- }
1466
- echo "<p style=\"color: red\">" . __('Note: HTML format will always deliver the full post.', 'subscribe2') . "</p>\r\n";
1467
- echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
1468
- echo "<input type=\"radio\" name=\"new_category\" value=\"yes\" ";
1469
- if ('yes' == get_usermeta($user_ID, 's2_autosub')) {
1470
- echo "checked=\"yes\" ";
1471
- }
1472
- echo "/> Yes <input type=\"radio\" name=\"new_category\" value=\"no\" ";
1473
- if ('no' == get_usermeta($user_ID, 's2_autosub')) {
1474
- echo "checked=\"yes\" ";
1475
- }
1476
- echo "/> No<br /><br />";
1477
-
1478
- // subscribed categories
1479
- echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
1480
- $this->display_category_form(explode(',', get_usermeta($user_ID, 's2_subscribed')), $this->subscribe2_options['reg_override']);
1481
- } else {
1482
- // we're doing daily digests, so just show
1483
- // subscribe / unnsubscribe
1484
- echo __('Receive daily summary of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
1485
- echo "<input type=\"radio\" name=\"category\" value=\"1\" ";
1486
- if (get_usermeta($user_ID, 's2_subscribed')) {
1487
- echo "checked=\"yes\" ";
1488
- }
1489
- echo "/> Yes <input type=\"radio\" name=\"category\" value=\"\" ";
1490
- if (! get_usermeta($user_ID, 's2_subscribed')) {
1491
- echo "checked=\"yes\" ";
1492
- }
1493
- echo "/> No";
1494
- }
1495
-
1496
- // submit
1497
- echo "<p align=\"right\"><span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __("Update Preferences &raquo;", 'subscribe2') . "\" /></span></p>";
1498
- echo "</form></div>\r\n";
1499
-
1500
- include(ABSPATH . '/wp-admin/admin-footer.php');
1501
- // just to be sure
1502
- die;
1503
- } // end user_menu()
1504
-
1505
- /**
1506
- Display the Write sub-menu
1507
- */
1508
- function write_menu() {
1509
- // was anything POSTed?
1510
- if (isset($_POST['s2_admin']) && ('mail' == $_POST['s2_admin']) ) {
1511
- if ('confirmed' == $_POST['what']) {
1512
- $recipients = $this->get_public();
1513
- } elseif ('unconfirmed' == $_POST['what']) {
1514
- $recipients = $this->get_public(0);
1515
- } elseif ('public' == $_POST['what']) {
1516
- $confirmed = $this->get_public();
1517
- $unconfirmed = $this->get_public(0);
1518
- $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
1519
- } elseif (is_numeric($_POST['what'])) {
1520
- $cat = intval($_POST['what']);
1521
- $recipients = $this->get_registered("cats=$cat");
1522
- } else {
1523
- $recipients = $this->get_registered();
1524
- }
1525
- global $user_identity, $user_email;
1526
- get_currentuserinfo();
1527
- $this->myname = $user_identity;
1528
- $this->myemail = $user_email;
1529
- $subject = strip_tags($_POST['subject']);
1530
- $message = stripslashes($_POST['message']);
1531
- $this->mail($recipients, $subject, $message, 'text');
1532
- $message = $this->mail_sent;
1533
- }
1534
-
1535
- if ('' != $message) {
1536
- echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
1537
- }
1538
- // show our form
1539
- echo "<div class=\"wrap\"><h2>" . __('Send email to all subscribers', 'subscribe2') . "</h2>\r\n";
1540
- echo "<form method=\"post\" action=\"\">\r\n";
1541
- echo __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . __('A message from ', 'subscribe2') . get_settings('blogname') . "\" /> <br />";
1542
- echo "<textarea rows=\"12\" cols=\"75\" name=\"message\"></textarea>";
1543
- echo "<br />\r\n";
1544
- echo __('Recipients: ', 'subscribe2');
1545
- $this->display_subscriber_dropdown('registered', false, array('all'));
1546
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
1547
- echo "&nbsp;&nbsp;<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></span>&nbsp;";
1548
- echo "</form></div>\r\n";
1549
- echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1550
-
1551
- include(ABSPATH . '/wp-admin/admin-footer.php');
1552
- // just to be sure
1553
- die;
1554
- } // end write_menu()
1555
-
1556
- /* ===== helper functions: forms and stuff ===== */
1557
- /**
1558
- Display a table of categories with checkboxes
1559
-
1560
- Optionally pre-select those categories specified
1561
- */
1562
- function display_category_form($selected = array(), $override = 1) {
1563
- global $wpdb;
1564
-
1565
- $all_cats = $this->get_all_categories('array');
1566
- if (0 == $override) {
1567
- // registered users are not allowed to subscribe to
1568
- // excluded categories
1569
- foreach (explode(',', $this->get_excluded_cats()) as $cat) {
1570
- $category = get_category($cat);
1571
- $excluded[$cat] = $category->cat_name;
1572
- }
1573
- $all_cats = array_diff($all_cats, $excluded);
1574
- }
1575
-
1576
- $half = (count($all_cats) / 2);
1577
- $i = 0;
1578
- $j = 0;
1579
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">";
1580
- echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">";
1581
- foreach ($all_cats as $cat_ID => $cat_name) {
1582
- if ( ($i >= $half) && (0 == $j) ){
1583
- echo "</td><td width=\"50%\" align=\"left\">";
1584
- $j++;
1585
- }
1586
- if (0 == $j) {
1587
- echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat_ID . "\"";
1588
- if (in_array($cat_ID, $selected)) {
1589
- echo " checked=\"checked\" ";
1590
- }
1591
- echo " /> " . $cat_name . "<br />\r\n";
1592
- } else {
1593
-
1594
- echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat_ID . "\"";
1595
- if (in_array($cat_ID, $selected)) {
1596
- echo " checked=\"checked\" ";
1597
- }
1598
- echo " /> " . $cat_name . "<br />\r\n";
1599
- }
1600
- $i++;
1601
- }
1602
- echo "</td></tr></table>\r\n";
1603
- } // end display_category_form()
1604
-
1605
- /**
1606
- Display a drop-down form to select subscribers
1607
- $selected is the option to select
1608
- $submit is the text to use on the Submit button
1609
- */
1610
- function display_subscriber_dropdown ($selected = 'registered', $submit = '', $exclude = array()) {
1611
- global $wpdb;
1612
-
1613
- $who = array('all' => __('All Subscribers', 'subscribe2'),
1614
- 'public' => __('Public Subscribers', 'subscribe2'),
1615
- 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
1616
- 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
1617
- 'registered' => __('Registered Subscribers', 'subscribe2'));
1618
-
1619
- // count the number of subscribers
1620
- $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
1621
- $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
1622
- if (in_array('unconfirmed', $exclude)) {
1623
- $count['public'] = $count['confirmed'];
1624
- } elseif (in_array('confirmed', $exclude)) {
1625
- $count['public'] = $count['unconfirmed'];
1626
- } else {
1627
- $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
1628
- }
1629
- $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='s2_subscribed'");
1630
- $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['registered']);
1631
- foreach ($this->get_all_categories('array') as $cat_ID => $cat_name) {
1632
- $count[$cat_name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='s2_cat$cat_ID'");
1633
- }
1634
-
1635
- // do have actually have some subscribers?
1636
- if ( (0 == $count['confirmed']) && (0 == $count['unconfirmed']) && (0 == $count['registered']) ) {
1637
- // no? bail out
1638
- return;
1639
- }
1640
-
1641
- if (false !== $submit) {
1642
- echo "<form method=\"post\" action=\"\">";
1643
- }
1644
- echo "<select name=\"what\">\r\n";
1645
- foreach ($who as $whom => $display) {
1646
- if (in_array($whom, $exclude)) { continue; }
1647
- if (0 == $count[$whom]) { continue; }
1648
-
1649
- echo "<option value=\"$whom\"";
1650
- if ($whom == $selected) { echo " selected=\"selected\" "; }
1651
- echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
1652
- }
1653
-
1654
- if ($count['registered'] > 0) {
1655
- foreach ($this->get_all_categories('array') as $cat_ID => $cat_name) {
1656
- if (in_array($cat_ID, $exclude)) { continue; }
1657
- if (0 == $count[$cat_name]) { continue; }
1658
- echo "<option value=\"$cat_ID\"";
1659
- if ($cat_ID == $selected) { echo " selected=\"selected\" "; }
1660
- echo "> &nbsp;&nbsp;$cat_name (" . $count[$cat_name] . ") </option>\r\n";
1661
- }
1662
- }
1663
- echo "</select>";
1664
- if (false !== $submit) {
1665
- echo "<span class=\"submit\"><input type=\"submit\" value=\"$submit\" /></span></form>\r\n";
1666
- }
1667
- } // end display_subscriber_dropdown()
1668
-
1669
- /* ===== template and filter functions ===== */
1670
- /**
1671
- Display our form; also handles (un)subscribe requests
1672
- */
1673
- function filter($content = '') {
1674
- if (('' == $content) || (! preg_match('|<!--subscribe2-->|', $content))) { return $content; }
1675
- $this->s2form = $this->form;
1676
-
1677
- global $user_ID;
1678
- get_currentuserinfo();
1679
- if ($user_ID) {
1680
- $this->s2form = $this->use_profile;
1681
- }
1682
- if (isset($_POST['s2_action'])) {
1683
- global $wpdb, $user_email;
1684
- if (! is_email($_POST['email'])) {
1685
- $this->s2form = $this->form . $this->not_an_email;
1686
- } elseif ($this->is_barred($_POST['email'])) {
1687
- $this->s2form = $this->form . $this->barred_domain;
1688
- } else {
1689
- $this->email = $_POST['email'];
1690
- // does the supplied email belong to a registered user?
1691
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
1692
- if ('' != $check) {
1693
- // this is a registered email
1694
- $this->s2form = $this->please_log_in;
1695
- } else {
1696
- // this is not a registered email
1697
- // what should we do?
1698
- if ('subscribe' == $_POST['s2_action']) {
1699
- // someone is trying to subscribe
1700
- // lets see if they've tried to subscribe previously
1701
- if ('1' !== $this->is_public($this->email)) {
1702
- // the user is unknown or inactive
1703
- $this->add();
1704
- $this->send_confirm('add');
1705
- // set a variable to denote that we've already run, and shouldn't run again
1706
- $this->filtered = 1; //set this to not send duplicate emails
1707
- $this->s2form = $this->confirmation_sent;
1708
- } else {
1709
- // they're already subscribed
1710
- $this->s2form = $this->already_subscribed;
1711
- }
1712
- $this->action = 'subscribe';
1713
- } elseif ('unsubscribe' == $_POST['s2_action']) {
1714
- // is this email a subscriber?
1715
- if (false == $this->is_public($this->email)) {
1716
- $this->s2form = $this->form . $this->not_subscribed;
1717
- } else {
1718
- $this->send_confirm('del');
1719
- // set a variable to denote that we've already run, and shouldn't run again
1720
- $this->filtered = 1;
1721
- $this->s2form = $this->confirmation_sent;
1722
- }
1723
- $this->action='unsubscribe';
1724
- }
1725
- }
1726
- }
1727
- }
1728
- return preg_replace('|(<p>)(\n)*<!--subscribe2-->(\n)*(</p>)|', $this->s2form, $content);
1729
- } // end filter()
1730
-
1731
- /**
1732
- Overrides the default query when handling a (un)subscription confirmation
1733
- This is basically a trick: if the s2 variable is in the query string, just grab the first static page
1734
- and override it's contents later with title_filter() and template_filter()
1735
- */
1736
- function query_filter() {
1737
- // don't interfere if we've already done our thing
1738
- if (1 == $this->filtered) { return; }
1739
-
1740
- global $wpdb;
1741
-
1742
- if ( defined('S2PAGE') && 0 !== S2PAGE ) {
1743
- return "page_id=" . S2PAGE;
1744
- } else {
1745
- $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status='static' LIMIT 1");
1746
- if ($id) {
1747
- return "page_id=$id";
1748
- } else {
1749
- return "showposts=1";
1750
- }
1751
- }
1752
- } // end query_filter()
1753
-
1754
- /**
1755
- Overrides the page title
1756
- */
1757
- function title_filter() {
1758
- // don't interfere if we've already done our thing
1759
- if (1 == $this->filtered) { return; }
1760
- return __('Subscription Confirmation', 'subscribe2');
1761
- } // end title_filter()
1762
-
1763
- /**
1764
- Override the template filter to make sure a special template is not used
1765
- */
1766
- function template_filter() {
1767
- // don't interfere if we've already done our thing
1768
- if (1 == $this->filtered) { return; }
1769
- return;
1770
- } // end template_filter()
1771
-
1772
- /* ===== wp-cron functions ===== */
1773
- /**
1774
- Send notifications for any posts that are now visible
1775
- */
1776
- function subscribe2_hourly() {
1777
- $future_posts = get_option('s2_future_posts');
1778
-
1779
- // if we have no future posts, bail out
1780
- if (! $future_posts) { return; }
1781
-
1782
- // this will hold the posts that aren't yet visible
1783
- $not_yet = array();
1784
-
1785
- foreach ($future_posts as $post) {
1786
- if ( current_time('mysql') > $post['date'] ) {
1787
- // this post is now visible, so let's
1788
- // send a notification
1789
- $this->publish($post['id'], 1);
1790
- } else {
1791
- array_push($not_yet, $post);
1792
- }
1793
- }
1794
- // are the number of elements in $not_yet
1795
- // the same as in $future posts?
1796
- if ( count($not_yet) != count($future_posts) ) {
1797
- // if not, then some posts have been removed
1798
- // from $future_posts, and the remainder need
1799
- // to be recorded back to the database
1800
- update_option('s2_future_posts', $not_yet);
1801
- }
1802
- } // end subscribe2_hourly
1803
-
1804
- /**
1805
- Send a daily digest of today's new posts
1806
- */
1807
- function subscribe2_daily() {
1808
- global $wpdb;
1809
-
1810
- // collect yesterday's posts
1811
- $yesterday = date('Y-m-d', (get_option('wp_cron_daily_lastrun')-60));
1812
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content FROM $wpdb->posts WHERE post_date > '$yesterday 00:00:00' AND post_date < '$yesterday 23:59:59' AND post_status='publish'");
1813
-
1814
- // do we have any posts?
1815
- if (! $posts) { return; }
1816
-
1817
- // if we have posts, let's prepare the digest
1818
- foreach ($posts as $post) {
1819
- $post_cats = wp_get_post_cats('1', $post->ID);
1820
- $post_cats_string = implode(',', $post_cats);
1821
- $check = false;
1822
- // is the current post assigned to any categories
1823
- // which should not generate a notification email?
1824
- foreach (explode(',', $this->get_excluded_cats()) as $cat) {
1825
- if (in_array($cat, $post_cats)) {
1826
- $check = true;
1827
- }
1828
- }
1829
- // if this post is in an excluded category,
1830
- // don't include it in the digest
1831
- if ($check) {
1832
- continue;
1833
- }
1834
- $message .= $post->post_title . "\r\n";
1835
- $message .= get_permalink($post->ID) . "\r\n";
1836
- $excerpt = $post->post_excerpt;
1837
- if ('' == $excerpt) {
1838
- // no excerpt, is there a <!--more--> ?
1839
- if (false !== strpos($post->post_content, '<!--more-->')) {
1840
- list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
1841
- // strip leading and trailing whitespace
1842
- $excerpt = trim($excerpt);
1843
- } else {
1844
- $excerpt = strip_tags($post->post_content);
1845
- $words = explode(' ', $excerpt, 56);
1846
- if (count($words) > 55) {
1847
- array_pop($words);
1848
- array_push($words, '[...]');
1849
- $excerpt = implode(' ', $words);
1850
- }
1851
- }
1852
- }
1853
- $message .= $excerpt . "\r\n\r\n";
1854
- }
1855
-
1856
- $author = get_userdata($post->post_author);
1857
- $this->authorname = $author->display_name;
1858
-
1859
- // do we send as admin, or post author?
1860
- if ('author' == $this->subscribe2_options['sender']) {
1861
- // get author details
1862
- $user =& $author;
1863
- } else {
1864
- // get admin detailts
1865
- $user = get_userdata(1);
1866
- }
1867
- $this->myemail = $user->user_email;
1868
- $this->myname = $user->display_name;
1869
-
1870
- $subject = '[' . stripslashes(get_settings('blogname')) . '] ' . __('Daily Digest', 'subscribe2') . ' ' . $yesterday;
1871
- $public = $this->get_public();
1872
- $registered = $this->get_registered();
1873
- $recipients = array_merge((array)$public, (array)$registered);
1874
- $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
1875
- $body = str_replace('POST', $message, $mailtext);
1876
- $this->mail($recipients, $subject, $body);
1877
- } // end subscribe2_daily
1878
-
1879
- /**
1880
- If the to-be-deleted post was future-dated, remove it from the list of future-dated posts
1881
- */
1882
- function delete_future($id = 0) {
1883
- if (0 == $id) { return $id; }
1884
-
1885
- $future = get_settings('s2_future_posts');
1886
- // if we have no future-dated posts scheduled, bail out
1887
- if ( ! $future) {
1888
- return $id;
1889
- }
1890
- foreach ($future as $post) {
1891
- // is the deleted post in the list of future posts?
1892
- if ($id == $post['id']) {
1893
- // skip it
1894
- continue;
1895
- } else {
1896
- // add this to the new list of future posts
1897
- $new_future[] = $post;
1898
- }
1899
- }
1900
- if ($new_future != $future) {
1901
- update_option('s2_future_posts', $new_future);
1902
- }
1903
- } // end delete_future()
1904
-
1905
- /* ===== Our constructor ===== */
1906
- /**
1907
- Subscribe2 constructor
1908
- */
1909
- function subscribe2() {
1910
- global $table_prefix;
1911
-
1912
- load_plugin_textdomain('subscribe2', 'wp-content/plugins/subscribe2');
1913
-
1914
- // load the options
1915
- $this->subscribe2_options = array();
1916
- $this->subscribe2_options = get_option('subscribe2_options');
1917
-
1918
- // do we need to install anything?
1919
- $this->public = $table_prefix . "subscribe2";
1920
- if(mysql_query("SELECT COUNT(*) FROM ".$this->public)==FALSE) { $this->install(); }
1921
- //do we need to upgrade anything?
1922
- if ($this->subscribe2_options['version'] !== S2VERSION) {
1923
- $this->upgrade();
1924
- }
1925
-
1926
- if (isset($_GET['s2'])) {
1927
- // someone is confirming a request
1928
- add_filter('query_string', array(&$this, 'query_filter'));
1929
- add_filter('the_title', array(&$this, 'title_filter'));
1930
- add_filter('the_content', array(&$this, 'confirm'));
1931
- }
1932
-
1933
- add_action('admin_menu', array(&$this, 'admin_menu'));
1934
- add_action('publish_post', array(&$this, 'publish'));
1935
- add_action('edit_post', array(&$this, 'edit'));
1936
- add_action('private_to_published', array(&$this, 'private2publish'));
1937
- add_action('user_register', array(&$this, 'register'));
1938
- add_action('create_category', array(&$this, 'autosub_new_category'));
1939
- add_filter('the_content', array(&$this, 'filter'));
1940
- add_action('wp_cron_hourly', array(&$this, 'subscribe2_hourly'));
1941
- if (defined('S2DIGEST') && TRUE == S2DIGEST) {
1942
- add_action('wp_cron_daily', array(&$this, 'subscribe2_daily'));
1943
- }
1944
- add_action('delete_post', array(&$this, 'delete_future'));
1945
- // add our button
1946
- if ('1' == $this->subscribe2_options['show_button']) {
1947
- add_action('init', array(&$this, 's2_button_init'));
1948
- add_action('marker_css', array(&$this, 'subscribe2_css'));
1949
- }
1950
- // load our strings
1951
- $this->load_strings();
1952
- } // end subscribe2()
1953
-
1954
- /* ===== our variables ===== */
1955
- // cache variables
1956
- var $version = '';
1957
- var $all_public = '';
1958
- var $all_unconfirmed = '';
1959
- var $excluded_cats = '';
1960
- var $post_title = '';
1961
- var $permalink = '';
1962
- var $myname = '';
1963
- var $myemail = '';
1964
- var $s2_subject = '[BLOGNAME] TITLE';
1965
- var $signup_dates = array();
1966
- var $private = false;
1967
- var $filtered = 0;
1968
-
1969
- // state variables used to affect processing
1970
- var $action = '';
1971
- var $email = '';
1972
- var $message = '';
1973
- var $error = '';
1974
-
1975
- // some messages
1976
- var $please_log_in = '';
1977
- var $use_profile = '';
1978
- var $confirmation_sent = '';
1979
- var $already_subscribed = '';
1980
- var $not_subscribed ='';
1981
- var $not_an_email = '';
1982
- var $barred_domain = '';
1983
- var $mail_sent = '';
1984
- var $form = '';
1985
- var $no_such_email = '';
1986
- var $added = '';
1987
- var $deleted = '';
1988
- var $confirm_subject = '';
1989
- var $options_saved = '';
1990
- var $options_reset = '';
1991
-
1992
- } // end class subscribe2
1993
-
1994
- function s2init() {
1995
- global $subscribe2;
1996
- $mysubscribe2 = new subscribe2();
1997
- $mysubscribe2->subscribe2();
1998
- }
1999
-
2000
- add_action('init', 's2init');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2001
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Subscribe2
4
+ Plugin URI: http://subscribe2.wordpress.com
5
+ Description: Notifies an email list when new entries are posted. Tested with WordPress 2.1.x and 2.2.x.
6
+ Version: 3.6
7
+ Author: Matthew Robinson
8
+ Author URI: http://subscribe2.wordpress.com
9
+ */
10
+
11
+ /*
12
+ Copyright (C) 2006-7 Matthew Robinson
13
+ Based on the Original Subscribe2 plugin by
14
+ Copyright (C) 2005 Scott Merrill (skippy@skippy.net)
15
+
16
+ This program is free software; you can redistribute it and/or
17
+ modify it under the terms of the GNU General Public License
18
+ as published by the Free Software Foundation; either version 2
19
+ of the License, or (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program; if not, write to the Free Software
28
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
+ http://www.gnu.org/licenses/gpl.html
30
+ */
31
+
32
+ // If you are on a host that limits the number of recipients
33
+ // permitted on each outgoing email message
34
+ // change the value on the line below to your hosts limit
35
+ define('BCCLIMIT', '0');
36
+
37
+ // by default, Subscribe2 grabs the first page from your database for use
38
+ // when displaying the confirmation screen to public subscribers.
39
+ // You can override this by specifying a page ID on the line below.
40
+ define('S2PAGE', '0');
41
+
42
+ // our version number. Don't touch this or any line below
43
+ // unless you know exacly what you are doing
44
+ define('S2VERSION', '3.6');
45
+
46
+ // use Owen's excellent ButtonSnap library
47
+ require(ABSPATH . '/wp-content/plugins/buttonsnap.php');
48
+
49
+ $mysubscribe2 = new s2class;
50
+ $mysubscribe2->s2init();
51
+
52
+ // start our class
53
+ class s2class {
54
+ // variables and constructor are declared at the end
55
+
56
+ /**
57
+ Load all our strings
58
+ */
59
+ function load_strings() {
60
+ // adjust the output of Subscribe2 here
61
+
62
+ $this->please_log_in = "<p>" . __('To manage your subscription options please ', 'subscribe2') . "<a href=\"" . get_settings('siteurl') . "/wp-login.php\">login</a>.</p>";
63
+
64
+ $this->use_profile_admin = "<p>" . __('You may manage your subscription options from your ', 'subscribe2') . "<a href=\"" . get_settings('siteurl') . "/wp-admin/users.php?page=" . plugin_basename(__FILE__) . "\">profile</a>.</p>";
65
+
66
+ $this->use_profile_users = "<p>" . __('You may manage your subscription options from your ', 'subscribe2') . "<a href=\"" . get_settings('siteurl') . "/wp-admin/profile.php?page=" . plugin_basename(__FILE__) . "\">profile</a>.</p>";
67
+
68
+ $this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
69
+
70
+ $this->already_subscribed = "<p>" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
71
+
72
+ $this->not_subscribed = "<p>" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
73
+
74
+ $this->not_an_email = "<p>" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
75
+
76
+ $this->barred_domain = "<p>" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
77
+
78
+ $this->mail_sent = "<p>" . __('Message sent!', 'subscribe2') . "</p>";
79
+
80
+ $this->form = "<form method=\"post\" action=\"\">" . __('Your email:', 'subscribe2') . "&#160;<input type=\"text\" name=\"email\" value=\"\" size=\"20\" />&#160;<br /><input type=\"radio\" name=\"s2_action\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . " <input type=\"radio\" name=\"s2_action\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . " &#160;<input type=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></form>\r\n";
81
+
82
+ // confirmation messages
83
+ $this->no_such_email = "<p>" . __('No such email address is registered.', 'subscribe2') . "</p>";
84
+
85
+ $this->added = "<p>" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
86
+
87
+ $this->deleted = "<p>" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
88
+
89
+ $this->confirm_subject = "[" . get_settings('blogname') . "] " . __('Please confirm your request', 'subscribe2');
90
+
91
+ $this->remind_subject = "[" . get_settings('blogname') . "] " . __('Subscription Reminder', 'subscribe2');
92
+
93
+ $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
94
+
95
+ $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
96
+
97
+ // menu strings
98
+ $this->options_saved = __('Options saved!', 'subscribe2');
99
+ $this->options_reset = __('Options reset!', 'subscribe2');
100
+ } // end load_strings()
101
+
102
+ /* ===== WordPress menu registration ===== */
103
+ /**
104
+ Hook the menu
105
+ */
106
+ function admin_menu() {
107
+ add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", __FILE__, array(&$this, 'manage_menu'));
108
+ add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2','subscribe2'), "manage_options", __FILE__, array(&$this, 'options_menu'));
109
+ if (current_user_can('manage_options')) {
110
+ add_submenu_page('users.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
111
+ } else {
112
+ add_submenu_page('profile.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
113
+ }
114
+ add_submenu_page('post-new.php', __('Mail Subscribers','subscribe2'), __('Mail Subscribers', 'subscribe2'),"manage_options", __FILE__, array(&$this, 'write_menu'));
115
+ $s2nonce = md5('subscribe2');
116
+ }
117
+
118
+ /**
119
+ Insert Javascript into admin_header
120
+ */
121
+ function admin_head() {
122
+ echo "<script type=\"text/javascript\">\r\n";
123
+ echo "<!--\r\n";
124
+ echo "function setAll(theElement) {\r\n";
125
+ echo " var theForm = theElement.form, z = 0;\r\n";
126
+ echo " for(z=0; z<theForm.length;z++){\r\n";
127
+ echo " if(theForm[z].type == 'checkbox' && theForm[z].name == 'category[]'){\r\n";
128
+ echo " theForm[z].checked = theElement.checked;\r\n";
129
+ echo " }\r\n";
130
+ echo " }\r\n";
131
+ echo "}\r\n";
132
+ echo "-->\r\n";
133
+ echo "</script>\r\n";
134
+ }
135
+
136
+ function add_weekly_sched($sched) {
137
+ $sched['weekly'] = array('interval' => 604800, 'display' => __('Once Weekly','subscribe2'));
138
+ return $sched;
139
+ }
140
+
141
+ /* ===== Install, upgrade, reset ===== */
142
+ /**
143
+ Install our table
144
+ */
145
+ function install() {
146
+ // include upgrade-functions for maybe_create_table;
147
+ if (!function_exists('maybe_create_table')) {
148
+ require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
149
+ }
150
+ $date = date('Y-m-d');
151
+ $sql = "CREATE TABLE $this->public (
152
+ id int(11) NOT NULL auto_increment,
153
+ email varchar(64) NOT NULL default '',
154
+ active tinyint(1) default 0,
155
+ date DATE default '$date' NOT NULL,
156
+ PRIMARY KEY (id) )";
157
+
158
+ // create the table, as needed
159
+ maybe_create_table($this->public, $sql);
160
+ $this->reset();
161
+ } // end install()
162
+
163
+ /**
164
+ Upgrade the database
165
+ */
166
+ function upgrade() {
167
+ global $wpdb;
168
+
169
+ // include upgrade-functions for maybe_create_table;
170
+ if (!function_exists('maybe_create_table')) {
171
+ require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
172
+ }
173
+ $date = date('Y-m-d');
174
+ maybe_add_column($this->public, 'date', "ALTER TABLE `$this->public` ADD `date` DATE DEFAULT '$date' NOT NULL AFTER `active`;");
175
+
176
+ // let's take the time to check process registered users
177
+ // existing public subscribers are subscribed to all categories
178
+ $users = $wpdb->get_col("SELECT ID FROM $wpdb->users");
179
+ if (!empty($users)) {
180
+ foreach ($users as $user) {
181
+ $this->register($user);
182
+ }
183
+ }
184
+ // update the options table to serialized format
185
+ $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
186
+
187
+ if (!empty($old_options)) {
188
+ foreach ($old_options as $option) {
189
+ $value = get_option($option);
190
+ $option_array = substr($option, 3);
191
+ $this->subscribe2_options[$option_array] = $value;
192
+ delete_option($option);
193
+ }
194
+ }
195
+ $this->subscribe2_options['version'] = S2VERSION;
196
+ //double check that the options are in the database
197
+ require(ABSPATH . "/wp-content/plugins/subscribe2/include.php");
198
+ update_option('subscribe2_options', $this->subscribe2_options);
199
+ } // end upgrade()
200
+
201
+ /**
202
+ Reset our options
203
+ */
204
+ function reset() {
205
+ delete_option('subscribe2_options');
206
+ unset($this->subscribe2_options);
207
+ require(ABSPATH . "/wp-content/plugins/subscribe2/include.php");
208
+ update_option('subscribe2_options', $this->subscribe2_options);
209
+ } // end reset()
210
+
211
+ /* ===== mail handling ===== */
212
+ /**
213
+ Performs string substitutions for subscribe2 mail texts
214
+ */
215
+ function substitute($string = '') {
216
+ if ('' == $string) {
217
+ return;
218
+ }
219
+ $string = str_replace('BLOGNAME', get_settings('blogname'), $string);
220
+ $string = str_replace('BLOGLINK', get_bloginfo('url'), $string);
221
+ $string = str_replace('TITLE', stripslashes($this->post_title), $string);
222
+ $string = str_replace('PERMALINK', $this->permalink, $string);
223
+ $string = str_replace('MYNAME', stripslashes($this->myname), $string);
224
+ $string = str_replace('EMAIL', $this->myemail, $string);
225
+ $string = str_replace('AUTHORNAME', $this->authorname, $string);
226
+ return $string;
227
+ } // end sustitute()
228
+
229
+ /**
230
+ Delivers email to recipients in HTML or plaintext
231
+ */
232
+ function mail ($recipients = array(), $subject = '', $message = '', $type='text') {
233
+ if ( (empty($recipients)) || ('' == $message) ) { return; }
234
+
235
+ // Set sender details
236
+ if ('' == $this->myname) {
237
+ $admin = get_userdata(1);
238
+ $this->myname = $admin->display_name;
239
+ $this->myemail = $admin->user_email;
240
+ }
241
+ $headers = "From: " . $this->myname . " <" . $this->myemail . ">\n";
242
+ $headers .= "Return-Path: <" . $this->myemail . ">\n";
243
+ $headers .= "Reply-To: " . $this->myemail . "\n";
244
+ $headers .= "X-Mailer:PHP" . phpversion() . "\n";
245
+ $headers .= "Precedence: list\nList-Id: " . get_settings('blogname') . "\n";
246
+
247
+ if ('html' == $type) {
248
+ // To send HTML mail, the Content-Type header must be set
249
+ $headers .= "MIME-Version: 1.0\n";
250
+ $headers .= "Content-Type: " . get_bloginfo('html_type') . "; charset=\"". get_bloginfo('charset') . "\"\n";
251
+ $mailtext = "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>";
252
+ } else {
253
+ $headers .= "MIME-Version: 1.0\n";
254
+ $headers .= "Content-Type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
255
+ $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
256
+ $message = preg_replace('|&amp;|', '&', $message);
257
+ $mailtext = wordwrap(strip_tags($message), 80, "\n");
258
+ }
259
+
260
+ // BCC all recipients
261
+ $bcc = '';
262
+ if ( (defined('BCCLIMIT') && (BCCLIMIT > 0) ) &&
263
+ (count($recipients) > BCCLIMIT) ) {
264
+ // we're on Dreamhost, and have more than 30 susbcribers
265
+ $count = 1;
266
+ $batch = array();
267
+ foreach ($recipients as $recipient) {
268
+ // advance the array pointer by one, for use down below
269
+ // the array pointer _is not_ advanced by the foreach() loop itself
270
+ next($recipients);
271
+ $recipient = trim($recipient);
272
+ // sanity check -- make sure we have a valid email
273
+ if (!is_email($recipient)) { continue; }
274
+ // and NOT the sender's email, since they'll
275
+ // get a copy anyway
276
+ if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
277
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
278
+ // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
279
+ }
280
+ if (BCCLIMIT == $count) {
281
+ $count = 1;
282
+ $batch[] = $bcc;
283
+ $bcc = '';
284
+ } else {
285
+ if (false == current($recipients)) {
286
+ // we've reached the end of the subscriber list
287
+ // add what we have to the batch, and move on
288
+ $batch[] = $bcc;
289
+ break;
290
+ } else {
291
+ $count++;
292
+ }
293
+ }
294
+ }
295
+ // rewind the array, just to be safe
296
+ reset($recipients);
297
+ } else {
298
+ // we're not on dreamhost, or have less than 30
299
+ // subscribers, so do it normal
300
+ foreach ($recipients as $recipient) {
301
+ $recipient = trim($recipient);
302
+ // sanity check -- make sure we have a valid email
303
+ if (!is_email($recipient)) { continue; }
304
+ // and NOT the sender's email, since they'll
305
+ // get a copy anyway
306
+ if ( (!empty($recipient)) && ($this->myemail != $recipient) ) {
307
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
308
+ // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
309
+ }
310
+ }
311
+ $headers .= "$bcc\r\n";
312
+ }
313
+ // actually send mail
314
+ if ( (defined('BCCLIMIT')) && (BCCLIMIT > 0) && (isset($batch)) ) {
315
+ foreach ($batch as $bcc) {
316
+ $newheaders = $headers . "$bcc\r\n";
317
+ @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
318
+ }
319
+ } else {
320
+ @wp_mail($this->myemail, $subject, $mailtext, $headers);
321
+ }
322
+ } // end mail()
323
+
324
+ /**
325
+ Sends an email notification of a new post
326
+ */
327
+ function publish($id = 0) {
328
+ if (!$id) { return $id; }
329
+
330
+ // are we doing daily digests? If so, don't send anything now
331
+ if ($this->subscribe2_options['email_freq'] != 'never') { return; }
332
+
333
+ // we need to determine whether this is a new post, or an edit
334
+ if ($this->private) {
335
+ // this post was published from draft status
336
+ // OR is an edit of an existing post
337
+ // so send no notification
338
+ return $id;
339
+ }
340
+
341
+ $post_cats = wp_get_post_cats('1', $id);
342
+ $post_cats_string = implode(',', $post_cats);
343
+ $check = false;
344
+ // is the current post assigned to any categories
345
+ // which should not generate a notification email?
346
+ foreach (explode(',', $this->subscribe2_options['exclude']) as $cat) {
347
+ if (in_array($cat, $post_cats)) {
348
+ $check = true;
349
+ }
350
+ }
351
+ // if so, bail out
352
+ if ($check) {
353
+ // hang on -- can registered users subscribe to
354
+ // excluded categories?
355
+ if ('0' == $this->subscribe2_options['reg_override']) {
356
+ // nope? okay, let's leave
357
+ return $id;
358
+ }
359
+ }
360
+
361
+ global $wpdb;
362
+ $post =& get_post($id);
363
+ // is the post password protected?
364
+ if ( ($this->subscribe2_options['password'] == "no") && ($post->post_password != '') ) {return $id; }
365
+
366
+ // is this post set in the future?
367
+ if ($post->post_date > current_time('mysql')) {
368
+ // bail out
369
+ return $id;
370
+ }
371
+
372
+ // lets collect our public subscribers
373
+ // and all our registered subscribers for these categories
374
+ if (!$check) {
375
+ // if this post is assigned to an excluded
376
+ // category, then this test will prevent
377
+ // the public from receiving notification
378
+ $public = $this->get_public();
379
+ }
380
+ $registered = $this->get_registered("cats=$post_cats_string");
381
+
382
+ // do we have subscribers?
383
+ if ( (empty($public)) && (empty($registered)) ) {
384
+ // if not, no sense doing anything else
385
+ return $id;
386
+ }
387
+ // we set these class variables so that we can avoid
388
+ // passing them in function calls a little later
389
+ $this->post_title = $post->post_title;
390
+ $this->permalink = "<a href=\"" . get_permalink($id) . "\">" . get_permalink($id) . "</a>";
391
+
392
+ $author = get_userdata($post->post_author);
393
+ $this->authorname = $author->display_name;
394
+
395
+ // do we send as admin, or post author?
396
+ if ('author' == $this->subscribe2_options['sender']) {
397
+ // get author details
398
+ $user =& $author;
399
+ } else {
400
+ // get admin details
401
+ $user = get_userdata(1);
402
+ }
403
+ $this->myemail = $user->user_email;
404
+ $this->myname = $user->display_name;
405
+ // Get email subject
406
+ $subject = $this->substitute(stripslashes($this->s2_subject));
407
+ // Get the message template
408
+ $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
409
+
410
+ $plaintext = $post->post_content;
411
+ $content = apply_filters('the_content', $post->post_content);
412
+ $content = str_replace(']]>', ']]&gt', $content);
413
+ $excerpt = $post->post_excerpt;
414
+ if ('' == $excerpt) {
415
+ // no excerpt, is there a <!--more--> ?
416
+ if (false !== strpos($plaintext, '<!--more-->')) {
417
+ list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
418
+ // strip leading and trailing whitespace
419
+ $excerpt = strip_tags($excerpt);
420
+ $excerpt = trim($excerpt);
421
+ } else {
422
+ // no <!--more-->, so grab the first 55 words
423
+ $excerpt = strip_tags($plaintext);
424
+ $excerpt_length = 55;
425
+ $words = explode(' ', $excerpt, $excerpt_length + 1);
426
+ if (count($words) > $excerpt_length) {
427
+ array_pop($words);
428
+ array_push($words, '[...]');
429
+ $excerpt = implode(' ', $words);
430
+ }
431
+ }
432
+ }
433
+
434
+ // first we send plaintext summary emails
435
+ $body = str_replace('POST', $excerpt, $mailtext);
436
+ $registered = $this->get_registered("cats=$post_cats_string&format=text&amount=excerpt");
437
+ if (empty($registered)) {
438
+ $recipients = (array)$public;
439
+ }
440
+ elseif (empty($public)) {
441
+ $recipients = (array)$registered;
442
+ } else {
443
+ $recipients = array_merge((array)$public, (array)$registered);
444
+ }
445
+ $this->mail($recipients, $subject, $body);
446
+ // next we send plaintext full content emails
447
+ $body = str_replace('POST', strip_tags($plaintext), $mailtext);
448
+ $this->mail($this->get_registered("cats=$post_cats_string&format=text&amount=post"), $subject, $body);
449
+ // finally we send html full content emails
450
+ $body = str_replace("\r\n", "<br />\r\n", $mailtext);
451
+ $body = str_replace('POST', $content, $body);
452
+ $this->mail($this->get_registered("cats=$post_cats_string&format=html"), $subject, $body, 'html');
453
+
454
+ return $id;
455
+ } // end publish()
456
+
457
+ /**
458
+ Sends a notification when a draft post is published
459
+ */
460
+ function private2publish($id = 0) {
461
+ if (0 == $id) { return $id; }
462
+
463
+ $this->publish($id);
464
+ $this->private = TRUE;
465
+ return $id;
466
+ } // end private2publish()
467
+
468
+ /**
469
+ Prevents notifications from being sent when editing posts
470
+ */
471
+ function edit($id = 0) {
472
+ if (0 == $id) { return; }
473
+
474
+ $this->private = TRUE;
475
+ return $id;
476
+ }
477
+
478
+ /**
479
+ Send confirmation email to the user
480
+ */
481
+ function send_confirm($what = '', $is_remind = FALSE) {
482
+ if ($this->filtered == 1) { return; }
483
+ if ( (!$this->email) || (!$what) ) {
484
+ return false;
485
+ }
486
+ $id = $this->get_id($this->email);
487
+ if (!$id) {
488
+ return false;
489
+ }
490
+
491
+ // generate the URL "?s2=ACTION+HASH+ID"
492
+ // ACTION = 1 to subscribe, 0 to unsubscribe
493
+ // HASH = md5 hash of email address
494
+ // ID = user's ID in the subscribe2 table
495
+ $link = get_settings('siteurl') . "?s2=";
496
+
497
+ if ('add' == $what) {
498
+ $link .= '1';
499
+ } elseif ('del' == $what) {
500
+ $link .= '0';
501
+ }
502
+ $link .= md5($this->email);
503
+ $link .= $id;
504
+
505
+ $admin = get_userdata(1);
506
+ $this->myname = $admin->display_name;
507
+
508
+ if ($is_remind == TRUE) {
509
+ $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
510
+ $subject = stripslashes($this->remind_subject);
511
+ } else {
512
+ $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
513
+ if ('add' == $what) {
514
+ $body = str_replace("ACTION", $this->subscribe, $body);
515
+ } elseif ('del' == $what) {
516
+ $body = str_replace("ACTION", $this->unsubscribe, $body);
517
+ }
518
+ $subject = stripslashes($this->confirm_subject);
519
+ }
520
+
521
+ $body = str_replace("LINK", $link, $body);
522
+
523
+ $mailheaders .= "From: $admin->display_name <$admin->user_email>\n";
524
+ $mailheaders .= "Return-Path: <$admin->user_email>\n";
525
+ $mailheaders .= "X-Mailer:PHP" . phpversion() . "\n";
526
+ $mailheaders .= "Precedence: list\nList-Id: " . get_settings('blogname') . "\n";
527
+ $mailheaders .= "MIME-Version: 1.0\n";
528
+ $mailheaders .= "Content-Type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
529
+
530
+ @wp_mail ($this->email, $subject, $body, $mailheaders);
531
+ } // end send_confirm()
532
+
533
+ /* ===== Subscriber functions ===== */
534
+ /**
535
+ Given a public subscriber ID, returns the email address
536
+ */
537
+ function get_email ($id = 0) {
538
+ global $wpdb;
539
+
540
+ if (!$id) {
541
+ return false;
542
+ }
543
+ return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
544
+ } // end get_email
545
+
546
+ /**
547
+ Given a public subscriber email, returns the subscriber ID
548
+ */
549
+ function get_id ($email = '') {
550
+ global $wpdb;
551
+
552
+ if (!$email) {
553
+ return false;
554
+ }
555
+ return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
556
+ } // end get_id()
557
+
558
+ /**
559
+ Activate an email address
560
+ If the address is not already present, it will be added
561
+ */
562
+ function activate ($email = '') {
563
+ global $wpdb;
564
+
565
+ if ('' == $email) {
566
+ if ('' != $this->email) {
567
+ $email = $this->email;
568
+ } else {
569
+ return false;
570
+ }
571
+ }
572
+
573
+ if (false !== $this->is_public($email)) {
574
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
575
+ if ($check) { return; }
576
+ $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
577
+ } else {
578
+ $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '1', NOW())");
579
+ }
580
+ } // end activate()
581
+
582
+ /**
583
+ Add an unconfirmed email address to the subscriber list
584
+ */
585
+ function add ($email = '') {
586
+ if ($this->filtered ==1) { return; }
587
+ global $wpdb;
588
+
589
+ if ('' == $email) {
590
+ if ('' != $this->email) {
591
+ $email = $this->email;
592
+ } else {
593
+ return false;
594
+ }
595
+ }
596
+
597
+ if (!is_email($email)) { return false; }
598
+
599
+ if (false !== $this->is_public($email)) {
600
+ $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE email='$email'");
601
+ } else {
602
+ $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '0', NOW())");
603
+ }
604
+ } // end add()
605
+
606
+ /**
607
+ Remove a user from the subscription table
608
+ */
609
+ function delete($email = '') {
610
+ global $wpdb;
611
+
612
+ if ('' == $email) {
613
+ if ('' != $this->email) {
614
+ $email = $this->email;
615
+ } else {
616
+ return false;
617
+ }
618
+ }
619
+
620
+ if (!is_email($email)) { return false; }
621
+ $wpdb->get_results("DELETE FROM $this->public WHERE email='$email'");
622
+ } // end delete()
623
+
624
+ /**
625
+ Toggle a public subscriber's status
626
+ */
627
+ function toggle($email = '') {
628
+ global $wpdb;
629
+
630
+ if ( ('' == $email) || (! is_email($email)) ) { return false; }
631
+
632
+ // let's see if this is a public user
633
+ $status = $this->is_public($email);
634
+ if (false === $status) { return false; }
635
+
636
+ if ('0' == $status) {
637
+ $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
638
+ } else {
639
+ $wpdb->get_results("UPDATE $this->public SET active='0' WHERE email='$email'");
640
+ }
641
+ } // end toggle()
642
+
643
+ /**
644
+ Send reminder email to unconfirmed public subscribers
645
+ */
646
+ function remind($emails = '') {
647
+ if ('' == $emails) { return false; }
648
+
649
+ $admin = get_userdata(1);
650
+ $this->myname = $admin->display_name;
651
+
652
+ $recipients = explode(",", $emails);
653
+ if (!is_array($recipients)) { $recipients = array(); }
654
+ foreach ($recipients as $recipient) {
655
+ $this->email = $recipient;
656
+ $this->send_confirm('add', TRUE);
657
+ }
658
+ } //end remind()
659
+
660
+ /**
661
+ Export email list to CSV download
662
+ */
663
+ function exportcsv($emails = '') {
664
+ if ('' == $emails) {return false; }
665
+
666
+ $f = fopen(ABSPATH . '/wp-content/email.csv', 'w');
667
+ fwrite($f, $emails);
668
+ fclose($f);
669
+ } //end exportcsv
670
+
671
+ /**
672
+ Check email is not from a barred domain
673
+ */
674
+ function is_barred($email='') {
675
+ $barred_option = $this->subscribe2_options['barred'];
676
+ list($user, $domain) = split('@', $email);
677
+ $bar_check = stristr($barred_option, $domain);
678
+
679
+ if(!empty($bar_check)) {
680
+ return true;
681
+ } else {
682
+ return false;
683
+ }
684
+ } //end is_barred()
685
+
686
+ /**
687
+ Confirm request from the link emailed to the user and email the admin
688
+ */
689
+ function confirm($content = '') {
690
+ global $wpdb;
691
+
692
+ if (1 == $this->filtered) { return $content; }
693
+
694
+ $code = $_GET['s2'];
695
+ $action = intval(substr($code, 0, 1));
696
+ $hash = substr($code, 1, 32);
697
+ $code = str_replace($hash, '', $code);
698
+ $id = intval(substr($code, 1));
699
+ if ($id) {
700
+ $this->email = $this->get_email($id);
701
+ if ( (!$this->email) || ($hash !== md5($this->email)) ) {
702
+ return $this->no_such_email;
703
+ }
704
+ } else {
705
+ return $this->no_such_email;
706
+ }
707
+
708
+ if ('1' == $action) {
709
+ // make this subscription active
710
+ $this->activate();
711
+ $this->message = $this->added;
712
+ $subject = '[' . get_settings('blogname') . '] ' . __('New subscriber', 'subscribe2');
713
+ $message = "$this->email " . __('subscribed to email notifications!', 'subscribe2');
714
+ $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='wp_user_level' AND $wpdb->usermeta.meta_value='10'");
715
+ $this->mail($recipients, $subject, $message);
716
+ $this->filtered = 1;
717
+ } elseif ('0' == $action) {
718
+ // remove this subscriber
719
+ $this->delete();
720
+ $this->message = $this->deleted;
721
+ $this->filtered = 1;
722
+ }
723
+
724
+ if ('' != $this->message) {
725
+ return $this->message;
726
+ }
727
+ } // end confirm
728
+
729
+ /**
730
+ Is the supplied email address a public subscriber?
731
+ */
732
+ function is_public($email = '') {
733
+ global $wpdb;
734
+
735
+ if ('' == $email) { return false; }
736
+
737
+ $check = $wpdb->get_var("SELECT active FROM $this->public WHERE email='$email'");
738
+ if ( ('0' == $check) || ('1' == $check) ) {
739
+ return $check;
740
+ } else {
741
+ return false;
742
+ }
743
+ } // end is_public
744
+
745
+ /**
746
+ Is the supplied email address a registered user of the blog?
747
+ */
748
+ function is_registered($email = '') {
749
+ global $wpdb;
750
+
751
+ if ('' == $email) { return false; }
752
+
753
+ $check = $wpdb->get_var("SELECT email FROM $wpdb->users WHERE user_email='$email'");
754
+ if ($check) {
755
+ return true;
756
+ } else {
757
+ return false;
758
+ }
759
+ }
760
+
761
+ /**
762
+ Return an array of all the public subscribers
763
+ */
764
+ function get_public ($confirmed = 1) {
765
+ global $wpdb;
766
+ if (1 == $confirmed) {
767
+ if ('' == $this->all_public) {
768
+ $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
769
+ }
770
+ return $this->all_public;
771
+ } else {
772
+ if ('' == $this->all_unconfirmed) {
773
+ $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
774
+ }
775
+ return $this->all_unconfirmed;
776
+ }
777
+ } // end get_public()
778
+
779
+ /**
780
+ Return an array of registered subscribers
781
+ Collect all the registered users of the blog who are subscribed to the specified categories
782
+ */
783
+ function get_registered ($args = '') {
784
+ global $wpdb;
785
+
786
+ $format = '';
787
+ $amount = '';
788
+ $cats = '';
789
+ $subscribers = array();
790
+
791
+ parse_str($args, $r);
792
+ if (!isset($r['cats']))
793
+ $r['cats'] = '';
794
+ if (!isset($r['format']))
795
+ $r['format'] = 'all';
796
+ if (!isset($r['amount']))
797
+ $r['amount'] = 'all';
798
+
799
+ $JOIN = ''; $AND = '';
800
+ // text or HTML subscribers
801
+ if ('all' != $r['format']) {
802
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
803
+ $AND .= " AND b.meta_key='s2_format' AND b.meta_value=";
804
+ if ('html' == $r['format']) {
805
+ $AND .= "'html'";
806
+ } elseif ('text' == $r['format']) {
807
+ $AND .= "'text'";
808
+ }
809
+ }
810
+
811
+ // full post or excerpt subscribers
812
+ if ('all' != $r['amount']) {
813
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
814
+ $AND .= " AND c.meta_key='s2_excerpt' AND c.meta_value=";
815
+ if ('excerpt' == $r['amount']) {
816
+ $AND .= "'excerpt'";
817
+ } elseif ('post' == $r['amount']) {
818
+ $AND.= "'post'";
819
+ }
820
+ }
821
+
822
+ // specific category subscribers
823
+ if ('' != $r['cats']) {
824
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
825
+ foreach (explode(',', $r['cats']) as $cat) {
826
+ ('' == $and) ? $and = "d.meta_key='s2_cat$cat'" : $and .= " OR d.meta_key='s2_cat$cat'";
827
+ }
828
+ $AND .= "AND ($and)";
829
+ }
830
+
831
+ $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . " WHERE a.meta_key='s2_subscribed'" . $AND;
832
+ $result = $wpdb->get_col($sql);
833
+ if ($result) {
834
+ $ids = implode(',', $result);
835
+ return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
836
+ }
837
+ } // end get_registered()
838
+
839
+ /**
840
+ Collects the signup date for all public subscribers
841
+ */
842
+ function signup_date($email = '') {
843
+ if ('' == $email) { return false; }
844
+
845
+ global $wpdb;
846
+ if (!empty($this->signup_dates)) {
847
+ return $this->signup_dates[$email];
848
+ } else {
849
+ $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
850
+ foreach ($results as $result) {
851
+ $this->signup_dates[$result[0]] = $result[1];
852
+ }
853
+ return $this->signup_dates[$email];
854
+ }
855
+ } // end signup_date()
856
+
857
+ /**
858
+ Create the appropriate usermeta values when a user registers
859
+ If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
860
+ */
861
+ function register ($user_id = 0, $wpreg = '') {
862
+ global $wpdb;
863
+
864
+ if (0 == $user_id) { return $user_id; }
865
+ $user = get_userdata($user_id);
866
+ $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
867
+
868
+ if (0 == $this->subscribe2_options['reg_override']) {
869
+ // registered users are not allowed to subscribe to
870
+ // excluded categories
871
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
872
+ foreach ($all_cats as $cat => $cat_ID) {
873
+ if (in_array($all_cats[$cat]->cat_ID, $exclude)) {
874
+ $cat = (int)$cat;
875
+ unset($all_cats[$cat]);
876
+ }
877
+ }
878
+ }
879
+
880
+ foreach ($all_cats as $cat) {
881
+ ('' == $cats) ? $cats = "$cat->cat_ID" : $cats .= ",$cat->cat_ID";
882
+ }
883
+
884
+ if ('' == $cats) {
885
+ // sanity check, might occur if all cats excluded and reg_override = 0
886
+ return $user_id;
887
+ }
888
+
889
+ // has this user previously signed up for email notification?
890
+ if (false !== $this->is_public($user->user_email)) {
891
+ // delete this user from the public table, and subscribe them to all the categories
892
+ $this->delete($user->user_email);
893
+ update_usermeta($user_id, 's2_subscribed', $cats);
894
+ foreach(explode(',', $cats) as $cat) {
895
+ update_usermeta($user_id, 's2_cat' . $cat, "$cat");
896
+ }
897
+ update_usermeta($user_id, 's2_format', 'text');
898
+ update_usermeta($user_id, 's2_excerpt', 'excerpt');
899
+ } else {
900
+ // add the usermeta for new registrations, but don't subscribe them
901
+ $check = get_usermeta($user_id, 's2_subscribed');
902
+ // ensure existing subscriptions are not overwritten on upgrade
903
+ if (empty($check)) {
904
+ if ( ('yes' == $this->subscribe2_options['autosub']) || (('wpreg' == $this->subscribe2_options['autosub']) && (1 == $wpreg)) ) {
905
+ // don't add entires by default if autosub is off, messes up daily digests
906
+ update_usermeta($user_id, 's2_subscribed', $cats);
907
+ foreach(explode(',', $cats) as $cat) {
908
+ update_usermeta($user_id, 's2_cat' . $cat, "$cat");
909
+ }
910
+ if ('html' == $this->subscribe2_options['autoformat']) {
911
+ update_usermeta($user_id, 's2_format', 'html');
912
+ update_usermeta($user_id, 's2_excerpt', 'post');
913
+ } elseif ('fulltext' == $this->subscribe2_options['autoformat']) {
914
+ update_usermeta($user_id, 's2_format', 'text');
915
+ update_usermeta($user_id, 's2_excerpt', 'post');
916
+ } else {
917
+ update_usermeta($user_id, 's2_format', 'text');
918
+ update_usermeta($user_id, 's2_excerpt', 'excerpt');
919
+ }
920
+ } else {
921
+ update_usermeta($user_id, 's2_subscribed', '-1');
922
+ }
923
+ }
924
+ }
925
+ return $user_id;
926
+ } // end register()
927
+
928
+ /**
929
+ Subscribe all registered users to category selected on Admin Manage Page
930
+ */
931
+ function subscribe_registered_users ($emails = '', $cats = '') {
932
+ if ( ('' == $emails) || ('' == $cats) ) { return false; }
933
+ global $wpdb;
934
+
935
+ $useremails = explode(",", $emails);
936
+ $useremails = implode("', '", $useremails);
937
+
938
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
939
+ $user_IDs = $wpdb->get_col($sql);
940
+ if (!is_array($cats)) {
941
+ $cats = array($cats);
942
+ }
943
+
944
+ foreach ($user_IDs as $user_ID) {
945
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
946
+ if (!is_array($old_cats)) {
947
+ $old_cats = array($old_cats);
948
+ }
949
+ $new = array_diff($cats, $old_cats);
950
+ if (!empty($new)) {
951
+ // add subscription to these cat IDs
952
+ foreach ($new as $id) {
953
+ update_usermeta($user_ID, 's2_cat' . $id, "$id");
954
+ }
955
+ }
956
+ $newcats = array_merge($cats, $old_cats);
957
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
958
+ }
959
+ } // end subscribe_registered_users
960
+
961
+ /**
962
+ Unsubscribe all registered users to category selected on Admin Manage Page
963
+ */
964
+ function unsubscribe_registered_users ($emails = '', $cats = '') {
965
+ if ( ('' == $emails) || ('' == $cats) ) { return false; }
966
+ global $wpdb;
967
+
968
+ $useremails = explode(",", $emails);
969
+ $useremails = implode("', '", $useremails);
970
+
971
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
972
+ $user_IDs = $wpdb->get_col($sql);
973
+ if (!is_array($cats)) {
974
+ $cats = array($cats);
975
+ }
976
+
977
+ foreach ($user_IDs as $user_ID) {
978
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
979
+ if (!is_array($old_cats)) {
980
+ $old_cats = array($old_cats);
981
+ }
982
+ $remain = array_diff($old_cats, $cats);
983
+ if (!empty($remain)) {
984
+ // remove subscription to these cat IDs and update s2_subscribed
985
+ foreach ($cats as $id) {
986
+ delete_usermeta($user_ID, 's2_cat' . $id, "$id");
987
+ }
988
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $remain));
989
+ } else {
990
+ // remove subscription to these cat IDs and update s2_subscribed to ''
991
+ foreach ($cats as $id) {
992
+ delete_usermeta($user_ID, 's2_cat' . $id, "$id");
993
+ }
994
+ update_usermeta($user_ID, 's2_subscribed', '-1');
995
+ }
996
+ }
997
+ } // end unsubscribe_registered_users
998
+
999
+ /**
1000
+ Autosubscribe registered users to newly created categories
1001
+ if registered user has selected this option
1002
+ */
1003
+ function autosub_new_category ($new_category='') {
1004
+ global $wpdb;
1005
+
1006
+ $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='s2_autosub' AND $wpdb->usermeta.meta_value='yes'";
1007
+ $user_IDs = $wpdb->get_col($sql);
1008
+ if ('' == $user_IDs) { return; }
1009
+
1010
+ foreach ($user_IDs as $user_ID) {
1011
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1012
+ if (!is_array($old_cats)) {
1013
+ $old_cats = array($old_cats);
1014
+ }
1015
+ // add subscription to these cat IDs
1016
+ update_usermeta($user_ID, 's2_cat' . $new_category, "$new_category");
1017
+ $newcats = array_merge($old_cats, (array)$new_category);
1018
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
1019
+ }
1020
+ } // end autosub_new_category
1021
+
1022
+ /* ===== Menus ===== */
1023
+ /**
1024
+ Our management page
1025
+ */
1026
+ function manage_menu() {
1027
+ global $wpdb, $s2nonce;
1028
+
1029
+ //Get Registered Subscribers for bulk management
1030
+ $registered = $this->get_registered();
1031
+ if (!empty($registered)) {
1032
+ $emails = implode(",", $registered);
1033
+ }
1034
+
1035
+ $what = '';
1036
+ $reminderform = false;
1037
+
1038
+ // was anything POSTed ?
1039
+ if (isset($_POST['s2_admin'])) {
1040
+ check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
1041
+ if ('subscribe' == $_POST['s2_admin']) {
1042
+ foreach (preg_split ("/[\s,]+/", $_POST['addresses']) as $email) {
1043
+ if (is_email($email)) {
1044
+ $this->activate($email);
1045
+ }
1046
+ }
1047
+ $_POST['what'] = 'confirmed';
1048
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Address(es) subscribed!', 'subscribe2') . "</p></strong></div>";
1049
+ } elseif ('delete' == $_POST['s2_admin']) {
1050
+ $this->delete($_POST['email']);
1051
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . $_POST['email'] . ' ' . __('deleted!', 'subscribe2') . "</p></strong></div>";
1052
+ } elseif ('toggle' == $_POST['s2_admin']) {
1053
+ $this->toggle($_POST['email']);
1054
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . $_POST['email'] . ' ' . __('status changed!', 'subscribe2') . "</p></strong></div>";
1055
+ } elseif ('remind' == $_POST['s2_admin']) {
1056
+ $this->remind($_POST['reminderemails']);
1057
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Reminder Email(s) Sent!','subscribe2') . "</p></strong></div>";
1058
+ } elseif ('exportcsv' == $_POST['s2_admin']) {
1059
+ $this->exportcsv($_POST['exportcsv']);
1060
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('CSV File Created in wp-content','subscribe2') . "</p></strong></div>";
1061
+ } elseif ( ('register' == $_POST['s2_admin']) && ('Subscribe' == $_POST['submit']) ) {
1062
+ $this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1063
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Subscribed!','subscribe2') . "</p></strong></div>";
1064
+ } elseif ( ('register' == $_POST['s2_admin']) && ('Unsubscribe' == $_POST['submit']) ) {
1065
+ $this->unsubscribe_registered_users($_POST['emails'], $_POST['category']);
1066
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Unsubscribed!','subscribe2') . "</p></strong></div>";
1067
+ }
1068
+ }
1069
+
1070
+ if (isset($_POST['what'])) {
1071
+ if ('all' == $_POST['what']) {
1072
+ $what = 'all';
1073
+ $confirmed = $this->get_public();
1074
+ $unconfirmed = $this->get_public(0);
1075
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$registered);
1076
+ } elseif ('public' == $_POST['what']) {
1077
+ $what = 'public';
1078
+ $confirmed = $this->get_public();
1079
+ $unconfirmed = $this->get_public(0);
1080
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1081
+ } elseif ('confirmed' == $_POST['what']) {
1082
+ $what = 'confirmed';
1083
+ $confirmed = $this->get_public();
1084
+ $subscribers = $confirmed;
1085
+ } elseif ('unconfirmed' == $_POST['what']) {
1086
+ $what = 'unconfirmed';
1087
+ $unconfirmed = $this->get_public(0);
1088
+ $subscribers = $unconfirmed;
1089
+ if (!empty($unconfirmed)) {
1090
+ $reminderemails = implode(",", $unconfirmed);
1091
+ $reminderform = true;
1092
+ }
1093
+ } elseif (is_numeric($_POST['what'])) {
1094
+ $what = intval($_POST['what']);
1095
+ $subscribers = $this->get_registered("cats=$what");
1096
+ } elseif ('registered' == $_POST['what']) {
1097
+ $what = 'registered';
1098
+ $subscribers = $registered;
1099
+ }
1100
+ } elseif ('' == $what) {
1101
+ $what = 'registered';
1102
+ $subscribers = $registered;
1103
+ $registermessage = '';
1104
+ if (empty($subscribers)) {
1105
+ $confirmed = $this->get_public();
1106
+ $subscribers = $confirmed;
1107
+ $what = 'confirmed';
1108
+ if (empty($subscribers)) {
1109
+ $unconfirmed = $this->get_public(0);
1110
+ $subscribers = $unconfirmed;
1111
+ $what = 'unconfirmed';
1112
+ if (empty($subscribers)) {
1113
+ $what = 'all';
1114
+ }
1115
+ }
1116
+ }
1117
+ }
1118
+ if (!empty($subscribers)) {
1119
+ natcasesort($subscribers);
1120
+ }
1121
+ // safety check for our arrays
1122
+ if ('' == $confirmed) { $confirmed = array(); }
1123
+ if ('' == $unconfirmed) { $unconfirmed = array(); }
1124
+ if ('' == $registered) { $registered = array(); }
1125
+
1126
+ // show our form
1127
+ echo "<div class=\"wrap\">";
1128
+ echo "<h2>" . __('Subscribe Addresses', 'subscribe2') . "</h2>\r\n";
1129
+ echo "<form method=\"post\" action=\"\">\r\n";
1130
+ if (function_exists('wp_nonce_field')) {
1131
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1132
+ }
1133
+ echo "<span style=\"align:left\">" . __('Enter addresses, one per line or comma-seperated', 'subscribe2') . "</span><br />\r\n";
1134
+ echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea>";
1135
+ echo "<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Subscribe', 'subscribe2') . "\"/>";
1136
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"subscribe\" /></span>";
1137
+ echo "</form></div>";
1138
+
1139
+ // subscriber lists
1140
+ echo "<div class=\"wrap\"><h2>" . __('Subscribers', 'subscribe2') . "</h2>\r\n";
1141
+
1142
+ $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1143
+ // show the selected subscribers
1144
+ $alternate = 'alternate';
1145
+ if (!empty($subscribers)) {
1146
+ echo "<p align=\"center\"><b>" . __('Registered on the left, confirmed in the middle, unconfirmed on the right', 'subscribe2') . "</b></p>";
1147
+ if (is_writable(ABSPATH . '/wp-content')) {
1148
+ $exportcsv = implode(",", $subscribers);
1149
+ echo "<span class=\"submit\"><form method=\"post\" action=\"\">\r\n";
1150
+ if (function_exists('wp_nonce_field')) {
1151
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1152
+ }
1153
+ echo "<input type=\"hidden\" name=\"exportcsv\" value=\"$exportcsv\" />\r\n";
1154
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"exportcsv\" />\r\n";
1155
+ echo "<input type=\"submit\" name=\"submit\" value=\"" . __('Save Emails to CSV File','subscribe2') . "\" />\r\n";
1156
+ echo "</form></span>\r\n";
1157
+ }
1158
+ }
1159
+ echo "<table cellpadding=\"2\" cellspacing=\"2\">";
1160
+ if (!empty($subscribers)) {
1161
+ foreach ($subscribers as $subscriber) {
1162
+ echo "<tr class=\"$alternate\">";
1163
+ echo "<td width=\"75%\"";
1164
+ if (in_array($subscriber, $unconfirmed)) {
1165
+ echo " align=\"right\">";
1166
+ } elseif (in_array($subscriber, $confirmed)) {
1167
+ echo "align=\"center\">";
1168
+ } else {
1169
+ echo "align=\"left\" colspan=\"3\">";
1170
+ }
1171
+ echo "<a href=\"mailto:$subscriber\">$subscriber</a>\r\n";
1172
+ if (in_array($subscriber, $unconfirmed) || in_array($subscriber, $confirmed) ) {
1173
+ echo "(" . $this->signup_date($subscriber) . ")</td>\r\n";
1174
+ echo "<td width=\"5%\" align=\"center\">\r\n";
1175
+ echo "<form method=\"post\" action=\"\">";
1176
+ if (function_exists('wp_nonce_field')) {
1177
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1178
+ }
1179
+ echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1180
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"toggle\" />\r\n";
1181
+ echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1182
+ echo "<input type=\"submit\" name=\"submit\" value=\"";
1183
+ (in_array($subscriber, $unconfirmed)) ? $foo = '&lt;-' : $foo= '-&gt;';
1184
+ echo "$foo\" /></form></td>\r\n";
1185
+ echo "<td width=\"2%\" align=\"center\">\r\n";
1186
+ echo "<form method=\"post\" action=\"\">\r\n";
1187
+ if (function_exists('wp_nonce_field')) {
1188
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1189
+ }
1190
+ echo "<span class=\"delete\">\r\n";
1191
+ echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1192
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"delete\" />\r\n";
1193
+ echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1194
+ echo "<input type=\"submit\" name=\"submit\" value=\"X\" />\r\n";
1195
+ echo "</span></form>";
1196
+ }
1197
+ echo "</td></tr>\r\n";
1198
+ ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1199
+ }
1200
+ } else {
1201
+ echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1202
+ }
1203
+ echo "</table>";
1204
+ if ($reminderform) {
1205
+ echo "<span class=\"submit\"><form method=\"post\" action=\"\">\r\n";
1206
+ if (function_exists('wp_nonce_field')) {
1207
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1208
+ }
1209
+ echo "<input type=\"hidden\" name=\"reminderemails\" value=\"$reminderemails\" />\r\n";
1210
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"remind\" />\r\n";
1211
+ echo "<input type=\"submit\" name=\"submit\" value=\"" . __('Send Reminder Email','subscribe2') . "\" />\r\n";
1212
+ echo "</form></span>";
1213
+ }
1214
+ echo "</div>\r\n";
1215
+
1216
+ //show bulk managment form
1217
+ echo "<div class=\"wrap\">";
1218
+ echo "<h2 >" . __('Categories', 'subscribe2') . "</h2>\r\n";
1219
+ echo __('Existing Registered Users can be automatically (un)subscribed to categories using this section.', 'subscribe2') . "<br />\r\n";
1220
+ echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1221
+ echo "<span class=\"submit\"><form method=\"post\" action=\"\">\r\n";
1222
+ if (function_exists('wp_nonce_field')) {
1223
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1224
+ }
1225
+ echo "<input type=\"hidden\" name=\"emails\" value=\"$emails\" /><input type=\"hidden\" name=\"s2_admin\" value=\"register\" />";
1226
+ $this->display_category_form();
1227
+ echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Subscribe','subscribe2') . "\" />";
1228
+ echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Unsubscribe','subscribe2') . "\" /></form></span>";
1229
+
1230
+ echo "</div>\r\n";
1231
+ echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1232
+
1233
+ include(ABSPATH . '/wp-admin/admin-footer.php');
1234
+ // just to be sure
1235
+ die;
1236
+ } // end manage_menu()
1237
+
1238
+ /**
1239
+ Our options page
1240
+ */
1241
+ function options_menu() {
1242
+ global $s2nonce;
1243
+
1244
+ // was anything POSTed?
1245
+ if (isset($_POST['s2_admin'])) {
1246
+ check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
1247
+ if ('RESET' == $_POST['s2_admin']) {
1248
+ $this->reset();
1249
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_reset</p></strong></div>";
1250
+ } elseif ('options' == $_POST['s2_admin']) {
1251
+ // excluded categories
1252
+ if (!empty($_POST['category'])) {
1253
+ $exclude_cats = implode(',', $_POST['category']);
1254
+ } else {
1255
+ $exclude_cats = '';
1256
+ }
1257
+ $this->subscribe2_options['exclude'] = $exclude_cats;
1258
+ // allow override?
1259
+ (isset($_POST['reg_override'])) ? $override = '1' : $override = '0';
1260
+ $this->subscribe2_options['reg_override'] = $override;
1261
+
1262
+ // show button?
1263
+ ($_POST['show_button'] == '1') ? $showbutton = '1' : $showbutton = '0';
1264
+ $this->subscribe2_options['show_button'] = $showbutton;
1265
+
1266
+ // send as author or admin?
1267
+ $sender = 'author';
1268
+ if ('admin' == $_POST['sender']) {
1269
+ $sender = 'admin';
1270
+ }
1271
+ $this->subscribe2_options['sender'] = $sender;
1272
+
1273
+ // send email for pages and password protected posts
1274
+ $pages_option = $_POST['pages'];
1275
+ $this->subscribe2_options['pages']= $pages_option;
1276
+ $password_option = $_POST['password'];
1277
+ $this->subscribe2_options['password']= $password_option;
1278
+
1279
+ // send per-post or digest emails
1280
+ $email_freq = $_POST['email_freq'];
1281
+ $this->subscribe2_options['email_freq'] = $email_freq;
1282
+ wp_clear_scheduled_hook('s2_digest_cron');
1283
+ $scheds = (array) wp_get_schedules();
1284
+ $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
1285
+ if ($interval == 0) {
1286
+ // if we are on per-post emails remove last_cron entry
1287
+ unset($this->subscribe2_options['last_s2cron']);
1288
+ } else {
1289
+ if (!wp_next_scheduled('s2_digest_cron')) {
1290
+ // if we are using digest schedule the event and prime last_cron as now
1291
+ wp_schedule_event(time() + $interval, $email_freq, 's2_digest_cron');
1292
+ $now = date('Y-m-d H:i:s', time());
1293
+ $this->subscribe2_options['last_s2cron'] = $now;
1294
+ }
1295
+ }
1296
+
1297
+ // email templates
1298
+ $mailtext = $_POST['mailtext'];
1299
+ $this->subscribe2_options['mailtext'] = $mailtext;
1300
+ $confirm_email = $_POST['confirm_email'];
1301
+ $this->subscribe2_options['confirm_email'] = $confirm_email;
1302
+ $remind_email = $_POST['remind_email'];
1303
+ $this->subscribe2_options['remind_email'] = $remind_email;
1304
+
1305
+ //automatic subscription
1306
+ $autosub_option = $_POST['autosub'];
1307
+ $this->subscribe2_options['autosub'] = $autosub_option;
1308
+ $autosub_wpregdef_option = $_POST['wpregdef'];
1309
+ $this->subscribe2_options['wpregdef'] = $autosub_wpregdef_option;
1310
+ $autosub_format_option = $_POST['autoformat'];
1311
+ $this->subscribe2_options['autoformat'] = $autosub_format_option;
1312
+
1313
+ //barred domains
1314
+ $barred_option = $_POST['barred'];
1315
+ $this->subscribe2_options['barred'] = $barred_option;
1316
+ echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_saved</p></strong></div>";
1317
+ update_option('subscribe2_options', $this->subscribe2_options);
1318
+ }
1319
+ }
1320
+ // show our form
1321
+ echo "<div class=\"wrap\">";
1322
+ echo "<form method=\"post\" action=\"\">\r\n";
1323
+ if (function_exists('wp_nonce_field')) {
1324
+ wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1325
+ }
1326
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
1327
+ echo "<h2>" . __('Delivery Options', 'subscribe2') . ":</h2>\r\n";
1328
+ echo __('Send Emails for Pages', 'subscribe2') . ': ';
1329
+ echo "<input type=\"radio\" name=\"pages\" value=\"yes\"";
1330
+ if ('yes' == $this->subscribe2_options['pages']) {
1331
+ echo " checked=\"checked\"";
1332
+ }
1333
+ echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1334
+ echo "<input type=\"radio\" name=\"pages\" value=\"no\"";
1335
+ if ('no' == $this->subscribe2_options['pages']) {
1336
+ echo " checked=\"checked\"";
1337
+ }
1338
+ echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1339
+ echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
1340
+ echo "<input type=\"radio\" name=\"password\" value=\"yes\"";
1341
+ if ('yes' == $this->subscribe2_options['password']) {
1342
+ echo " checked=\"checked\"";
1343
+ }
1344
+ echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1345
+ echo "<input type=\"radio\" name=\"password\" value=\"no\"";
1346
+ if ('no' == $this->subscribe2_options['password']) {
1347
+ echo " checked=\"checked\"";
1348
+ }
1349
+ echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1350
+ echo __('Send Email From', 'subscribe2') . ': ';
1351
+ echo "<input type=\"radio\" name=\"sender\" value=\"author\"";
1352
+ if ('author' == $this->subscribe2_options['sender']) {
1353
+ echo "checked=\"checked\" ";
1354
+ }
1355
+ echo " /> " . __('Author of the post', 'subscribe2') . " &nbsp;&nbsp;";
1356
+ echo "<input type=\"radio\" name=\"sender\" value=\"admin\"";
1357
+ if ('admin' == $this->subscribe2_options['sender']) {
1358
+ echo "checked=\"checked\" ";
1359
+ }
1360
+ echo " /> " . __('Blog Admin', 'subscribe2') . "<br /><br />\r\n";
1361
+ if (function_exists('wp_schedule_event')) {
1362
+ echo __('Send Email as Digest', 'subscribe2') . ": <br /><br />\r\n";
1363
+ $this->display_digest_choices();
1364
+ echo "<br />\r\n";
1365
+ }
1366
+ echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
1367
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
1368
+ echo "<tr><td>";
1369
+ echo __('New Post email (must not be empty)', 'subscribe2') . ":";
1370
+ echo "<br />\r\n";
1371
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
1372
+ echo "</td><td valign=\"top\" rowspan=\"3\">";
1373
+ echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
1374
+ echo "<dl>";
1375
+ echo "<dt><b>BLOGNAME</b></dt><dd>" . get_bloginfo('name') . "</dd>\r\n";
1376
+ echo "<dt><b>BLOGLINK</b></dt><dd>" . get_bloginfo('url') . "</dd>\r\n";
1377
+ echo "<dt><b>TITLE</b></dt><dd>" . __("the post's title", 'subscribe2') . "</dd>\r\n";
1378
+ 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";
1379
+ echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink", 'subscribe2') . "</dd>\r\n";
1380
+ echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
1381
+ echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
1382
+ echo "<dt><b>AUTHORNAME</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
1383
+ 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";
1384
+ 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";
1385
+ echo "</dl></td></tr><tr><td>";
1386
+ echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
1387
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
1388
+ echo "</td></tr><tr valign=\"top\"><td>";
1389
+ echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
1390
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
1391
+ echo "</td></tr></table><br />\r\n";
1392
+
1393
+ // excluded categories
1394
+ echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
1395
+ $this->display_category_form(explode(',', $this->subscribe2_options['exclude']));
1396
+ echo "<center><input type=\"checkbox\" name=\"reg_override\" value=\"1\"";
1397
+ if ('1' == $this->subscribe2_options['reg_override']) {
1398
+ echo " checked=\"checked\"";
1399
+ }
1400
+ echo " /> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</center><br />\r\n";
1401
+ echo "<h2>" . __('Writing Options', 'subscribe2') . "</h2>\r\n";
1402
+ echo "<input type=\"checkbox\" name=\"show_button\" value=\"1\"";
1403
+ if ('1' == $this->subscribe2_options['show_button']) {
1404
+ echo " checked=\"checked\"";
1405
+ }
1406
+ echo " /> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "<br /><br />\r\n";
1407
+
1408
+ //Auto Subscription for new registrations
1409
+ echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
1410
+ echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
1411
+ echo "<input type=\"radio\" name=\"autosub\" value=\"yes\"";
1412
+ if ('yes' == $this->subscribe2_options['autosub']) {
1413
+ echo " checked=\"checked\"";
1414
+ }
1415
+ echo " /> " . __('Automatically', 'subscribe2') . " &nbsp;&nbsp;";
1416
+ echo "<input type=\"radio\" name=\"autosub\" value=\"wpreg\"";
1417
+ if ('wpreg' == $this->subscribe2_options['autosub']) {
1418
+ echo " checked=\"checked\"";
1419
+ }
1420
+ echo " /> " . __('Display option on Registration Form', 'subscribe2') . " &nbsp;&nbsp;";
1421
+ echo "<input type=\"radio\" name=\"autosub\" value=\"no\"";
1422
+ if ('no' == $this->subscribe2_options['autosub']) {
1423
+ echo " checked=\"checked\"";
1424
+ }
1425
+ echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1426
+ echo __('Registration Form option is checked by default', 'subscribe2') . ": &nbsp;&nbsp;";
1427
+ echo "<input type=\"radio\" name=\"wpregdef\" value=\"yes\"";
1428
+ if ('yes' == $this->subscribe2_options['wpregdef']) {
1429
+ echo " checked=\"checked\"";
1430
+ }
1431
+ echo " />" . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1432
+ echo "<input type=\"radio\" name=\"wpregdef\" value=\"no\"";
1433
+ if ('no' == $this->subscribe2_options['wpregdef']) {
1434
+ echo " checked=\"checked\"";
1435
+ }
1436
+ echo " />" . __('No', 'subscribe2') . "<br /><br />\r\n";
1437
+ echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
1438
+ echo "<input type=\"radio\" name=\"autoformat\" value=\"html\"";
1439
+ if ('html' == $this->subscribe2_options['autoformat']) {
1440
+ echo "checked=\"checked\" ";
1441
+ }
1442
+ echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1443
+ echo "<input type=\"radio\" name=\"autoformat\" value=\"fulltext\" ";
1444
+ if ('fulltext' == $this->subscribe2_options['autoformat']) {
1445
+ echo "checked=\"checked\" ";
1446
+ }
1447
+ echo "/> " . __('Plain Text - Full', 'subscribe2') . " &nbsp;&nbsp;";
1448
+ echo "<input type=\"radio\" name=\"autoformat\" value=\"text\" ";
1449
+ if ('text' == $this->subscribe2_options['autoformat']) {
1450
+ echo "checked=\"checked\" ";
1451
+ }
1452
+ echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . " <br /><br />";
1453
+
1454
+ //barred domains
1455
+ echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
1456
+ 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');
1457
+ echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
1458
+
1459
+ // submit
1460
+ echo "<p align=\"center\"><span class=\"submit\"><input type=\"submit\" id=\"save\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></span></p>";
1461
+ echo "</form>\r\n";
1462
+ echo "</div><div class=\"wrap\">";
1463
+
1464
+ // reset
1465
+ echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
1466
+ 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";
1467
+ echo "<form method=\"post\" action=\"\">";
1468
+ if (function_exists('wp_nonce_field')) {
1469
+ wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1470
+ }
1471
+ echo "<p align=\"center\"><span class=\"submit\">";
1472
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"RESET\" />";
1473
+ echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('RESET', 'subscribe2') .
1474
+ "\" />";
1475
+ echo "</span></p></form></div>\r\n";
1476
+
1477
+ include(ABSPATH . '/wp-admin/admin-footer.php');
1478
+ // just to be sure
1479
+ die;
1480
+ } // end options_menu()
1481
+
1482
+ /**
1483
+ Our profile menu
1484
+ */
1485
+ function user_menu() {
1486
+ global $user_ID, $s2nonce;
1487
+
1488
+ get_currentuserinfo();
1489
+
1490
+ // was anything POSTed?
1491
+ if ( (isset($_POST['s2_admin'])) && ('user' == $_POST['s2_admin']) ) {
1492
+ check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
1493
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
1494
+ $format = 'text';
1495
+ $post = 'post';
1496
+ if ('html' == $_POST['s2_format']) {
1497
+ $format = 'html';
1498
+ }
1499
+ if ('excerpt' == $_POST['s2_excerpt']) {
1500
+ $post = 'excerpt';
1501
+ }
1502
+ update_usermeta($user_ID, 's2_excerpt', $post);
1503
+ update_usermeta($user_ID, 's2_format', $format);
1504
+ update_usermeta($user_ID, 's2_autosub', $_POST['new_category']);
1505
+
1506
+ $cats = $_POST['category'];
1507
+ if (empty($cats)) {
1508
+ $cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1509
+ if ($cats) {
1510
+ foreach ($cats as $cat) {
1511
+ delete_usermeta($user_ID, "s2_cat" . $cat);
1512
+ }
1513
+ }
1514
+ update_usermeta($user_ID, 's2_subscribed', '-1');
1515
+ } else {
1516
+ if (!is_array($cats)) {
1517
+ $cats = array($_POST['category']);
1518
+ }
1519
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1520
+ $remove = array_diff($old_cats, $cats);
1521
+ $new = array_diff($cats, $old_cats);
1522
+ if (!empty($remove)) {
1523
+ // remove subscription to these cat IDs
1524
+ foreach ($remove as $id) {
1525
+ delete_usermeta($user_ID, "s2_cat" .$id);
1526
+ }
1527
+ }
1528
+ if (!empty($new)) {
1529
+ // add subscription to these cat IDs
1530
+ foreach ($new as $id) {
1531
+ update_usermeta($user_ID, 's2_cat' . $id, "$id");
1532
+ }
1533
+ }
1534
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $cats));
1535
+ }
1536
+ }
1537
+
1538
+ // show our form
1539
+ echo "<div class=\"wrap\">";
1540
+ echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
1541
+ echo "<form method=\"post\" action=\"\">";
1542
+ if (function_exists('wp_nonce_field')) {
1543
+ wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
1544
+ }
1545
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
1546
+ if ($this->subscribe2_options['email_freq'] == 'never') {
1547
+ echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
1548
+ echo "<input type=\"radio\" name=\"s2_format\" value=\"html\"";
1549
+ if ('html' == get_usermeta($user_ID, 's2_format')) {
1550
+ echo "checked=\"checked\" ";
1551
+ }
1552
+ echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1553
+ echo "<input type=\"radio\" name=\"s2_format\" value=\"text\" ";
1554
+ if ('text' == get_usermeta($user_ID, 's2_format')) {
1555
+ echo "checked=\"checked\" ";
1556
+ }
1557
+ echo "/> " . __('Plain Text', 'subscribe2') . "<br /><br />\r\n";
1558
+
1559
+ echo __('Email contains', 'subscribe2') . ": &nbsp;&nbsp;";
1560
+ $amount = array ('excerpt' => __('Excerpt Only', 'subscribe2'), 'post' => __('Full Post', 'subscribe2'));
1561
+ foreach ($amount as $key => $value) {
1562
+ echo "<input type=\"radio\" name=\"s2_excerpt\" value=\"" . $key . "\"";
1563
+ if ($key == get_usermeta($user_ID, 's2_excerpt')) {
1564
+ echo " checked=\"checked\"";
1565
+ }
1566
+ echo " /> " . $value . "&nbsp;&nbsp;";
1567
+ }
1568
+ echo "<p style=\"color: red\">" . __('Note: HTML format will always deliver the full post.', 'subscribe2') . "</p>\r\n";
1569
+ echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
1570
+ echo "<input type=\"radio\" name=\"new_category\" value=\"yes\" ";
1571
+ if ('yes' == get_usermeta($user_ID, 's2_autosub')) {
1572
+ echo "checked=\"yes\" ";
1573
+ }
1574
+ echo "/> Yes &nbsp;&nbsp;";
1575
+ echo "<input type=\"radio\" name=\"new_category\" value=\"no\" ";
1576
+ if ('no' == get_usermeta($user_ID, 's2_autosub')) {
1577
+ echo "checked=\"yes\" ";
1578
+ }
1579
+ echo "/> No<br /><br />";
1580
+
1581
+ // subscribed categories
1582
+ echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
1583
+ $this->display_category_form(explode(',', get_usermeta($user_ID, 's2_subscribed')), $this->subscribe2_options['reg_override']);
1584
+ } else {
1585
+ // we're doing daily digests, so just show
1586
+ // subscribe / unnsubscribe
1587
+ echo __('Receive daily summary of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
1588
+ echo "<input type=\"radio\" name=\"category\" value=\"1\" ";
1589
+ if (get_usermeta($user_ID, 's2_subscribed')) {
1590
+ echo "checked=\"yes\" ";
1591
+ }
1592
+ echo "/> Yes <input type=\"radio\" name=\"category\" value=\"\" ";
1593
+ if (! get_usermeta($user_ID, 's2_subscribed')) {
1594
+ echo "checked=\"yes\" ";
1595
+ }
1596
+ echo "/> No";
1597
+ }
1598
+
1599
+ // submit
1600
+ echo "<p align=\"right\"><span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __("Update Preferences &raquo;", 'subscribe2') . "\" /></span></p>";
1601
+ echo "</form></div>\r\n";
1602
+
1603
+ include(ABSPATH . '/wp-admin/admin-footer.php');
1604
+ // just to be sure
1605
+ die;
1606
+ } // end user_menu()
1607
+
1608
+ /**
1609
+ Display the Write sub-menu
1610
+ */
1611
+ function write_menu() {
1612
+ global $wpdb, $s2nonce;
1613
+
1614
+ // was anything POSTed?
1615
+ if (isset($_POST['s2_admin']) && ('mail' == $_POST['s2_admin']) ) {
1616
+ check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
1617
+ if ('confirmed' == $_POST['what']) {
1618
+ $recipients = $this->get_public();
1619
+ } elseif ('unconfirmed' == $_POST['what']) {
1620
+ $recipients = $this->get_public(0);
1621
+ } elseif ('public' == $_POST['what']) {
1622
+ $confirmed = $this->get_public();
1623
+ $unconfirmed = $this->get_public(0);
1624
+ $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
1625
+ } elseif (is_numeric($_POST['what'])) {
1626
+ $cat = intval($_POST['what']);
1627
+ $recipients = $this->get_registered("cats=$cat");
1628
+ } else {
1629
+ $recipients = $this->get_registered();
1630
+ }
1631
+ global $user_identity, $user_email;
1632
+ get_currentuserinfo();
1633
+ $this->myname = $user_identity;
1634
+ $this->myemail = $user_email;
1635
+ $subject = strip_tags($_POST['subject']);
1636
+ $message = stripslashes($_POST['message']);
1637
+ $this->mail($recipients, $subject, $message, 'text');
1638
+ $message = $this->mail_sent;
1639
+ }
1640
+
1641
+ if ('' != $message) {
1642
+ echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
1643
+ }
1644
+ // show our form
1645
+ echo "<div class=\"wrap\"><h2>" . __('Send email to all subscribers', 'subscribe2') . "</h2>\r\n";
1646
+ echo "<form method=\"post\" action=\"\">\r\n";
1647
+ if (function_exists('wp_nonce_field')) {
1648
+ wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
1649
+ }
1650
+ echo __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . __('A message from ', 'subscribe2') . get_settings('blogname') . "\" /> <br />";
1651
+ echo "<textarea rows=\"12\" cols=\"75\" name=\"message\"></textarea>";
1652
+ echo "<br />\r\n";
1653
+ echo __('Recipients: ', 'subscribe2');
1654
+ $this->display_subscriber_dropdown('registered', false, array('all'));
1655
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
1656
+ echo "&nbsp;&nbsp;<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></span>&nbsp;";
1657
+ echo "</form></div>\r\n";
1658
+ echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1659
+
1660
+ include(ABSPATH . '/wp-admin/admin-footer.php');
1661
+ // just to be sure
1662
+ die;
1663
+ } // end write_menu()
1664
+
1665
+ /* ===== helper functions: forms and stuff ===== */
1666
+ /**
1667
+ Display a table of categories with checkboxes
1668
+ Optionally pre-select those categories specified
1669
+ */
1670
+ function display_category_form($selected = array(), $override = 1) {
1671
+ global $wpdb;
1672
+
1673
+ $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
1674
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
1675
+
1676
+ if (0 == $override) {
1677
+ // registered users are not allowed to subscribe to
1678
+ // excluded categories
1679
+ foreach ($all_cats as $cat => $cat_ID) {
1680
+ if (in_array($all_cats[$cat]->cat_ID, $exclude)) {
1681
+ $cat = (int)$cat;
1682
+ unset($all_cats[$cat]);
1683
+ }
1684
+ }
1685
+ }
1686
+
1687
+ $half = (count($all_cats) / 2);
1688
+ $i = 0;
1689
+ $j = 0;
1690
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
1691
+ echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
1692
+ foreach ($all_cats as $cat) {
1693
+ if ( ($i >= $half) && (0 == $j) ){
1694
+ echo "</td><td width=\"50%\" align=\"left\">\r\n";
1695
+ $j++;
1696
+ }
1697
+ if (0 == $j) {
1698
+ echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->cat_ID . "\"";
1699
+ if (in_array($cat->cat_ID, $selected)) {
1700
+ echo " checked=\"checked\" ";
1701
+ }
1702
+ echo " /> " . $cat->cat_name . "<br />\r\n";
1703
+ } else {
1704
+
1705
+ echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->cat_ID . "\"";
1706
+ if (in_array($cat->cat_ID, $selected)) {
1707
+ echo " checked=\"checked\" ";
1708
+ }
1709
+ echo " /> " . $cat->cat_name . "<br />\r\n";
1710
+ }
1711
+ $i++;
1712
+ }
1713
+ echo "</td></tr>\r\n";
1714
+ echo "<tr><td align=\"left\">\r\n";
1715
+ echo "<input type=\"checkbox\" name=\"checkall\" onclick=\"setAll(this)\" /> " . __('Select / Unselect All' ,'subscribe2') . "\r\n";
1716
+ echo "</td></tr>\r\n";
1717
+ echo "</table>\r\n";
1718
+ } // end display_category_form()
1719
+
1720
+ /**
1721
+ Display a drop-down form to select subscribers
1722
+ $selected is the option to select
1723
+ $submit is the text to use on the Submit button
1724
+ */
1725
+ function display_subscriber_dropdown ($selected = 'registered', $submit = '', $exclude = array()) {
1726
+ global $wpdb;
1727
+
1728
+ $who = array('all' => __('All Subscribers', 'subscribe2'),
1729
+ 'public' => __('Public Subscribers', 'subscribe2'),
1730
+ 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
1731
+ 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
1732
+ 'registered' => __('Registered Subscribers', 'subscribe2'));
1733
+
1734
+ $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
1735
+
1736
+ // count the number of subscribers
1737
+ $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
1738
+ $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
1739
+ if (in_array('unconfirmed', $exclude)) {
1740
+ $count['public'] = $count['confirmed'];
1741
+ } elseif (in_array('confirmed', $exclude)) {
1742
+ $count['public'] = $count['unconfirmed'];
1743
+ } else {
1744
+ $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
1745
+ }
1746
+ $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='s2_subscribed'");
1747
+ $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['registered']);
1748
+ foreach ($all_cats as $cat) {
1749
+ $count[$cat->cat_name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='s2_cat$cat->cat_ID'");
1750
+ }
1751
+
1752
+ // do have actually have some subscribers?
1753
+ if ( (0 == $count['confirmed']) && (0 == $count['unconfirmed']) && (0 == $count['registered']) ) {
1754
+ // no? bail out
1755
+ return;
1756
+ }
1757
+
1758
+ if (false !== $submit) {
1759
+ echo "<form method=\"post\" action=\"\">";
1760
+ }
1761
+ echo "<select name=\"what\">\r\n";
1762
+ foreach ($who as $whom => $display) {
1763
+ if (in_array($whom, $exclude)) { continue; }
1764
+ if (0 == $count[$whom]) { continue; }
1765
+
1766
+ echo "<option value=\"" . $whom . "\"";
1767
+ if ($whom == $selected) { echo " selected=\"selected\" "; }
1768
+ echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
1769
+ }
1770
+
1771
+ if ($count['registered'] > 0) {
1772
+ foreach ($all_cats as $cat) {
1773
+ if (in_array($cat->cat_ID, $exclude)) { continue; }
1774
+ echo "<option value=\"" . $cat->cat_ID . "\"";
1775
+ if ($cat->cat_ID == $selected) { echo " selected=\"selected\" "; }
1776
+ echo "> &nbsp;&nbsp;" . $cat->cat_name . "&nbsp;(" . $count[$cat->cat_name] . ") </option>\r\n";
1777
+ }
1778
+ }
1779
+ echo "</select>";
1780
+ if (false !== $submit) {
1781
+ echo "<span class=\"submit\"><input type=\"submit\" value=\"$submit\" /></span></form>\r\n";
1782
+ }
1783
+ } // end display_subscriber_dropdown()
1784
+
1785
+ function display_digest_choices() {
1786
+ global $wpdb;
1787
+ $schedule = (array)wp_get_schedules();
1788
+ $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('Per Post Email','subscribe2'))), $schedule);
1789
+ $sort = array();
1790
+ foreach ( (array)$schedule as $key => $value ) $sort[$key] = $value['interval'];
1791
+ asort($sort);
1792
+ $schedule_sorted = array();
1793
+ foreach ($sort as $key => $value) {
1794
+ $schedule_sorted[$key] = $schedule[$key];
1795
+ }
1796
+ foreach ($schedule_sorted as $key => $value) {
1797
+ echo "<input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"";
1798
+ if ($key == $this->subscribe2_options['email_freq']) {
1799
+ echo " checked=\"checked\" ";
1800
+ }
1801
+ echo " /> " . $value['display'] . "<br />\r\n";
1802
+ }
1803
+ if (wp_next_scheduled('s2_digest_cron')) {
1804
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
1805
+ $now = time();
1806
+ echo "<p>" . __('Current server time is', 'subscribe2') . ": \r\n";
1807
+ echo "<strong>" . gmdate($datetime, $now+ (get_option('gmt_offset') * 3600)) . "</strong></p>\r\n";
1808
+ echo "<p>" . __('Next email notification will be sent', 'subscribe2') . ": \r\n";
1809
+ echo "<strong>" . gmdate($datetime, wp_next_scheduled('s2_digest_cron') + (get_option('gmt_offset') * 3600)) . "</strong></p>\r\n";
1810
+ }
1811
+ } // end display_digest_choices()
1812
+
1813
+ /**
1814
+ Adds information to the WordPress registration screen for new users
1815
+ */
1816
+ function register_form() {
1817
+ if ('wpreg' == $this->subscribe2_options['autosub']) {
1818
+ echo "<p>\r\n<label>";
1819
+ echo __('Check here to Subscribe to email notifications for new posts') . ":<br />\r\n";
1820
+ echo "<input type=\"checkbox\" name=\"subscribe\"";
1821
+ if ('yes' == $this->subscribe2_options['wpregdef']) {
1822
+ echo " checked=\"checked\"";
1823
+ }
1824
+ echo " /></label>\r\n";
1825
+ echo "</p>\r\n";
1826
+ } elseif ('yes' == $this->subscribe2_options['autosub']) {
1827
+ echo "<p>\r\n<center>\r\n";
1828
+ echo __('By Registering with this blog you are also agreeing to recieve email notifications for new posts') . "<br />\r\n";
1829
+ echo "</center></p>\r\n";
1830
+ }
1831
+ }
1832
+
1833
+ /**
1834
+ Process function to add action if user selects to subscribe to posts during registration
1835
+ */
1836
+ function register_post() {
1837
+ if ('on' == $_POST['subscribe']) {
1838
+ add_action('user_register', array(&$this, 'register_action'));
1839
+ }
1840
+ }
1841
+
1842
+ /**
1843
+ Action to process Subscribe2 registration from WordPress registration
1844
+ */
1845
+ function register_action($user_id = 0) {
1846
+ if (0 == $user_id) { return $user_id; }
1847
+ $this->register($user_id, 1);
1848
+ }
1849
+
1850
+ /* ===== template and filter functions ===== */
1851
+ /**
1852
+ Display our form; also handles (un)subscribe requests
1853
+ */
1854
+ function filter($content = '') {
1855
+ if ( ('' == $content) || (! preg_match('|<!--subscribe2-->|', $content)) ) { return $content; }
1856
+ $this->s2form = $this->form;
1857
+
1858
+ global $user_ID;
1859
+ get_currentuserinfo();
1860
+ if ($user_ID) {
1861
+ if (current_user_can('manage_options')) {
1862
+ $this->s2form = $this->use_profile_admin;
1863
+ } else {
1864
+ $this->s2form = $this->use_profile_users;
1865
+ }
1866
+ }
1867
+ if (isset($_POST['s2_action'])) {
1868
+ global $wpdb, $user_email;
1869
+ if (!is_email($_POST['email'])) {
1870
+ $this->s2form = $this->form . $this->not_an_email;
1871
+ } elseif ($this->is_barred($_POST['email'])) {
1872
+ $this->s2form = $this->form . $this->barred_domain;
1873
+ } else {
1874
+ $this->email = $_POST['email'];
1875
+ // does the supplied email belong to a registered user?
1876
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
1877
+ if ('' != $check) {
1878
+ // this is a registered email
1879
+ $this->s2form = $this->please_log_in;
1880
+ } else {
1881
+ // this is not a registered email
1882
+ // what should we do?
1883
+ if ('subscribe' == $_POST['s2_action']) {
1884
+ // someone is trying to subscribe
1885
+ // lets see if they've tried to subscribe previously
1886
+ if ('1' !== $this->is_public($this->email)) {
1887
+ // the user is unknown or inactive
1888
+ $this->add();
1889
+ $this->send_confirm('add');
1890
+ // set a variable to denote that we've already run, and shouldn't run again
1891
+ $this->filtered = 1; //set this to not send duplicate emails
1892
+ $this->s2form = $this->confirmation_sent;
1893
+ } else {
1894
+ // they're already subscribed
1895
+ $this->s2form = $this->already_subscribed;
1896
+ }
1897
+ $this->action = 'subscribe';
1898
+ } elseif ('unsubscribe' == $_POST['s2_action']) {
1899
+ // is this email a subscriber?
1900
+ if (false == $this->is_public($this->email)) {
1901
+ $this->s2form = $this->form . $this->not_subscribed;
1902
+ } else {
1903
+ $this->send_confirm('del');
1904
+ // set a variable to denote that we've already run, and shouldn't run again
1905
+ $this->filtered = 1;
1906
+ $this->s2form = $this->confirmation_sent;
1907
+ }
1908
+ $this->action='unsubscribe';
1909
+ }
1910
+ }
1911
+ }
1912
+ }
1913
+ return preg_replace('|(<p>)(\n)*<!--subscribe2-->(\n)*(</p>)|', $this->s2form, $content);
1914
+ } // end filter()
1915
+
1916
+ /**
1917
+ Overrides the default query when handling a (un)subscription confirmation
1918
+ This is basically a trick: if the s2 variable is in the query string, just grab the first
1919
+ static page and override it's contents later with title_filter()
1920
+ */
1921
+ function query_filter() {
1922
+ // don't interfere if we've already done our thing
1923
+ if (1 == $this->filtered) { return; }
1924
+
1925
+ global $wpdb;
1926
+
1927
+ if ( (defined('S2PAGE')) && (0 != S2PAGE) ) {
1928
+ return "page_id=" . S2PAGE;
1929
+ } else {
1930
+ $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' LIMIT 1");
1931
+ if ($id) {
1932
+ return "page_id=$id";
1933
+ } else {
1934
+ return "showposts=1";
1935
+ }
1936
+ }
1937
+ } // end query_filter()
1938
+
1939
+ /**
1940
+ Overrides the page title
1941
+ */
1942
+ function title_filter() {
1943
+ // don't interfere if we've already done our thing
1944
+ if (1 == $this->filtered) { return; }
1945
+ return __('Subscription Confirmation', 'subscribe2');
1946
+ } // end title_filter()
1947
+
1948
+ /* ===== wp-cron functions ===== */
1949
+ /**
1950
+ Send a daily digest of today's new posts
1951
+ */
1952
+ function subscribe2_cron() {
1953
+ global $wpdb;
1954
+
1955
+ // collect posts
1956
+ $now = date('Y-m-d H:i:s', time());
1957
+ $prev = $this->subscribe2_options['last_s2cron'];
1958
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status='publish' AND post_type='post'");
1959
+
1960
+ // update last_s2cron execution time before completing or bailing
1961
+ $this->subscribe2_options['last_s2cron'] = $now;
1962
+ update_option('subscribe2_options', $this->subscribe2_options);
1963
+
1964
+ // do we have any posts?
1965
+ if (empty($posts)) { return; }
1966
+
1967
+ // if we have posts, let's prepare the digest
1968
+ foreach ($posts as $post) {
1969
+ $post_cats = wp_get_post_cats('1', $post->ID);
1970
+ $post_cats_string = implode(',', $post_cats);
1971
+ $check = false;
1972
+ // is the current post assigned to any categories
1973
+ // which should not generate a notification email?
1974
+ foreach (explode(',', $this->subscribe2_options['exclude']) as $cat) {
1975
+ if (in_array($cat, $post_cats)) {
1976
+ $check = true;
1977
+ }
1978
+ }
1979
+ // if this post is in an excluded category,
1980
+ // don't include it in the digest
1981
+ if ($check) {
1982
+ continue;
1983
+ }
1984
+ $message .= $post->post_title . "\r\n";
1985
+ $message .= get_permalink($post->ID) . "\r\n";
1986
+ $excerpt = $post->post_excerpt;
1987
+ if ('' == $excerpt) {
1988
+ // no excerpt, is there a <!--more--> ?
1989
+ if (false !== strpos($post->post_content, '<!--more-->')) {
1990
+ list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
1991
+ // strip leading and trailing whitespace
1992
+ $excerpt = trim($excerpt);
1993
+ } else {
1994
+ $excerpt = strip_tags($post->post_content);
1995
+ $words = explode(' ', $excerpt, 56);
1996
+ if (count($words) > 55) {
1997
+ array_pop($words);
1998
+ array_push($words, '[...]');
1999
+ $excerpt = implode(' ', $words);
2000
+ }
2001
+ }
2002
+ }
2003
+ $message .= $excerpt . "\r\n\r\n";
2004
+ }
2005
+
2006
+ $author = get_userdata($post->post_author);
2007
+ $this->authorname = $author->display_name;
2008
+
2009
+ // do we send as admin, or post author?
2010
+ if ('author' == $this->subscribe2_options['sender']) {
2011
+ // get author details
2012
+ $user =& $author;
2013
+ } else {
2014
+ // get admin detailts
2015
+ $user = get_userdata(1);
2016
+ }
2017
+ $this->myemail = $user->user_email;
2018
+ $this->myname = $user->display_name;
2019
+
2020
+ $scheds = (array) wp_get_schedules();
2021
+ $email_freq = $this->subscribe2_options['email_freq'];
2022
+ $display = $scheds[$email_freq]['display'];
2023
+ $subject = '[' . stripslashes(get_settings('blogname')) . '] ' . $display . ' ' . __('Digest Email', 'subscribe2');
2024
+ $public = $this->get_public();
2025
+ $registered = $this->get_registered();
2026
+ $recipients = array_merge((array)$public, (array)$registered);
2027
+ $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
2028
+ $body = str_replace('POST', $message, $mailtext);
2029
+ $this->mail($recipients, $subject, $body);
2030
+ } // end subscribe2_cron
2031
+
2032
+ /* ===== Our constructor ===== */
2033
+ /**
2034
+ Subscribe2 constructor
2035
+ */
2036
+ function s2init() {
2037
+ // load the options
2038
+ $this->subscribe2_options = array();
2039
+ $this->subscribe2_options = get_option('subscribe2_options');
2040
+
2041
+ add_action('init', array(&$this, 'subscribe2'));
2042
+ if('1' == $this->subscribe2_options['show_button']) {
2043
+ add_action('init', array(&$this, 'button_init'));
2044
+ }
2045
+ }
2046
+
2047
+ function subscribe2() {
2048
+ global $table_prefix;
2049
+
2050
+ load_plugin_textdomain('subscribe2', 'wp-content/plugins/subscribe2');
2051
+
2052
+ // do we need to install anything?
2053
+ $this->public = $table_prefix . "subscribe2";
2054
+ if(!mysql_query("DESCRIBE " . $this->public)) { $this->install(); }
2055
+ //do we need to upgrade anything?
2056
+ if ($this->subscribe2_options['version'] !== S2VERSION) {
2057
+ add_action('shutdown', array(&$this, 'upgrade'));
2058
+ }
2059
+
2060
+ if (isset($_GET['s2'])) {
2061
+ // someone is confirming a request
2062
+ add_filter('query_string', array(&$this, 'query_filter'));
2063
+ add_filter('the_title', array(&$this, 'title_filter'));
2064
+ add_filter('the_content', array(&$this, 'confirm'));
2065
+ }
2066
+
2067
+ //add regular actions and filters
2068
+ add_action('admin_head', array(&$this, 'admin_head'));
2069
+ add_action('admin_menu', array(&$this, 'admin_menu'));
2070
+ add_action('create_category', array(&$this, 'autosub_new_category'));
2071
+ add_action('register_form', array(&$this, 'register_form'));
2072
+ add_filter('the_content', array(&$this, 'filter'));
2073
+ add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
2074
+
2075
+ // add action to display editor buttons if option is enabled
2076
+ if ('1' == $this->subscribe2_options['show_button']) {
2077
+ add_action('edit_page_form', array(&$this, 's2_edit_form'));
2078
+ add_action('edit_form_advanced', array(&$this, 's2_edit_form'));
2079
+ }
2080
+
2081
+ // add action for automatic subscription based on option settings
2082
+ if ('yes' == $this->subscribe2_options['autosub']) {
2083
+ add_action('user_register', array(&$this, 'register'));
2084
+ } elseif ('wpreg' == $this->subscribe2_options['autosub']) {
2085
+ add_action('register_post', array(&$this, 'register_post'));
2086
+ }
2087
+
2088
+ // add actions for processing posts based on per-post or cron email settings
2089
+ if ($this->subscribe2_options['email_freq'] != 'never') {
2090
+ add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
2091
+ } else {
2092
+ add_action('publish_post', array(&$this, 'publish'));
2093
+ add_action('edit_post', array(&$this, 'edit'));
2094
+ add_action('private_to_published', array(&$this, 'private2publish'));
2095
+ }
2096
+
2097
+ // add action to email notification about pages if option is enabled
2098
+ if ($this->subscribe2_options['pages'] == 'yes') {
2099
+ add_action('publish_page', array(&$this, 'publish'));
2100
+ }
2101
+
2102
+ // load our strings
2103
+ $this->load_strings();
2104
+ } // end subscribe2()
2105
+
2106
+ /* ===== ButtonSnap configuration ===== */
2107
+ /**
2108
+ Register our button in the QuickTags bar
2109
+ */
2110
+ function button_init() {
2111
+ if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) return;
2112
+ if ( 'true' == get_user_option('rich_editing') ) {
2113
+ // Load and append our TinyMCE external plugin
2114
+ add_filter('mce_plugins', array(&$this, 'mce_plugins'));
2115
+ add_filter('mce_buttons', array(&$this, 'mce_buttons'));
2116
+ add_action('tinymce_before_init', array(&$this, 'tinymce_before_init'));
2117
+ add_action('marker_css', array(&$this, 'button_css'));
2118
+ } else {
2119
+ buttonsnap_separator();
2120
+ buttonsnap_jsbutton(get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_button.png', __('Subscribe2', 'subscribe2'), 's2_insert_token();');
2121
+ }
2122
+ }
2123
+
2124
+ /**
2125
+ Style a marker in the Rich Text Editor for our tag
2126
+ By default, the RTE suppresses output of HTML comments, so this
2127
+ places a CSS style on our token in order to make it display
2128
+ */
2129
+ function button_css() {
2130
+ $marker_url = get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_marker.png';
2131
+ echo "
2132
+ .s2_marker {
2133
+ display: block;
2134
+ height: 45px;
2135
+ margin-top: 5px;
2136
+ background-image: url({$marker_url});
2137
+ background-repeat: no-repeat;
2138
+ background-position: center;
2139
+ }
2140
+ ";
2141
+ }
2142
+
2143
+ // Add buttons in WordPress v2.1+, thanks to An-archos
2144
+ function mce_plugins($plugins) {
2145
+ array_push($plugins, '-subscribe2quicktags');
2146
+ return $plugins;
2147
+ }
2148
+
2149
+ function mce_buttons($buttons) {
2150
+ array_push($buttons, 'separator');
2151
+ array_push($buttons, 'subscribe2quicktags');
2152
+ return $buttons;
2153
+ }
2154
+
2155
+ function tinymce_before_init() {
2156
+ $this->fullpath = get_settings('siteurl') . '/wp-content/plugins/subscribe2/tinymce/';
2157
+ echo "tinyMCE.loadPlugin('subscribe2quicktags', '" . $this->fullpath . "');\n";
2158
+ }
2159
+
2160
+ function s2_edit_form() {
2161
+ echo "<!-- Start Subscribe2 Quicktags Javascript -->\r\n";
2162
+ echo "<script type=\"text/javascript\">\r\n";
2163
+ echo "//<![CDATA[\r\n";
2164
+ echo "function s2_insert_token() {
2165
+ buttonsnap_settext('<!--subscribe2-->');
2166
+ }\r\n";
2167
+ echo "//]]>\r\n";
2168
+ echo "</script>\r\n";
2169
+ echo "<!-- End Subscribe2 Quicktags Javascript -->\r\n";
2170
+ }
2171
+
2172
+ /* ===== our variables ===== */
2173
+ // cache variables
2174
+ var $version = '';
2175
+ var $all_public = '';
2176
+ var $all_unconfirmed = '';
2177
+ var $excluded_cats = '';
2178
+ var $post_title = '';
2179
+ var $permalink = '';
2180
+ var $myname = '';
2181
+ var $myemail = '';
2182
+ var $s2_subject = '[BLOGNAME] TITLE';
2183
+ var $signup_dates = array();
2184
+ var $private = false;
2185
+ var $filtered = 0;
2186
+
2187
+ // state variables used to affect processing
2188
+ var $action = '';
2189
+ var $email = '';
2190
+ var $message = '';
2191
+ var $error = '';
2192
+
2193
+ // some messages
2194
+ var $please_log_in = '';
2195
+ var $use_profile = '';
2196
+ var $confirmation_sent = '';
2197
+ var $already_subscribed = '';
2198
+ var $not_subscribed ='';
2199
+ var $not_an_email = '';
2200
+ var $barred_domain = '';
2201
+ var $mail_sent = '';
2202
+ var $form = '';
2203
+ var $no_such_email = '';
2204
+ var $added = '';
2205
+ var $deleted = '';
2206
+ var $confirm_subject = '';
2207
+ var $options_saved = '';
2208
+ var $options_reset = '';
2209
+ } // end class subscribe2
2210
  ?>
subscribe2/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: 2007-01-07 19:26+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"
@@ -20,425 +20,480 @@ msgstr ""
20
  msgid "To manage your subscription options please "
21
  msgstr ""
22
 
23
- #: subscribe2.php:64
24
  msgid "You may manage your subscription options from your "
25
  msgstr ""
26
 
27
- #: subscribe2.php:66
28
  msgid "A confirmation message is on its way!"
29
  msgstr ""
30
 
31
- #: subscribe2.php:68
32
  msgid "That email address is already subscribed."
33
  msgstr ""
34
 
35
- #: subscribe2.php:70
36
  msgid "That email address is not subscribed."
37
  msgstr ""
38
 
39
- #: subscribe2.php:72
40
  msgid "Sorry, but that does not look like an email address to me."
41
  msgstr ""
42
 
43
- #: subscribe2.php:74
44
  msgid ""
45
  "Sorry, email addresses at that domain are currently barred due to spam, "
46
  "please use an alternative email address."
47
  msgstr ""
48
 
49
- #: subscribe2.php:76
50
  msgid "Message sent!"
51
  msgstr ""
52
 
53
- #: subscribe2.php:78
54
  msgid "Your email:"
55
  msgstr ""
56
 
57
- #: subscribe2.php:78 subscribe2.php:1153 subscribe2.php:1207
58
  msgid "Subscribe"
59
  msgstr ""
60
 
61
- #: subscribe2.php:78 subscribe2.php:1208
62
  msgid "Unsubscribe"
63
  msgstr ""
64
 
65
- #: subscribe2.php:78 subscribe2.php:1547
66
  msgid "Send"
67
  msgstr ""
68
 
69
- #: subscribe2.php:81
70
  msgid "No such email address is registered."
71
  msgstr ""
72
 
73
- #: subscribe2.php:83
74
  msgid "You have successfully subscribed!"
75
  msgstr ""
76
 
77
- #: subscribe2.php:85
78
  msgid "You have successfully unsubscribed."
79
  msgstr ""
80
 
81
- #: subscribe2.php:87
82
  msgid "Please confirm your request"
83
  msgstr ""
84
 
85
- #: subscribe2.php:89
86
  msgid "Subscription Reminder"
87
  msgstr ""
88
 
89
- #: subscribe2.php:91
90
  msgid "subscribe"
91
  msgstr ""
92
 
93
- #: subscribe2.php:93
94
  msgid "unsubscribe"
95
  msgstr ""
96
 
97
- #: subscribe2.php:96
98
  msgid "Options saved!"
99
  msgstr ""
100
 
101
- #: subscribe2.php:97
102
  msgid "Options reset!"
103
  msgstr ""
104
 
105
- #: subscribe2.php:105 subscribe2.php:1158
106
  msgid "Subscribers"
107
  msgstr ""
108
 
109
- #: subscribe2.php:106
110
  msgid "Subscribe2 Options"
111
  msgstr ""
112
 
113
- #: subscribe2.php:106
114
  msgid "Subscribe2"
115
  msgstr ""
116
 
117
- #: subscribe2.php:107
118
  msgid "Subscriptions"
119
  msgstr ""
120
 
121
- #: subscribe2.php:108
122
  msgid "Mail Subscribers"
123
  msgstr ""
124
 
125
- #: subscribe2.php:753
 
 
 
 
126
  msgid "New subscriber"
127
  msgstr ""
128
 
129
- #: subscribe2.php:754
130
  msgid "subscribed to email notifications!"
131
  msgstr ""
132
 
133
- #: subscribe2.php:1069
134
  msgid "Address(es) subscribed!"
135
  msgstr ""
136
 
137
- #: subscribe2.php:1072
138
  msgid "deleted!"
139
  msgstr ""
140
 
141
- #: subscribe2.php:1075
142
  msgid "status changed!"
143
  msgstr ""
144
 
145
- #: subscribe2.php:1078
146
  msgid "Reminder Email(s) Sent!"
147
  msgstr ""
148
 
149
- #: subscribe2.php:1081
150
  msgid "CSV File Created in wp-content"
151
  msgstr ""
152
 
153
- #: subscribe2.php:1084
154
  msgid "Registered Users Subscribed!"
155
  msgstr ""
156
 
157
- #: subscribe2.php:1087
158
  msgid "Registered Users Unsubscribed!"
159
  msgstr ""
160
 
161
- #: subscribe2.php:1112
162
- msgid "Send Reminder Email"
163
- msgstr ""
164
-
165
- #: subscribe2.php:1149
166
  msgid "Subscribe Addresses"
167
  msgstr ""
168
 
169
- #: subscribe2.php:1151
170
  msgid "Enter addresses, one per line or comma-seperated"
171
  msgstr ""
172
 
173
- #: subscribe2.php:1160
174
  msgid "Filter"
175
  msgstr ""
176
 
177
- #: subscribe2.php:1164
178
  msgid ""
179
  "Registered on the left, confirmed in the middle, unconfirmed on the right"
180
  msgstr ""
181
 
182
- #: subscribe2.php:1167
183
  msgid "Save Emails to CSV File"
184
  msgstr ""
185
 
186
- #: subscribe2.php:1194
187
  msgid "NONE"
188
  msgstr ""
189
 
190
- #: subscribe2.php:1202
 
 
 
 
191
  msgid "Categories"
192
  msgstr ""
193
 
194
- #: subscribe2.php:1203
195
  msgid ""
196
  "Existing Registered Users can be automatically (un)subscribed to categories "
197
  "using this section."
198
  msgstr ""
199
 
200
- #: subscribe2.php:1204
201
  msgid "Consider User Privacy as changes cannot be undone"
202
  msgstr ""
203
 
204
- #: subscribe2.php:1275
205
  msgid "Delivery Options"
206
  msgstr ""
207
 
208
- #: subscribe2.php:1276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  msgid "Send Email From"
210
  msgstr ""
211
 
212
- #: subscribe2.php:1281
213
  msgid "Author of the post"
214
  msgstr ""
215
 
216
- #: subscribe2.php:1286
217
  msgid "Blog Admin"
218
  msgstr ""
219
 
220
- #: subscribe2.php:1287
 
 
 
 
221
  msgid "Email Templates"
222
  msgstr ""
223
 
224
- #: subscribe2.php:1290
225
  msgid "New Post email (must not be empty)"
226
  msgstr ""
227
 
228
- #: subscribe2.php:1294
229
  msgid "Message substitions"
230
  msgstr ""
231
 
232
- #: subscribe2.php:1298
233
  msgid "the post's title"
234
  msgstr ""
235
 
236
- #: subscribe2.php:1299
237
  msgid ""
238
  "the excerpt or the entire post<br />(<i>based on the subscriber's "
239
  "preferences</i>)"
240
  msgstr ""
241
 
242
- #: subscribe2.php:1300
243
  msgid "the post's permalink"
244
  msgstr ""
245
 
246
- #: subscribe2.php:1301
247
  msgid "the admin or post author's name"
248
  msgstr ""
249
 
250
- #: subscribe2.php:1302
251
  msgid "the admin or post author's email"
252
  msgstr ""
253
 
254
- #: subscribe2.php:1303
255
  msgid "the post author's name"
256
  msgstr ""
257
 
258
- #: subscribe2.php:1304
259
  msgid ""
260
  "the generated link to confirm a request<br />(<i>only used in the "
261
  "confirmation email template</i>)"
262
  msgstr ""
263
 
264
- #: subscribe2.php:1305
265
  msgid ""
266
  "Action performed by LINK in confirmation email<br />(<i>only used in the "
267
  "confirmation email template</i>)"
268
  msgstr ""
269
 
270
- #: subscribe2.php:1307
271
  msgid "Subscribe / Unsubscribe confirmation email"
272
  msgstr ""
273
 
274
- #: subscribe2.php:1310
275
  msgid "Reminder email to Unconfirmed Subscribers"
276
  msgstr ""
277
 
278
- #: subscribe2.php:1315
279
  msgid "Excluded Categories"
280
  msgstr ""
281
 
282
- #: subscribe2.php:1321
283
  msgid "Allow registered users to subscribe to excluded categories?"
284
  msgstr ""
285
 
286
- #: subscribe2.php:1322
287
  msgid "Writing Options"
288
  msgstr ""
289
 
290
- #: subscribe2.php:1327
291
  msgid "Show the Subscribe2 button on the Write toolbar?"
292
  msgstr ""
293
 
294
- #: subscribe2.php:1330
295
  msgid "Auto Subscribe"
296
  msgstr ""
297
 
298
- #: subscribe2.php:1331
299
- msgid "Automatically subscribe new users registering with your blog."
300
  msgstr ""
301
 
302
- #: subscribe2.php:1336
303
- msgid "Yes"
304
  msgstr ""
305
 
306
- #: subscribe2.php:1341
307
- msgid "No"
 
 
 
 
308
  msgstr ""
309
 
310
- #: subscribe2.php:1342
311
  msgid "Auto-subscribe users to receive email as"
312
  msgstr ""
313
 
314
- #: subscribe2.php:1347 subscribe2.php:1450
315
  msgid "HTML"
316
  msgstr ""
317
 
318
- #: subscribe2.php:1352
319
  msgid "Plain Text - Full"
320
  msgstr ""
321
 
322
- #: subscribe2.php:1357
323
  msgid "Plain Text - Excerpt"
324
  msgstr ""
325
 
326
- #: subscribe2.php:1360
327
  msgid "Barred Domains"
328
  msgstr ""
329
 
330
- #: subscribe2.php:1361
331
  msgid ""
332
  "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
333
  "each entry and omit the \"@\" symbol, for example email.com)"
334
  msgstr ""
335
 
336
- #: subscribe2.php:1365
337
  msgid "Submit"
338
  msgstr ""
339
 
340
- #: subscribe2.php:1370
341
  msgid "Reset Default"
342
  msgstr ""
343
 
344
- #: subscribe2.php:1371
345
  msgid ""
346
  "Use this to reset all options to their defaults. This <strong><em>will not</"
347
  "em></strong> modify your list of subscribers."
348
  msgstr ""
349
 
350
- #: subscribe2.php:1375
351
  msgid "RESET"
352
  msgstr ""
353
 
354
- #: subscribe2.php:1394
355
  msgid "Subscription preferences updated."
356
  msgstr ""
357
 
358
- #: subscribe2.php:1441
359
  msgid "Notification Settings"
360
  msgstr ""
361
 
362
- #: subscribe2.php:1445
363
  msgid "Receive email as"
364
  msgstr ""
365
 
366
- #: subscribe2.php:1455
367
  msgid "Plain Text"
368
  msgstr ""
369
 
370
- #: subscribe2.php:1457
371
  msgid "Email contains"
372
  msgstr ""
373
 
374
- #: subscribe2.php:1458
375
  msgid "Excerpt Only"
376
  msgstr ""
377
 
378
- #: subscribe2.php:1458
379
  msgid "Full Post"
380
  msgstr ""
381
 
382
- #: subscribe2.php:1466
383
  msgid "Note: HTML format will always deliver the full post."
384
  msgstr ""
385
 
386
- #: subscribe2.php:1467
387
  msgid "Automatically subscribe me to newly created categories"
388
  msgstr ""
389
 
390
- #: subscribe2.php:1479
391
  msgid "Subscribed Categories"
392
  msgstr ""
393
 
394
- #: subscribe2.php:1484
395
  msgid "Receive daily summary of new posts?"
396
  msgstr ""
397
 
398
- #: subscribe2.php:1497
399
  msgid "Update Preferences &raquo;"
400
  msgstr ""
401
 
402
- #: subscribe2.php:1539
403
  msgid "Send email to all subscribers"
404
  msgstr ""
405
 
406
- #: subscribe2.php:1541
407
  msgid "Subject"
408
  msgstr ""
409
 
410
- #: subscribe2.php:1541
411
  msgid "A message from "
412
  msgstr ""
413
 
414
- #: subscribe2.php:1544
415
  msgid "Recipients: "
416
  msgstr ""
417
 
418
- #: subscribe2.php:1613
 
 
 
 
419
  msgid "All Subscribers"
420
  msgstr ""
421
 
422
- #: subscribe2.php:1614
423
  msgid "Public Subscribers"
424
  msgstr ""
425
 
426
- #: subscribe2.php:1615
427
  msgid "Confirmed"
428
  msgstr ""
429
 
430
- #: subscribe2.php:1616
431
  msgid "Unconfirmed"
432
  msgstr ""
433
 
434
- #: subscribe2.php:1617
435
  msgid "Registered Subscribers"
436
  msgstr ""
437
 
438
- #: subscribe2.php:1760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  msgid "Subscription Confirmation"
440
  msgstr ""
441
 
442
- #: subscribe2.php:1870
443
- msgid "Daily Digest"
444
  msgstr ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2007-06-24 20:29+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"
20
  msgid "To manage your subscription options please "
21
  msgstr ""
22
 
23
+ #: subscribe2.php:64 subscribe2.php:66
24
  msgid "You may manage your subscription options from your "
25
  msgstr ""
26
 
27
+ #: subscribe2.php:68
28
  msgid "A confirmation message is on its way!"
29
  msgstr ""
30
 
31
+ #: subscribe2.php:70
32
  msgid "That email address is already subscribed."
33
  msgstr ""
34
 
35
+ #: subscribe2.php:72
36
  msgid "That email address is not subscribed."
37
  msgstr ""
38
 
39
+ #: subscribe2.php:74
40
  msgid "Sorry, but that does not look like an email address to me."
41
  msgstr ""
42
 
43
+ #: subscribe2.php:76
44
  msgid ""
45
  "Sorry, email addresses at that domain are currently barred due to spam, "
46
  "please use an alternative email address."
47
  msgstr ""
48
 
49
+ #: subscribe2.php:78
50
  msgid "Message sent!"
51
  msgstr ""
52
 
53
+ #: subscribe2.php:80
54
  msgid "Your email:"
55
  msgstr ""
56
 
57
+ #: subscribe2.php:80 subscribe2.php:1135 subscribe2.php:1227
58
  msgid "Subscribe"
59
  msgstr ""
60
 
61
+ #: subscribe2.php:80 subscribe2.php:1228
62
  msgid "Unsubscribe"
63
  msgstr ""
64
 
65
+ #: subscribe2.php:80 subscribe2.php:1656
66
  msgid "Send"
67
  msgstr ""
68
 
69
+ #: subscribe2.php:83
70
  msgid "No such email address is registered."
71
  msgstr ""
72
 
73
+ #: subscribe2.php:85
74
  msgid "You have successfully subscribed!"
75
  msgstr ""
76
 
77
+ #: subscribe2.php:87
78
  msgid "You have successfully unsubscribed."
79
  msgstr ""
80
 
81
+ #: subscribe2.php:89
82
  msgid "Please confirm your request"
83
  msgstr ""
84
 
85
+ #: subscribe2.php:91
86
  msgid "Subscription Reminder"
87
  msgstr ""
88
 
89
+ #: subscribe2.php:93
90
  msgid "subscribe"
91
  msgstr ""
92
 
93
+ #: subscribe2.php:95
94
  msgid "unsubscribe"
95
  msgstr ""
96
 
97
+ #: subscribe2.php:98
98
  msgid "Options saved!"
99
  msgstr ""
100
 
101
+ #: subscribe2.php:99
102
  msgid "Options reset!"
103
  msgstr ""
104
 
105
+ #: subscribe2.php:107 subscribe2.php:1140
106
  msgid "Subscribers"
107
  msgstr ""
108
 
109
+ #: subscribe2.php:108
110
  msgid "Subscribe2 Options"
111
  msgstr ""
112
 
113
+ #: subscribe2.php:108 subscribe2.php:2120
114
  msgid "Subscribe2"
115
  msgstr ""
116
 
117
+ #: subscribe2.php:110 subscribe2.php:112
118
  msgid "Subscriptions"
119
  msgstr ""
120
 
121
+ #: subscribe2.php:114
122
  msgid "Mail Subscribers"
123
  msgstr ""
124
 
125
+ #: subscribe2.php:137
126
+ msgid "Once Weekly"
127
+ msgstr ""
128
+
129
+ #: subscribe2.php:712
130
  msgid "New subscriber"
131
  msgstr ""
132
 
133
+ #: subscribe2.php:713
134
  msgid "subscribed to email notifications!"
135
  msgstr ""
136
 
137
+ #: subscribe2.php:1048
138
  msgid "Address(es) subscribed!"
139
  msgstr ""
140
 
141
+ #: subscribe2.php:1051
142
  msgid "deleted!"
143
  msgstr ""
144
 
145
+ #: subscribe2.php:1054
146
  msgid "status changed!"
147
  msgstr ""
148
 
149
+ #: subscribe2.php:1057
150
  msgid "Reminder Email(s) Sent!"
151
  msgstr ""
152
 
153
+ #: subscribe2.php:1060
154
  msgid "CSV File Created in wp-content"
155
  msgstr ""
156
 
157
+ #: subscribe2.php:1063
158
  msgid "Registered Users Subscribed!"
159
  msgstr ""
160
 
161
+ #: subscribe2.php:1066
162
  msgid "Registered Users Unsubscribed!"
163
  msgstr ""
164
 
165
+ #: subscribe2.php:1128
 
 
 
 
166
  msgid "Subscribe Addresses"
167
  msgstr ""
168
 
169
+ #: subscribe2.php:1133
170
  msgid "Enter addresses, one per line or comma-seperated"
171
  msgstr ""
172
 
173
+ #: subscribe2.php:1142
174
  msgid "Filter"
175
  msgstr ""
176
 
177
+ #: subscribe2.php:1146
178
  msgid ""
179
  "Registered on the left, confirmed in the middle, unconfirmed on the right"
180
  msgstr ""
181
 
182
+ #: subscribe2.php:1155
183
  msgid "Save Emails to CSV File"
184
  msgstr ""
185
 
186
+ #: subscribe2.php:1201
187
  msgid "NONE"
188
  msgstr ""
189
 
190
+ #: subscribe2.php:1211
191
+ msgid "Send Reminder Email"
192
+ msgstr ""
193
+
194
+ #: subscribe2.php:1218
195
  msgid "Categories"
196
  msgstr ""
197
 
198
+ #: subscribe2.php:1219
199
  msgid ""
200
  "Existing Registered Users can be automatically (un)subscribed to categories "
201
  "using this section."
202
  msgstr ""
203
 
204
+ #: subscribe2.php:1220
205
  msgid "Consider User Privacy as changes cannot be undone"
206
  msgstr ""
207
 
208
+ #: subscribe2.php:1327
209
  msgid "Delivery Options"
210
  msgstr ""
211
 
212
+ #: subscribe2.php:1328
213
+ msgid "Send Emails for Pages"
214
+ msgstr ""
215
+
216
+ #: subscribe2.php:1333 subscribe2.php:1344 subscribe2.php:1431
217
+ msgid "Yes"
218
+ msgstr ""
219
+
220
+ #: subscribe2.php:1338 subscribe2.php:1349 subscribe2.php:1425
221
+ #: subscribe2.php:1436
222
+ msgid "No"
223
+ msgstr ""
224
+
225
+ #: subscribe2.php:1339
226
+ msgid "Send Emails for Password Protected Posts"
227
+ msgstr ""
228
+
229
+ #: subscribe2.php:1350
230
  msgid "Send Email From"
231
  msgstr ""
232
 
233
+ #: subscribe2.php:1355
234
  msgid "Author of the post"
235
  msgstr ""
236
 
237
+ #: subscribe2.php:1360
238
  msgid "Blog Admin"
239
  msgstr ""
240
 
241
+ #: subscribe2.php:1362
242
+ msgid "Send Email as Digest"
243
+ msgstr ""
244
+
245
+ #: subscribe2.php:1366
246
  msgid "Email Templates"
247
  msgstr ""
248
 
249
+ #: subscribe2.php:1369
250
  msgid "New Post email (must not be empty)"
251
  msgstr ""
252
 
253
+ #: subscribe2.php:1373
254
  msgid "Message substitions"
255
  msgstr ""
256
 
257
+ #: subscribe2.php:1377
258
  msgid "the post's title"
259
  msgstr ""
260
 
261
+ #: subscribe2.php:1378
262
  msgid ""
263
  "the excerpt or the entire post<br />(<i>based on the subscriber's "
264
  "preferences</i>)"
265
  msgstr ""
266
 
267
+ #: subscribe2.php:1379
268
  msgid "the post's permalink"
269
  msgstr ""
270
 
271
+ #: subscribe2.php:1380
272
  msgid "the admin or post author's name"
273
  msgstr ""
274
 
275
+ #: subscribe2.php:1381
276
  msgid "the admin or post author's email"
277
  msgstr ""
278
 
279
+ #: subscribe2.php:1382
280
  msgid "the post author's name"
281
  msgstr ""
282
 
283
+ #: subscribe2.php:1383
284
  msgid ""
285
  "the generated link to confirm a request<br />(<i>only used in the "
286
  "confirmation email template</i>)"
287
  msgstr ""
288
 
289
+ #: subscribe2.php:1384
290
  msgid ""
291
  "Action performed by LINK in confirmation email<br />(<i>only used in the "
292
  "confirmation email template</i>)"
293
  msgstr ""
294
 
295
+ #: subscribe2.php:1386
296
  msgid "Subscribe / Unsubscribe confirmation email"
297
  msgstr ""
298
 
299
+ #: subscribe2.php:1389
300
  msgid "Reminder email to Unconfirmed Subscribers"
301
  msgstr ""
302
 
303
+ #: subscribe2.php:1394
304
  msgid "Excluded Categories"
305
  msgstr ""
306
 
307
+ #: subscribe2.php:1400
308
  msgid "Allow registered users to subscribe to excluded categories?"
309
  msgstr ""
310
 
311
+ #: subscribe2.php:1401
312
  msgid "Writing Options"
313
  msgstr ""
314
 
315
+ #: subscribe2.php:1406
316
  msgid "Show the Subscribe2 button on the Write toolbar?"
317
  msgstr ""
318
 
319
+ #: subscribe2.php:1409
320
  msgid "Auto Subscribe"
321
  msgstr ""
322
 
323
+ #: subscribe2.php:1410
324
+ msgid "Subscribe new users registering with your blog"
325
  msgstr ""
326
 
327
+ #: subscribe2.php:1415
328
+ msgid "Automatically"
329
  msgstr ""
330
 
331
+ #: subscribe2.php:1420
332
+ msgid "Display option on Registration Form"
333
+ msgstr ""
334
+
335
+ #: subscribe2.php:1426
336
+ msgid "Registration Form option is checked by default"
337
  msgstr ""
338
 
339
+ #: subscribe2.php:1437
340
  msgid "Auto-subscribe users to receive email as"
341
  msgstr ""
342
 
343
+ #: subscribe2.php:1442 subscribe2.php:1552
344
  msgid "HTML"
345
  msgstr ""
346
 
347
+ #: subscribe2.php:1447
348
  msgid "Plain Text - Full"
349
  msgstr ""
350
 
351
+ #: subscribe2.php:1452
352
  msgid "Plain Text - Excerpt"
353
  msgstr ""
354
 
355
+ #: subscribe2.php:1455
356
  msgid "Barred Domains"
357
  msgstr ""
358
 
359
+ #: subscribe2.php:1456
360
  msgid ""
361
  "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
362
  "each entry and omit the \"@\" symbol, for example email.com)"
363
  msgstr ""
364
 
365
+ #: subscribe2.php:1460
366
  msgid "Submit"
367
  msgstr ""
368
 
369
+ #: subscribe2.php:1465
370
  msgid "Reset Default"
371
  msgstr ""
372
 
373
+ #: subscribe2.php:1466
374
  msgid ""
375
  "Use this to reset all options to their defaults. This <strong><em>will not</"
376
  "em></strong> modify your list of subscribers."
377
  msgstr ""
378
 
379
+ #: subscribe2.php:1473
380
  msgid "RESET"
381
  msgstr ""
382
 
383
+ #: subscribe2.php:1493
384
  msgid "Subscription preferences updated."
385
  msgstr ""
386
 
387
+ #: subscribe2.php:1540
388
  msgid "Notification Settings"
389
  msgstr ""
390
 
391
+ #: subscribe2.php:1547
392
  msgid "Receive email as"
393
  msgstr ""
394
 
395
+ #: subscribe2.php:1557
396
  msgid "Plain Text"
397
  msgstr ""
398
 
399
+ #: subscribe2.php:1559
400
  msgid "Email contains"
401
  msgstr ""
402
 
403
+ #: subscribe2.php:1560
404
  msgid "Excerpt Only"
405
  msgstr ""
406
 
407
+ #: subscribe2.php:1560
408
  msgid "Full Post"
409
  msgstr ""
410
 
411
+ #: subscribe2.php:1568
412
  msgid "Note: HTML format will always deliver the full post."
413
  msgstr ""
414
 
415
+ #: subscribe2.php:1569
416
  msgid "Automatically subscribe me to newly created categories"
417
  msgstr ""
418
 
419
+ #: subscribe2.php:1582
420
  msgid "Subscribed Categories"
421
  msgstr ""
422
 
423
+ #: subscribe2.php:1587
424
  msgid "Receive daily summary of new posts?"
425
  msgstr ""
426
 
427
+ #: subscribe2.php:1600
428
  msgid "Update Preferences &raquo;"
429
  msgstr ""
430
 
431
+ #: subscribe2.php:1645
432
  msgid "Send email to all subscribers"
433
  msgstr ""
434
 
435
+ #: subscribe2.php:1650
436
  msgid "Subject"
437
  msgstr ""
438
 
439
+ #: subscribe2.php:1650
440
  msgid "A message from "
441
  msgstr ""
442
 
443
+ #: subscribe2.php:1653
444
  msgid "Recipients: "
445
  msgstr ""
446
 
447
+ #: subscribe2.php:1715
448
+ msgid "Select / Unselect All"
449
+ msgstr ""
450
+
451
+ #: subscribe2.php:1728
452
  msgid "All Subscribers"
453
  msgstr ""
454
 
455
+ #: subscribe2.php:1729
456
  msgid "Public Subscribers"
457
  msgstr ""
458
 
459
+ #: subscribe2.php:1730
460
  msgid "Confirmed"
461
  msgstr ""
462
 
463
+ #: subscribe2.php:1731
464
  msgid "Unconfirmed"
465
  msgstr ""
466
 
467
+ #: subscribe2.php:1732
468
  msgid "Registered Subscribers"
469
  msgstr ""
470
 
471
+ #: subscribe2.php:1788
472
+ msgid "Per Post Email"
473
+ msgstr ""
474
+
475
+ #: subscribe2.php:1806
476
+ msgid "Current server time is"
477
+ msgstr ""
478
+
479
+ #: subscribe2.php:1808
480
+ msgid "Next email notification will be sent"
481
+ msgstr ""
482
+
483
+ #: subscribe2.php:1819
484
+ msgid "Check here to Subscribe to email notifications for new posts"
485
+ msgstr ""
486
+
487
+ #: subscribe2.php:1828
488
+ msgid ""
489
+ "By Registering with this blog you are also agreeing to recieve email "
490
+ "notifications for new posts"
491
+ msgstr ""
492
+
493
+ #: subscribe2.php:1945
494
  msgid "Subscription Confirmation"
495
  msgstr ""
496
 
497
+ #: subscribe2.php:2023
498
+ msgid "Digest Email"
499
  msgstr ""
subscribe2/tinymce/editor_plugin.js ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tinyMCE.importPluginLanguagePack('subscribe2quicktags', 'en_us,nl_nl');
2
+
3
+ var TinyMCE_Subscribe2Quicktags = {
4
+ getInfo : function() {
5
+ return {
6
+ longname : "Subscribe2 Quicktag",
7
+ author : 'MattyRob',
8
+ authorurl : 'http://subscribe2.wordpress.com/',
9
+ infourl : 'http://subscribe2.wordpress.com/',
10
+ version : tinyMCE.majorVersion + '.' + tinyMCE.minorVersion
11
+ };
12
+ },
13
+ getControlHTML : function(cn) {
14
+ switch (cn) {
15
+ case 'subscribe2quicktags':
16
+ buttons = tinyMCE.getButtonHTML('subscribe2', 'lang_subscribe2quicktags_subscribe2', '{$pluginurl}/../s2_button.png', 'subscribe2');
17
+ return buttons;
18
+ }
19
+ return '';
20
+ },
21
+ execCommand : function(editor_id, element, command, user_interface, value) {
22
+ var inst = tinyMCE.getInstanceById(editor_id);
23
+ var focusElm = inst.getFocusElement();
24
+ function getAttrib(elm, name) {
25
+ return elm.getAttribute(name) ? elm.getAttribute(name) : "";
26
+ }
27
+
28
+ switch (command) {
29
+ case 'subscribe2':
30
+ //s2_insert_token(); //Replaced by insert image:
31
+ var flag = "";
32
+ // is image is selected
33
+ if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
34
+ flag = getAttrib(focusElm, 'class');
35
+ flagIE = getAttrib(focusElm, 'className');
36
+
37
+ if ( flag == 'mce_plugin_s2_img' || flagIE == 'mce_plugin_s2_img' )
38
+ alert("Placeholder for Subscribe2 form " + getAttrib(focusElm,'moretext') );
39
+
40
+ return true;
41
+ }
42
+
43
+ alt = "Placeholder for Subscribe2 form";
44
+ cssstyle = 'background:url(../wp-content/plugins/subscribe2/s2_marker.png) no-repeat 5px 5px;';
45
+
46
+ html = ''
47
+ + '<img src="../wp-content/plugins/subscribe2/spacer.gif" '
48
+ + 'width="210px" height="25px" '
49
+ + 'alt="'+alt+'" title="'+alt+'" style="'+cssstyle+'" class="mce_plugin_s2_img" />';
50
+
51
+ tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html);
52
+ tinyMCE.selectedInstance.repaint();
53
+
54
+ return true;
55
+ }
56
+ return false;
57
+ },
58
+
59
+ /* EDIT: added for marker by Ravan */
60
+ cleanup : function(type, content) {
61
+ switch (type) {
62
+
63
+ case "insert_to_editor":
64
+ // Parse all <!--subscribe2--> tags and replace them with images
65
+ var startPos = 0;
66
+ var alt = "Placeholder for Subscribe2 form";
67
+ var cssstyle = 'background:url(../wp-content/plugins/subscribe2/s2_marker.png) no-repeat 5px 5px;';
68
+ while ((startPos = content.indexOf('<!--subscribe2', startPos)) != -1) {
69
+ var endPos = content.indexOf('-->', startPos) + 3;
70
+ // Insert image
71
+ var moreText = content.substring(startPos + 14, endPos - 3);
72
+ var contentAfter = content.substring(endPos);
73
+ content = content.substring(0, startPos);
74
+ content += '<img src="../wp-content/plugins/subscribe2/spacer.gif" ';
75
+ content += ' width="210px" height="25px" moretext="'+moreText+'" ';
76
+ content += 'alt="'+alt+'" title="'+alt+'" style="'+cssstyle+'" class="mce_plugin_s2_img" />';
77
+ content += contentAfter;
78
+ startPos++;
79
+ }
80
+ break;
81
+
82
+ case "get_from_editor":
83
+ // Parse all img tags and replace them with <!--subscribe2-->
84
+ var startPos = -1;
85
+ while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
86
+ var endPos = content.indexOf('/>', startPos);
87
+ var attribs = this._parseAttributes(content.substring(startPos + 4, endPos));
88
+
89
+ if (attribs['class'] == "mce_plugin_s2_img") {
90
+ endPos += 2;
91
+
92
+ var moreText = attribs['moretext'] ? attribs['moretext'] : '';
93
+ var embedHTML = '<!--subscribe2'+moreText+'-->';
94
+
95
+ // Insert embed/object chunk
96
+ chunkBefore = content.substring(0, startPos);
97
+ chunkAfter = content.substring(endPos);
98
+ content = chunkBefore + embedHTML + chunkAfter;
99
+ }
100
+ }
101
+ break;
102
+ }
103
+
104
+ // Pass through to next handler in chain
105
+ return content;
106
+ },
107
+
108
+ handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
109
+
110
+ tinyMCE.switchClass(editor_id + '_subscribe2', 'mceButtonNormal');
111
+
112
+ if (node == null)
113
+ return;
114
+
115
+ do {
116
+ if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_s2_img') == 0) {
117
+ tinyMCE.switchClass(editor_id + '_subscribe2', 'mceButtonSelected');
118
+ }
119
+ } while ((node = node.parentNode));
120
+
121
+ return true;
122
+ },
123
+
124
+ _parseAttributes : function(attribute_string) {
125
+ var attributeName = "";
126
+ var attributeValue = "";
127
+ var withInName;
128
+ var withInValue;
129
+ var attributes = new Array();
130
+ var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
131
+
132
+ if (attribute_string == null || attribute_string.length < 2)
133
+ return null;
134
+
135
+ withInName = withInValue = false;
136
+
137
+ for (var i=0; i<attribute_string.length; i++) {
138
+ var chr = attribute_string.charAt(i);
139
+
140
+ if ((chr == '"' || chr == "'") && !withInValue)
141
+ withInValue = true;
142
+ else if ((chr == '"' || chr == "'") && withInValue) {
143
+ withInValue = false;
144
+
145
+ var pos = attributeName.lastIndexOf(' ');
146
+ if (pos != -1)
147
+ attributeName = attributeName.substring(pos+1);
148
+
149
+ attributes[attributeName.toLowerCase()] = attributeValue.substring(1);
150
+
151
+ attributeName = "";
152
+ attributeValue = "";
153
+ } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
154
+ withInName = true;
155
+
156
+ if (chr == '=' && withInName)
157
+ withInName = false;
158
+
159
+ if (withInName)
160
+ attributeName += chr;
161
+
162
+ if (withInValue)
163
+ attributeValue += chr;
164
+ }
165
+
166
+ return attributes;
167
+ }
168
+ /* end */
169
+ };
170
+
171
+ tinyMCE.addPlugin('subscribe2quicktags', TinyMCE_Subscribe2Quicktags);
subscribe2/tinymce/langs/en_us.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ // US lang variables
2
+
3
+ tinyMCE.addToLang('subscribe2quicktags',{
4
+ subscribe2 : 'Embed Subscribe2 token'
5
+ });
subscribe2/tinymce/langs/nl_nl.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ // NL lang variables
2
+
3
+ tinyMCE.addToLang('subscribe2quicktags',{
4
+ subscribe2 : 'Subscribe2 teken invoegen'
5
+ });