Subscribe2 - Version 2.7

Version Description

Download this release

Release Info

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

Code changes from version 3.0 to 2.7

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.2
7
8
Sends a list of subscribers an email notification when new posts are published to your blog
9
@@ -77,47 +77,6 @@ Batches will occur for each group of message as described above. A site on Drea
77
78
== Version History ==
79
80
- Version 3.0 by Matthew Robinson
81
-
82
- * Updated for WordPress 2.1 Branch
83
-
84
- Version 2.14 by Matthew Robinson
85
-
86
- * Amended DREAMHOST setting to BCCLIMIT as more hosts are limiting emails
87
- * Fixed oversight in upgrade() function
88
-
89
- Version 2.13 by Matthew Robinson
90
-
91
- * Added WordPress nonce functionality to improve admin security
92
-
93
- Version 2.12 by Matthew Robinson
94
-
95
- * Fix for missing Quicktags (probably since version 2.2.10)
96
- * Fix for occasional email issue where excerpts are incomplete
97
-
98
- Version 2.11 by Matthew Robinson
99
- * Fixed bug that would cause all subscribers to get digest emails
100
- * Added Select All check box to category listing
101
-
102
- Version 2.10 by Matthew Robinson
103
- * Improved sign up process by double checking email address
104
- * Fix for submenu issues encountered in WP 2.0.6
105
-
106
- Version 2.9 by Matthew Robinson
107
-
108
- * Fixed get_userdata call issue
109
- * Added CSV export
110
- * Reworked options storage routines
111
-
112
- Version 2.8 by Matthew Robinson
113
-
114
- * Fixed missing line return in email headers that was causing failed emails
115
- * Added user feedback messages to profile area
116
- * Added 'Authorname' to the list of message substitutions in email messages
117
- * Fixed name and email substitution in Digest Mails
118
- * Fixed stripslashes issue in email subjects
119
- * Added new 'Action' token for confirmation emails
120
-
121
Version 2.7 by Matthew Robinson
122
123
* Link to post in HTML emails is now functional
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
78
== Version History ==
79
80
Version 2.7 by Matthew Robinson
81
82
* Link to post in HTML emails is now functional
subscribe2/include.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- // include.php - Handles options and common functions for subscribe2
3
- // DO NOT EDIT THIS FILE AS IT IS SET BY THE OPTIONS PAGE
4
-
5
- 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
16
-
17
- if (!isset($this->subscribe2_options['sender'])) {
18
- $this->subscribe2_options['sender'] = "author";
19
- } // option for email notification sender
20
-
21
- // reg_override : allow registered users to subscribed to excluded cats
22
- if (!isset($this->subscribe2_options['reg_override'])) {
23
- $this->subscribe2_options['reg_override'] = "1";
24
- } // option for excluded categories to be overriden for registered users
25
-
26
- if (!isset($this->subscribe2_options['show_button'])) {
27
- $this->subscribe2_options['show_button'] = "1";
28
- } // option to show Subscribe2 button on Write page
29
-
30
- if (!isset($this->subscribe2_options['barred'])) {
31
- $this->subscribe2_options['barred'] = '';
32
- } // option containing domains barred from public registration
33
-
34
- if (!isset($this->subscribe2_options['email_freq'])) {
35
- $this->subscribe2_options['email_freq'] = "never";
36
- } // option for sending emails periodically or per-post
37
-
38
- if (!isset($this->subscribe2_options['mailtext'])) {
39
- $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";
40
- } // Default notification email text
41
-
42
- if (!isset($this->subscribe2_options['confirm_email'])) {
43
- $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.";
44
- } // Default confirmation email text
45
-
46
- if (!isset($this->subscribe2_options['remind_email'])) {
47
- $this->subscribe2_options['remind_email'] = "This email address was subscribed for notifications at BLOGNAME (BLOGLINK) but the subscription remains incomplete.\n\nIf you wish to complete your subscription please click on the link below:\n\nLINK\n\nIf you do not wish to complete your subscription please ignore this email and your address will be removed from our database.\n\nRegards,\nMYNAME";
48
- } // Default reminder email text
49
- ?>
subscribe2/subscribe2.php CHANGED
@@ -3,13 +3,13 @@
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.3.1 for WP2.1
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
@@ -29,66 +29,25 @@ 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 numner of recipients
33
- // permitted on each outgoing email message
34
- // change this value 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 below.
40
- define('S2PAGE', '0');
41
-
42
- // our version number. Don't touch.
43
- define('S2VERSION', '2.3.1');
44
-
45
- // Add the Subscribe code into the WP API
46
- add_action('init', 's2init');
47
-
48
- // maybe add our button
49
- $s2_options = array();
50
- $s2_options = get_option('subscribe2_options');
51
- if ('1' == $s2_options['show_button']) {
52
- // use Owen's excellent ButtonSnap library
53
- include(ABSPATH . '/wp-content/plugins/buttonsnap.php');
54
- add_action('init', 's2_button_init');
55
- add_action('marker_css', 'subscribe2_css');
56
- }
57
- unset($s2_options);
58
-
59
- function s2init() {
60
- global $subscribe2;
61
- $mysubscribe2 = new subscribe2();
62
- $mysubscribe2->subscribe2();
63
- }
64
65
- /* ===== ButtonSnap configuration ===== */
66
- /**
67
- Register our button in the QuickTags bar
68
- */
69
- function s2_button_init() {
70
- $url = get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_button.png';
71
- buttonsnap_textbutton($url, 'Subscribe2', '<!--subscribe2-->');
72
- buttonsnap_register_marker('subscribe2', 's2_marker');
73
- }
74
75
- /**
76
- Style a marker in the Rich Text Editor for our tag
77
- By default, the RTE suppresses output of HTML comments, so this places a CSS style on our token in order to make it display
78
- */
79
- function subscribe2_css() {
80
- $marker_url = get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_marker.png';
81
- echo "
82
- .s2_marker {
83
- display: block;
84
- height: 45px;
85
- margin-top: 5px;
86
- background-image: url({$marker_url});
87
- background-repeat: no-repeat;
88
- background-position: center;
89
- }
90
- ";
91
- }
92
93
// start our class
94
class subscribe2 {
@@ -102,9 +61,7 @@ class subscribe2 {
102
103
$this->please_log_in = "<p>" . __('To manage your subscription options please ', 'subscribe2') . "<a href=\"" . get_settings('siteurl') . "/wp-login.php\">login</a>.</p>";
104
105
- $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>";
106
-
107
- $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>";
108
109
$this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
110
@@ -129,12 +86,6 @@ class subscribe2 {
129
130
$this->confirm_subject = "[" . get_settings('blogname') . "] " . __('Please confirm your request', 'subscribe2');
131
132
- $this->remind_subject = "[" . get_settings('blogname') . "] " . __('Subscription Reminder', 'subscribe2');
133
-
134
- $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
135
-
136
- $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
137
-
138
// menu strings
139
$this->options_saved = __('Options saved!', 'subscribe2');
140
$this->options_reset = __('Options reset!', 'subscribe2');
@@ -145,38 +96,39 @@ class subscribe2 {
145
Hook the menu
146
*/
147
function admin_menu() {
148
- add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", __FILE__, array(&$this, 'manage_menu'));
149
- add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2','subscribe2'), "manage_options", __FILE__, array(&$this, 'options_menu'));
150
- if (current_user_can('manage_options')) {
151
- add_submenu_page('users.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
152
- } else {
153
- add_submenu_page('profile.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
154
- }
155
- add_submenu_page('post-new.php', __('Mail Subscribers','subscribe2'), __('Mail Subscribers', 'subscribe2'),"manage_options", __FILE__, array(&$this, 'write_menu'));
156
- $s2nonce = md5('subscribe2');
157
}
158
159
/**
160
- Insert Javascript into admin_header
161
*/
162
- function admin_head() {
163
- echo "<script type=\"text/javascript\">\r\n";
164
- echo "<!--\r\n";
165
- echo "function setAll(theElement) {\r\n";
166
- echo " var theForm = theElement.form, z = 0;\r\n";
167
- echo " for(z=0; z<theForm.length;z++){\r\n";
168
- echo " if(theForm[z].type == 'checkbox' && theForm[z].name == 'category[]'){\r\n";
169
- echo " theForm[z].checked = theElement.checked;\r\n";
170
- echo " }\r\n";
171
- echo " }\r\n";
172
- echo "}\r\n";
173
- echo "-->\r\n";
174
- echo "</script>\r\n";
175
}
176
177
- function add_weekly_sched($sched) {
178
- $sched['weekly'] = array('interval' => 604800, 'display' => __('Once Weekly','subscribe2'));
179
- return $sched;
180
}
181
182
/* ===== Install, upgrade, reset ===== */
@@ -185,7 +137,7 @@ class subscribe2 {
185
*/
186
function install() {
187
// include upgrade-functions for maybe_create_table;
188
- if (!function_exists('maybe_create_table')) {
189
require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
190
}
191
$date = date('Y-m-d');
@@ -208,46 +160,41 @@ class subscribe2 {
208
global $wpdb;
209
210
// include upgrade-functions for maybe_create_table;
211
- if (!function_exists('maybe_create_table')) {
212
require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
213
}
214
$date = date('Y-m-d');
215
maybe_add_column($this->public, 'date', "ALTER TABLE `$this->public` ADD `date` DATE DEFAULT '$date' NOT NULL AFTER `active`;");
216
217
// let's take the time to check process registered users
218
- // existing public subscribers are subscribed to all categories
219
- $users = $wpdb->get_col("SELECT ID FROM $wpdb->users");
220
- if (!empty($users)) {
221
- foreach ($users as $user) {
222
$this->register($user);
223
}
224
}
225
- // update the options table to serialized format
226
- $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
227
-
228
- if (!empty($old_options)) {
229
- foreach ($old_options as $option) {
230
- $value = get_option($option);
231
- $option_array = substr($option, 3);
232
- $this->subscribe2_options[$option_array] = $value;
233
- delete_option($option);
234
- }
235
- }
236
- $this->subscribe2_options['version'] = S2VERSION;
237
- //double check that the options are in the database
238
- require_once(ABSPATH . "/wp-content/plugins/subscribe2/include.php");
239
- update_option('subscribe2_options', $this->subscribe2_options);
240
} // end upgrade()
241
242
/**
243
Reset our options
244
*/
245
function reset() {
246
- delete_option('subscribe2_options');
247
- unset($this->subscribe2_options);
248
- require(ABSPATH . "/wp-content/plugins/subscribe2/include.php");
249
- update_option('subscribe2_options', $this->subscribe2_options);
250
- } // end reset()
251
252
/* ===== mail handling ===== */
253
/**
@@ -263,7 +210,6 @@ class subscribe2 {
263
$string = str_replace('PERMALINK', $this->permalink, $string);
264
$string = str_replace('MYNAME', stripslashes($this->myname), $string);
265
$string = str_replace('EMAIL', $this->myemail, $string);
266
- $string = str_replace('AUTHORNAME', $this->authorname, $string);
267
return $string;
268
} // end sustitute()
269
@@ -271,11 +217,12 @@ class subscribe2 {
271
Delivers email to recipients in HTML or plaintext
272
*/
273
function mail ($recipients = array(), $subject = '', $message = '', $type='text') {
274
- if ( (empty($recipients)) || ('' == $message) ) { return; }
275
-
276
// Set sender details
277
if ('' == $this->myname) {
278
- $admin = get_userdata(1);
279
$this->myname = $admin->display_name;
280
$this->myemail = $admin->user_email;
281
}
@@ -299,83 +246,86 @@ class subscribe2 {
299
300
// BCC all recipients
301
$bcc = '';
302
- if ( (defined('BCCLIMIT') && (BCCLIMIT > 0) ) &&
303
- (count($recipients) > BCCLIMIT) ) {
304
// we're on Dreamhost, and have more than 30 susbcribers
305
$count = 1;
306
$batch = array();
307
foreach ($recipients as $recipient) {
308
// advance the array pointer by one, for use down below
309
// the array pointer _is not_ advanced by the foreach() loop itself
310
- next($recipients);
311
- $recipient = trim($recipient);
312
- // sanity check -- make sure we have a valid email
313
- if (!is_email($recipient)) { continue; }
314
- // and NOT the sender's email, since they'll
315
- // get a copy anyway
316
- if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
317
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
318
- // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
319
- }
320
- if (30 == $count) {
321
- $count = 1;
322
- $batch[] = $bcc;
323
- $bcc = '';
324
- } else {
325
- if (false == current($recipients)) {
326
- // we've reached the end of the subscriber list
327
- // add what we have to the batch, and move on
328
- $batch[] = $bcc;
329
- break;
330
} else {
331
- $count++;
332
}
333
- }
334
}
335
// rewind the array, just to be safe
336
reset($recipients);
337
} else {
338
// we're not on dreamhost, or have less than 30
339
// subscribers, so do it normal
340
- foreach ($recipients as $recipient) {
341
- $recipient = trim($recipient);
342
- // sanity check -- make sure we have a valid email
343
- if (!is_email($recipient)) { continue; }
344
// and NOT the sender's email, since they'll
345
// get a copy anyway
346
- if ( (!empty($recipient)) && ($this->myemail != $recipient) ) {
347
('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
348
// Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
349
}
350
- }
351
- $headers .= "$bcc\r\n";
352
}
353
// actually send mail
354
- if ( (defined('BCCLIMIT')) && (BCCLIMIT > 0) && (isset($batch)) ) {
355
- foreach ($batch as $bcc) {
356
- $newheaders = $headers . "$bcc\r\n";
357
- @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
358
}
359
- } else {
360
- @wp_mail($this->myemail, $subject, $mailtext, $headers);
361
- }
362
} // end mail()
363
364
/**
365
Sends an email notification of a new post
366
*/
367
- function publish($id = 0) {
368
- if ( (!$id) || is_page($id) ) { return $id; }
369
370
// are we doing daily digests? If so, don't send anything now
371
- if ($this->subscribe2_options['email_freq'] != 'never') { return; }
372
373
// we need to determine whether this is a new post, or an edit
374
- if ($this->private) {
375
- // this post was published from draft status
376
- // OR is an edit of an existing post
377
- // so send no notification
378
- return $id;
379
}
380
381
$post_cats = wp_get_post_cats('1', $id);
@@ -392,23 +342,36 @@ class subscribe2 {
392
if ($check) {
393
// hang on -- can registered users subscribe to
394
// excluded categories?
395
- if ('0' == $this->subscribe2_options['reg_override']) {
396
// nope? okay, let's leave
397
return $id;
398
}
399
}
400
401
global $wpdb;
402
- $post =& get_post($id);
403
// is this post set in the future?
404
if ($post->post_date > current_time('mysql')) {
405
// bail out
406
return $id;
407
}
408
409
// lets collect our public subscribers
410
// and all our registered subscribers for these categories
411
- if (!$check) {
412
// if this post is assigned to an excluded
413
// category, then this test will prevent
414
// the public from receiving notification
@@ -417,7 +380,7 @@ class subscribe2 {
417
$registered = $this->get_registered("cats=$post_cats_string");
418
419
// do we have subscribers?
420
- if ( (empty($public)) && (empty($registered)) ) {
421
// if not, no sense doing anything else
422
return $id;
423
}
@@ -425,16 +388,13 @@ class subscribe2 {
425
// passing them in function calls a little later
426
$this->post_title = $post->post_title;
427
$this->permalink = "<a href=\"" . get_permalink($id) . "\">" . get_permalink($id) . "</a>";
428
-
429
- $author = get_userdata($post->post_author);
430
- $this->authorname = $author->display_name;
431
432
// do we send as admin, or post author?
433
- if ('author' == $this->subscribe2_options['sender']) {
434
// get author details
435
- $user =& $author;
436
} else {
437
- // get admin details
438
$user = get_userdata(1);
439
}
440
$this->myemail = $user->user_email;
@@ -442,7 +402,7 @@ class subscribe2 {
442
// Get email subject
443
$subject = $this->substitute(stripslashes($this->s2_subject));
444
// Get the message template
445
- $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
446
447
$plaintext = $post->post_content;
448
$content = apply_filters('the_content', $post->post_content);
@@ -459,7 +419,7 @@ class subscribe2 {
459
// no <!--more-->, so grab the first 55 words
460
$excerpt = strip_tags($plaintext);
461
$excerpt_length = 55;
462
- $words = explode(' ', $excerpt, $excerpt_length + 1);
463
if (count($words) > $excerpt_length) {
464
array_pop($words);
465
array_push($words, '[...]');
@@ -494,22 +454,22 @@ class subscribe2 {
494
/**
495
Sends a notification when a draft post is published
496
*/
497
- function private2publish($id = 0) {
498
- if (0 == $id) { return $id; }
499
500
- $this->publish($id);
501
$this->private = TRUE;
502
- return $id;
503
} // end private2publish()
504
505
/**
506
Prevents notifications from being sent when editing posts
507
*/
508
- function edit($id = 0) {
509
- if (0 == $id) { return; }
510
511
$this->private = TRUE;
512
- return $id;
513
}
514
515
/**
@@ -517,11 +477,11 @@ class subscribe2 {
517
*/
518
function send_confirm($what = '', $is_remind = FALSE) {
519
if ($this->filtered == 1) { return; }
520
- if ( (!$this->email) || (!$what) ) {
521
return false;
522
}
523
$id = $this->get_id($this->email);
524
- if (!$id) {
525
return false;
526
}
527
@@ -541,28 +501,23 @@ class subscribe2 {
541
542
$admin = get_userdata(1);
543
$this->myname = $admin->display_name;
544
-
545
if ($is_remind == TRUE) {
546
- $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
547
- $subject = stripslashes($this->remind_subject);
548
} else {
549
- $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
550
- if ('add' == $what) {
551
- $body = str_replace("ACTION", $this->subscribe, $body);
552
- } elseif ('del' == $what) {
553
- $body = str_replace("ACTION", $this->unsubscribe, $body);
554
- }
555
- $subject = stripslashes($this->confirm_subject);
556
}
557
558
$body = str_replace("LINK", $link, $body);
559
560
- $mailheaders .= "From: $admin->display_name <$admin->user_email>\n";
561
$mailheaders .= "Return-Path: <$admin->user_email>\n";
562
$mailheaders .= "X-Mailer:PHP" . phpversion() . "\n";
563
$mailheaders .= "Precedence: list\nList-Id: " . get_settings('blogname') . "\n";
564
- $mailheaders .= "MIME-Version: 1.0\n";
565
- $mailheaders .= "Content-type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
566
567
@wp_mail ($this->email, $subject, $body, $mailheaders);
568
} // end send_confirm()
@@ -576,7 +531,7 @@ class subscribe2 {
576
return $this->excluded_cats;
577
} else {
578
global $wpdb;
579
- $this->excluded_cats = $this->subscribe2_options['exclude'];
580
return $this->excluded_cats;
581
}
582
} // end get_excluded_cats()
@@ -605,7 +560,7 @@ class subscribe2 {
605
function get_email ($id = 0) {
606
global $wpdb;
607
608
- if (!$id) {
609
return false;
610
}
611
return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
@@ -617,7 +572,7 @@ class subscribe2 {
617
function get_id ($email = '') {
618
global $wpdb;
619
620
- if (!$email) {
621
return false;
622
}
623
return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
@@ -662,7 +617,7 @@ class subscribe2 {
662
}
663
}
664
665
- if (!is_email($email)) { return false; }
666
667
if (false !== $this->is_public($email)) {
668
$wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE email='$email'");
@@ -685,7 +640,7 @@ class subscribe2 {
685
}
686
}
687
688
- if (!is_email($email)) { return false; }
689
$wpdb->get_results("DELETE FROM $this->public WHERE email='$email'");
690
} // end delete()
691
@@ -718,29 +673,18 @@ class subscribe2 {
718
$this->myname = $admin->display_name;
719
720
$recipients = explode(",", $emails);
721
- if (!is_array($recipients)) { $recipients = array(); }
722
foreach ($recipients as $recipient) {
723
$this->email = $recipient;
724
$this->send_confirm('add', TRUE);
725
}
726
} //end remind()
727
728
- /**
729
- Export email list to CSV download
730
- */
731
- function exportcsv($emails = '') {
732
- if ('' == $emails) {return false; }
733
-
734
- $f = fopen(ABSPATH . '/wp-content/email.csv', 'w');
735
- fwrite($f, $emails);
736
- fclose($f);
737
- } //end exportcsv
738
-
739
/**
740
Check email is not from a barred domain
741
*/
742
function is_barred($email='') {
743
- $barred_option = $this->subscribe2_options['barred'];
744
list($user, $domain) = split('@', $email);
745
$bar_check = stristr($barred_option, $domain);
746
@@ -766,7 +710,7 @@ class subscribe2 {
766
$id = intval(substr($code, 1));
767
if ($id) {
768
$this->email = $this->get_email($id);
769
- if ( (!$this->email) || ($hash !== md5($this->email)) ) {
770
return $this->no_such_email;
771
}
772
} else {
@@ -857,11 +801,11 @@ class subscribe2 {
857
$subscribers = array();
858
859
parse_str($args, $r);
860
- if (!isset($r['cats']))
861
$r['cats'] = '';
862
- if (!isset($r['format']))
863
$r['format'] = 'all';
864
- if (!isset($r['amount']))
865
$r['amount'] = 'all';
866
867
$JOIN = ''; $AND = '';
@@ -911,7 +855,7 @@ class subscribe2 {
911
if ('' == $email) { return false; }
912
913
global $wpdb;
914
- if (!empty($this->signup_dates)) {
915
return $this->signup_dates[$email];
916
} else {
917
$results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
@@ -931,18 +875,14 @@ class subscribe2 {
931
932
if (0 == $user_id) { return $user_id; }
933
$user = get_userdata($user_id);
934
- $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
935
- foreach ($all_cats as $cat) {
936
- ('' == $cats) ? $cats = "$cat->cat_ID" : $cats .= ",$cat->cat_ID";
937
- }
938
939
// has this user previously signed up for email notification?
940
if (false !== $this->is_public($user->user_email)) {
941
// delete this user from the public table, and subscribe them to all the categories
942
$this->delete($user->user_email);
943
- update_usermeta($user_id, 's2_subscribed', $cats);
944
- foreach(explode(',', $cats) as $cat) {
945
- update_usermeta($user_id, 's2_cat' . $all_cats->cat_ID, "$all_cats->cat_ID");
946
}
947
update_usermeta($user_id, 's2_format', 'text');
948
update_usermeta($user_id, 's2_excerpt', 'excerpt');
@@ -951,23 +891,26 @@ class subscribe2 {
951
$check = get_usermeta($user_id, 's2_subscribed');
952
// ensure existing subscriptions are not overwritten on upgrade
953
if (empty($check)) {
954
- if ('yes' == $this->subscribe2_options['autosub']) {
955
- // don't add entires by default if autosub is off, messes up daily digests
956
update_usermeta($user_id, 's2_subscribed', $this->get_all_categories());
957
foreach(explode(',', $this->get_all_categories()) as $cat) {
958
update_usermeta($user_id, 's2_cat' . $cat, "$cat");
959
}
960
- if ('html' == $this->subscribe2_options['autoformat']) {
961
update_usermeta($user_id, 's2_format', 'html');
962
- update_usermeta($user_id, 's2_excerpt', 'post');
963
- } elseif ('fulltext' == $this->subscribe2_options['autoformat']) {
964
update_usermeta($user_id, 's2_format', 'text');
965
- update_usermeta($user_id, 's2_excerpt', 'post');
966
} else {
967
update_usermeta($user_id, 's2_format', 'text');
968
update_usermeta($user_id, 's2_excerpt', 'excerpt');
969
}
970
- }
971
}
972
}
973
return $user_id;
@@ -977,7 +920,7 @@ class subscribe2 {
977
Subscribe all registered users to category selected on Admin Manage Page
978
*/
979
function subscribe_registered_users ($emails = '', $cats = '') {
980
- if ( ('' == $emails) || ('' == $cats) ) { return false; }
981
global $wpdb;
982
983
$useremails = explode(",", $emails);
@@ -986,17 +929,17 @@ class subscribe2 {
986
$sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
987
$user_IDs = $wpdb->get_col($sql);
988
$cats = $_POST['category'];
989
- if (!is_array($cats)) {
990
$cats = array($_POST['category']);
991
}
992
993
foreach ($user_IDs as $user_ID) {
994
$old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
995
- if (!is_array($old_cats)) {
996
$old_cats = array($old_cats);
997
}
998
$new = array_diff($cats, $old_cats);
999
- if (!empty($new)) {
1000
// add subscription to these cat IDs
1001
foreach ($new as $id) {
1002
update_usermeta($user_ID, 's2_cat' . $id, "$id");
@@ -1011,7 +954,7 @@ class subscribe2 {
1011
Unsubscribe all registered users to category selected on Admin Manage Page
1012
*/
1013
function unsubscribe_registered_users ($emails = '', $cats = '') {
1014
- if ( ('' == $emails) || ('' == $cats) ) { return false; }
1015
global $wpdb;
1016
1017
$useremails = explode(",", $emails);
@@ -1020,17 +963,17 @@ class subscribe2 {
1020
$sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
1021
$user_IDs = $wpdb->get_col($sql);
1022
$cats = $_POST['category'];
1023
- if (!is_array($cats)) {
1024
$cats = array($_POST['category']);
1025
}
1026
1027
foreach ($user_IDs as $user_ID) {
1028
$old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1029
- if (!is_array($old_cats)) {
1030
$old_cats = array($old_cats);
1031
}
1032
$remain = array_diff($old_cats, $cats);
1033
- if (!empty($remain)) {
1034
// remove subscription to these cat IDs and update s2_subscribed
1035
foreach ($cats as $id) {
1036
delete_usermeta($user_ID, 's2_cat' . $id, "$id");
@@ -1045,49 +988,25 @@ class subscribe2 {
1045
}
1046
}
1047
} // end unsubscribe_registered_users
1048
-
1049
- /**
1050
- Autosubscribe registered users to newly created categories
1051
- if registered user has selected this option
1052
- */
1053
- function autosub_new_category ($new_category='') {
1054
- global $wpdb;
1055
-
1056
- $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='s2_autosub' AND $wpdb->usermeta.meta_value='yes'";
1057
- $user_IDs = $wpdb->get_col($sql);
1058
- if ('' == $user_IDs) { return; }
1059
-
1060
- foreach ($user_IDs as $user_ID) {
1061
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1062
- if (!is_array($old_cats)) {
1063
- $old_cats = array($old_cats);
1064
- }
1065
- // add subscription to these cat IDs
1066
- update_usermeta($user_ID, 's2_cat' . $new_category, "$new_category");
1067
- $newcats = array_merge($old_cats, (array)$new_category);
1068
- update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
1069
- }
1070
- } // end autosub_new_category
1071
1072
/* ===== Menus ===== */
1073
/**
1074
Our management page
1075
*/
1076
function manage_menu() {
1077
- global $wpdb, $s2nonce;
1078
1079
//Get Registered Subscribers for bulk management
1080
$registered = $this->get_registered();
1081
- if (!empty($registered)) {
1082
$emails = implode(",", $registered);
1083
}
1084
1085
$what = '';
1086
- $reminderform = false;
1087
1088
// was anything POSTed ?
1089
if (isset($_POST['s2_admin'])) {
1090
- check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
1091
if ('subscribe' == $_POST['s2_admin']) {
1092
foreach (preg_split ("/[\s,]+/", $_POST['addresses']) as $email) {
1093
if (is_email($email)) {
@@ -1105,9 +1024,6 @@ class subscribe2 {
1105
} elseif ('remind' == $_POST['s2_admin']) {
1106
$this->remind($_POST['reminderemails']);
1107
echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Reminder Email(s) Sent!','subscribe2') . "</p></strong></div>";
1108
- } elseif ('exportcsv' == $_POST['s2_admin']) {
1109
- $this->exportcsv($_POST['exportcsv']);
1110
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('CSV File Created in wp-content','subscribe2') . "</p></strong></div>";
1111
} elseif ( ('register' == $_POST['s2_admin']) && ('Subscribe' == $_POST['submit']) ) {
1112
$this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1113
echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Subscribed!','subscribe2') . "</p></strong></div>";
@@ -1138,7 +1054,7 @@ class subscribe2 {
1138
$subscribers = $unconfirmed;
1139
if (!empty($unconfirmed)) {
1140
$reminderemails = implode(",", $unconfirmed);
1141
- $reminderform = true;
1142
}
1143
} elseif (is_numeric($_POST['what'])) {
1144
$what = intval($_POST['what']);
@@ -1155,7 +1071,7 @@ class subscribe2 {
1155
$confirmed = $this->get_public();
1156
$subscribers = $confirmed;
1157
$what = 'confirmed';
1158
- if (empty($subscribers)) {
1159
$unconfirmed = $this->get_public(0);
1160
$subscribers = $unconfirmed;
1161
$what = 'unconfirmed';
@@ -1165,7 +1081,7 @@ class subscribe2 {
1165
}
1166
}
1167
}
1168
- if (!empty($subscribers)) {
1169
natcasesort($subscribers);
1170
}
1171
// safety check for our arrays
@@ -1177,9 +1093,6 @@ class subscribe2 {
1177
echo "<div class=\"wrap\">";
1178
echo "<h2>" . __('Subscribe Addresses', 'subscribe2') . "</h2>\r\n";
1179
echo "<form method=\"post\" action=\"\">\r\n";
1180
- if (function_exists('wp_nonce_field')) {
1181
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1182
- }
1183
echo "<span style=\"align:left\">" . __('Enter addresses, one per line or comma-seperated', 'subscribe2') . "</span><br />\r\n";
1184
echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea>";
1185
echo "<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Subscribe', 'subscribe2') . "\"/>";
@@ -1192,22 +1105,11 @@ class subscribe2 {
1192
$this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1193
// show the selected subscribers
1194
$alternate = 'alternate';
1195
- if (!empty($subscribers)) {
1196
echo "<p align=\"center\"><b>" . __('Registered on the left, confirmed in the middle, unconfirmed on the right', 'subscribe2') . "</b></p>";
1197
- if (is_writable(ABSPATH . '/wp-content')) {
1198
- $exportcsv = implode(",", $subscribers);
1199
- echo "<span class=\"submit\"><form method=\"post\" action=\"\">\r\n";
1200
- if (function_exists('wp_nonce_field')) {
1201
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1202
- }
1203
- echo "<input type=\"hidden\" name=\"exportcsv\" value=\"$exportcsv\" />\r\n";
1204
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"exportcsv\" />\r\n";
1205
- echo "<input type=\"submit\" name=\"submit\" value=\"" . __('Save Emails to CSV File','subscribe2') . "\" />\r\n";
1206
- echo "</form></span>\r\n";
1207
- }
1208
}
1209
echo "<table cellpadding=\"2\" cellspacing=\"2\">";
1210
- if (!empty($subscribers)) {
1211
foreach ($subscribers as $subscriber) {
1212
echo "<tr class=\"$alternate\">";
1213
echo "<td width=\"75%\"";
@@ -1219,30 +1121,12 @@ class subscribe2 {
1219
echo "align=\"left\" colspan=\"3\">";
1220
}
1221
echo "<a href=\"mailto:$subscriber\">$subscriber</a>\r\n";
1222
- if (in_array($subscriber, $unconfirmed) || in_array($subscriber, $confirmed) ) {
1223
- echo "(" . $this->signup_date($subscriber) . ")</td>\r\n";
1224
- echo "<td width=\"5%\" align=\"center\">\r\n";
1225
- echo "<form method=\"post\" action=\"\">";
1226
- if (function_exists('wp_nonce_field')) {
1227
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1228
- }
1229
- echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1230
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"toggle\" />\r\n";
1231
- echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1232
- echo "<input type=\"submit\" name=\"submit\" value=\"";
1233
(in_array($subscriber, $unconfirmed)) ? $foo = '&lt;-' : $foo= '-&gt;';
1234
- echo "$foo\" /></form></td>\r\n";
1235
- echo "<td width=\"2%\" align=\"center\">\r\n";
1236
- echo "<form method=\"post\" action=\"\">\r\n";
1237
- if (function_exists('wp_nonce_field')) {
1238
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1239
- }
1240
- echo "<span class=\"delete\">\r\n";
1241
- echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1242
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"delete\" />\r\n";
1243
- echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1244
- echo "<input type=\"submit\" name=\"submit\" value=\"X\" />\r\n";
1245
- echo "</span></form>";
1246
}
1247
echo "</td></tr>\r\n";
1248
('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
@@ -1251,16 +1135,7 @@ class subscribe2 {
1251
echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1252
}
1253
echo "</table>";
1254
- if ($reminderform) {
1255
- echo "<span class=\"submit\"><form method=\"post\" action=\"\">\r\n";
1256
- if (function_exists('wp_nonce_field')) {
1257
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1258
- }
1259
- echo "<input type=\"hidden\" name=\"reminderemails\" value=\"$reminderemails\" />\r\n";
1260
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"remind\" />\r\n";
1261
- echo "<input type=\"submit\" name=\"submit\" value=\"" . __('Send Reminder Email','subscribe2') . "\" />\r\n";
1262
- echo "</form></span>";
1263
- }
1264
echo "</div>\r\n";
1265
1266
//show bulk managment form
@@ -1268,12 +1143,8 @@ class subscribe2 {
1268
echo "<h2 >" . __('Categories', 'subscribe2') . "</h2>\r\n";
1269
echo __('Existing Registered Users can be automatically (un)subscribed to categories using this section.', 'subscribe2') . "<br />\r\n";
1270
echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1271
- echo "<span class=\"submit\"><form method=\"post\" action=\"\">\r\n";
1272
- if (function_exists('wp_nonce_field')) {
1273
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1274
- }
1275
- echo "<input type=\"hidden\" name=\"emails\" value=\"$emails\" /><input type=\"hidden\" name=\"s2_admin\" value=\"register\" />";
1276
- $this->display_category_form();
1277
echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Subscribe','subscribe2') . "\" />";
1278
echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Unsubscribe','subscribe2') . "\" /></form></span>";
1279
@@ -1289,106 +1160,85 @@ class subscribe2 {
1289
Our options page
1290
*/
1291
function options_menu() {
1292
- global $s2nonce;
1293
-
1294
// was anything POSTed?
1295
if (isset($_POST['s2_admin'])) {
1296
- check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
1297
if ('RESET' == $_POST['s2_admin']) {
1298
$this->reset();
1299
echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_reset</p></strong></div>";
1300
} elseif ('options' == $_POST['s2_admin']) {
1301
// excluded categories
1302
- if (!empty($_POST['category'])) {
1303
$exclude_cats = implode(',', $_POST['category']);
1304
} else {
1305
$exclude_cats = '';
1306
}
1307
- $this->subscribe2_options['exclude'] = $exclude_cats;
1308
// allow override?
1309
- (isset($_POST['reg_override'])) ? $override = '1' : $override = '0';
1310
- $this->subscribe2_options['reg_override'] = $override;
1311
1312
// show button?
1313
- ($_POST['show_button'] == '1') ? $showbutton = '1' : $showbutton = '0';
1314
- $this->subscribe2_options['show_button'] = $showbutton;
1315
1316
// send as author or admin?
1317
$sender = 'author';
1318
- if ('admin' == $_POST['sender']) {
1319
$sender = 'admin';
1320
}
1321
- $this->subscribe2_options['sender'] = $sender;
1322
-
1323
- // send per-post or digest emails
1324
- $email_freq = $_POST['email_freq'];
1325
- $this->subscribe2_options['email_freq'] = $email_freq;
1326
- wp_clear_scheduled_hook('s2_digest_cron');
1327
- $scheds = (array) wp_get_schedules();
1328
- $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
1329
- if ($interval == 0) {
1330
- // if we are on per-post emails remove last_cron entry
1331
- unset($this->subscribe2_options['last_s2cron']);
1332
- } else {
1333
- if (!wp_next_scheduled('s2_digest_cron')) {
1334
- // if we are using digest schedule the event and prime last_cron as now
1335
- wp_schedule_event(time() + $interval, $email_freq, 's2_digest_cron');
1336
- $now = date('Y-m-d H:i:s', time());
1337
- $this->subscribe2_options['last_s2cron'] = $now;
1338
- }
1339
- }
1340
1341
// email templates
1342
- $mailtext = $_POST['mailtext'];
1343
- $this->subscribe2_options['mailtext'] = $mailtext;
1344
- $confirm_email = $_POST['confirm_email'];
1345
- $this->subscribe2_options['confirm_email'] = $confirm_email;
1346
- $remind_email = $_POST['remind_email'];
1347
- $this->subscribe2_options['remind_email'] = $remind_email;
1348
1349
//automatic subscription
1350
- $autosub_option = $_POST['autosub'];
1351
- $this->subscribe2_options['autosub']= $autosub_option;
1352
- $autosub_format_option = $_POST['autoformat'];
1353
- $this->subscribe2_options['autoformat']= $autosub_format_option;
1354
1355
//barred domains
1356
- $barred_option = $_POST['barred'];
1357
- $this->subscribe2_options['barred'] = $barred_option;
1358
echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_saved</p></strong></div>";
1359
- update_option('subscribe2_options', $this->subscribe2_options);
1360
}
1361
}
1362
// show our form
1363
echo "<div class=\"wrap\">";
1364
- echo "<form method=\"post\" action=\"\">\r\n";
1365
- if (function_exists('wp_nonce_field')) {
1366
- wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1367
- }
1368
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
1369
- echo "<h2>" . __('Delivery Options', 'subscribe2') . ":</h2>\r\n";
1370
echo __('Send Email From', 'subscribe2') . ': ';
1371
- echo "<input type=\"radio\" name=\"sender\" value=\"author\"";
1372
- if ('author' == $this->subscribe2_options['sender']) {
1373
echo "checked=\"checked\" ";
1374
}
1375
echo " /> " . __('Author of the post', 'subscribe2') . " &nbsp;&nbsp;";
1376
- echo "<input type=\"radio\" name=\"sender\" value=\"admin\"";
1377
- if ('admin' == $this->subscribe2_options['sender']) {
1378
echo "checked=\"checked\" ";
1379
}
1380
- echo " /> " . __('Blog Admin', 'subscribe2') . "<br /><br />\r\n";
1381
- if (function_exists('wp_schedule_event')) {
1382
- echo __('Send Email as Digest', 'subscribe2') . ": <br /><br />\r\n";
1383
- $this->display_digest_choices();
1384
- echo "<br />\r\n";
1385
- }
1386
echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
1387
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
1388
echo "<tr><td>";
1389
echo __('New Post email (must not be empty)', 'subscribe2') . ":";
1390
echo "<br />\r\n";
1391
- echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
1392
echo "</td><td valign=\"top\" rowspan=\"3\">";
1393
echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
1394
echo "<dl>";
@@ -1399,66 +1249,64 @@ class subscribe2 {
1399
echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink", 'subscribe2') . "</dd>\r\n";
1400
echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
1401
echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
1402
- echo "<dt><b>AUTHORNAME</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
1403
- 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";
1404
- 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";
1405
echo "</dl></td></tr><tr><td>";
1406
echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
1407
- echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
1408
- echo "</td></tr><tr valign=\"top\"><td>";
1409
echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
1410
- echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
1411
- echo "</td></tr></table><br />\r\n";
1412
1413
// excluded categories
1414
echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
1415
$this->display_category_form(explode(',', $this->get_excluded_cats()));
1416
- echo "<center><input type=\"checkbox\" name=\"reg_override\" value=\"1\"";
1417
- if ('1' == $this->subscribe2_options['reg_override']) {
1418
- echo " checked=\"checked\"";
1419
}
1420
- echo " /> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</center><br />\r\n";
1421
echo "<h2>" . __('Writing Options', 'subscribe2') . "</h2>\r\n";
1422
- echo "<input type=\"checkbox\" name=\"show_button\" value=\"1\"";
1423
- if ('1' == $this->subscribe2_options['show_button']) {
1424
- echo " checked=\"checked\"";
1425
}
1426
- echo " /> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "<br /><br />\r\n";
1427
1428
//Auto Subscription for new registrations
1429
echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
1430
echo __('Automatically subscribe new users registering with your blog.', 'subscribe2') . "<br />\r\n";
1431
- echo "<input type=\"radio\" name=\"autosub\" value=\"yes\"";
1432
- if ('yes' == $this->subscribe2_options['autosub']) {
1433
- echo " checked=\"checked\"";
1434
}
1435
echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1436
- echo "<input type=\"radio\" name=\"autosub\" value=\"no\"";
1437
- if ('no' == $this->subscribe2_options['autosub']) {
1438
- echo " checked=\"checked\"";
1439
}
1440
echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1441
echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
1442
- echo "<input type=\"radio\" name=\"autoformat\" value=\"html\"";
1443
- if ('html' == $this->subscribe2_options['autoformat']) {
1444
echo "checked=\"checked\" ";
1445
}
1446
echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1447
- echo "<input type=\"radio\" name=\"autoformat\" value=\"fulltext\" ";
1448
- if ('fulltext' == $this->subscribe2_options['autoformat']) {
1449
echo "checked=\"checked\" ";
1450
}
1451
echo "/> " . __('Plain Text - Full', 'subscribe2') . " &nbsp;&nbsp;";
1452
- echo "<input type=\"radio\" name=\"autoformat\" value=\"text\" ";
1453
- if ('text' == $this->subscribe2_options['autoformat']) {
1454
echo "checked=\"checked\" ";
1455
}
1456
- echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . " <br /><br />";
1457
1458
//barred domains
1459
echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
1460
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');
1461
- echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
1462
1463
// submit
1464
echo "<p align=\"center\"><span class=\"submit\"><input type=\"submit\" id=\"save\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></span></p>";
@@ -1469,9 +1317,6 @@ class subscribe2 {
1469
echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
1470
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";
1471
echo "<form method=\"post\" action=\"\">";
1472
- if (function_exists('wp_nonce_field')) {
1473
- wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1474
- }
1475
echo "<p align=\"center\"><span class=\"submit\">";
1476
echo "<input type=\"hidden\" name=\"s2_admin\" value=\"RESET\" />";
1477
echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('RESET', 'subscribe2') .
@@ -1487,14 +1332,12 @@ class subscribe2 {
1487
Our profile menu
1488
*/
1489
function user_menu() {
1490
- global $user_ID, $s2nonce;
1491
1492
get_currentuserinfo();
1493
1494
// was anything POSTed?
1495
if ( (isset($_POST['s2_admin'])) && ('user' == $_POST['s2_admin']) ) {
1496
- check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
1497
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
1498
$format = 'text';
1499
$post = 'post';
1500
if ('html' == $_POST['s2_format']) {
@@ -1505,7 +1348,6 @@ class subscribe2 {
1505
}
1506
update_usermeta($user_ID, 's2_excerpt', $post);
1507
update_usermeta($user_ID, 's2_format', $format);
1508
- update_usermeta($user_ID, 's2_autosub', $_POST['new_category']);
1509
1510
$cats = $_POST['category'];
1511
if (empty($cats)) {
@@ -1515,21 +1357,21 @@ class subscribe2 {
1515
delete_usermeta($user_ID, "s2_cat" . $cat);
1516
}
1517
}
1518
- delete_usermeta($user_ID, 's2_subscribed');
1519
} else {
1520
- if (!is_array($cats)) {
1521
$cats = array($_POST['category']);
1522
}
1523
$old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1524
$remove = array_diff($old_cats, $cats);
1525
$new = array_diff($cats, $old_cats);
1526
- if (!empty($remove)) {
1527
// remove subscription to these cat IDs
1528
foreach ($remove as $id) {
1529
delete_usermeta($user_ID, "s2_cat" .$id);
1530
}
1531
}
1532
- if (!empty($new)) {
1533
// add subscription to these cat IDs
1534
foreach ($new as $id) {
1535
update_usermeta($user_ID, 's2_cat' . $id, "$id");
@@ -1543,11 +1385,8 @@ class subscribe2 {
1543
echo "<div class=\"wrap\">";
1544
echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
1545
echo "<form method=\"post\" action=\"\">";
1546
- if (function_exists('wp_nonce_field')) {
1547
- wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
1548
- }
1549
echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
1550
- if ($this->subscribe2_options['email_freq'] == 'never') {
1551
echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
1552
echo "<input type=\"radio\" name=\"s2_format\" value=\"html\"";
1553
if ('html' == get_usermeta($user_ID, 's2_format')) {
@@ -1569,28 +1408,18 @@ class subscribe2 {
1569
}
1570
echo " /> $value ";
1571
}
1572
- echo "<p style=\"color: red\">" . __('Note: HTML format will always deliver the full post.', 'subscribe2') . "</p>\r\n";
1573
- echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
1574
- echo "<input type=\"radio\" name=\"new_category\" value=\"yes\" ";
1575
- if ('yes' == get_usermeta($user_ID, 's2_autosub')) {
1576
- echo "checked=\"yes\" ";
1577
- }
1578
- echo "/> Yes <input type=\"radio\" name=\"new_category\" value=\"no\" ";
1579
- if ('no' == get_usermeta($user_ID, 's2_autosub')) {
1580
- echo "checked=\"yes\" ";
1581
- }
1582
- echo "/> No<br /><br />";
1583
1584
// subscribed categories
1585
echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
1586
- $this->display_category_form(explode(',', get_usermeta($user_ID, 's2_subscribed')), $this->subscribe2_options['reg_override']);
1587
} else {
1588
// we're doing daily digests, so just show
1589
// subscribe / unnsubscribe
1590
echo __('Receive daily summary of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
1591
- echo "<input type=\"radio\" name=\"category\" value=\"1\" ";
1592
- if (get_usermeta($user_ID, 's2_subscribed')) {
1593
- echo "checked=\"yes\" ";
1594
}
1595
echo "/> Yes <input type=\"radio\" name=\"category\" value=\"\" ";
1596
if (! get_usermeta($user_ID, 's2_subscribed')) {
@@ -1612,11 +1441,8 @@ class subscribe2 {
1612
Display the Write sub-menu
1613
*/
1614
function write_menu() {
1615
- global $wpdb, $s2nonce;
1616
-
1617
// was anything POSTed?
1618
if (isset($_POST['s2_admin']) && ('mail' == $_POST['s2_admin']) ) {
1619
- check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
1620
if ('confirmed' == $_POST['what']) {
1621
$recipients = $this->get_public();
1622
} elseif ('unconfirmed' == $_POST['what']) {
@@ -1636,7 +1462,7 @@ class subscribe2 {
1636
$this->myname = $user_identity;
1637
$this->myemail = $user_email;
1638
$subject = strip_tags($_POST['subject']);
1639
- $message = stripslashes($_POST['message']);
1640
$this->mail($recipients, $subject, $message, 'text');
1641
$message = $this->mail_sent;
1642
}
@@ -1647,9 +1473,6 @@ class subscribe2 {
1647
// show our form
1648
echo "<div class=\"wrap\"><h2>" . __('Send email to all subscribers', 'subscribe2') . "</h2>\r\n";
1649
echo "<form method=\"post\" action=\"\">\r\n";
1650
- if (function_exists('wp_nonce_field')) {
1651
- wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
1652
- }
1653
echo __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . __('A message from ', 'subscribe2') . get_settings('blogname') . "\" /> <br />";
1654
echo "<textarea rows=\"12\" cols=\"75\" name=\"message\"></textarea>";
1655
echo "<br />\r\n";
@@ -1668,13 +1491,13 @@ class subscribe2 {
1668
/* ===== helper functions: forms and stuff ===== */
1669
/**
1670
Display a table of categories with checkboxes
1671
Optionally pre-select those categories specified
1672
*/
1673
function display_category_form($selected = array(), $override = 1) {
1674
global $wpdb;
1675
1676
- $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
1677
-
1678
if (0 == $override) {
1679
// registered users are not allowed to subscribe to
1680
// excluded categories
@@ -1688,34 +1511,30 @@ class subscribe2 {
1688
$half = (count($all_cats) / 2);
1689
$i = 0;
1690
$j = 0;
1691
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
1692
- echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
1693
- foreach ($all_cats as $cat) {
1694
if ( ($i >= $half) && (0 == $j) ){
1695
- echo "</td><td width=\"50%\" align=\"left\">\r\n";
1696
$j++;
1697
}
1698
if (0 == $j) {
1699
- echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->cat_ID . "\"";
1700
- if (in_array($cat->cat_ID, $selected)) {
1701
echo " checked=\"checked\" ";
1702
}
1703
- echo " /> " . $cat->cat_name . "<br />\r\n";
1704
} else {
1705
1706
- echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->cat_ID . "\"";
1707
- if (in_array($cat->cat_ID, $selected)) {
1708
echo " checked=\"checked\" ";
1709
}
1710
- echo " /> " . $cat->cat_name . "<br />\r\n";
1711
}
1712
$i++;
1713
}
1714
- echo "</td></tr>\r\n";
1715
- echo "<tr><td align=\"left\">\r\n";
1716
- echo "<input type=\"checkbox\" name=\"checkall\" onclick=\"setAll(this)\" /> " . __('Select / Unselect All' ,'subscribe2') . "\r\n";
1717
- echo "</td></tr>\r\n";
1718
- echo "</table>\r\n";
1719
} // end display_category_form()
1720
1721
/**
@@ -1732,8 +1551,6 @@ class subscribe2 {
1732
'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
1733
'registered' => __('Registered Subscribers', 'subscribe2'));
1734
1735
- $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
1736
-
1737
// count the number of subscribers
1738
$count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
1739
$count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
@@ -1746,8 +1563,8 @@ class subscribe2 {
1746
}
1747
$count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='s2_subscribed'");
1748
$count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['registered']);
1749
- foreach ($all_cats as $cat) {
1750
- $count[$cat->cat_name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='s2_cat$cat->cat_ID'");
1751
}
1752
1753
// do have actually have some subscribers?
@@ -1764,17 +1581,18 @@ class subscribe2 {
1764
if (in_array($whom, $exclude)) { continue; }
1765
if (0 == $count[$whom]) { continue; }
1766
1767
- echo "<option value=\"" . $whom . "\"";
1768
if ($whom == $selected) { echo " selected=\"selected\" "; }
1769
echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
1770
}
1771
1772
if ($count['registered'] > 0) {
1773
- foreach ($all_cats as $cat) {
1774
- if (in_array($cat->cat_ID, $exclude)) { continue; }
1775
- echo "<option value=\"" . $cat->cat_ID . "\"";
1776
- if ($cat->cat_ID == $selected) { echo " selected=\"selected\" "; }
1777
- echo "> &nbsp;&nbsp;" . $cat->cat_name . "&nbsp;(" . $count[$cat->cat_name] . ") </option>\r\n";
1778
}
1779
}
1780
echo "</select>";
@@ -1783,51 +1601,22 @@ class subscribe2 {
1783
}
1784
} // end display_subscriber_dropdown()
1785
1786
- function display_digest_choices() {
1787
- global $wpdb;
1788
- $schedule = (array)wp_get_schedules();
1789
- $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('Per Post Email','subscribe2'))), $schedule);
1790
- $sort = array();
1791
- foreach ( (array)$schedule as $key => $value ) $sort[$key] = $value['interval'];
1792
- asort($sort);
1793
- $schedule_sorted = array();
1794
- foreach ($sort as $key => $value) {
1795
- $schedule_sorted[$key] = $schedule[$key];
1796
- }
1797
- foreach ($schedule_sorted as $key => $value) {
1798
- echo "<input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"";
1799
- if ($key == $this->subscribe2_options['email_freq']) {
1800
- echo " checked=\"checked\" ";
1801
- }
1802
- echo " /> " . $value['display'] . "<br />\r\n";
1803
- }
1804
- if (wp_next_scheduled('s2_digest_cron')) {
1805
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
1806
- echo "<p>" . __('Next email notification will be sent', 'subscribe2') . ": \r\n";
1807
- echo "<strong>" . gmdate($datetime, wp_next_scheduled('s2_digest_cron') + (get_option('gmt_offset') * 3600)) . "</strong></p>\r\n";
1808
- }
1809
- } // end display_digest_choices()
1810
-
1811
/* ===== template and filter functions ===== */
1812
/**
1813
Display our form; also handles (un)subscribe requests
1814
*/
1815
function filter($content = '') {
1816
- if ( ('' == $content) || (! preg_match('|<!--subscribe2-->|', $content)) ) { return $content; }
1817
$this->s2form = $this->form;
1818
1819
global $user_ID;
1820
get_currentuserinfo();
1821
if ($user_ID) {
1822
- if (current_user_can('manage_options')) {
1823
- $this->s2form = $this->use_profile_admin;
1824
- } else {
1825
- $this->s2form = $this->use_profile_users;
1826
- }
1827
}
1828
if (isset($_POST['s2_action'])) {
1829
global $wpdb, $user_email;
1830
- if (!is_email($_POST['email'])) {
1831
$this->s2form = $this->form . $this->not_an_email;
1832
} elseif ($this->is_barred($_POST['email'])) {
1833
$this->s2form = $this->form . $this->barred_domain;
@@ -1885,7 +1674,7 @@ class subscribe2 {
1885
1886
global $wpdb;
1887
1888
- if ( (defined('S2PAGE')) && (0 !== S2PAGE) ) {
1889
return "page_id=" . S2PAGE;
1890
} else {
1891
$id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status='static' LIMIT 1");
@@ -1916,23 +1705,49 @@ class subscribe2 {
1916
} // end template_filter()
1917
1918
/* ===== wp-cron functions ===== */
1919
/**
1920
Send a daily digest of today's new posts
1921
*/
1922
- function subscribe2_cron() {
1923
global $wpdb;
1924
1925
- // collect posts
1926
- $now = date('Y-m-d H:i:s', time());
1927
- $prev = $this->subscribe2_options['last_s2cron'];
1928
- $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'");
1929
1930
- // update last_s2cron execution time before completing or bailing
1931
- $this->subscribe2_options['last_s2cron'] = $now;
1932
- update_option('subscribe2_options', $this->subscribe2_options);
1933
-
1934
// do we have any posts?
1935
- if (empty($posts)) { return; }
1936
1937
// if we have posts, let's prepare the digest
1938
foreach ($posts as $post) {
@@ -1951,7 +1766,7 @@ class subscribe2 {
1951
if ($check) {
1952
continue;
1953
}
1954
- $message .= $post->post_title . "\r\n";
1955
$message .= get_permalink($post->ID) . "\r\n";
1956
$excerpt = $post->post_excerpt;
1957
if ('' == $excerpt) {
@@ -1970,33 +1785,51 @@ class subscribe2 {
1970
}
1971
}
1972
}
1973
- $message .= $excerpt . "\r\n\r\n";
1974
}
1975
1976
- $author = get_userdata($post->post_author);
1977
-
1978
// do we send as admin, or post author?
1979
- if ('author' == $this->subscribe2_options['sender']) {
1980
// get author details
1981
- $user =& $author;
1982
} else {
1983
// get admin detailts
1984
$user = get_userdata(1);
1985
}
1986
- $this->myemail = $user->user_email;
1987
- $this->myname = $user->display_name;
1988
-
1989
- $scheds = (array) wp_get_schedules();
1990
- $email_freq = $this->subscribe2_options['email_freq'];
1991
- $display = $scheds[$email_freq]['display'];
1992
- $subject = '[' . stripslashes(get_settings('blogname')) . '] ' . $display . ' ' . __('Digest Email', 'subscribe2');
1993
$public = $this->get_public();
1994
$registered = $this->get_registered();
1995
$recipients = array_merge((array)$public, (array)$registered);
1996
- $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
1997
$body = str_replace('POST', $message, $mailtext);
1998
$this->mail($recipients, $subject, $body);
1999
- } // end subscribe2_cron
2000
2001
/* ===== Our constructor ===== */
2002
/**
@@ -2007,17 +1840,12 @@ class subscribe2 {
2007
2008
load_plugin_textdomain('subscribe2', 'wp-content/plugins/subscribe2');
2009
2010
- // load the options
2011
- $this->subscribe2_options = array();
2012
- $this->subscribe2_options = get_option('subscribe2_options');
2013
-
2014
// do we need to install anything?
2015
$this->public = $table_prefix . "subscribe2";
2016
- if(mysql_query("SELECT COUNT(*) FROM ".$this->public)==FALSE) { $this->install(); }
2017
//do we need to upgrade anything?
2018
- if ($this->subscribe2_options['version'] !== S2VERSION) {
2019
- $this->upgrade();
2020
- }
2021
2022
if (isset($_GET['s2'])) {
2023
// someone is confirming a request
@@ -2026,21 +1854,22 @@ class subscribe2 {
2026
add_filter('the_content', array(&$this, 'confirm'));
2027
}
2028
2029
- add_action('admin_head', array(&$this, 'admin_head'));
2030
add_action('admin_menu', array(&$this, 'admin_menu'));
2031
add_action('user_register', array(&$this, 'register'));
2032
- add_action('create_category', array(&$this, 'autosub_new_category'));
2033
add_filter('the_content', array(&$this, 'filter'));
2034
- add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
2035
-
2036
- if ($this->subscribe2_options['email_freq'] != 'never') {
2037
- add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
2038
- } else {
2039
- add_action('publish_post', array(&$this, 'publish'));
2040
- add_action('edit_post', array(&$this, 'edit'));
2041
- add_action('private_to_published', array(&$this, 'private2publish'));
2042
}
2043
-
2044
// load our strings
2045
$this->load_strings();
2046
} // end subscribe2()
@@ -2082,5 +1911,7 @@ class subscribe2 {
2082
var $confirm_subject = '';
2083
var $options_saved = '';
2084
var $options_reset = '';
2085
} // end class subscribe2
2086
?>
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.7
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
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', '107');
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.7');
51
52
// start our class
53
class subscribe2 {
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=subscribe2/subscribe2.php\">profile</a>.</p>";
65
66
$this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
67
86
87
$this->confirm_subject = "[" . get_settings('blogname') . "] " . __('Please confirm your request', 'subscribe2');
88
89
// menu strings
90
$this->options_saved = __('Options saved!', 'subscribe2');
91
$this->options_reset = __('Options reset!', 'subscribe2');
96
Hook the menu
97
*/
98
function admin_menu() {
99
+ add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", basename(__FILE__), array(&$this, 'manage_menu'));
100
+ add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2','subscribe2'), "manage_options", basename(__FILE__), array(&$this, 'options_menu'));
101
+ add_submenu_page('profile.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
102
+ add_submenu_page('post.php', __('Mail Subscribers','subscribe2'), __('Mail Subscribers', 'subscribe2'),"manage_options", __FILE__, array(&$this, 'write_menu'));
103
}
104
105
+ /* ===== ButtonSnap configuration ===== */
106
/**
107
+ Register our button in the QuickTags bar
108
*/
109
+ function s2_button_init() {
110
+ $url = get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_button.png';
111
+ buttonsnap_textbutton($url, 'Subscribe2', '<!--subscribe2-->');
112
+ buttonsnap_register_marker('subscribe2', 's2_marker');
113
}
114
115
+ /**
116
+ Style a marker in the Rich Text Editor for our tag
117
+
118
+ By default, the RTE suppresses output of HTML comments, so this places a CSS style on our token in order to make it display
119
+ */
120
+ function subscribe2_css() {
121
+ $marker_url = get_settings('siteurl') . '/wp-content/plugins/subscribe2/s2_marker.png';
122
+ echo "
123
+ .s2_marker {
124
+ display: block;
125
+ height: 45px;
126
+ margin-top: 5px;
127
+ background-image: url({$marker_url});
128
+ background-repeat: no-repeat;
129
+ background-position: center;
130
+ }
131
+ ";
132
}
133
134
/* ===== Install, upgrade, reset ===== */
137
*/
138
function install() {
139
// include upgrade-functions for maybe_create_table;
140
+ if (! function_exists('maybe_create_table')) {
141
require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
142
}
143
$date = date('Y-m-d');
160
global $wpdb;
161
162
// include upgrade-functions for maybe_create_table;
163
+ if (! function_exists('maybe_create_table')) {
164
require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
165
}
166
$date = date('Y-m-d');
167
maybe_add_column($this->public, 'date', "ALTER TABLE `$this->public` ADD `date` DATE DEFAULT '$date' NOT NULL AFTER `active`;");
168
+ //add reminder email template info for version 2.2.4
169
+ $s2_remind_email = get_option('s2_remind_email');
170
+ if (empty($s2_remind_email)) {
171
+ update_option('s2_remind_email', "This email address was subscribed for notifications at BLOGNAME (BLOGLINK) but the subscription remains incomplete.\n\nIf you wish to complete your subscription please click on the link below:\n\nLINK\n\nIf you do not wish to complete your subscription please ignore this email and your address will be removed from our database.\n\nRegards,\nMYNAME");
172
+ }
173
+ update_option('s2_version', S2VERSION);
174
175
// let's take the time to check process registered users
176
+ // existing public subscribers are subscribed to all categories
177
+ $check = $wpdb->get_col("SELECT ID FROM $wpdb->users");
178
+ if (! empty($check)) {
179
+ foreach ($check as $user) {
180
$this->register($user);
181
}
182
}
183
} // end upgrade()
184
185
/**
186
Reset our options
187
*/
188
function reset() {
189
+ update_option('s2_sender', 'author');
190
+ update_option('s2_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");
191
+ update_option('s2_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.");
192
+ update_option('s2_remind_email', "This email address was subscribed for notifications at BLOGNAME (BLOGLINK) but the subscription remains incomplete.\n\nIf you wish to complete your subscription please click on the link below:\n\nLINK\n\nIf you do not wish to complete your subscription please ignore this email and your address will be removed from our database.\n\nRegards,\nMYNAME");
193
+ update_option('s2_exclude', '');
194
+ update_option('s2_reg_override', '1');
195
+ update_option('s2_show_button', '1');
196
+ update_option('s2_barred', '');
197
+ } // end reset()
198
199
/* ===== mail handling ===== */
200
/**
210
$string = str_replace('PERMALINK', $this->permalink, $string);
211
$string = str_replace('MYNAME', stripslashes($this->myname), $string);
212
$string = str_replace('EMAIL', $this->myemail, $string);
213
return $string;
214
} // end sustitute()
215
217
Delivers email to recipients in HTML or plaintext
218
*/
219
function mail ($recipients = array(), $subject = '', $message = '', $type='text') {
220
+ if (empty($recipients)) { return; }
221
+ if ('' == $message) { return; }
222
+
223
// Set sender details
224
if ('' == $this->myname) {
225
+ $admin = get_userdata('1');
226
$this->myname = $admin->display_name;
227
$this->myemail = $admin->user_email;
228
}
246
247
// BCC all recipients
248
$bcc = '';
249
+ if ( (defined('DREAMHOST') && true == DREAMHOST) &&
250
+ (count($recipients) > 30) ) {
251
// we're on Dreamhost, and have more than 30 susbcribers
252
$count = 1;
253
$batch = array();
254
foreach ($recipients as $recipient) {
255
// advance the array pointer by one, for use down below
256
// the array pointer _is not_ advanced by the foreach() loop itself
257
+ next($recipients);
258
+ $recipient = trim($recipient);
259
+ // sanity check -- make sure we have a valid email
260
+ if (! is_email($recipient)) { continue; }
261
+ // and NOT the sender's email, since they'll
262
+ // get a copy anyway
263
+ if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
264
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
265
+ // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
266
+ }
267
+ if (30 == $count) {
268
+ $count = 1;
269
+ $batch[] = $bcc;
270
+ $bcc = '';
271
} else {
272
+ if (false == current($recipients)) {
273
+ // we've reached the end of the subscriber list
274
+ // add what we have to the batch, and move on
275
+ $batch[] = $bcc;
276
+ break;
277
+ } else {
278
+ $count++;
279
+ }
280
}
281
}
282
// rewind the array, just to be safe
283
reset($recipients);
284
} else {
285
// we're not on dreamhost, or have less than 30
286
// subscribers, so do it normal
287
+ foreach ($recipients as $recipient) {
288
+ $recipient = trim($recipient);
289
+ // sanity check -- make sure we have a valid email
290
+ if (! is_email($recipient)) { continue; }
291
// and NOT the sender's email, since they'll
292
// get a copy anyway
293
+ if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
294
('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
295
// Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
296
}
297
+ }
298
+ $headers .= "$bcc\r\n";
299
}
300
// actually send mail
301
+ if ( (defined('DREAMHOST') && true == DREAMHOST) && (isset($batch)) ) {
302
+ foreach ($batch as $bcc) {
303
+ $newheaders = $headers . "$bcc\r\n";
304
+ @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
305
+ }
306
+ } else {
307
+ @wp_mail($this->myemail, $subject, $mailtext, $headers);
308
}
309
} // end mail()
310
311
/**
312
Sends an email notification of a new post
313
*/
314
+ function publish($id = 0, $cron = 0) {
315
+ if (! $id) { return $id; }
316
317
// are we doing daily digests? If so, don't send anything now
318
+ if ( defined('S2DIGEST') && true == S2DIGEST ) { return; }
319
320
// we need to determine whether this is a new post, or an edit
321
+ if (0 == $cron) {
322
+ // we're not being called from WP-Cron
323
+ if ($this->private) {
324
+ // this post was published from draft status
325
+ // OR is an edit of an existing post
326
+ // so send no notification
327
+ return $id;
328
+ }
329
}
330
331
$post_cats = wp_get_post_cats('1', $id);
342
if ($check) {
343
// hang on -- can registered users subscribe to
344
// excluded categories?
345
+ if ('0' == get_option('s2_reg_override')) {
346
// nope? okay, let's leave
347
return $id;
348
}
349
}
350
351
global $wpdb;
352
+ $post = & get_post($id);
353
// is this post set in the future?
354
if ($post->post_date > current_time('mysql')) {
355
+ // is wp-cron installed?
356
+ if (function_exists('wp_cron_init')) {
357
+ // are we doing daily digests?
358
+ if ( defined('S2DIGEST') && false == S2DIGEST ) {
359
+ // not doing daily digests, so
360
+ // add this post to the list of
361
+ // future posts
362
+ $our_post = array('id' => $id, 'date' => $post->post_date);
363
+ $future_posts = get_option('s2_future_posts');
364
+ $future_posts[] = $our_post;
365
+ update_option('s2_future_posts', $future_posts);
366
+ }
367
+ }
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
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
}
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
// do we send as admin, or post author?
393
+ if ('author' == get_option('s2_sender')) {
394
// get author details
395
+ $user = get_userdata($post->post_author);
396
} else {
397
+ // get admin detailts
398
$user = get_userdata(1);
399
}
400
$this->myemail = $user->user_email;
402
// Get email subject
403
$subject = $this->substitute(stripslashes($this->s2_subject));
404
// Get the message template
405
+ $mailtext = $this->substitute(stripslashes(get_option('s2_mailtext')));
406
407
$plaintext = $post->post_content;
408
$content = apply_filters('the_content', $post->post_content);
419
// no <!--more-->, so grab the first 55 words
420
$excerpt = strip_tags($plaintext);
421
$excerpt_length = 55;
422
+ $words = explode(' ', $plaintext, $excerpt_length + 1);
423
if (count($words) > $excerpt_length) {
424
array_pop($words);
425
array_push($words, '[...]');
454
/**
455
Sends a notification when a draft post is published
456
*/
457
+ function private2publish($ID = 0) {
458
+ if (0 == $ID) { return $ID; }
459
460
+ $this->publish($ID);
461
$this->private = TRUE;
462
+ return $ID;
463
} // end private2publish()
464
465
/**
466
Prevents notifications from being sent when editing posts
467
*/
468
+ function edit($ID = 0) {
469
+ if (0 == $ID) { return; }
470
471
$this->private = TRUE;
472
+ return $ID;
473
}
474
475
/**
477
*/
478
function send_confirm($what = '', $is_remind = FALSE) {
479
if ($this->filtered == 1) { return; }
480
+ if ( (! $this->email) || (! $what) ) {
481
return false;
482
}
483
$id = $this->get_id($this->email);
484
+ if (! $id) {
485
return false;
486
}
487
501
502
$admin = get_userdata(1);
503
$this->myname = $admin->display_name;
504
+
505
if ($is_remind == TRUE) {
506
+ $body = $this->substitute(get_option('s2_remind_email'));
507
+ $subject = __('Subscription Reminder', 'subscribe2');
508
} else {
509
+ $body = $this->substitute(get_option('s2_confirm_email'));
510
+ $subject = $this->substitute($this->confirm_subject);
511
}
512
513
$body = str_replace("LINK", $link, $body);
514
515
+ $mailheaders .= "MIME-Version: 1.0\n";
516
+ $mailheaders .= "Content-type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
517
+ $mailheaders .= "From: $admin->display_name <$admin->user_email>";
518
$mailheaders .= "Return-Path: <$admin->user_email>\n";
519
$mailheaders .= "X-Mailer:PHP" . phpversion() . "\n";
520
$mailheaders .= "Precedence: list\nList-Id: " . get_settings('blogname') . "\n";
521
522
@wp_mail ($this->email, $subject, $body, $mailheaders);
523
} // end send_confirm()
531
return $this->excluded_cats;
532
} else {
533
global $wpdb;
534
+ $this->excluded_cats = get_option('s2_exclude');
535
return $this->excluded_cats;
536
}
537
} // end get_excluded_cats()
560
function get_email ($id = 0) {
561
global $wpdb;
562
563
+ if (! $id) {
564
return false;
565
}
566
return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
572
function get_id ($email = '') {
573
global $wpdb;
574
575
+ if (! $email) {
576
return false;
577
}
578
return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
617
}
618
}
619
620
+ if (! is_email($email)) { return false; }
621
622
if (false !== $this->is_public($email)) {
623
$wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE email='$email'");
640
}
641
}
642
643
+ if (! is_email($email)) { return false; }
644
$wpdb->get_results("DELETE FROM $this->public WHERE email='$email'");
645
} // end delete()
646
673
$this->myname = $admin->display_name;
674
675
$recipients = explode(",", $emails);
676
+ if (! is_array($recipients)) { $recipients = array(); }
677
foreach ($recipients as $recipient) {
678
$this->email = $recipient;
679
$this->send_confirm('add', TRUE);
680
}
681
} //end remind()
682
683
/**
684
Check email is not from a barred domain
685
*/
686
function is_barred($email='') {
687
+ $barred_option = get_option('s2_barred');
688
list($user, $domain) = split('@', $email);
689
$bar_check = stristr($barred_option, $domain);
690
710
$id = intval(substr($code, 1));
711
if ($id) {
712
$this->email = $this->get_email($id);
713
+ if (! $this->email) {
714
return $this->no_such_email;
715
}
716
} else {
801
$subscribers = array();
802
803
parse_str($args, $r);
804
+ if (! isset($r['cats']))
805
$r['cats'] = '';
806
+ if (! isset($r['format']))
807
$r['format'] = 'all';
808
+ if (! isset($r['amount']))
809
$r['amount'] = 'all';
810
811
$JOIN = ''; $AND = '';
855
if ('' == $email) { return false; }
856
857
global $wpdb;
858
+ if (! empty($this->signup_dates)) {
859
return $this->signup_dates[$email];
860
} else {
861
$results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
875
876
if (0 == $user_id) { return $user_id; }
877
$user = get_userdata($user_id);
878
879
// has this user previously signed up for email notification?
880
if (false !== $this->is_public($user->user_email)) {
881
// delete this user from the public table, and subscribe them to all the categories
882
$this->delete($user->user_email);
883
+ update_usermeta($user_id, 's2_subscribed', $this->get_all_categories());
884
+ foreach(explode(',', $this->get_all_categories()) as $cat) {
885
+ update_usermeta($user_id, 's2_cat' . $cat, "$cat");
886
}
887
update_usermeta($user_id, 's2_format', 'text');
888
update_usermeta($user_id, 's2_excerpt', 'excerpt');
891
$check = get_usermeta($user_id, 's2_subscribed');
892
// ensure existing subscriptions are not overwritten on upgrade
893
if (empty($check)) {
894
+ if ('yes' == get_option('s2_autosub')) {
895
update_usermeta($user_id, 's2_subscribed', $this->get_all_categories());
896
foreach(explode(',', $this->get_all_categories()) as $cat) {
897
update_usermeta($user_id, 's2_cat' . $cat, "$cat");
898
}
899
+ if ('html' == get_option('s2_autoformat')) {
900
update_usermeta($user_id, 's2_format', 'html');
901
+ update_usermeta($user_id, 's2_excerpt', 'full');
902
+ } elseif ('fulltext' == get_option('s2_autoformat')) {
903
update_usermeta($user_id, 's2_format', 'text');
904
+ update_usermeta($user_id, 's2_excerpt', 'full');
905
} else {
906
update_usermeta($user_id, 's2_format', 'text');
907
update_usermeta($user_id, 's2_excerpt', 'excerpt');
908
}
909
+ } else {
910
+ update_usermeta($user_id, 's2_subscribed', '');
911
+ update_usermeta($user_id, 's2_format', 'text');
912
+ update_usermeta($user_id, 's2_excerpt', 'excerpt');
913
+ }
914
}
915
}
916
return $user_id;
920
Subscribe all registered users to category selected on Admin Manage Page
921
*/
922
function subscribe_registered_users ($emails = '', $cats = '') {
923
+ if (('' == $emails) || ('' == $cats)) { return false; }
924
global $wpdb;
925
926
$useremails = explode(",", $emails);
929
$sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
930
$user_IDs = $wpdb->get_col($sql);
931
$cats = $_POST['category'];
932
+ if (! is_array($cats)) {
933
$cats = array($_POST['category']);
934
}
935
936
foreach ($user_IDs as $user_ID) {
937
$old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
938
+ if (! is_array($old_cats)) {
939
$old_cats = array($old_cats);
940
}
941
$new = array_diff($cats, $old_cats);
942
+ if (! empty($new)) {
943
// add subscription to these cat IDs
944
foreach ($new as $id) {
945
update_usermeta($user_ID, 's2_cat' . $id, "$id");
954
Unsubscribe all registered users to category selected on Admin Manage Page
955
*/
956
function unsubscribe_registered_users ($emails = '', $cats = '') {
957
+ if (('' == $emails) || ('' == $cats)) { return false; }
958
global $wpdb;
959
960
$useremails = explode(",", $emails);
963
$sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
964
$user_IDs = $wpdb->get_col($sql);
965
$cats = $_POST['category'];
966
+ if (! is_array($cats)) {
967
$cats = array($_POST['category']);
968
}
969
970
foreach ($user_IDs as $user_ID) {
971
$old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
972
+ if (! is_array($old_cats)) {
973
$old_cats = array($old_cats);
974
}
975
$remain = array_diff($old_cats, $cats);
976
+ if (! empty($remain)) {
977
// remove subscription to these cat IDs and update s2_subscribed
978
foreach ($cats as $id) {
979
delete_usermeta($user_ID, 's2_cat' . $id, "$id");
988
}
989
}
990
} // end unsubscribe_registered_users
991
992
/* ===== Menus ===== */
993
/**
994
Our management page
995
*/
996
function manage_menu() {
997
+ global $wpdb;
998
999
//Get Registered Subscribers for bulk management
1000
$registered = $this->get_registered();
1001
+ if(!empty($registered)) {
1002
$emails = implode(",", $registered);
1003
}
1004
1005
$what = '';
1006
+ $reminderform = '';
1007
1008
// was anything POSTed ?
1009
if (isset($_POST['s2_admin'])) {
1010
if ('subscribe' == $_POST['s2_admin']) {
1011
foreach (preg_split ("/[\s,]+/", $_POST['addresses']) as $email) {
1012
if (is_email($email)) {
1024
} elseif ('remind' == $_POST['s2_admin']) {
1025
$this->remind($_POST['reminderemails']);
1026
echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Reminder Email(s) Sent!','subscribe2') . "</p></strong></div>";
1027
} elseif ( ('register' == $_POST['s2_admin']) && ('Subscribe' == $_POST['submit']) ) {
1028
$this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1029
echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Subscribed!','subscribe2') . "</p></strong></div>";
1054
$subscribers = $unconfirmed;
1055
if (!empty($unconfirmed)) {
1056
$reminderemails = implode(",", $unconfirmed);
1057
+ $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>";
1058
}
1059
} elseif (is_numeric($_POST['what'])) {
1060
$what = intval($_POST['what']);
1071
$confirmed = $this->get_public();
1072
$subscribers = $confirmed;
1073
$what = 'confirmed';
1074
+ if (empty ($subscribers)) {
1075
$unconfirmed = $this->get_public(0);
1076
$subscribers = $unconfirmed;
1077
$what = 'unconfirmed';
1081
}
1082
}
1083
}
1084
+ if (! empty($subscribers)) {
1085
natcasesort($subscribers);
1086
}
1087
// safety check for our arrays
1093
echo "<div class=\"wrap\">";
1094
echo "<h2>" . __('Subscribe Addresses', 'subscribe2') . "</h2>\r\n";
1095
echo "<form method=\"post\" action=\"\">\r\n";
1096
echo "<span style=\"align:left\">" . __('Enter addresses, one per line or comma-seperated', 'subscribe2') . "</span><br />\r\n";
1097
echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea>";
1098
echo "<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Subscribe', 'subscribe2') . "\"/>";
1105
$this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1106
// show the selected subscribers
1107
$alternate = 'alternate';
1108
+ if (! empty($subscribers)) {
1109
echo "<p align=\"center\"><b>" . __('Registered on the left, confirmed in the middle, unconfirmed on the right', 'subscribe2') . "</b></p>";
1110
}
1111
echo "<table cellpadding=\"2\" cellspacing=\"2\">";
1112
+ if (! empty($subscribers)) {
1113
foreach ($subscribers as $subscriber) {
1114
echo "<tr class=\"$alternate\">";
1115
echo "<td width=\"75%\"";
1121
echo "align=\"left\" colspan=\"3\">";
1122
}
1123
echo "<a href=\"mailto:$subscriber\">$subscriber</a>\r\n";
1124
+ if ( in_array($subscriber, $unconfirmed) || in_array($subscriber, $confirmed) ) {
1125
+ echo "(" . $this->signup_date($subscriber) . ")</td>";
1126
+ 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=\"";
1127
(in_array($subscriber, $unconfirmed)) ? $foo = '&lt;-' : $foo= '-&gt;';
1128
+ echo "$foo\" /></form></td>";
1129
+ 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>";
1130
}
1131
echo "</td></tr>\r\n";
1132
('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1135
echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1136
}
1137
echo "</table>";
1138
+ if (!empty($reminderform)) {echo $reminderform;}
1139
echo "</div>\r\n";
1140
1141
//show bulk managment form
1143
echo "<h2 >" . __('Categories', 'subscribe2') . "</h2>\r\n";
1144
echo __('Existing Registered Users can be automatically (un)subscribed to categories using this section.', 'subscribe2') . "<br />\r\n";
1145
echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1146
+ echo "<span class=\"submit\"><form method=\"post\" action=\"\"><input type=\"hidden\" name=\"emails\" value=\"$emails\" /><input type=\"hidden\" name=\"s2_admin\" value=\"register\" />";
1147
+ $this->display_category_form(explode(',', $this->get_excluded_cats()));
1148
echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Subscribe','subscribe2') . "\" />";
1149
echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Unsubscribe','subscribe2') . "\" /></form></span>";
1150
1160
Our options page
1161
*/
1162
function options_menu() {
1163
// was anything POSTed?
1164
if (isset($_POST['s2_admin'])) {
1165
if ('RESET' == $_POST['s2_admin']) {
1166
$this->reset();
1167
echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_reset</p></strong></div>";
1168
} elseif ('options' == $_POST['s2_admin']) {
1169
// excluded categories
1170
+ if (! empty($_POST['category'])) {
1171
$exclude_cats = implode(',', $_POST['category']);
1172
} else {
1173
$exclude_cats = '';
1174
}
1175
+ update_option('s2_exclude', $exclude_cats);
1176
// allow override?
1177
+ (isset($_POST['override'])) ? $override = '1' : $override = '0';
1178
+ update_option('s2_reg_override', $override);
1179
1180
// show button?
1181
+ (isset($_POST['showbutton'])) ? $showbutton = '1' : $showbutton = '0';
1182
+ update_option('s2_show_button', $showbutton);
1183
1184
// send as author or admin?
1185
$sender = 'author';
1186
+ if ('admin' == $_POST['s2_sender']) {
1187
$sender = 'admin';
1188
}
1189
+ update_option('s2_sender', $sender);
1190
1191
// email templates
1192
+ $mailtext = $_POST['s2_mailtext'];
1193
+ update_option('s2_mailtext', $mailtext);
1194
+ $confirm_email = $_POST['s2_confirm_email'];
1195
+ update_option('s2_confirm_email', $confirm_email);
1196
+ $remind_email = $_POST['s2_remind_email'];
1197
+ update_option('s2_remind_email', $remind_email);
1198
1199
//automatic subscription
1200
+ $autosub_option = $_POST['s2_autosub'];
1201
+ update_option('s2_autosub', $autosub_option);
1202
+ $autosub_format_option = $_POST['s2_autoformat'];
1203
+ update_option('s2_autoformat', $autosub_format_option);
1204
1205
//barred domains
1206
+ $barred_option = $_POST['s2_barred'];
1207
+ update_option('s2_barred', $barred_option);
1208
echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_saved</p></strong></div>";
1209
}
1210
}
1211
// show our form
1212
+ $this->sender = get_option('s2_sender');
1213
+ $this->mailtext = get_option('s2_mailtext');
1214
+ $this->confirm_email = get_option('s2_confirm_email');
1215
+ $this->remind_email = get_option('s2_remind_email');
1216
+ $this->override = get_option('s2_reg_override');
1217
+ $this->show_button = get_option('s2_show_button');
1218
+ $this->autosub = get_option('s2_autosub');
1219
+ $this->barred_option = get_option('s2_barred');
1220
+
1221
echo "<div class=\"wrap\">";
1222
+ echo "<form method=\"post\" action=\"\">";
1223
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />";
1224
+ echo "<h2>" . __('Delivery Options', 'subscribe2') . ":</h2>";
1225
echo __('Send Email From', 'subscribe2') . ': ';
1226
+ echo "<input type=\"radio\" name=\"s2_sender\" value=\"author\" ";
1227
+ if ('author' == $this->sender) {
1228
echo "checked=\"checked\" ";
1229
}
1230
echo " /> " . __('Author of the post', 'subscribe2') . " &nbsp;&nbsp;";
1231
+ echo "<input type=\"radio\" name=\"s2_sender\" value=\"admin\" ";
1232
+ if ('admin' == $this->sender) {
1233
echo "checked=\"checked\" ";
1234
}
1235
+ echo " /> " . __('Blog Admin', 'subscribe2') . "<br />\r\n";
1236
echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
1237
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">";
1238
echo "<tr><td>";
1239
echo __('New Post email (must not be empty)', 'subscribe2') . ":";
1240
echo "<br />\r\n";
1241
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"s2_mailtext\">" . stripslashes($this->mailtext) . "</textarea><p>\r\n";
1242
echo "</td><td valign=\"top\" rowspan=\"3\">";
1243
echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
1244
echo "<dl>";
1249
echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink", 'subscribe2') . "</dd>\r\n";
1250
echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
1251
echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
1252
+ 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";
1253
echo "</dl></td></tr><tr><td>";
1254
echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
1255
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"s2_confirm_email\">" . stripslashes($this->confirm_email) . "</textarea><p>";
1256
+ echo "</td></tr><tr><td>";
1257
echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
1258
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"s2_remind_email\">" . stripslashes($this->remind_email) . "</textarea><p>";
1259
+ echo "</td></tr></table>\r\n";
1260
1261
// excluded categories
1262
echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
1263
$this->display_category_form(explode(',', $this->get_excluded_cats()));
1264
+ echo "<p align=\"center\"><input type=\"checkbox\" name=\"override\" ";
1265
+ if ('1' == $this->override) {
1266
+ echo "checked=\"checked\"";
1267
}
1268
+ echo "/> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</p>";
1269
echo "<h2>" . __('Writing Options', 'subscribe2') . "</h2>\r\n";
1270
+ echo "<p align=\"center\"><input type=\"checkbox\" name=\"showbutton\" ";
1271
+ if ('1' == $this->show_button) {
1272
+ echo "checked=\"checked\"";
1273
}
1274
+ echo "/> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "</p>";
1275
1276
//Auto Subscription for new registrations
1277
echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
1278
echo __('Automatically subscribe new users registering with your blog.', 'subscribe2') . "<br />\r\n";
1279
+ echo "<input type=\"radio\" name=\"s2_autosub\" value=\"yes\" ";
1280
+ if ('yes' == $this->autosub) {
1281
+ echo "checked=\"checked\" ";
1282
}
1283
echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1284
+ echo "<input type=\"radio\" name=\"s2_autosub\" value=\"no\" ";
1285
+ if ('no' == $this->autosub) {
1286
+ echo "checked=\"checked\" ";
1287
}
1288
echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1289
echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
1290
+ echo "<input type=\"radio\" name=\"s2_autoformat\" value=\"html\"";
1291
+ if ('html' == get_option('s2_autoformat')) {
1292
echo "checked=\"checked\" ";
1293
}
1294
echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1295
+ echo "<input type=\"radio\" name=\"s2_autoformat\" value=\"fulltext\" ";
1296
+ if ('fulltext' == get_option('s2_autoformat')) {
1297
echo "checked=\"checked\" ";
1298
}
1299
echo "/> " . __('Plain Text - Full', 'subscribe2') . " &nbsp;&nbsp;";
1300
+ echo "<input type=\"radio\" name=\"s2_autoformat\" value=\"text\" ";
1301
+ if ('text' == get_option('s2_autoformat')) {
1302
echo "checked=\"checked\" ";
1303
}
1304
+ echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . " &nbsp;&nbsp;";
1305
1306
//barred domains
1307
echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
1308
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');
1309
+ echo "<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"s2_barred\">" . $this->barred_option . "</textarea>";
1310
1311
// submit
1312
echo "<p align=\"center\"><span class=\"submit\"><input type=\"submit\" id=\"save\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></span></p>";
1317
echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
1318
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";
1319
echo "<form method=\"post\" action=\"\">";
1320
echo "<p align=\"center\"><span class=\"submit\">";
1321
echo "<input type=\"hidden\" name=\"s2_admin\" value=\"RESET\" />";
1322
echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('RESET', 'subscribe2') .
1332
Our profile menu
1333
*/
1334
function user_menu() {
1335
+ global $user_ID;
1336
1337
get_currentuserinfo();
1338
1339
// was anything POSTed?
1340
if ( (isset($_POST['s2_admin'])) && ('user' == $_POST['s2_admin']) ) {
1341
$format = 'text';
1342
$post = 'post';
1343
if ('html' == $_POST['s2_format']) {
1348
}
1349
update_usermeta($user_ID, 's2_excerpt', $post);
1350
update_usermeta($user_ID, 's2_format', $format);
1351
1352
$cats = $_POST['category'];
1353
if (empty($cats)) {
1357
delete_usermeta($user_ID, "s2_cat" . $cat);
1358
}
1359
}
1360
+ update_usermeta($user_ID, 's2_subscribed', '');
1361
} else {
1362
+ if (! is_array($cats)) {
1363
$cats = array($_POST['category']);
1364
}
1365
$old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1366
$remove = array_diff($old_cats, $cats);
1367
$new = array_diff($cats, $old_cats);
1368
+ if (! empty($remove)) {
1369
// remove subscription to these cat IDs
1370
foreach ($remove as $id) {
1371
delete_usermeta($user_ID, "s2_cat" .$id);
1372
}
1373
}
1374
+ if (! empty($new)) {
1375
// add subscription to these cat IDs
1376
foreach ($new as $id) {
1377
update_usermeta($user_ID, 's2_cat' . $id, "$id");
1385
echo "<div class=\"wrap\">";
1386
echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
1387
echo "<form method=\"post\" action=\"\">";
1388
echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
1389
+ if ( defined('S2DIGEST') && FALSE == S2DIGEST ) {
1390
echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
1391
echo "<input type=\"radio\" name=\"s2_format\" value=\"html\"";
1392
if ('html' == get_usermeta($user_ID, 's2_format')) {
1408
}
1409
echo " /> $value ";
1410
}
1411
+ echo __('<p>Note: HTML format will always deliver the full post.</p>', 'subscribe2');
1412
1413
// subscribed categories
1414
echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
1415
+ $this->display_category_form(explode(',', get_usermeta($user_ID, 's2_subscribed')), get_option('s2_reg_override'));
1416
} else {
1417
// we're doing daily digests, so just show
1418
// subscribe / unnsubscribe
1419
echo __('Receive daily summary of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
1420
+ echo "<input type=\"radio\" name=\"category\" value=\"1\" ";
1421
+ if (get_usermeta($user_ID, 's2_subscribed')) {
1422
+ echo "checked=\"yes\" ";
1423
}
1424
echo "/> Yes <input type=\"radio\" name=\"category\" value=\"\" ";
1425
if (! get_usermeta($user_ID, 's2_subscribed')) {
1441
Display the Write sub-menu
1442
*/
1443
function write_menu() {
1444
// was anything POSTed?
1445
if (isset($_POST['s2_admin']) && ('mail' == $_POST['s2_admin']) ) {
1446
if ('confirmed' == $_POST['what']) {
1447
$recipients = $this->get_public();
1448
} elseif ('unconfirmed' == $_POST['what']) {
1462
$this->myname = $user_identity;
1463
$this->myemail = $user_email;
1464
$subject = strip_tags($_POST['subject']);
1465
+ $message = $_POST['message'];
1466
$this->mail($recipients, $subject, $message, 'text');
1467
$message = $this->mail_sent;
1468
}
1473
// show our form
1474
echo "<div class=\"wrap\"><h2>" . __('Send email to all subscribers', 'subscribe2') . "</h2>\r\n";
1475
echo "<form method=\"post\" action=\"\">\r\n";
1476
echo __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . __('A message from ', 'subscribe2') . get_settings('blogname') . "\" /> <br />";
1477
echo "<textarea rows=\"12\" cols=\"75\" name=\"message\"></textarea>";
1478
echo "<br />\r\n";
1491
/* ===== helper functions: forms and stuff ===== */
1492
/**
1493
Display a table of categories with checkboxes
1494
+
1495
Optionally pre-select those categories specified
1496
*/
1497
function display_category_form($selected = array(), $override = 1) {
1498
global $wpdb;
1499
1500
+ $all_cats = $this->get_all_categories('array');
1501
if (0 == $override) {
1502
// registered users are not allowed to subscribe to
1503
// excluded categories
1511
$half = (count($all_cats) / 2);
1512
$i = 0;
1513
$j = 0;
1514
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">";
1515
+ echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">";
1516
+ foreach ($all_cats as $cat_ID => $cat_name) {
1517
if ( ($i >= $half) && (0 == $j) ){
1518
+ echo "</td><td width=\"50%\" align=\"left\">";
1519
$j++;
1520
}
1521
if (0 == $j) {
1522
+ echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat_ID . "\"";
1523
+ if (in_array($cat_ID, $selected)) {
1524
echo " checked=\"checked\" ";
1525
}
1526
+ echo " /> " . $cat_name . "<br />\r\n";
1527
} else {
1528
1529
+ echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat_ID . "\"";
1530
+ if (in_array($cat_ID, $selected)) {
1531
echo " checked=\"checked\" ";
1532
}
1533
+ echo " /> " . $cat_name . "<br />\r\n";
1534
}
1535
$i++;
1536
}
1537
+ echo "</td></tr></table>\r\n";
1538
} // end display_category_form()
1539
1540
/**
1551
'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
1552
'registered' => __('Registered Subscribers', 'subscribe2'));
1553
1554
// count the number of subscribers
1555
$count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
1556
$count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
1563
}
1564
$count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='s2_subscribed'");
1565
$count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['registered']);
1566
+ foreach ($this->get_all_categories('array') as $cat_ID => $cat_name) {
1567
+ $count[$cat_name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='s2_cat$cat_ID'");
1568
}
1569
1570
// do have actually have some subscribers?
1581
if (in_array($whom, $exclude)) { continue; }
1582
if (0 == $count[$whom]) { continue; }
1583
1584
+ echo "<option value=\"$whom\"";
1585
if ($whom == $selected) { echo " selected=\"selected\" "; }
1586
echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
1587
}
1588
1589
if ($count['registered'] > 0) {
1590
+ foreach ($this->get_all_categories('array') as $cat_ID => $cat_name) {
1591
+ if (in_array($cat_ID, $exclude)) { continue; }
1592
+ if (0 == $count[$cat_name]) { continue; }
1593
+ echo "<option value=\"$cat_ID\"";
1594
+ if ($cat_ID == $selected) { echo " selected=\"selected\" "; }
1595
+ echo "> &nbsp;&nbsp;$cat_name (" . $count[$cat_name] . ") </option>\r\n";
1596
}
1597
}
1598
echo "</select>";
1601
}
1602
} // end display_subscriber_dropdown()
1603
1604
/* ===== template and filter functions ===== */
1605
/**
1606
Display our form; also handles (un)subscribe requests
1607
*/
1608
function filter($content = '') {
1609
+ if (('' == $content) || (! preg_match('|<!--subscribe2-->|', $content))) { return $content; }
1610
$this->s2form = $this->form;
1611
1612
global $user_ID;
1613
get_currentuserinfo();
1614
if ($user_ID) {
1615
+ $this->s2form = $this->use_profile;
1616
}
1617
if (isset($_POST['s2_action'])) {
1618
global $wpdb, $user_email;
1619
+ if (! is_email($_POST['email'])) {
1620
$this->s2form = $this->form . $this->not_an_email;
1621
} elseif ($this->is_barred($_POST['email'])) {
1622
$this->s2form = $this->form . $this->barred_domain;
1674
1675
global $wpdb;
1676
1677
+ if ( defined('S2PAGE') && 0 !== S2PAGE ) {
1678
return "page_id=" . S2PAGE;
1679
} else {
1680
$id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status='static' LIMIT 1");
1705
} // end template_filter()
1706
1707
/* ===== wp-cron functions ===== */
1708
+ /**
1709
+ Send notifications for any posts that are now visible
1710
+ */
1711
+ function subscribe2_hourly() {
1712
+ $future_posts = get_option('s2_future_posts');
1713
+
1714
+ // if we have no future posts, bail out
1715
+ if (! $future_posts) { return; }
1716
+
1717
+ // this will hold the posts that aren't yet visible
1718
+ $not_yet = array();
1719
+
1720
+ foreach ($future_posts as $post) {
1721
+ if ( current_time('mysql') > $post['date'] ) {
1722
+ // this post is now visible, so let's
1723
+ // send a notification
1724
+ $this->publish($post['id'], 1);
1725
+ } else {
1726
+ array_push($not_yet, $post);
1727
+ }
1728
+ }
1729
+ // are the number of elements in $not_yet
1730
+ // the same as in $future posts?
1731
+ if ( count($not_yet) != count($future_posts) ) {
1732
+ // if not, then some posts have been removed
1733
+ // from $future_posts, and the remainder need
1734
+ // to be recorded back to the database
1735
+ update_option('s2_future_posts', $not_yet);
1736
+ }
1737
+ } // end subscribe2_hourly
1738
+
1739
/**
1740
Send a daily digest of today's new posts
1741
*/
1742
+ function subscribe2_daily() {
1743
global $wpdb;
1744
1745
+ // collect yesterday's posts
1746
+ $yesterday = date('Y-m-d', (get_option('wp_cron_daily_lastrun')-60));
1747
+ $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'");
1748
1749
// do we have any posts?
1750
+ if (! $posts) { return; }
1751
1752
// if we have posts, let's prepare the digest
1753
foreach ($posts as $post) {
1766
if ($check) {
1767
continue;
1768
}
1769
+ $message .= "$post->post_title\r\n";
1770
$message .= get_permalink($post->ID) . "\r\n";
1771
$excerpt = $post->post_excerpt;
1772
if ('' == $excerpt) {
1785
}
1786
}
1787
}
1788
+ $message .= "$excerpt\r\n\r\n";
1789
}
1790
1791
// do we send as admin, or post author?
1792
+ if ('author' == get_option('s2_sender')) {
1793
// get author details
1794
+ $user = get_userdata($post->post_author);
1795
} else {
1796
// get admin detailts
1797
$user = get_userdata(1);
1798
}
1799
+ $subject = '[' . get_settings('blogname') . '] ' . __('Daily Digest', 'subscribe2') . ' ' . $yesterday;
1800
$public = $this->get_public();
1801
$registered = $this->get_registered();
1802
$recipients = array_merge((array)$public, (array)$registered);
1803
+ $mailtext = $this->substitute(stripslashes(get_option('s2_mailtext')));
1804
$body = str_replace('POST', $message, $mailtext);
1805
$this->mail($recipients, $subject, $body);
1806
+ } // end subscribe2_daily
1807
+
1808
+ /**
1809
+ If the to-be-deleted post was future-dated, remove it from the list of future-dated posts
1810
+ */
1811
+ function delete_future($ID = 0) {
1812
+ if (0 == $ID) { return $ID; }
1813
+
1814
+ $future = get_settings('s2_future_posts');
1815
+ // if we have no future-dated posts scheduled, bail out
1816
+ if ( ! $future) {
1817
+ return $ID;
1818
+ }
1819
+ foreach ($future as $post) {
1820
+ // is the deleted post in the list of future posts?
1821
+ if ($ID == $post['id']) {
1822
+ // skip it
1823
+ continue;
1824
+ } else {
1825
+ // add this to the new list of future posts
1826
+ $new_future[] = $post;
1827
+ }
1828
+ }
1829
+ if ($new_future != $future) {
1830
+ update_option('s2_future_posts', $new_future);
1831
+ }
1832
+ } // end delete_future()
1833
1834
/* ===== Our constructor ===== */
1835
/**
1840
1841
load_plugin_textdomain('subscribe2', 'wp-content/plugins/subscribe2');
1842
1843
// do we need to install anything?
1844
$this->public = $table_prefix . "subscribe2";
1845
+ if(mysql_query("SELECT COUNT(*) FROM ".$this->public)==FALSE) { $this->install(); }
1846
//do we need to upgrade anything?
1847
+ $this->version = get_option('s2_version');
1848
+ if ($this->version !== S2VERSION) { $this->upgrade(); }
1849
1850
if (isset($_GET['s2'])) {
1851
// someone is confirming a request
1854
add_filter('the_content', array(&$this, 'confirm'));
1855
}
1856
1857
add_action('admin_menu', array(&$this, 'admin_menu'));
1858
+ add_action('publish_post', array(&$this, 'publish'));
1859
+ add_action('edit_post', array(&$this, 'edit'));
1860
+ add_action('private_to_published', array(&$this, 'private2publish'));
1861
add_action('user_register', array(&$this, 'register'));
1862
add_filter('the_content', array(&$this, 'filter'));
1863
+ add_action('wp_cron_hourly', array(&$this, 'subscribe2_hourly'));
1864
+ if ( defined('S2DIGEST') && TRUE == S2DIGEST ) {
1865
+ add_action('wp_cron_daily', array(&$this, 'subscribe2_daily'));
1866
+ }
1867
+ add_action('delete_post', array(&$this, 'delete_future'));
1868
+ // add our button
1869
+ if ('1' == get_option('s2_show_button')) {
1870
+ add_action('init', array(&$this, 's2_button_init'));
1871
+ add_action('marker_css', array(&$this, 'subscribe2_css'));
1872
}
1873
// load our strings
1874
$this->load_strings();
1875
} // end subscribe2()
1911
var $confirm_subject = '';
1912
var $options_saved = '';
1913
var $options_reset = '';
1914
+
1915
} // end class subscribe2
1916
+ $mysubscribe2 = new subscribe2();
1917
?>
subscribe2/subscribe2.pot CHANGED
@@ -1,464 +1,410 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
#
6
#, fuzzy
7
msgid ""
8
msgstr ""
9
- "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2007-03-19 19:24+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"
15
"MIME-Version: 1.0\n"
16
"Content-Type: text/plain; charset=CHARSET\n"
17
"Content-Transfer-Encoding: 8bit\n"
18
19
- #: subscribe2.php:103
20
msgid "To manage your subscription options please "
21
msgstr ""
22
23
- #: subscribe2.php:105 subscribe2.php:107
24
msgid "You may manage your subscription options from your "
25
msgstr ""
26
27
- #: subscribe2.php:109
28
msgid "A confirmation message is on its way!"
29
msgstr ""
30
31
- #: subscribe2.php:111
32
msgid "That email address is already subscribed."
33
msgstr ""
34
35
- #: subscribe2.php:113
36
msgid "That email address is not subscribed."
37
msgstr ""
38
39
- #: subscribe2.php:115
40
msgid "Sorry, but that does not look like an email address to me."
41
msgstr ""
42
43
- #: subscribe2.php:117
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:119
50
msgid "Message sent!"
51
msgstr ""
52
53
- #: subscribe2.php:121
54
msgid "Your email:"
55
msgstr ""
56
57
- #: subscribe2.php:121 subscribe2.php:1185 subscribe2.php:1277
58
msgid "Subscribe"
59
msgstr ""
60
61
- #: subscribe2.php:121 subscribe2.php:1278
62
msgid "Unsubscribe"
63
msgstr ""
64
65
- #: subscribe2.php:121 subscribe2.php:1659
66
msgid "Send"
67
msgstr ""
68
69
- #: subscribe2.php:124
70
msgid "No such email address is registered."
71
msgstr ""
72
73
- #: subscribe2.php:126
74
msgid "You have successfully subscribed!"
75
msgstr ""
76
77
- #: subscribe2.php:128
78
msgid "You have successfully unsubscribed."
79
msgstr ""
80