Subscribe2 - Version 4.7

Version Description

Download this release

Release Info

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

Code changes from version 3.8 to 4.7

ReadMe.txt CHANGED
@@ -1,20 +1,22 @@
1
  === Subscribe2 ===
2
- 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
- Stable tag: 3.8
8
 
9
  Sends a list of subscribers an email notification when new posts are published to your blog
10
 
11
  == Description ==
12
 
13
- Subscribe2 provides a comprehensive subscription management system for WordPress blogs that sends email notifications on a per-post or periodical basis to a list of subscribers when you publish new content to your blog. The plugin also handles subscription requests allowing users to publically subscribe by submitting their email address in an easy to use form or to register with your blog which enables greater flexibility for email content for the subscriber. Admins are given control over the presentation of the email notifications, can bulk manage subscriptions for users and manually send email notices to subscribers.
14
 
15
- Subscribe2 supports two classes of subscribers: the general public, and registered users of the blog. The general public may subscribe and unsubscribe. They will receive an email notification whenever a new post is made (unless that post is assigned to one of the excluded categories you defined). The general public will receive a plaintext email with an excerpt of the post: either the excerpt you created when making the post, the portion of text before a <!--more--> tag (if present), or the first 55 words of the post.
16
 
17
- Registered users of the blog can elect to receive email notifications for specific categories. The Users->Subscription menu item will allow them to select the delivery format (plaintext or HTML), amount of message (excerpt or full post), and the categories to which they want to subscribe. You, the blog owner, have the option (Options->Subscribe2) to allow registered users to subscribe to your excluded categories or not.
 
 
18
 
19
  When you post a new item, subscribe2 will generate (at least) one email for each of the following combinations of subscribers:
20
 
@@ -26,27 +28,26 @@ So for each new post you make, you may receive up to three emails.
26
 
27
  == Installation ==
28
 
29
- 1. Copy buttonsnap.php into your /wp-content/plugins directory.
30
- 2. Copy the entire /subscribe2/ directory into your /wp-content/plugins/ directory.
31
- 3. Activate the plugin.
32
- 4. Click the "Options" admin menu link, and select "Subscribe2".
33
- 5. Configure the options to taste, including the email template and any categories which should be excluded from notification
34
- 6. Click the "Manage" admin menu link, and select "Subscribers".
35
- 7. Manually subscribe people as you see fit.
36
- 8. Create a WordPress Page (http://codex.wordpress.org/Pages) to display the subscription form. When creating the page, you may click the "S2" button on the QuickBar to automatically insert the subscribe2 token. Or, if you prefer, you may manually insert the subscribe2 token:
37
  <!--subscribe2-->
38
  ***Ensure the token is on a line by itself and that it has a blank line above and below.***
39
  This token will automatically be replaced by the subscription form, and will display all messages as necessary.
40
- 9. In the subscribe2.php file define S2PAGE to point at your WordPress page created in step 8.
41
 
42
  == Frequently Asked Questions ==
43
 
44
  = Which version should I be using, I'm on WordPress x.x.x? =
45
  WordPress 2.0.x will be supported until 2010. Subscribe2 will remain supported (but not actively developed) until WordPress 2.0.x is no longer supported. For WordPress 2.0.x use the Subscribe code from the 2.x stable.
46
 
47
- WordPress 2.1.x and 2.2.x are also supported. For the latest information visit http://subscribe2.wordpress.com. For versions of WordPress use Subscribe2 code from the 3.x stable.
48
 
49
- Finally, there is a development version for WordPress 2.3 but as WordPress 2.3 is not recommended for active websites you should only get this code from the branch if you are testing it.
50
 
51
  = How do I upgrade from a previous version? =
52
  If you are upgrading from any 2.1.x version of subscribe2, please delete both the /subscribe.php and /wp-content/plugins/subscribe2.php files before copying the new files into place. Your subscriber list will remain intact, and your options should be preserved. Now create a WordPress Page as described above.
@@ -65,7 +66,7 @@ Subscribe2 provides a facility to work around this restriction by sending batche
65
  define('BCCLIMIT', 0);
66
  Change the 0 to the number of allowed outgoing email recipients as set by your host.
67
 
68
- Reminder: because subscribe2 places all recipients in BCC fields, and places the blog admin in the TO field, the blog admin will receive one email per batched delivery. So if you have 90 subscribers, the blog admin should receive three post notification emails, one for eah set of 30 BCC recipients.
69
 
70
  Batches will occur for each group of message as described above. A site on Dreamhost with many public and registered subscribers could conceivably generate a lot of email for your own inbox.
71
 
@@ -78,6 +79,83 @@ Batches will occur for each group of message as described above. A site on Drea
78
 
79
  == Version History ==
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  Version 3.8 by Matthew Robinson
82
 
83
  * Fixed User Menu Settings when Digests enabled
1
  === Subscribe2 ===
2
+ Contributors: MattyRob, Skippy, RavanH
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.5
7
+ Stable tag: 4.7
8
 
9
  Sends a list of subscribers an email notification when new posts are published to your blog
10
 
11
  == Description ==
12
 
13
+ Subscribe2 provides a comprehensive subscription management system for WordPress blogs that sends email notifications to a list of subscribers when you publish new content to your blog. The plugin also handles subscription requests allowing users to publically subscribe by submitting their email address in an easy to use form or to register with your blog which enables greater flexibility for email content for the subscriber. Admins are given control over the presentation of the email notifications, can bulk manage subscriptions for users and manually send email notices to subscribers.
14
 
15
+ Email Notifications can be sent on a per-post basis or periodically in a Digest email. Additionally, certain categories can be excluded from inclusion in the notification and post can be excluded on an individual basis by setting a custom field of 's2mail' to 'no'.
16
 
17
+ Subscribe2 supports two classes of subscribers: the general public, and registered users of the blog. The general public may subscribe and unsubscribe. They will receive a limited email notification when new post is made or periodically (unless that post is assigned to one of the excluded categories you defined). The general public will receive a plaintext email with an excerpt of the post: either the excerpt you created when making the post, the portion of text before a <!--more--> tag (if present), or the first 55 words of the post.
18
+
19
+ Registered users of the blog can elect to receive email notifications for specific categories (unless Digest email are select, then it is an opt in or out decision). The Users->Subscription menu item will allow them to select the delivery format (plaintext or HTML), amount of message (excerpt or full post), and the categories to which they want to subscribe. You, the blog owner, have the option (Options->Subscribe2) to allow registered users to subscribe to your excluded categories or not.
20
 
21
  When you post a new item, subscribe2 will generate (at least) one email for each of the following combinations of subscribers:
22
 
28
 
29
  == Installation ==
30
 
31
+ 1. Copy the entire /subscribe2/ directory into your /wp-content/plugins/ directory.
32
+ 2. Activate the plugin.
33
+ 3. Click the "Options" admin menu link, and select "Subscribe2".
34
+ 4. Configure the options to taste, including the email template and any categories which should be excluded from notification
35
+ 5. Click the "Manage" admin menu link, and select "Subscribers".
36
+ 6. Manually subscribe people as you see fit.
37
+ 7. Create a WordPress Page (http://codex.wordpress.org/Pages) to display the subscription form. When creating the page, you may click the "S2" button on the QuickBar to automatically insert the subscribe2 token. Or, if you prefer, you may manually insert the subscribe2 token:
 
38
  <!--subscribe2-->
39
  ***Ensure the token is on a line by itself and that it has a blank line above and below.***
40
  This token will automatically be replaced by the subscription form, and will display all messages as necessary.
41
+ 8. In the subscribe2.php file define S2PAGE to point at your WordPress page created in step 8.
42
 
43
  == Frequently Asked Questions ==
44
 
45
  = Which version should I be using, I'm on WordPress x.x.x? =
46
  WordPress 2.0.x will be supported until 2010. Subscribe2 will remain supported (but not actively developed) until WordPress 2.0.x is no longer supported. For WordPress 2.0.x use the Subscribe code from the 2.x stable.
47
 
48
+ WordPress 2.1.x and 2.2.x are supported. For the latest information visit http://subscribe2.wordpress.com. For these versions of WordPress use Subscribe2 code from the 3.x stable.
49
 
50
+ Finally, WordPress 2.3 and 2.5 are supported. Again, for the latest information visit http://subscribe2.wordpress.com. For this versions of WordPress use Subscribe2 code from the 4.x stable.
51
 
52
  = How do I upgrade from a previous version? =
53
  If you are upgrading from any 2.1.x version of subscribe2, please delete both the /subscribe.php and /wp-content/plugins/subscribe2.php files before copying the new files into place. Your subscriber list will remain intact, and your options should be preserved. Now create a WordPress Page as described above.
66
  define('BCCLIMIT', 0);
67
  Change the 0 to the number of allowed outgoing email recipients as set by your host.
68
 
69
+ Reminder: because subscribe2 places all recipients in BCC fields, and places the blog admin in the TO field, the blog admin will receive one email per batched delivery. So if you have 90 subscribers, the blog admin should receive three post notification emails, one for each set of 30 BCC recipients.
70
 
71
  Batches will occur for each group of message as described above. A site on Dreamhost with many public and registered subscribers could conceivably generate a lot of email for your own inbox.
72
 
79
 
80
  == Version History ==
81
 
82
+ Version 4.7 by Matthew Robinson
83
+
84
+ * Added admin control over default auto subscribe to new category option
85
+ * Improved Cron code to reduce the chance of duplicate emails
86
+ * Fixed a string that was missed from the translation files
87
+ * Improved time variable handling for cron functions, especially when UTC is different from both server time and blog time
88
+ * Completed code changes to allow WPMU compatibility
89
+ * Fixed some issues with the email headers now that Subscribe2 is using wp_mail() again
90
+
91
+ Version 4.6 by Matthew Robinson
92
+
93
+ * Fixed mis-reporting of server error when unsubscribing
94
+ * Fixed fatal errors involving buttonsnap library
95
+ * Improved database entry management for new subscribers
96
+ * Fixed issue where Subscribe2 grabbed the first page from the database even if it wasn't published
97
+ * Fixed upgrade reporting for Debug and Uninstaller plugins
98
+
99
+ Version 4.5 by Matthew Robinson
100
+
101
+ * Added Support for WordPress 2.5!
102
+ * Fixed HTML typo in admin submission message
103
+ * Fixed time display for cron jobs in Options->Subscribe2 when displayed on blogs using a time offset
104
+ * Added Debug plugin to the download package
105
+ * Improved descriptions of email template keywords in Options->Subscribe2
106
+ * Display subscribers in batches of 50 in Manage->Subscribers
107
+ * Fixed some XHTML validation errors
108
+ * Improved admin menu layout for compliance with WordPress 2.5
109
+ * Reverted to using wp_mail instead of mail to ensure proper header encoding
110
+ * Improved mail header formatting - thanks to Chris Carlson
111
+ * Add ability to skip email notification using a Custom Field (s2mail set as "no")
112
+ * Improved CSV export - thanks to Aaron Axelsen
113
+ * Added some compatibility for WPMU - thanks to Aaron Axelsen
114
+ * Added some error feedback to blog users if mails fail to send
115
+ * Moved Buttonsnap due to far to many fatal error complaints
116
+ * Added option to send notifications for Private posts
117
+ * Improved handling of notification for Password Protected Posts
118
+
119
+ Version 4.4 by Matthew Robinson
120
+
121
+ * Fixed non-substitution of TABLE keyword
122
+ * Fixed bug in usermeta update calls in unsubscribe_registered_users function
123
+ * Fixed bug in array handling in cron function that may have stopped emails sending
124
+ * Improved array handling in the Digest function
125
+ * Added an Un-installer to completely removed Subscribe2 from your WordPress install
126
+
127
+ Version 4.3 by Matthew Robinson
128
+
129
+ * Fixed bug where digest emails were sent to unsubscribed users - Thanks to Mr Papa
130
+ * Stripped slashes from Subject when sending from Write->Mail Subscribers - Thanks to James
131
+ * Ensured all admin pages created by Subscribe2 are valid XHTML 1.0 Transitional code
132
+ * Added default mail templates and other missed string values to i18n files to allow easier first time translation - thanks to Kjell
133
+ * Added option to set the hour for digest email notifications provided the schedule interval is one day or greater
134
+ * Moved option variable declaration to ensure better caching
135
+ * Fixed bug where cron tasks were not removed when options were reset
136
+ * Fixed email notifications for future dated posts
137
+ * Fixed QuickTag Icons and mouse-over floating text
138
+
139
+ Version 4.2 by Matthew Robinson
140
+
141
+ * Added translation capability to user feedback strings - thanks to Lise
142
+ * Corrected some other translation strings
143
+ * Fixed bug in notification emails to admins when new users subscribe
144
+ * Updated default options code
145
+
146
+ Version 4.1 by Matthew Robinson
147
+
148
+ * Fixed sending of notifications for Pages
149
+ * Fixed password protected post bug for Digest email notifications
150
+ * Fixed blank email headers if admin data is not at ID 1
151
+
152
+ Version 4.0 by Matthew Robinson
153
+
154
+ * Compatible with WordPress 2.3
155
+ * Widget Code now integrated into the main plugin and added as an option
156
+ * More Options for Email Notifications
157
+ * Category Lists fixed for WordPress 2.3 and now show empty categories
158
+
159
  Version 3.8 by Matthew Robinson
160
 
161
  * Fixed User Menu Settings when Digests enabled
{subscribe2/include → include}/arrow_left.png RENAMED
File without changes
{subscribe2/include → include}/arrow_right.png RENAMED
File without changes
buttonsnap.php → include/buttonsnap.php RENAMED
File without changes
{subscribe2/include → include}/cross.png RENAMED
File without changes
{subscribe2/include → include}/options.php RENAMED
@@ -1,5 +1,5 @@
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'])) {
@@ -8,12 +8,16 @@ if (!isset($this->subscribe2_options['autosub'])) {
8
 
9
  if (!isset($this->subscribe2_options['wpregdef'])) {
10
  $this->subscribe2_options['wpregdef'] = "no";
11
- } // option to
12
 
13
  if (!isset($this->subscribe2_options['autoformat'])) {
14
  $this->subscribe2_options['autoformat'] = "text";
15
  } // option for default auto-subscription email format
16
 
 
 
 
 
17
  if (!isset($this->subscribe2_options['pages'])) {
18
  $this->subscribe2_options['pages'] = "no";
19
  } // option for sending notifications for WordPress pages
@@ -22,6 +26,10 @@ if (!isset($this->subscribe2_options['password'])) {
22
  $this->subscribe2_options['password'] = "no";
23
  } // option for sending notifications for posts that are password protected
24
 
 
 
 
 
25
  if (!isset($this->subscribe2_options['email_freq'])) {
26
  $this->subscribe2_options['email_freq'] = "never";
27
  } // option for sending emails per-post or as a digest email on a cron schedule
@@ -43,19 +51,23 @@ if (!isset($this->subscribe2_options['show_button'])) {
43
  $this->subscribe2_options['show_button'] = "1";
44
  } // option to show Subscribe2 button on Write page
45
 
 
 
 
 
46
  if (!isset($this->subscribe2_options['barred'])) {
47
  $this->subscribe2_options['barred'] = '';
48
  } // option containing domains barred from public registration
49
 
50
  if (!isset($this->subscribe2_options['mailtext'])) {
51
- $this->subscribe2_options['mailtext'] = "BLOGNAME has posted a new item, 'TITLE'\n\nPOST\n\nYou may view the latest post at\nPERMALINK\n\nYou received this e-mail because you asked to be notified when new updates are posted.\nBest regards,\nMYNAME\nEMAIL";
52
  } // Default notification email text
53
 
54
  if (!isset($this->subscribe2_options['confirm_email'])) {
55
- $this->subscribe2_options['confirm_email'] = "BLOGNAME has received a request to ACTION for this email address. To complete your request please click on the link below:\n\nLINK\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\nMYNAME.";
56
  } // Default confirmation email text
57
 
58
  if (!isset($this->subscribe2_options['remind_email'])) {
59
- $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";
60
  } // Default reminder email text
61
  ?>
1
  <?php
2
+ // include.php - Handles options for subscribe2
3
  // DO NOT EDIT THIS FILE AS IT IS SET BY THE OPTIONS PAGE
4
 
5
  if (!isset($this->subscribe2_options['autosub'])) {
8
 
9
  if (!isset($this->subscribe2_options['wpregdef'])) {
10
  $this->subscribe2_options['wpregdef'] = "no";
11
+ } // option to check registration form box by default
12
 
13
  if (!isset($this->subscribe2_options['autoformat'])) {
14
  $this->subscribe2_options['autoformat'] = "text";
15
  } // option for default auto-subscription email format
16
 
17
+ if (!isset($this->subscribe2_options['autosub_def'])) {
18
+ $this->subscribe2_options['autosub_def'] = "yes";
19
+ } // option for user default auto-subscription to new categories
20
+
21
  if (!isset($this->subscribe2_options['pages'])) {
22
  $this->subscribe2_options['pages'] = "no";
23
  } // option for sending notifications for WordPress pages
26
  $this->subscribe2_options['password'] = "no";
27
  } // option for sending notifications for posts that are password protected
28
 
29
+ if (!isset($this->subscribe2_options['private'])) {
30
+ $this->subscribe2_options['private'] = "no";
31
+ } // option for sending notifications for posts that are private
32
+
33
  if (!isset($this->subscribe2_options['email_freq'])) {
34
  $this->subscribe2_options['email_freq'] = "never";
35
  } // option for sending emails per-post or as a digest email on a cron schedule
51
  $this->subscribe2_options['show_button'] = "1";
52
  } // option to show Subscribe2 button on Write page
53
 
54
+ if (!isset($this->subscribe2_options['widget'])) {
55
+ $this->subscribe2_options['widget'] = "0";
56
+ } // option to enable Subscribe2 Widget
57
+
58
  if (!isset($this->subscribe2_options['barred'])) {
59
  $this->subscribe2_options['barred'] = '';
60
  } // option containing domains barred from public registration
61
 
62
  if (!isset($this->subscribe2_options['mailtext'])) {
63
+ $this->subscribe2_options['mailtext'] = __("BLOGNAME has posted a new item, 'TITLE'\n\nPOST\n\nYou may view the latest post at\nPERMALINK\n\nYou received this e-mail because you asked to be notified when new updates are posted.\nBest regards,\nMYNAME\nEMAIL", "subscribe2");
64
  } // Default notification email text
65
 
66
  if (!isset($this->subscribe2_options['confirm_email'])) {
67
+ $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.", "subscribe2");
68
  } // Default confirmation email text
69
 
70
  if (!isset($this->subscribe2_options['remind_email'])) {
71
+ $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", "subscribe2");
72
  } // Default reminder email text
73
  ?>
{subscribe2/include → include}/s2_button.png RENAMED
File without changes
{subscribe2/include → include}/s2_marker.png RENAMED
File without changes
{subscribe2/include → include}/spacer.gif RENAMED
File without changes
subscribe2/subscribe2.php → subscribe2.php RENAMED
@@ -1,2234 +1,2508 @@
1
- <?php
2
- /*
3
- Plugin Name: Subscribe2
4
- Plugin URI: http://subscribe2.wordpress.com
5
- Description: Notifies an email list when new entries are posted.
6
- Version: 3.8
7
- Author: Matthew Robinson
8
- Author URI: http://subscribe2.wordpress.com
9
- */
10
-
11
- /*
12
- Copyright (C) 2006-7 Matthew Robinson
13
- Based on the Original Subscribe2 plugin by
14
- Copyright (C) 2005 Scott Merrill (skippy@skippy.net)
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
- http://www.gnu.org/licenses/gpl.html
30
- */
31
-
32
- // If you are on a host that limits the number of recipients
33
- // permitted on each outgoing email message
34
- // change the value on the line below to your hosts limit
35
- define('BCCLIMIT', '0');
36
-
37
- // by default, Subscribe2 grabs the first page from your database for use
38
- // when displaying the confirmation screen to public subscribers.
39
- // You can override this by specifying a page ID on the line below.
40
- define('S2PAGE', '0');
41
-
42
- // our version number. Don't touch this or any line below
43
- // unless you know exacly what you are doing
44
- define('S2VERSION', '3.8');
45
- define ('S2PATH', trailingslashit(dirname(__FILE__)));
46
-
47
- // use Owen's excellent ButtonSnap library
48
- require(ABSPATH . 'wp-content/plugins/buttonsnap.php');
49
-
50
- $mysubscribe2 = new s2class;
51
- $mysubscribe2->s2init();
52
-
53
- // start our class
54
- class s2class {
55
- // variables and constructor are declared at the end
56
-
57
- /**
58
- Load all our strings
59
- */
60
- function load_strings() {
61
- // adjust the output of Subscribe2 here
62
-
63
- $this->please_log_in = "<p>" . __('To manage your subscription options please ', 'subscribe2') . "<a href=\"" . get_option('siteurl') . "/wp-login.php\">login</a>.</p>";
64
-
65
- $this->use_profile_admin = "<p>" . __('You may manage your subscription options from your ', 'subscribe2') . "<a href=\"" . get_option('siteurl') . "/wp-admin/users.php?page=" . plugin_basename(__FILE__) . "\">profile</a>.</p>";
66
-
67
- $this->use_profile_users = "<p>" . __('You may manage your subscription options from your ', 'subscribe2') . "<a href=\"" . get_option('siteurl') . "/wp-admin/profile.php?page=" . plugin_basename(__FILE__) . "\">profile</a>.</p>";
68
-
69
- $this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
70
-
71
- $this->already_subscribed = "<p>" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
72
-
73
- $this->not_subscribed = "<p>" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
74
-
75
- $this->not_an_email = "<p>" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
76
-
77
- $this->barred_domain = "<p>" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
78
-
79
- $this->mail_sent = "<p>" . __('Message sent!', 'subscribe2') . "</p>";
80
-
81
- $this->form = "<form method=\"post\" action=\"\">" . __('Your email:', 'subscribe2') . "&#160;<input type=\"text\" name=\"email\" value=\"\" size=\"20\" />&#160;<br /><input type=\"radio\" name=\"s2_action\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . " <input type=\"radio\" name=\"s2_action\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . " &#160;<input type=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></form>\r\n";
82
-
83
- // confirmation messages
84
- $this->no_such_email = "<p>" . __('No such email address is registered.', 'subscribe2') . "</p>";
85
-
86
- $this->added = "<p>" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
87
-
88
- $this->deleted = "<p>" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
89
-
90
- $this->confirm_subject = "[" . get_option('blogname') . "] " . __('Please confirm your request', 'subscribe2');
91
-
92
- $this->remind_subject = "[" . get_option('blogname') . "] " . __('Subscription Reminder', 'subscribe2');
93
-
94
- $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
95
-
96
- $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
97
-
98
- // menu strings
99
- $this->options_saved = __('Options saved!', 'subscribe2');
100
- $this->options_reset = __('Options reset!', 'subscribe2');
101
- } // end load_strings()
102
-
103
- /* ===== WordPress menu registration ===== */
104
- /**
105
- Hook the menu
106
- */
107
- function admin_menu() {
108
- add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", __FILE__, array(&$this, 'manage_menu'));
109
- add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2','subscribe2'), "manage_options", __FILE__, array(&$this, 'options_menu'));
110
- if (current_user_can('manage_options')) {
111
- add_submenu_page('users.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
112
- } else {
113
- add_submenu_page('profile.php', __('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
114
- }
115
- add_submenu_page('post-new.php', __('Mail Subscribers','subscribe2'), __('Mail Subscribers', 'subscribe2'),"manage_options", __FILE__, array(&$this, 'write_menu'));
116
- $s2nonce = md5('subscribe2');
117
- }
118
-
119
- /**
120
- Insert Javascript into admin_header
121
- */
122
- function admin_head() {
123
- echo "<script type=\"text/javascript\">\r\n";
124
- echo "<!--\r\n";
125
- echo "function setAll(theElement) {\r\n";
126
- echo " var theForm = theElement.form, z = 0;\r\n";
127
- echo " for(z=0; z<theForm.length;z++){\r\n";
128
- echo " if(theForm[z].type == 'checkbox' && theForm[z].name == 'category[]'){\r\n";
129
- echo " theForm[z].checked = theElement.checked;\r\n";
130
- echo " }\r\n";
131
- echo " }\r\n";
132
- echo "}\r\n";
133
- echo "-->\r\n";
134
- echo "</script>\r\n";
135
- }
136
-
137
- function add_weekly_sched($sched) {
138
- $sched['weekly'] = array('interval' => 604800, 'display' => __('Once Weekly','subscribe2'));
139
- return $sched;
140
- }
141
-
142
- /* ===== Install, upgrade, reset ===== */
143
- /**
144
- Install our table
145
- */
146
- function install() {
147
- // include upgrade-functions for maybe_create_table;
148
- if (!function_exists('maybe_create_table')) {
149
- require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
150
- }
151
- $date = date('Y-m-d');
152
- $sql = "CREATE TABLE $this->public (
153
- id int(11) NOT NULL auto_increment,
154
- email varchar(64) NOT NULL default '',
155
- active tinyint(1) default 0,
156
- date DATE default '$date' NOT NULL,
157
- PRIMARY KEY (id) )";
158
-
159
- // create the table, as needed
160
- maybe_create_table($this->public, $sql);
161
- $this->reset();
162
- } // end install()
163
-
164
- /**
165
- Upgrade the database
166
- */
167
- function upgrade() {
168
- global $wpdb;
169
-
170
- // include upgrade-functions for maybe_create_table;
171
- if (!function_exists('maybe_create_table')) {
172
- require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
173
- }
174
- $date = date('Y-m-d');
175
- maybe_add_column($this->public, 'date', "ALTER TABLE `$this->public` ADD `date` DATE DEFAULT '$date' NOT NULL AFTER `active`;");
176
-
177
- // let's take the time to check process registered users
178
- // existing public subscribers are subscribed to all categories
179
- $users = $wpdb->get_col("SELECT ID FROM $wpdb->users");
180
- if (!empty($users)) {
181
- foreach ($users as $user) {
182
- $this->register($user);
183
- }
184
- }
185
- // update the options table to serialized format
186
- $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
187
-
188
- if (!empty($old_options)) {
189
- foreach ($old_options as $option) {
190
- $value = get_option($option);
191
- $option_array = substr($option, 3);
192
- $this->subscribe2_options[$option_array] = $value;
193
- delete_option($option);
194
- }
195
- }
196
- $this->subscribe2_options['version'] = S2VERSION;
197
- //double check that the options are in the database
198
- require(S2PATH . "include/options.php");
199
- update_option('subscribe2_options', $this->subscribe2_options);
200
- } // end upgrade()
201
-
202
- /**
203
- Reset our options
204
- */
205
- function reset() {
206
- delete_option('subscribe2_options');
207
- unset($this->subscribe2_options);
208
- require(S2PATH . "include/options.php");
209
- update_option('subscribe2_options', $this->subscribe2_options);
210
- } // end reset()
211
-
212
- /* ===== mail handling ===== */
213
- /**
214
- Performs string substitutions for subscribe2 mail texts
215
- */
216
- function substitute($string = '') {
217
- if ('' == $string) {
218
- return;
219
- }
220
- $string = str_replace("BLOGNAME", get_option('blogname'), $string);
221
- $string = str_replace("BLOGLINK", get_bloginfo('url'), $string);
222
- $string = str_replace("TITLE", stripslashes($this->post_title), $string);
223
- $string = str_replace("PERMALINK", $this->permalink, $string);
224
- $string = str_replace("MYNAME", stripslashes($this->myname), $string);
225
- $string = str_replace("EMAIL", $this->myemail, $string);
226
- $string = str_replace("AUTHORNAME", $this->authorname, $string);
227
- return $string;
228
- } // end substitute()
229
-
230
- /**
231
- Delivers email to recipients in HTML or plaintext
232
- */
233
- function mail ($recipients = array(), $subject = '', $message = '', $type='text') {
234
- if ( (empty($recipients)) || ('' == $message) ) { return; }
235
-
236
- // Set sender details
237
- if ('' == $this->myname) {
238
- $admin = get_userdata(1);
239
- $this->myname = $admin->display_name;
240
- $this->myemail = $admin->user_email;
241
- }
242
- $headers = "From: " . $this->myname . " <" . $this->myemail . ">\n";
243
- $headers .= "Return-Path: <" . $this->myemail . ">\n";
244
- $headers .= "Reply-To: " . $this->myemail . "\n";
245
- $headers .= "X-Mailer:PHP" . phpversion() . "\n";
246
- $headers .= "Precedence: list\nList-Id: " . get_option('blogname') . "\n";
247
-
248
- if ('html' == $type) {
249
- // To send HTML mail, the Content-Type header must be set
250
- $headers .= "MIME-Version: 1.0\n";
251
- $headers .= "Content-Type: " . get_bloginfo('html_type') . "; charset=\"". get_bloginfo('charset') . "\"\n";
252
- $mailtext = "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>";
253
- } else {
254
- $headers .= "MIME-Version: 1.0\n";
255
- $headers .= "Content-Type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
256
- $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
257
- $message = preg_replace('|&amp;|', '&', $message);
258
- $mailtext = wordwrap(strip_tags($message), 80, "\n");
259
- }
260
-
261
- // BCC all recipients
262
- $bcc = '';
263
- if ( (defined('BCCLIMIT')) && (BCCLIMIT > 0) && (count($recipients) > BCCLIMIT) ) {
264
- // we're on Dreamhost, and have more than 30 susbcribers
265
- $count = 1;
266
- $batch = array();
267
- foreach ($recipients as $recipient) {
268
- // advance the array pointer by one, for use down below
269
- // the array pointer _is not_ advanced by the foreach() loop itself
270
- next($recipients);
271
- $recipient = trim($recipient);
272
- // sanity check -- make sure we have a valid email
273
- if (!is_email($recipient)) { continue; }
274
- // and NOT the sender's email, since they'll
275
- // get a copy anyway
276
- if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
277
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
278
- // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
279
- }
280
- if (BCCLIMIT == $count) {
281
- $count = 1;
282
- $batch[] = $bcc;
283
- $bcc = '';
284
- } else {
285
- if (false == current($recipients)) {
286
- // we've reached the end of the subscriber list
287
- // add what we have to the batch, and move on
288
- $batch[] = $bcc;
289
- break;
290
- } else {
291
- $count++;
292
- }
293
- }
294
- }
295
- // rewind the array, just to be safe
296
- reset($recipients);
297
- } else {
298
- // we're not on dreamhost, or have less than 30
299
- // subscribers, so do it normal
300
- foreach ($recipients as $recipient) {
301
- $recipient = trim($recipient);
302
- // sanity check -- make sure we have a valid email
303
- if (!is_email($recipient)) { continue; }
304
- // and NOT the sender's email, since they'll
305
- // get a copy anyway
306
- if ( (!empty($recipient)) && ($this->myemail != $recipient) ) {
307
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ",\r\n $recipient";
308
- // Headers constructed as per definition at http://www.ietf.org/rfc/rfc2822.txt
309
- }
310
- }
311
- $headers .= "$bcc\r\n";
312
- }
313
- // actually send mail
314
- if ( (defined('BCCLIMIT')) && (BCCLIMIT > 0) && (isset($batch)) ) {
315
- foreach ($batch as $bcc) {
316
- $newheaders = $headers . "$bcc\r\n";
317
- @mail($this->myemail, $subject, $mailtext, $newheaders);
318
- }
319
- } else {
320
- @mail($this->myemail, $subject, $mailtext, $headers);
321
- }
322
- return;
323
- } // end mail()
324
-
325
- /**
326
- Sends an email notification of a new post
327
- */
328
- function publish($id = 0) {
329
- if (!$id) { return $id; }
330
-
331
- // are we doing daily digests? If so, don't send anything now
332
- if ($this->subscribe2_options['email_freq'] != 'never') { return $id; }
333
-
334
- // we need to determine whether this is a new post, or an edit
335
- if ($this->private) {
336
- // this post was published from draft status
337
- // OR is an edit of an existing post
338
- // so send no notification
339
- return $id;
340
- }
341
-
342
- $post_cats = wp_get_post_cats('1', $id);
343
- $post_cats_string = implode(',', $post_cats);
344
- $check = false;
345
- // is the current post assigned to any categories
346
- // which should not generate a notification email?
347
- foreach (explode(',', $this->subscribe2_options['exclude']) as $cat) {
348
- if (in_array($cat, $post_cats)) {
349
- $check = true;
350
- }
351
- }
352
- // if so, bail out
353
- if ($check) {
354
- // hang on -- can registered users subscribe to
355
- // excluded categories?
356
- if ('0' == $this->subscribe2_options['reg_override']) {
357
- // nope? okay, let's leave
358
- return $id;
359
- }
360
- }
361
-
362
- global $wpdb;
363
- $post =& get_post($id);
364
- // is the post password protected?
365
- if ( ($this->subscribe2_options['password'] == "no") && ($post->post_password != '') ) {return $id; }
366
-
367
- // is this post set in the future?
368
- if ($post->post_date > current_time('mysql')) {
369
- // bail out
370
- return $id;
371
- }
372
-
373
- // lets collect our public subscribers
374
- // and all our registered subscribers for these categories
375
- if (!$check) {
376
- // if this post is assigned to an excluded
377
- // category, then this test will prevent
378
- // the public from receiving notification
379
- $public = $this->get_public();
380
- }
381
- $registered = $this->get_registered("cats=$post_cats_string");
382
-
383
- // do we have subscribers?
384
- if ( (empty($public)) && (empty($registered)) ) {
385
- // if not, no sense doing anything else
386
- return $id;
387
- }
388
- // we set these class variables so that we can avoid
389
- // passing them in function calls a little later
390
- $this->post_title = $post->post_title;
391
- $this->permalink = "<a href=\"" . get_permalink($id) . "\">" . get_permalink($id) . "</a>";
392
-
393
- $author = get_userdata($post->post_author);
394
- $this->authorname = $author->display_name;
395
-
396
- // do we send as admin, or post author?
397
- if ('author' == $this->subscribe2_options['sender']) {
398
- // get author details
399
- $user =& $author;
400
- } else {
401
- // get admin details
402
- $user = get_userdata(1);
403
- }
404
- $this->myemail = $user->user_email;
405
- $this->myname = $user->display_name;
406
- // Get email subject
407
- $subject = $this->substitute(stripslashes($this->s2_subject));
408
- // Get the message template
409
- $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
410
-
411
- $plaintext = $post->post_content;
412
- $content = apply_filters('the_content', $post->post_content);
413
- $content = str_replace("]]>", "]]&gt", $content);
414
- $excerpt = $post->post_excerpt;
415
- if ('' == $excerpt) {
416
- // no excerpt, is there a <!--more--> ?
417
- if (false !== strpos($plaintext, '<!--more-->')) {
418
- list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
419
- // strip leading and trailing whitespace
420
- $excerpt = strip_tags($excerpt);
421
- $excerpt = trim($excerpt);
422
- } else {
423
- // no <!--more-->, so grab the first 55 words
424
- $excerpt = strip_tags($plaintext);
425
- $excerpt_length = 55;
426
- $words = explode(' ', $excerpt, $excerpt_length + 1);
427
- if (count($words) > $excerpt_length) {
428
- array_pop($words);
429
- array_push($words, '[...]');
430
- $excerpt = implode(' ', $words);
431
- }
432
- }
433
- }
434
-
435
- // first we send plaintext summary emails
436
- $body = str_replace("POST", $excerpt, $mailtext);
437
- $registered = $this->get_registered("cats=$post_cats_string&format=text&amount=excerpt");
438
- if (empty($registered)) {
439
- $recipients = (array)$public;
440
- }
441
- elseif (empty($public)) {
442
- $recipients = (array)$registered;
443
- } else {
444
- $recipients = array_merge((array)$public, (array)$registered);
445
- }
446
- $this->mail($recipients, $subject, $body);
447
- // next we send plaintext full content emails
448
- $body = str_replace("POST", strip_tags($plaintext), $mailtext);
449
- $this->mail($this->get_registered("cats=$post_cats_string&format=text&amount=post"), $subject, $body);
450
- // finally we send html full content emails
451
- $body = str_replace("\r\n", "<br />\r\n", $mailtext);
452
- $body = str_replace("POST", $content, $body);
453
- $this->mail($this->get_registered("cats=$post_cats_string&format=html"), $subject, $body, 'html');
454
-
455
- return $id;
456
- } // end publish()
457
-
458
- /**
459
- Sends a notification when a draft post is published
460
- */
461
- function private2publish($id = 0) {
462
- if (0 == $id) { return $id; }
463
-
464
- $this->publish($id);
465
- $this->private = TRUE;
466
- return $id;
467
- } // end private2publish()
468
-
469
- /**
470
- Prevents notifications from being sent when editing posts
471
- */
472
- function edit($id = 0) {
473
- if (0 == $id) { return; }
474
-
475
- $this->private = TRUE;
476
- return $id;
477
- }
478
-
479
- /**
480
- Send confirmation email to the user
481
- */
482
- function send_confirm($what = '', $is_remind = FALSE) {
483
- if ($this->filtered == 1) { return; }
484
- if ( (!$this->email) || (!$what) ) {
485
- return false;
486
- }
487
- $id = $this->get_id($this->email);
488
- if (!$id) {
489
- return false;
490
- }
491
-
492
- // generate the URL "?s2=ACTION+HASH+ID"
493
- // ACTION = 1 to subscribe, 0 to unsubscribe
494
- // HASH = md5 hash of email address
495
- // ID = user's ID in the subscribe2 table
496
- //use home instead of siteurl incase index.php is not in core wordpress directory
497
- $link = get_option('home') . "/?s2=";
498
-
499
- if ('add' == $what) {
500
- $link .= '1';
501
- } elseif ('del' == $what) {
502
- $link .= '0';
503
- }
504
- $link .= md5($this->email);
505
- $link .= $id;
506
-
507
- $admin = get_userdata(1);
508
- $this->myname = $admin->display_name;
509
-
510
- if ($is_remind == TRUE) {
511
- $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
512
- $subject = stripslashes($this->remind_subject);
513
- } else {
514
- $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
515
- if ('add' == $what) {
516
- $body = str_replace("ACTION", $this->subscribe, $body);
517
- } elseif ('del' == $what) {
518
- $body = str_replace("ACTION", $this->unsubscribe, $body);
519
- }
520
- $subject = stripslashes($this->confirm_subject);
521
- }
522
-
523
- $body = str_replace("LINK", $link, $body);
524
-
525
- $mailheaders .= "From: $admin->display_name <$admin->user_email>\n";
526
- $mailheaders .= "Return-Path: <$admin->user_email>\n";
527
- $mailheaders .= "X-Mailer:PHP" . phpversion() . "\n";
528
- $mailheaders .= "Precedence: list\nList-Id: " . get_option('blogname') . "\n";
529
- $mailheaders .= "MIME-Version: 1.0\n";
530
- $mailheaders .= "Content-Type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
531
-
532
- @wp_mail ($this->email, $subject, $body, $mailheaders);
533
- } // end send_confirm()
534
-
535
- /* ===== Subscriber functions ===== */
536
- /**
537
- Given a public subscriber ID, returns the email address
538
- */
539
- function get_email ($id = 0) {
540
- global $wpdb;
541
-
542
- if (!$id) {
543
- return false;
544
- }
545
- return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
546
- } // end get_email
547
-
548
- /**
549
- Given a public subscriber email, returns the subscriber ID
550
- */
551
- function get_id ($email = '') {
552
- global $wpdb;
553
-
554
- if (!$email) {
555
- return false;
556
- }
557
- return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
558
- } // end get_id()
559
-
560
- /**
561
- Activate an email address
562
- If the address is not already present, it will be added
563
- */
564
- function activate ($email = '') {
565
- global $wpdb;
566
-
567
- if ('' == $email) {
568
- if ('' != $this->email) {
569
- $email = $this->email;
570
- } else {
571
- return false;
572
- }
573
- }
574
-
575
- if (false !== $this->is_public($email)) {
576
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
577
- if ($check) { return; }
578
- $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
579
- } else {
580
- $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '1', NOW())");
581
- }
582
- } // end activate()
583
-
584
- /**
585
- Add an unconfirmed email address to the subscriber list
586
- */
587
- function add ($email = '') {
588
- if ($this->filtered ==1) { return; }
589
- global $wpdb;
590
-
591
- if ('' == $email) {
592
- if ('' != $this->email) {
593
- $email = $this->email;
594
- } else {
595
- return false;
596
- }
597
- }
598
-
599
- if (!is_email($email)) { return false; }
600
-
601
- if (false !== $this->is_public($email)) {
602
- $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE email='$email'");
603
- } else {
604
- $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '0', NOW())");
605
- }
606
- } // end add()
607
-
608
- /**
609
- Remove a user from the subscription table
610
- */
611
- function delete($email = '') {
612
- global $wpdb;
613
-
614
- if ('' == $email) {
615
- if ('' != $this->email) {
616
- $email = $this->email;
617
- } else {
618
- return false;
619
- }
620
- }
621
-
622
- if (!is_email($email)) { return false; }
623
- $wpdb->get_results("DELETE FROM $this->public WHERE email='$email'");
624
- } // end delete()
625
-
626
- /**
627
- Toggle a public subscriber's status
628
- */
629
- function toggle($email = '') {
630
- global $wpdb;
631
-
632
- if ( ('' == $email) || (! is_email($email)) ) { return false; }
633
-
634
- // let's see if this is a public user
635
- $status = $this->is_public($email);
636
- if (false === $status) { return false; }
637
-
638
- if ('0' == $status) {
639
- $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
640
- } else {
641
- $wpdb->get_results("UPDATE $this->public SET active='0' WHERE email='$email'");
642
- }
643
- } // end toggle()
644
-
645
- /**
646
- Send reminder email to unconfirmed public subscribers
647
- */
648
- function remind($emails = '') {
649
- if ('' == $emails) { return false; }
650
-
651
- $admin = get_userdata(1);
652
- $this->myname = $admin->display_name;
653
-
654
- $recipients = explode(",", $emails);
655
- if (!is_array($recipients)) { $recipients = array(); }
656
- foreach ($recipients as $recipient) {
657
- $this->email = $recipient;
658
- $this->send_confirm('add', TRUE);
659
- }
660
- } //end remind()
661
-
662
- /**
663
- Export email list to CSV download
664
- */
665
- function exportcsv($emails = '') {
666
- if ('' == $emails) {return false; }
667
-
668
- $f = fopen(ABSPATH . 'wp-content/email.csv', 'w');
669
- fwrite($f, $emails);
670
- fclose($f);
671
- } //end exportcsv
672
-
673
- /**
674
- Check email is not from a barred domain
675
- */
676
- function is_barred($email='') {
677
- $barred_option = $this->subscribe2_options['barred'];
678
- list($user, $domain) = split('@', $email);
679
- $bar_check = stristr($barred_option, $domain);
680
-
681
- if(!empty($bar_check)) {
682
- return true;
683
- } else {
684
- return false;
685
- }
686
- } //end is_barred()
687
-
688
- /**
689
- Confirm request from the link emailed to the user and email the admin
690
- */
691
- function confirm($content = '') {
692
- global $wpdb;
693
-
694
- if (1 == $this->filtered) { return $content; }
695
-
696
- $code = $_GET['s2'];
697
- $action = intval(substr($code, 0, 1));
698
- $hash = substr($code, 1, 32);
699
- $code = str_replace($hash, '', $code);
700
- $id = intval(substr($code, 1));
701
- if ($id) {
702
- $this->email = $this->get_email($id);
703
- if ( (!$this->email) || ($hash !== md5($this->email)) ) {
704
- return $this->no_such_email;
705
- }
706
- } else {
707
- return $this->no_such_email;
708
- }
709
-
710
- if ('1' == $action) {
711
- // make this subscription active
712
- $this->activate();
713
- $this->message = $this->added;
714
- $subject = '[' . get_option('blogname') . '] ' . __('New subscriber', 'subscribe2');
715
- $message = "$this->email " . __('subscribed to email notifications!', 'subscribe2');
716
- $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='wp_user_level' AND $wpdb->usermeta.meta_value='10'");
717
- $this->mail($recipients, $subject, $message);
718
- $this->filtered = 1;
719
- } elseif ('0' == $action) {
720
- // remove this subscriber
721
- $this->delete();
722
- $this->message = $this->deleted;
723
- $this->filtered = 1;
724
- }
725
-
726
- if ('' != $this->message) {
727
- return $this->message;
728
- }
729
- } // end confirm
730
-
731
- /**
732
- Is the supplied email address a public subscriber?
733
- */
734
- function is_public($email = '') {
735
- global $wpdb;
736
-
737
- if ('' == $email) { return false; }
738
-
739
- $check = $wpdb->get_var("SELECT active FROM $this->public WHERE email='$email'");
740
- if ( ('0' == $check) || ('1' == $check) ) {
741
- return $check;
742
- } else {
743
- return false;
744
- }
745
- } // end is_public
746
-
747
- /**
748
- Is the supplied email address a registered user of the blog?
749
- */
750
- function is_registered($email = '') {
751
- global $wpdb;
752
-
753
- if ('' == $email) { return false; }
754
-
755
- $check = $wpdb->get_var("SELECT email FROM $wpdb->users WHERE user_email='$email'");
756
- if ($check) {
757
- return true;
758
- } else {
759
- return false;
760
- }
761
- }
762
-
763
- /**
764
- Return an array of all the public subscribers
765
- */
766
- function get_public ($confirmed = 1) {
767
- global $wpdb;
768
- if (1 == $confirmed) {
769
- if ('' == $this->all_public) {
770
- $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
771
- }
772
- return $this->all_public;
773
- } else {
774
- if ('' == $this->all_unconfirmed) {
775
- $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
776
- }
777
- return $this->all_unconfirmed;
778
- }
779
- } // end get_public()
780
-
781
- /**
782
- Return an array of registered subscribers
783
- Collect all the registered users of the blog who are subscribed to the specified categories
784
- */
785
- function get_registered ($args = '') {
786
- global $wpdb;
787
-
788
- $format = '';
789
- $amount = '';
790
- $cats = '';
791
- $subscribers = array();
792
-
793
- parse_str($args, $r);
794
- if (!isset($r['cats']))
795
- $r['cats'] = '';
796
- if (!isset($r['format']))
797
- $r['format'] = 'all';
798
- if (!isset($r['amount']))
799
- $r['amount'] = 'all';
800
-
801
- $JOIN = ''; $AND = '';
802
- // text or HTML subscribers
803
- if ('all' != $r['format']) {
804
- $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
805
- $AND .= " AND b.meta_key='s2_format' AND b.meta_value=";
806
- if ('html' == $r['format']) {
807
- $AND .= "'html'";
808
- } elseif ('text' == $r['format']) {
809
- $AND .= "'text'";
810
- }
811
- }
812
-
813
- // full post or excerpt subscribers
814
- if ('all' != $r['amount']) {
815
- $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
816
- $AND .= " AND c.meta_key='s2_excerpt' AND c.meta_value=";
817
- if ('excerpt' == $r['amount']) {
818
- $AND .= "'excerpt'";
819
- } elseif ('post' == $r['amount']) {
820
- $AND.= "'post'";
821
- }
822
- }
823
-
824
- // specific category subscribers
825
- if ('' != $r['cats']) {
826
- $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
827
- foreach (explode(',', $r['cats']) as $cat) {
828
- ('' == $and) ? $and = "d.meta_key='s2_cat$cat'" : $and .= " OR d.meta_key='s2_cat$cat'";
829
- }
830
- $AND .= "AND ($and)";
831
- }
832
-
833
- $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . " WHERE a.meta_key='s2_subscribed'" . $AND;
834
- $result = $wpdb->get_col($sql);
835
- if ($result) {
836
- $ids = implode(',', $result);
837
- return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
838
- }
839
- } // end get_registered()
840
-
841
- /**
842
- Collects the signup date for all public subscribers
843
- */
844
- function signup_date($email = '') {
845
- if ('' == $email) { return false; }
846
-
847
- global $wpdb;
848
- if (!empty($this->signup_dates)) {
849
- return $this->signup_dates[$email];
850
- } else {
851
- $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
852
- foreach ($results as $result) {
853
- $this->signup_dates[$result[0]] = $result[1];
854
- }
855
- return $this->signup_dates[$email];
856
- }
857
- } // end signup_date()
858
-
859
- /**
860
- Create the appropriate usermeta values when a user registers
861
- If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
862
- */
863
- function register ($user_id = 0, $wpreg = '') {
864
- global $wpdb;
865
-
866
- if (0 == $user_id) { return $user_id; }
867
- $user = get_userdata($user_id);
868
- $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
869
-
870
- if (0 == $this->subscribe2_options['reg_override']) {
871
- // registered users are not allowed to subscribe to
872
- // excluded categories
873
- $exclude = explode(',', $this->subscribe2_options['exclude']);
874
- foreach ($all_cats as $cat => $cat_ID) {
875
- if (in_array($all_cats[$cat]->cat_ID, $exclude)) {
876
- $cat = (int)$cat;
877
- unset($all_cats[$cat]);
878
- }
879
- }
880
- }
881
-
882
- foreach ($all_cats as $cat) {
883
- ('' == $cats) ? $cats = "$cat->cat_ID" : $cats .= ",$cat->cat_ID";
884
- }
885
-
886
- if ('' == $cats) {
887
- // sanity check, might occur if all cats excluded and reg_override = 0
888
- return $user_id;
889
- }
890
-
891
- // has this user previously signed up for email notification?
892
- if (false !== $this->is_public($user->user_email)) {
893
- // delete this user from the public table, and subscribe them to all the categories
894
- $this->delete($user->user_email);
895
- update_usermeta($user_id, 's2_subscribed', $cats);
896
- foreach(explode(',', $cats) as $cat) {
897
- update_usermeta($user_id, 's2_cat' . $cat, "$cat");
898
- }
899
- update_usermeta($user_id, 's2_format', 'text');
900
- update_usermeta($user_id, 's2_excerpt', 'excerpt');
901
- } else {
902
- // add the usermeta for new registrations, but don't subscribe them
903
- $check = get_usermeta($user_id, 's2_subscribed');
904
- // ensure existing subscriptions are not overwritten on upgrade
905
- if (empty($check)) {
906
- if ( ('yes' == $this->subscribe2_options['autosub']) || (('wpreg' == $this->subscribe2_options['autosub']) && (1 == $wpreg)) ) {
907
- // don't add entires by default if autosub is off, messes up daily digests
908
- update_usermeta($user_id, 's2_subscribed', $cats);
909
- foreach(explode(',', $cats) as $cat) {
910
- update_usermeta($user_id, 's2_cat' . $cat, "$cat");
911
- }
912
- if ('html' == $this->subscribe2_options['autoformat']) {
913
- update_usermeta($user_id, 's2_format', 'html');
914
- update_usermeta($user_id, 's2_excerpt', 'post');
915
- } elseif ('fulltext' == $this->subscribe2_options['autoformat']) {
916
- update_usermeta($user_id, 's2_format', 'text');
917
- update_usermeta($user_id, 's2_excerpt', 'post');
918
- } else {
919
- update_usermeta($user_id, 's2_format', 'text');
920
- update_usermeta($user_id, 's2_excerpt', 'excerpt');
921
- }
922
- } else {
923
- update_usermeta($user_id, 's2_subscribed', '-1');
924
- }
925
- }
926
- }
927
- return $user_id;
928
- } // end register()
929
-
930
- /**
931
- Subscribe all registered users to category selected on Admin Manage Page
932
- */
933
- function subscribe_registered_users ($emails = '', $cats = '') {
934
- if ( ('' == $emails) || ('' == $cats) ) { return false; }
935
- global $wpdb;
936
-
937
- $useremails = explode(",", $emails);
938
- $useremails = implode("', '", $useremails);
939
-
940
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
941
- $user_IDs = $wpdb->get_col($sql);
942
- if (!is_array($cats)) {
943
- $cats = array($cats);
944
- }
945
-
946
- foreach ($user_IDs as $user_ID) {
947
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
948
- if (!is_array($old_cats)) {
949
- $old_cats = array($old_cats);
950
- }
951
- $new = array_diff($cats, $old_cats);
952
- if (!empty($new)) {
953
- // add subscription to these cat IDs
954
- foreach ($new as $id) {
955
- update_usermeta($user_ID, 's2_cat' . $id, "$id");
956
- }
957
- }
958
- $newcats = array_merge($cats, $old_cats);
959
- update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
960
- }
961
- } // end subscribe_registered_users
962
-
963
- /**
964
- Unsubscribe all registered users to category selected on Admin Manage Page
965
- */
966
- function unsubscribe_registered_users ($emails = '', $cats = '') {
967
- if ( ('' == $emails) || ('' == $cats) ) { return false; }
968
- global $wpdb;
969
-
970
- $useremails = explode(",", $emails);
971
- $useremails = implode("', '", $useremails);
972
-
973
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
974
- $user_IDs = $wpdb->get_col($sql);
975
- if (!is_array($cats)) {
976
- $cats = array($cats);
977
- }
978
-
979
- foreach ($user_IDs as $user_ID) {
980
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
981
- if (!is_array($old_cats)) {
982
- $old_cats = array($old_cats);
983
- }
984
- $remain = array_diff($old_cats, $cats);
985
- if (!empty($remain)) {
986
- // remove subscription to these cat IDs and update s2_subscribed
987
- foreach ($cats as $id) {
988
- delete_usermeta($user_ID, 's2_cat' . $id, "$id");
989
- }
990
- update_usermeta($user_ID, 's2_subscribed', implode(',', $remain));
991
- } else {
992
- // remove subscription to these cat IDs and update s2_subscribed to ''
993
- foreach ($cats as $id) {
994
- delete_usermeta($user_ID, 's2_cat' . $id, "$id");
995
- }
996
- update_usermeta($user_ID, 's2_subscribed', '-1');
997
- }
998
- }
999
- } // end unsubscribe_registered_users
1000
-
1001
- /**
1002
- Autosubscribe registered users to newly created categories
1003
- if registered user has selected this option
1004
- */
1005
- function autosub_new_category ($new_category='') {
1006
- global $wpdb;
1007
-
1008
- $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='s2_autosub' AND $wpdb->usermeta.meta_value='yes'";
1009
- $user_IDs = $wpdb->get_col($sql);
1010
- if ('' == $user_IDs) { return; }
1011
-
1012
- foreach ($user_IDs as $user_ID) {
1013
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1014
- if (!is_array($old_cats)) {
1015
- $old_cats = array($old_cats);
1016
- }
1017
- // add subscription to these cat IDs
1018
- update_usermeta($user_ID, 's2_cat' . $new_category, "$new_category");
1019
- $newcats = array_merge($old_cats, (array)$new_category);
1020
- update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
1021
- }
1022
- } // end autosub_new_category
1023
-
1024
- /* ===== Menus ===== */
1025
- /**
1026
- Our management page
1027
- */
1028
- function manage_menu() {
1029
- global $wpdb, $s2nonce;
1030
-
1031
- //Get Registered Subscribers for bulk management
1032
- $registered = $this->get_registered();
1033
- if (!empty($registered)) {
1034
- $emails = implode(",", $registered);
1035
- }
1036
-
1037
- $what = '';
1038
- $reminderform = false;
1039
- $urlpath = str_replace("\\","/",S2PATH);
1040
- $urlpath = trailingslashit(get_option('siteurl')) . substr($urlpath,strpos($urlpath,"wp-content/"));
1041
-
1042
- // was anything POSTed ?
1043
- if (isset($_POST['s2_admin'])) {
1044
- check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
1045
- if ('subscribe' == $_POST['s2_admin']) {
1046
- foreach (preg_split ("/[\s,]+/", $_POST['addresses']) as $email) {
1047
- if (is_email($email)) {
1048
- $this->activate($email);
1049
- }
1050
- }
1051
- $_POST['what'] = 'confirmed';
1052
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Address(es) subscribed!', 'subscribe2') . "</p></strong></div>";
1053
- } elseif ('delete' == $_POST['s2_admin']) {
1054
- $this->delete($_POST['email']);
1055
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . $_POST['email'] . ' ' . __('deleted!', 'subscribe2') . "</p></strong></div>";
1056
- } elseif ('toggle' == $_POST['s2_admin']) {
1057
- $this->toggle($_POST['email']);
1058
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . $_POST['email'] . ' ' . __('status changed!', 'subscribe2') . "</p></strong></div>";
1059
- } elseif ('remind' == $_POST['s2_admin']) {
1060
- $this->remind($_POST['reminderemails']);
1061
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Reminder Email(s) Sent!','subscribe2') . "</p></strong></div>";
1062
- } elseif ('exportcsv' == $_POST['s2_admin']) {
1063
- $this->exportcsv($_POST['exportcsv']);
1064
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('CSV File Created in wp-content','subscribe2') . "</p></strong></div>";
1065
- } elseif ( ('register' == $_POST['s2_admin']) && ('subscribe' == $_POST['manage']) ) {
1066
- $this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1067
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Subscribed!','subscribe2') . "</p></strong></div>";
1068
- } elseif ( ('register' == $_POST['s2_admin']) && ('unsubscribe' == $_POST['manage']) ) {
1069
- $this->unsubscribe_registered_users($_POST['emails'], $_POST['category']);
1070
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>" . __('Registered Users Unsubscribed!','subscribe2') . "</p></strong></div>";
1071
- }
1072
- }
1073
-
1074
- if (isset($_POST['what'])) {
1075
- if ('all' == $_POST['what']) {
1076
- $what = 'all';
1077
- $confirmed = $this->get_public();
1078
- $unconfirmed = $this->get_public(0);
1079
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$registered);
1080
- } elseif ('public' == $_POST['what']) {
1081
- $what = 'public';
1082
- $confirmed = $this->get_public();
1083
- $unconfirmed = $this->get_public(0);
1084
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1085
- } elseif ('confirmed' == $_POST['what']) {
1086
- $what = 'confirmed';
1087
- $confirmed = $this->get_public();
1088
- $subscribers = $confirmed;
1089
- } elseif ('unconfirmed' == $_POST['what']) {
1090
- $what = 'unconfirmed';
1091
- $unconfirmed = $this->get_public(0);
1092
- $subscribers = $unconfirmed;
1093
- if (!empty($unconfirmed)) {
1094
- $reminderemails = implode(",", $unconfirmed);
1095
- $reminderform = true;
1096
- }
1097
- } elseif (is_numeric($_POST['what'])) {
1098
- $what = intval($_POST['what']);
1099
- $subscribers = $this->get_registered("cats=$what");
1100
- } elseif ('registered' == $_POST['what']) {
1101
- $what = 'registered';
1102
- $subscribers = $registered;
1103
- }
1104
- } elseif ('' == $what) {
1105
- $what = 'registered';
1106
- $subscribers = $registered;
1107
- $registermessage = '';
1108
- if (empty($subscribers)) {
1109
- $confirmed = $this->get_public();
1110
- $subscribers = $confirmed;
1111
- $what = 'confirmed';
1112
- if (empty($subscribers)) {
1113
- $unconfirmed = $this->get_public(0);
1114
- $subscribers = $unconfirmed;
1115
- $what = 'unconfirmed';
1116
- if (empty($subscribers)) {
1117
- $what = 'all';
1118
- }
1119
- }
1120
- }
1121
- }
1122
- if (!empty($subscribers)) {
1123
- natcasesort($subscribers);
1124
- }
1125
- // safety check for our arrays
1126
- if ('' == $confirmed) { $confirmed = array(); }
1127
- if ('' == $unconfirmed) { $unconfirmed = array(); }
1128
- if ('' == $registered) { $registered = array(); }
1129
-
1130
- // show our form
1131
- echo "<div class=\"wrap\">";
1132
- echo "<h2>" . __('Subscribe Addresses', 'subscribe2') . "</h2>\r\n";
1133
- echo "<form method=\"post\" action=\"\">\r\n";
1134
- if (function_exists('wp_nonce_field')) {
1135
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1136
- }
1137
- echo __('Enter addresses, one per line or comma-seperated', 'subscribe2') . "<br />\r\n";
1138
- echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea><br />\r\n";
1139
- echo "<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Subscribe', 'subscribe2') . "\"/>\r\n";
1140
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"subscribe\" /></span>";
1141
- echo "</form></div>";
1142
-
1143
- // subscriber lists
1144
- echo "<div class=\"wrap\"><h2>" . __('Subscribers', 'subscribe2') . "</h2>\r\n";
1145
-
1146
- $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1147
- // show the selected subscribers
1148
- $alternate = 'alternate';
1149
- if (!empty($subscribers)) {
1150
- echo "<p align=\"center\"><b>" . __('Registered on the left, confirmed in the middle, unconfirmed on the right', 'subscribe2') . "</b></p>\r\n";
1151
- if (is_writable(ABSPATH . 'wp-content')) {
1152
- $exportcsv = implode(",", $subscribers);
1153
- echo "<form method=\"post\" action=\"\">\r\n";
1154
- if (function_exists('wp_nonce_field')) {
1155
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1156
- }
1157
- echo "<input type=\"hidden\" name=\"exportcsv\" value=\"$exportcsv\" />\r\n";
1158
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"exportcsv\" />\r\n";
1159
- echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Save Emails to CSV File','subscribe2') . "\" /></p>\r\n";
1160
- echo "</form>\r\n";
1161
- }
1162
- }
1163
- echo "<table cellpadding=\"2\" cellspacing=\"2\">";
1164
- if (!empty($subscribers)) {
1165
- foreach ($subscribers as $subscriber) {
1166
- echo "<tr class=\"$alternate\">";
1167
- echo "<td width=\"75%\"";
1168
- if (in_array($subscriber, $unconfirmed)) {
1169
- echo " align=\"right\">";
1170
- } elseif (in_array($subscriber, $confirmed)) {
1171
- echo " align=\"center\">";
1172
- } else {
1173
- echo " align=\"left\" colspan=\"3\">";
1174
- }
1175
- echo "<a href=\"mailto:$subscriber\">$subscriber</a>\r\n";
1176
- if (in_array($subscriber, $unconfirmed) || in_array($subscriber, $confirmed) ) {
1177
- echo "(" . $this->signup_date($subscriber) . ")</td>\r\n";
1178
- echo "<td width=\"5%\" align=\"center\">\r\n";
1179
- echo "<form method=\"post\" action=\"\">";
1180
- if (function_exists('wp_nonce_field')) {
1181
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1182
- }
1183
- echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1184
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"toggle\" />\r\n";
1185
- echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1186
- if (in_array($subscriber, $unconfirmed)) {
1187
- $foo = '&lt;-';
1188
- $image = 'include/arrow_left.png';
1189
- } else {
1190
- $foo = '-&gt;';
1191
- $image = 'include/arrow_right.png';
1192
- }
1193
- echo "<input type=\"image\" src=\"" . $urlpath . $image . "\" name=\"submit\" value=\"$foo\" /></form></td>\r\n";
1194
- echo "<td width=\"2%\" align=\"center\">\r\n";
1195
- echo "<form method=\"post\" action=\"\">\r\n";
1196
- if (function_exists('wp_nonce_field')) {
1197
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1198
- }
1199
- echo "<span class=\"delete\">\r\n";
1200
- echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1201
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"delete\" />\r\n";
1202
- echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1203
- echo "<input type=\"image\" src=\"" . $urlpath . "include/cross.png\"name=\"submit\" value=\"X\" />\r\n";
1204
- echo "</span></form>";
1205
- }
1206
- echo "</td></tr>\r\n";
1207
- ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1208
- }
1209
- } else {
1210
- echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1211
- }
1212
- echo "</table>";
1213
- if ($reminderform) {
1214
- echo "<form method=\"post\" action=\"\">\r\n";
1215
- if (function_exists('wp_nonce_field')) {
1216
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1217
- }
1218
- echo "<input type=\"hidden\" name=\"reminderemails\" value=\"$reminderemails\" />\r\n";
1219
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"remind\" />\r\n";
1220
- echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Send Reminder Email','subscribe2') . "\" /></p>\r\n";
1221
- echo "</form>";
1222
- }
1223
- echo "</div>\r\n";
1224
-
1225
- //show bulk managment form
1226
- echo "<div class=\"wrap\">";
1227
- echo "<h2>" . __('Categories', 'subscribe2') . "</h2>\r\n";
1228
- echo __('Existing Registered Users can be automatically (un)subscribed to categories using this section.', 'subscribe2') . "<br />\r\n";
1229
- echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1230
- echo "<form method=\"post\" action=\"\">\r\n";
1231
- if (function_exists('wp_nonce_field')) {
1232
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1233
- }
1234
- echo "<br />" . __('Action to perform', 'subscribe2') . ":\r\n";
1235
- echo "<input type=\"radio\" name=\"manage\" value=\"subscribe\" checked=\"checked\" />" . __('Subscribe', 'subscribe2') . "\r\n";
1236
- echo "<input type=\"radio\" name=\"manage\" value=\"unsubscribe\" />" . __('Unsubscribe', 'subscribe2') . "<br /><br />\r\n";
1237
- echo "<input type=\"hidden\" name=\"emails\" value=\"$emails\" /><input type=\"hidden\" name=\"s2_admin\" value=\"register\" />\r\n";
1238
- $this->display_category_form();
1239
- echo "<p class=\"submit\"><input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p></form>";
1240
-
1241
- echo "</div>\r\n";
1242
- echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1243
-
1244
- include(ABSPATH . 'wp-admin/admin-footer.php');
1245
- // just to be sure
1246
- die;
1247
- } // end manage_menu()
1248
-
1249
- /**
1250
- Our options page
1251
- */
1252
- function options_menu() {
1253
- global $s2nonce;
1254
-
1255
- // was anything POSTed?
1256
- if (isset($_POST['s2_admin'])) {
1257
- check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
1258
- if ('RESET' == $_POST['s2_admin']) {
1259
- $this->reset();
1260
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_reset</p></strong></div>";
1261
- } elseif ('options' == $_POST['s2_admin']) {
1262
- // excluded categories
1263
- if (!empty($_POST['category'])) {
1264
- $exclude_cats = implode(',', $_POST['category']);
1265
- } else {
1266
- $exclude_cats = '';
1267
- }
1268
- $this->subscribe2_options['exclude'] = $exclude_cats;
1269
- // allow override?
1270
- (isset($_POST['reg_override'])) ? $override = '1' : $override = '0';
1271
- $this->subscribe2_options['reg_override'] = $override;
1272
-
1273
- // show button?
1274
- ($_POST['show_button'] == '1') ? $showbutton = '1' : $showbutton = '0';
1275
- $this->subscribe2_options['show_button'] = $showbutton;
1276
-
1277
- // send as author or admin?
1278
- $sender = 'author';
1279
- if ('admin' == $_POST['sender']) {
1280
- $sender = 'admin';
1281
- }
1282
- $this->subscribe2_options['sender'] = $sender;
1283
-
1284
- // send email for pages and password protected posts
1285
- $pages_option = $_POST['pages'];
1286
- $this->subscribe2_options['pages']= $pages_option;
1287
- $password_option = $_POST['password'];
1288
- $this->subscribe2_options['password']= $password_option;
1289
-
1290
- // send per-post or digest emails
1291
- $email_freq = $_POST['email_freq'];
1292
- $this->subscribe2_options['email_freq'] = $email_freq;
1293
- wp_clear_scheduled_hook('s2_digest_cron');
1294
- $scheds = (array) wp_get_schedules();
1295
- $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
1296
- if ($interval == 0) {
1297
- // if we are on per-post emails remove last_cron entry
1298
- unset($this->subscribe2_options['last_s2cron']);
1299
- } else {
1300
- if (!wp_next_scheduled('s2_digest_cron')) {
1301
- // if we are using digest schedule the event and prime last_cron as now
1302
- wp_schedule_event(time() + $interval, $email_freq, 's2_digest_cron');
1303
- $now = date('Y-m-d H:i:s', time());
1304
- $this->subscribe2_options['last_s2cron'] = $now;
1305
- }
1306
- }
1307
-
1308
- // email templates
1309
- $mailtext = $_POST['mailtext'];
1310
- $this->subscribe2_options['mailtext'] = $mailtext;
1311
- $confirm_email = $_POST['confirm_email'];
1312
- $this->subscribe2_options['confirm_email'] = $confirm_email;
1313
- $remind_email = $_POST['remind_email'];
1314
- $this->subscribe2_options['remind_email'] = $remind_email;
1315
-
1316
- //automatic subscription
1317
- $autosub_option = $_POST['autosub'];
1318
- $this->subscribe2_options['autosub'] = $autosub_option;
1319
- $autosub_wpregdef_option = $_POST['wpregdef'];
1320
- $this->subscribe2_options['wpregdef'] = $autosub_wpregdef_option;
1321
- $autosub_format_option = $_POST['autoformat'];
1322
- $this->subscribe2_options['autoformat'] = $autosub_format_option;
1323
-
1324
- //barred domains
1325
- $barred_option = $_POST['barred'];
1326
- $this->subscribe2_options['barred'] = $barred_option;
1327
- echo "<div id=\"message\" class=\"updated fade\"><strong><p>$this->options_saved</p></strong></div>";
1328
- update_option('subscribe2_options', $this->subscribe2_options);
1329
- }
1330
- }
1331
- // show our form
1332
- echo "<div class=\"wrap\">";
1333
- echo "<form method=\"post\" action=\"\">\r\n";
1334
- if (function_exists('wp_nonce_field')) {
1335
- wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1336
- }
1337
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
1338
- echo "<h2>" . __('Delivery Options', 'subscribe2') . ":</h2>\r\n";
1339
- echo __('Send Emails for Pages', 'subscribe2') . ': ';
1340
- echo "<input type=\"radio\" name=\"pages\" value=\"yes\"";
1341
- if ('yes' == $this->subscribe2_options['pages']) {
1342
- echo " checked=\"checked\"";
1343
- }
1344
- echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1345
- echo "<input type=\"radio\" name=\"pages\" value=\"no\"";
1346
- if ('no' == $this->subscribe2_options['pages']) {
1347
- echo " checked=\"checked\"";
1348
- }
1349
- echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1350
- echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
1351
- echo "<input type=\"radio\" name=\"password\" value=\"yes\"";
1352
- if ('yes' == $this->subscribe2_options['password']) {
1353
- echo " checked=\"checked\"";
1354
- }
1355
- echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1356
- echo "<input type=\"radio\" name=\"password\" value=\"no\"";
1357
- if ('no' == $this->subscribe2_options['password']) {
1358
- echo " checked=\"checked\"";
1359
- }
1360
- echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1361
- echo __('Send Email From', 'subscribe2') . ': ';
1362
- echo "<input type=\"radio\" name=\"sender\" value=\"author\"";
1363
- if ('author' == $this->subscribe2_options['sender']) {
1364
- echo " checked=\"checked\" ";
1365
- }
1366
- echo " /> " . __('Author of the post', 'subscribe2') . " &nbsp;&nbsp;";
1367
- echo "<input type=\"radio\" name=\"sender\" value=\"admin\"";
1368
- if ('admin' == $this->subscribe2_options['sender']) {
1369
- echo " checked=\"checked\" ";
1370
- }
1371
- echo " /> " . __('Blog Admin', 'subscribe2') . "<br /><br />\r\n";
1372
- if (function_exists('wp_schedule_event')) {
1373
- echo __('Send Email as Digest', 'subscribe2') . ": <br /><br />\r\n";
1374
- $this->display_digest_choices();
1375
- echo "<br />\r\n";
1376
- }
1377
- echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
1378
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
1379
- echo "<tr><td>";
1380
- echo __('New Post email (must not be empty)', 'subscribe2') . ":";
1381
- echo "<br />\r\n";
1382
- echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
1383
- echo "</td><td valign=\"top\" rowspan=\"3\">";
1384
- echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
1385
- echo "<dl>";
1386
- echo "<dt><b>BLOGNAME</b></dt><dd>" . get_bloginfo('name') . "</dd>\r\n";
1387
- echo "<dt><b>BLOGLINK</b></dt><dd>" . get_bloginfo('url') . "</dd>\r\n";
1388
- echo "<dt><b>TITLE</b></dt><dd>" . __("the post's title", 'subscribe2') . "</dd>\r\n";
1389
- echo "<dt><b>POST</b></dt><dd>" . __("the excerpt or the entire post<br />(<i>based on the subscriber's preferences</i>)", 'subscribe2') . "</dd>\r\n";
1390
- echo "<dt><b>TABLE</b></dt><dd>" . __("a list of post titles (for digest emails)", 'subscribe2') . "</dd>\r\n";
1391
- echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink", 'subscribe2') . "</dd>\r\n";
1392
- echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
1393
- echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
1394
- echo "<dt><b>AUTHORNAME</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
1395
- 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";
1396
- 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";
1397
- echo "</dl></td></tr><tr><td>";
1398
- echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
1399
- echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
1400
- echo "</td></tr><tr valign=\"top\"><td>";
1401
- echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
1402
- echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
1403
- echo "</td></tr></table><br />\r\n";
1404
-
1405
- // excluded categories
1406
- echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
1407
- echo "<strong><em style=\"color: red\">" . __('Posts assigned to any Excluded Category do not generate notifications and are not included in digest notifications', 'subscribe2') . "</em></strong><br />\r\n";
1408
- $this->display_category_form(explode(',', $this->subscribe2_options['exclude']));
1409
- echo "<center><input type=\"checkbox\" name=\"reg_override\" value=\"1\"";
1410
- if ('1' == $this->subscribe2_options['reg_override']) {
1411
- echo " checked=\"checked\"";
1412
- }
1413
- echo " /> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</center><br />\r\n";
1414
-
1415
- // show button in QuickTags
1416
- echo "<h2>" . __('Writing Options', 'subscribe2') . "</h2>\r\n";
1417
- echo "<input type=\"checkbox\" name=\"show_button\" value=\"1\"";
1418
- if ('1' == $this->subscribe2_options['show_button']) {
1419
- echo " checked=\"checked\"";
1420
- }
1421
- echo " /> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "<br /><br />\r\n";
1422
-
1423
- //Auto Subscription for new registrations
1424
- echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
1425
- echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
1426
- echo "<input type=\"radio\" name=\"autosub\" value=\"yes\"";
1427
- if ('yes' == $this->subscribe2_options['autosub']) {
1428
- echo " checked=\"checked\"";
1429
- }
1430
- echo " /> " . __('Automatically', 'subscribe2') . " &nbsp;&nbsp;";
1431
- echo "<input type=\"radio\" name=\"autosub\" value=\"wpreg\"";
1432
- if ('wpreg' == $this->subscribe2_options['autosub']) {
1433
- echo " checked=\"checked\"";
1434
- }
1435
- echo " /> " . __('Display option on Registration Form', '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 __('Registration Form option is checked by default', 'subscribe2') . ": &nbsp;&nbsp;";
1442
- echo "<input type=\"radio\" name=\"wpregdef\" value=\"yes\"";
1443
- if ('yes' == $this->subscribe2_options['wpregdef']) {
1444
- echo " checked=\"checked\"";
1445
- }
1446
- echo " />" . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1447
- echo "<input type=\"radio\" name=\"wpregdef\" value=\"no\"";
1448
- if ('no' == $this->subscribe2_options['wpregdef']) {
1449
- echo " checked=\"checked\"";
1450
- }
1451
- echo " />" . __('No', 'subscribe2') . "<br /><br />\r\n";
1452
- echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
1453
- echo "<input type=\"radio\" name=\"autoformat\" value=\"html\"";
1454
- if ('html' == $this->subscribe2_options['autoformat']) {
1455
- echo "checked=\"checked\" ";
1456
- }
1457
- echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1458
- echo "<input type=\"radio\" name=\"autoformat\" value=\"fulltext\" ";
1459
- if ('fulltext' == $this->subscribe2_options['autoformat']) {
1460
- echo "checked=\"checked\" ";
1461
- }
1462
- echo "/> " . __('Plain Text - Full', 'subscribe2') . " &nbsp;&nbsp;";
1463
- echo "<input type=\"radio\" name=\"autoformat\" value=\"text\" ";
1464
- if ('text' == $this->subscribe2_options['autoformat']) {
1465
- echo "checked=\"checked\" ";
1466
- }
1467
- echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . " <br /><br />";
1468
-
1469
- //barred domains
1470
- echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
1471
- 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');
1472
- echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
1473
-
1474
- // submit
1475
- echo "<p align=\"center\"><span class=\"submit\"><input type=\"submit\" id=\"save\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></span></p>";
1476
- echo "</form>\r\n";
1477
- echo "</div><div class=\"wrap\">";
1478
-
1479
- // reset
1480
- echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
1481
- 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";
1482
- echo "<form method=\"post\" action=\"\">";
1483
- if (function_exists('wp_nonce_field')) {
1484
- wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1485
- }
1486
- echo "<p align=\"center\"><span class=\"submit\">";
1487
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"RESET\" />";
1488
- echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('RESET', 'subscribe2') .
1489
- "\" />";
1490
- echo "</span></p></form></div>\r\n";
1491
-
1492
- include(ABSPATH . 'wp-admin/admin-footer.php');
1493
- // just to be sure
1494
- die;
1495
- } // end options_menu()
1496
-
1497
- /**
1498
- Our profile menu
1499
- */
1500
- function user_menu() {
1501
- global $user_ID, $s2nonce;
1502
-
1503
- get_currentuserinfo();
1504
-
1505
- // was anything POSTed?
1506
- if ( (isset($_POST['s2_admin'])) && ('user' == $_POST['s2_admin']) ) {
1507
- check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
1508
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
1509
- $format = 'text';
1510
- $post = 'post';
1511
- if ('html' == $_POST['s2_format']) {
1512
- $format = 'html';
1513
- }
1514
- if ('excerpt' == $_POST['s2_excerpt']) {
1515
- $post = 'excerpt';
1516
- }
1517
- update_usermeta($user_ID, 's2_excerpt', $post);
1518
- update_usermeta($user_ID, 's2_format', $format);
1519
- update_usermeta($user_ID, 's2_autosub', $_POST['new_category']);
1520
-
1521
- $cats = $_POST['category'];
1522
- if ( (empty($cats)) || ($cats == '-1') ) {
1523
- $cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1524
- if ($cats) {
1525
- foreach ($cats as $cat) {
1526
- delete_usermeta($user_ID, "s2_cat" . $cat);
1527
- }
1528
- }
1529
- update_usermeta($user_ID, 's2_subscribed', '-1');
1530
- } elseif ($cats == 'digest') {
1531
- $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
1532
- foreach ($all_cats as $cat) {
1533
- ('' == $catids) ? $catids = "$cat->cat_ID" : $catids .= ",$cat->cat_ID";
1534
- update_usermeta($user_ID, 's2_cat' . $cat->cat_ID, $cat->cat_ID);
1535
- }
1536
- update_usermeta($user_ID, 's2_subscribed', $catids);
1537
- } else {
1538
- if (!is_array($cats)) {
1539
- $cats = array($_POST['category']);
1540
- }
1541
- $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1542
- $remove = array_diff($old_cats, $cats);
1543
- $new = array_diff($cats, $old_cats);
1544
- if (!empty($remove)) {
1545
- // remove subscription to these cat IDs
1546
- foreach ($remove as $id) {
1547
- delete_usermeta($user_ID, "s2_cat" . $id);
1548
- }
1549
- }
1550
- if (!empty($new)) {
1551
- // add subscription to these cat IDs
1552
- foreach ($new as $id) {
1553
- update_usermeta($user_ID, 's2_cat' . $id, $id);
1554
- }
1555
- }
1556
- update_usermeta($user_ID, 's2_subscribed', implode(',', $cats));
1557
- }
1558
- }
1559
-
1560
- // show our form
1561
- echo "<div class=\"wrap\">";
1562
- echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
1563
- echo "<form method=\"post\" action=\"\">";
1564
- if (function_exists('wp_nonce_field')) {
1565
- wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
1566
- }
1567
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
1568
- if ($this->subscribe2_options['email_freq'] == 'never') {
1569
- echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
1570
- echo "<input type=\"radio\" name=\"s2_format\" value=\"html\"";
1571
- if ('html' == get_usermeta($user_ID, 's2_format')) {
1572
- echo "checked=\"checked\" ";
1573
- }
1574
- echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1575
- echo "<input type=\"radio\" name=\"s2_format\" value=\"text\" ";
1576
- if ('text' == get_usermeta($user_ID, 's2_format')) {
1577
- echo "checked=\"checked\" ";
1578
- }
1579
- echo "/> " . __('Plain Text', 'subscribe2') . "<br /><br />\r\n";
1580
-
1581
- echo __('Email contains', 'subscribe2') . ": &nbsp;&nbsp;";
1582
- $amount = array ('excerpt' => __('Excerpt Only', 'subscribe2'), 'post' => __('Full Post', 'subscribe2'));
1583
- foreach ($amount as $key => $value) {
1584
- echo "<input type=\"radio\" name=\"s2_excerpt\" value=\"" . $key . "\"";
1585
- if ($key == get_usermeta($user_ID, 's2_excerpt')) {
1586
- echo " checked=\"checked\"";
1587
- }
1588
- echo " /> " . $value . "&nbsp;&nbsp;";
1589
- }
1590
- echo "<p style=\"color: red\">" . __('Note: HTML format will always deliver the full post.', 'subscribe2') . "</p>\r\n";
1591
- echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
1592
- echo "<input type=\"radio\" name=\"new_category\" value=\"yes\" ";
1593
- if ('yes' == get_usermeta($user_ID, 's2_autosub')) {
1594
- echo "checked=\"checked\" ";
1595
- }
1596
- echo "/> Yes &nbsp;&nbsp;";
1597
- echo "<input type=\"radio\" name=\"new_category\" value=\"no\" ";
1598
- if ('no' == get_usermeta($user_ID, 's2_autosub')) {
1599
- echo "checked=\"checked\" ";
1600
- }
1601
- echo "/> No<br /><br />";
1602
-
1603
- // subscribed categories
1604
- echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
1605
- $this->display_category_form(explode(',', get_usermeta($user_ID, 's2_subscribed')), $this->subscribe2_options['reg_override']);
1606
- } else {
1607
- // we're doing daily digests, so just show
1608
- // subscribe / unnsubscribe
1609
- echo __('Receive daily summary of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
1610
- echo "<input type=\"radio\" name=\"category\" value=\"digest\" ";
1611
- if (get_usermeta($user_ID, 's2_subscribed') != '-1') {
1612
- echo "checked=\"yes\" ";
1613
- }
1614
- echo "/> Yes <input type=\"radio\" name=\"category\" value=\"-1\" ";
1615
- if (get_usermeta($user_ID, 's2_subscribed') == '-1') {
1616
- echo "checked=\"yes\" ";
1617
- }
1618
- echo "/> No";
1619
- }
1620
-
1621
- // submit
1622
- echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __("Update Preferences &raquo;", 'subscribe2') . "\" /></p>";
1623
- echo "</form></div>\r\n";
1624
-
1625
- include(ABSPATH . 'wp-admin/admin-footer.php');
1626
- // just to be sure
1627
- die;
1628
- } // end user_menu()
1629
-
1630
- /**
1631
- Display the Write sub-menu
1632
- */
1633
- function write_menu() {
1634
- global $wpdb, $s2nonce;
1635
-
1636
- // was anything POSTed?
1637
- if (isset($_POST['s2_admin']) && ('mail' == $_POST['s2_admin']) ) {
1638
- check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
1639
- if ('confirmed' == $_POST['what']) {
1640
- $recipients = $this->get_public();
1641
- } elseif ('unconfirmed' == $_POST['what']) {
1642
- $recipients = $this->get_public(0);
1643
- } elseif ('public' == $_POST['what']) {
1644
- $confirmed = $this->get_public();
1645
- $unconfirmed = $this->get_public(0);
1646
- $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
1647
- } elseif (is_numeric($_POST['what'])) {
1648
- $cat = intval($_POST['what']);
1649
- $recipients = $this->get_registered("cats=$cat");
1650
- } else {
1651
- $recipients = $this->get_registered();
1652
- }
1653
- global $user_identity, $user_email;
1654
- get_currentuserinfo();
1655
- $this->myname = $user_identity;
1656
- $this->myemail = $user_email;
1657
- $subject = strip_tags($_POST['subject']);
1658
- $message = stripslashes($_POST['message']);
1659
- $this->mail($recipients, $subject, $message, 'text');
1660
- $message = $this->mail_sent;
1661
- }
1662
-
1663
- if ('' != $message) {
1664
- echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
1665
- }
1666
- // show our form
1667
- echo "<div class=\"wrap\"><h2>" . __('Send email to all subscribers', 'subscribe2') . "</h2>\r\n";
1668
- echo "<form method=\"post\" action=\"\">\r\n";
1669
- if (function_exists('wp_nonce_field')) {
1670
- wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
1671
- }
1672
- echo __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . __('A message from ', 'subscribe2') . get_option('blogname') . "\" /> <br />";
1673
- echo "<textarea rows=\"12\" cols=\"75\" name=\"message\"></textarea>";
1674
- echo "<br />\r\n";
1675
- echo __('Recipients: ', 'subscribe2');
1676
- $this->display_subscriber_dropdown('registered', false, array('all'));
1677
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
1678
- echo "&nbsp;&nbsp;<span class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></span>&nbsp;";
1679
- echo "</form></div>\r\n";
1680
- echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1681
-
1682
- include(ABSPATH . 'wp-admin/admin-footer.php');
1683
- // just to be sure
1684
- die;
1685
- } // end write_menu()
1686
-
1687
- /* ===== helper functions: forms and stuff ===== */
1688
- /**
1689
- Display a table of categories with checkboxes
1690
- Optionally pre-select those categories specified
1691
- */
1692
- function display_category_form($selected = array(), $override = 1) {
1693
- global $wpdb;
1694
-
1695
- $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
1696
- $exclude = explode(',', $this->subscribe2_options['exclude']);
1697
-
1698
- if (0 == $override) {
1699
- // registered users are not allowed to subscribe to
1700
- // excluded categories
1701
- foreach ($all_cats as $cat => $cat_ID) {
1702
- if (in_array($all_cats[$cat]->cat_ID, $exclude)) {
1703
- $cat = (int)$cat;
1704
- unset($all_cats[$cat]);
1705
- }
1706
- }
1707
- }
1708
-
1709
- $half = (count($all_cats) / 2);
1710
- $i = 0;
1711
- $j = 0;
1712
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
1713
- echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
1714
- foreach ($all_cats as $cat) {
1715
- if ( ($i >= $half) && (0 == $j) ){
1716
- echo "</td><td width=\"50%\" align=\"left\">\r\n";
1717
- $j++;
1718
- }
1719
- if (0 == $j) {
1720
- echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->cat_ID . "\"";
1721
- if (in_array($cat->cat_ID, $selected)) {
1722
- echo " checked=\"checked\" ";
1723
- }
1724
- echo " /> " . $cat->cat_name . "<br />\r\n";
1725
- } else {
1726
-
1727
- echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->cat_ID . "\"";
1728
- if (in_array($cat->cat_ID, $selected)) {
1729
- echo " checked=\"checked\" ";
1730
- }
1731
- echo " /> " . $cat->cat_name . "<br />\r\n";
1732
- }
1733
- $i++;
1734
- }
1735
- echo "</td></tr>\r\n";
1736
- echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
1737
- echo "<input type=\"checkbox\" name=\"checkall\" onclick=\"setAll(this)\" /> " . __('Select / Unselect All' ,'subscribe2') . "\r\n";
1738
- echo "</td></tr>\r\n";
1739
- echo "</table>\r\n";
1740
- } // end display_category_form()
1741
-
1742
- /**
1743
- Display a drop-down form to select subscribers
1744
- $selected is the option to select
1745
- $submit is the text to use on the Submit button
1746
- */
1747
- function display_subscriber_dropdown ($selected = 'registered', $submit = '', $exclude = array()) {
1748
- global $wpdb;
1749
-
1750
- $who = array('all' => __('All Subscribers', 'subscribe2'),
1751
- 'public' => __('Public Subscribers', 'subscribe2'),
1752
- 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
1753
- 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
1754
- 'registered' => __('Registered Users', 'subscribe2'));
1755
-
1756
- $all_cats = get_categories('type=post&hide_empty=1&hierarchical=0');
1757
-
1758
- // count the number of subscribers
1759
- $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
1760
- $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
1761
- if (in_array('unconfirmed', $exclude)) {
1762
- $count['public'] = $count['confirmed'];
1763
- } elseif (in_array('confirmed', $exclude)) {
1764
- $count['public'] = $count['unconfirmed'];
1765
- } else {
1766
- $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
1767
- }
1768
- $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='s2_subscribed'");
1769
- $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['registered']);
1770
- foreach ($all_cats as $cat) {
1771
- $count[$cat->cat_name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='s2_cat$cat->cat_ID'");
1772
- }
1773
-
1774
- // do have actually have some subscribers?
1775
- if ( (0 == $count['confirmed']) && (0 == $count['unconfirmed']) && (0 == $count['registered']) ) {
1776
- // no? bail out
1777
- return;
1778
- }
1779
-
1780
- if (false !== $submit) {
1781
- echo "<form method=\"post\" action=\"\">";
1782
- }
1783
- echo "<select name=\"what\">\r\n";
1784
- foreach ($who as $whom => $display) {
1785
- if (in_array($whom, $exclude)) { continue; }
1786
- if (0 == $count[$whom]) { continue; }
1787
-
1788
- echo "<option value=\"" . $whom . "\"";
1789
- if ($whom == $selected) { echo " selected=\"selected\" "; }
1790
- echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
1791
- }
1792
-
1793
- if ($count['registered'] > 0) {
1794
- foreach ($all_cats as $cat) {
1795
- if (in_array($cat->cat_ID, $exclude)) { continue; }
1796
- echo "<option value=\"" . $cat->cat_ID . "\"";
1797
- if ($cat->cat_ID == $selected) { echo " selected=\"selected\" "; }
1798
- echo "> &nbsp;&nbsp;" . $cat->cat_name . "&nbsp;(" . $count[$cat->cat_name] . ") </option>\r\n";
1799
- }
1800
- }
1801
- echo "</select>";
1802
- if (false !== $submit) {
1803
- echo "<span class=\"submit\"><input type=\"submit\" value=\"$submit\" /></span></form>\r\n";
1804
- }
1805
- } // end display_subscriber_dropdown()
1806
-
1807
- function display_digest_choices() {
1808
- global $wpdb;
1809
- $schedule = (array)wp_get_schedules();
1810
- $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('Per Post Email','subscribe2'))), $schedule);
1811
- $sort = array();
1812
- foreach ( (array)$schedule as $key => $value ) $sort[$key] = $value['interval'];
1813
- asort($sort);
1814
- $schedule_sorted = array();
1815
- foreach ($sort as $key => $value) {
1816
- $schedule_sorted[$key] = $schedule[$key];
1817
- }
1818
- foreach ($schedule_sorted as $key => $value) {
1819
- echo "<input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"";
1820
- if ($key == $this->subscribe2_options['email_freq']) {
1821
- echo " checked=\"checked\" ";
1822
- }
1823
- echo " /> " . $value['display'] . "<br />\r\n";
1824
- }
1825
- if (wp_next_scheduled('s2_digest_cron')) {
1826
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
1827
- $now = time();
1828
- echo "<p>" . __('Current server time is', 'subscribe2') . ": \r\n";
1829
- echo "<strong>" . gmdate($datetime, $now+ (get_option('gmt_offset') * 3600)) . "</strong></p>\r\n";
1830
- echo "<p>" . __('Next email notification will be sent', 'subscribe2') . ": \r\n";
1831
- echo "<strong>" . gmdate($datetime, wp_next_scheduled('s2_digest_cron') + (get_option('gmt_offset') * 3600)) . "</strong></p>\r\n";
1832
- }
1833
- } // end display_digest_choices()
1834
-
1835
- /**
1836
- Adds information to the WordPress registration screen for new users
1837
- */
1838
- function register_form() {
1839
- if ('wpreg' == $this->subscribe2_options['autosub']) {
1840
- echo "<p>\r\n<label>";
1841
- echo __('Check here to Subscribe to email notifications for new posts') . ":<br />\r\n";
1842
- echo "<input type=\"checkbox\" name=\"subscribe\"";
1843
- if ('yes' == $this->subscribe2_options['wpregdef']) {
1844
- echo " checked=\"checked\"";
1845
- }
1846
- echo " /></label>\r\n";
1847
- echo "</p>\r\n";
1848
- } elseif ('yes' == $this->subscribe2_options['autosub']) {
1849
- echo "<p>\r\n<center>\r\n";
1850
- echo __('By Registering with this blog you are also agreeing to recieve email notifications for new posts') . "<br />\r\n";
1851
- echo "</center></p>\r\n";
1852
- }
1853
- }
1854
-
1855
- /**
1856
- Process function to add action if user selects to subscribe to posts during registration
1857
- */
1858
- function register_post() {
1859
- if ('on' == $_POST['subscribe']) {
1860
- add_action('user_register', array(&$this, 'register_action'));
1861
- }
1862
- }
1863
-
1864
- /**
1865
- Action to process Subscribe2 registration from WordPress registration
1866
- */
1867
- function register_action($user_id = 0) {
1868
- if (0 == $user_id) { return $user_id; }
1869
- $this->register($user_id, 1);
1870
- }
1871
-
1872
- /* ===== template and filter functions ===== */
1873
- /**
1874
- Display our form; also handles (un)subscribe requests
1875
- */
1876
- function filter($content = '') {
1877
- if ( ('' == $content) || (! preg_match('|<!--subscribe2-->|', $content)) ) { return $content; }
1878
- $this->s2form = $this->form;
1879
-
1880
- global $user_ID;
1881
- get_currentuserinfo();
1882
- if ($user_ID) {
1883
- if (current_user_can('manage_options')) {
1884
- $this->s2form = $this->use_profile_admin;
1885
- } else {
1886
- $this->s2form = $this->use_profile_users;
1887
- }
1888
- }
1889
- if (isset($_POST['s2_action'])) {
1890
- global $wpdb, $user_email;
1891
- if (!is_email($_POST['email'])) {
1892
- $this->s2form = $this->form . $this->not_an_email;
1893
- } elseif ($this->is_barred($_POST['email'])) {
1894
- $this->s2form = $this->form . $this->barred_domain;
1895
- } else {
1896
- $this->email = $_POST['email'];
1897
- // does the supplied email belong to a registered user?
1898
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
1899
- if ('' != $check) {
1900
- // this is a registered email
1901
- $this->s2form = $this->please_log_in;
1902
- } else {
1903
- // this is not a registered email
1904
- // what should we do?
1905
- if ('subscribe' == $_POST['s2_action']) {
1906
- // someone is trying to subscribe
1907
- // lets see if they've tried to subscribe previously
1908
- if ('1' !== $this->is_public($this->email)) {
1909
- // the user is unknown or inactive
1910
- $this->add();
1911
- $this->send_confirm('add');
1912
- // set a variable to denote that we've already run, and shouldn't run again
1913
- $this->filtered = 1; //set this to not send duplicate emails
1914
- $this->s2form = $this->confirmation_sent;
1915
- } else {
1916
- // they're already subscribed
1917
- $this->s2form = $this->already_subscribed;
1918
- }
1919
- $this->action = 'subscribe';
1920
- } elseif ('unsubscribe' == $_POST['s2_action']) {
1921
- // is this email a subscriber?
1922
- if (false == $this->is_public($this->email)) {
1923
- $this->s2form = $this->form . $this->not_subscribed;
1924
- } else {
1925
- $this->send_confirm('del');
1926
- // set a variable to denote that we've already run, and shouldn't run again
1927
- $this->filtered = 1;
1928
- $this->s2form = $this->confirmation_sent;
1929
- }
1930
- $this->action='unsubscribe';
1931
- }
1932
- }
1933
- }
1934
- }
1935
- return preg_replace('|(<p>)(\n)*<!--subscribe2-->(\n)*(</p>)|', $this->s2form, $content);
1936
- } // end filter()
1937
-
1938
- /**
1939
- Overrides the default query when handling a (un)subscription confirmation
1940
- This is basically a trick: if the s2 variable is in the query string, just grab the first
1941
- static page and override it's contents later with title_filter()
1942
- */
1943
- function query_filter() {
1944
- // don't interfere if we've already done our thing
1945
- if (1 == $this->filtered) { return; }
1946
-
1947
- global $wpdb;
1948
-
1949
- if ( (defined('S2PAGE')) && (0 != S2PAGE) ) {
1950
- return "page_id=" . S2PAGE;
1951
- } else {
1952
- $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' LIMIT 1");
1953
- if ($id) {
1954
- return "page_id=$id";
1955
- } else {
1956
- return "showposts=1";
1957
- }
1958
- }
1959
- } // end query_filter()
1960
-
1961
- /**
1962
- Overrides the page title
1963
- */
1964
- function title_filter() {
1965
- // don't interfere if we've already done our thing
1966
- if (1 == $this->filtered) { return; }
1967
- return __('Subscription Confirmation', 'subscribe2');
1968
- } // end title_filter()
1969
-
1970
- /* ===== wp-cron functions ===== */
1971
- /**
1972
- Send a daily digest of today's new posts
1973
- */
1974
- function subscribe2_cron() {
1975
- global $wpdb;
1976
-
1977
- // collect posts
1978
- $now = date('Y-m-d H:i:s', time());
1979
- $prev = $this->subscribe2_options['last_s2cron'];
1980
- $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'");
1981
-
1982
- // update last_s2cron execution time before completing or bailing
1983
- $this->subscribe2_options['last_s2cron'] = $now;
1984
- update_option('subscribe2_options', $this->subscribe2_options);
1985
-
1986
- // do we have any posts?
1987
- if (empty($posts)) { return; }
1988
-
1989
- // if we have posts, let's prepare the digest
1990
- foreach ($posts as $post) {
1991
- $post_cats = wp_get_post_cats('1', $post->ID);
1992
- $post_cats_string = implode(',', $post_cats);
1993
- $check = false;
1994
- // is the current post assigned to any categories
1995
- // which should not generate a notification email?
1996
- foreach (explode(',', $this->subscribe2_options['exclude']) as $cat) {
1997
- if (in_array($cat, $post_cats)) {
1998
- $check = true;
1999
- }
2000
- }
2001
- // if this post is in an excluded category,
2002
- // don't include it in the digest
2003
- if ($check) {
2004
- continue;
2005
- }
2006
- $table .= $post->post_title . "\r\n";
2007
- $message .= $post->post_title . "\r\n";
2008
- $message .= get_permalink($post->ID) . "\r\n";
2009
- $excerpt = $post->post_excerpt;
2010
- if ('' == $excerpt) {
2011
- // no excerpt, is there a <!--more--> ?
2012
- if (false !== strpos($post->post_content, '<!--more-->')) {
2013
- list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
2014
- // strip leading and trailing whitespace
2015
- $excerpt = trim($excerpt);
2016
- } else {
2017
- $excerpt = strip_tags($post->post_content);
2018
- $words = explode(' ', $excerpt, 56);
2019
- if (count($words) > 55) {
2020
- array_pop($words);
2021
- array_push($words, '[...]');
2022
- $excerpt = implode(' ', $words);
2023
- }
2024
- }
2025
- }
2026
- $message .= $excerpt . "\r\n\r\n";
2027
- }
2028
-
2029
- $author = get_userdata($post->post_author);
2030
- $this->authorname = $author->display_name;
2031
-
2032
- // do we send as admin, or post author?
2033
- if ('author' == $this->subscribe2_options['sender']) {
2034
- // get author details
2035
- $user =& $author;
2036
- } else {
2037
- // get admin detailts
2038
- $user = get_userdata(1);
2039
- }
2040
- $this->myemail = $user->user_email;
2041
- $this->myname = $user->display_name;
2042
-
2043
- $scheds = (array) wp_get_schedules();
2044
- $email_freq = $this->subscribe2_options['email_freq'];
2045
- $display = $scheds[$email_freq]['display'];
2046
- $subject = '[' . stripslashes(get_option('blogname')) . '] ' . $display . ' ' . __('Digest Email', 'subscribe2');
2047
- $public = $this->get_public();
2048
- $registered = $this->get_registered();
2049
- $recipients = array_merge((array)$public, (array)$registered);
2050
- $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
2051
- $body = str_replace("TABLE", $table, $mailtext);
2052
- $body = str_replace("POST", $message, $mailtext);
2053
- $this->mail($recipients, $subject, $body);
2054
- } // end subscribe2_cron
2055
-
2056
- /* ===== Our constructor ===== */
2057
- /**
2058
- Subscribe2 constructor
2059
- */
2060
- function s2init() {
2061
- // load the options
2062
- $this->subscribe2_options = array();
2063
- $this->subscribe2_options = get_option('subscribe2_options');
2064
-
2065
- add_action('init', array(&$this, 'subscribe2'));
2066
- if ('1' == $this->subscribe2_options['show_button']) {
2067
- add_action('init', array(&$this, 'button_init'));
2068
- }
2069
- }
2070
-
2071
- function subscribe2() {
2072
- global $table_prefix;
2073
-
2074
- load_plugin_textdomain('subscribe2', 'wp-content/plugins/subscribe2');
2075
-
2076
- // do we need to install anything?
2077
- $this->public = $table_prefix . "subscribe2";
2078
- if(!mysql_query("DESCRIBE " . $this->public)) { $this->install(); }
2079
- //do we need to upgrade anything?
2080
- if ($this->subscribe2_options['version'] !== S2VERSION) {
2081
- add_action('shutdown', array(&$this, 'upgrade'));
2082
- }
2083
-
2084
- if (isset($_GET['s2'])) {
2085
- // someone is confirming a request
2086
- add_filter('query_string', array(&$this, 'query_filter'));
2087
- add_filter('the_title', array(&$this, 'title_filter'));
2088
- add_filter('the_content', array(&$this, 'confirm'));
2089
- }
2090
-
2091
- //add regular actions and filters
2092
- add_action('admin_head', array(&$this, 'admin_head'));
2093
- add_action('admin_menu', array(&$this, 'admin_menu'));
2094
- add_action('create_category', array(&$this, 'autosub_new_category'));
2095
- add_action('register_form', array(&$this, 'register_form'));
2096
- add_filter('the_content', array(&$this, 'filter'));
2097
- add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
2098
-
2099
- // add action to display editor buttons if option is enabled
2100
- if ('1' == $this->subscribe2_options['show_button']) {
2101
- add_action('edit_page_form', array(&$this, 's2_edit_form'));
2102
- add_action('edit_form_advanced', array(&$this, 's2_edit_form'));
2103
- }
2104
-
2105
- // add action for automatic subscription based on option settings
2106
- if ('yes' == $this->subscribe2_options['autosub']) {
2107
- add_action('user_register', array(&$this, 'register'));
2108
- } elseif ('wpreg' == $this->subscribe2_options['autosub']) {
2109
- add_action('register_post', array(&$this, 'register_post'));
2110
- }
2111
-
2112
- // add actions for processing posts based on per-post or cron email settings
2113
- if ($this->subscribe2_options['email_freq'] != 'never') {
2114
- add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
2115
- } else {
2116
- add_action('publish_post', array(&$this, 'publish'));
2117
- add_action('edit_post', array(&$this, 'edit'));
2118
- add_action('private_to_published', array(&$this, 'private2publish'));
2119
- }
2120
-
2121
- // add action to email notification about pages if option is enabled
2122
- if ($this->subscribe2_options['pages'] == 'yes') {
2123
- add_action('publish_page', array(&$this, 'publish'));
2124
- }
2125
-
2126
- // load our strings
2127
- $this->load_strings();
2128
- } // end subscribe2()
2129
-
2130
- /* ===== ButtonSnap configuration ===== */
2131
- /**
2132
- Register our button in the QuickTags bar
2133
- */
2134
- function button_init() {
2135
- if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) return;
2136
- if ( 'true' == get_user_option('rich_editing') ) {
2137
- // Load and append our TinyMCE external plugin
2138
- add_filter('mce_plugins', array(&$this, 'mce_plugins'));
2139
- add_filter('mce_buttons', array(&$this, 'mce_buttons'));
2140
- add_action('tinymce_before_init', array(&$this, 'tinymce_before_init'));
2141
- add_action('marker_css', array(&$this, 'button_css'));
2142
- } else {
2143
- buttonsnap_separator();
2144
- buttonsnap_jsbutton(get_option('siteurl') . '/wp-content/plugins/subscribe2/include/s2_button.png', __('Subscribe2', 'subscribe2'), 's2_insert_token();');
2145
- }
2146
- }
2147
-
2148
- /**
2149
- Style a marker in the Rich Text Editor for our tag
2150
- By default, the RTE suppresses output of HTML comments, so this
2151
- places a CSS style on our token in order to make it display
2152
- */
2153
- function button_css() {
2154
- $marker_url = get_option('siteurl') . '/wp-content/plugins/subscribe2/include/s2_marker.png';
2155
- echo "
2156
- .s2_marker {
2157
- display: block;
2158
- height: 45px;
2159
- margin-top: 5px;
2160
- background-image: url({$marker_url});
2161
- background-repeat: no-repeat;
2162
- background-position: center;
2163
- }
2164
- ";
2165
- }
2166
-
2167
- // Add buttons in WordPress v2.1+, thanks to An-archos
2168
- function mce_plugins($plugins) {
2169
- array_push($plugins, '-subscribe2quicktags');
2170
- return $plugins;
2171
- }
2172
-
2173
- function mce_buttons($buttons) {
2174
- array_push($buttons, 'separator');
2175
- array_push($buttons, 'subscribe2quicktags');
2176
- return $buttons;
2177
- }
2178
-
2179
- function tinymce_before_init() {
2180
- $this->fullpath = get_option('siteurl') . '/wp-content/plugins/subscribe2/tinymce/';
2181
- echo "tinyMCE.loadPlugin('subscribe2quicktags', '" . $this->fullpath . "');\n";
2182
- }
2183
-
2184
- function s2_edit_form() {
2185
- echo "<!-- Start Subscribe2 Quicktags Javascript -->\r\n";
2186
- echo "<script type=\"text/javascript\">\r\n";
2187
- echo "//<![CDATA[\r\n";
2188
- echo "function s2_insert_token() {
2189
- buttonsnap_settext('<!--subscribe2-->');
2190
- }\r\n";
2191
- echo "//]]>\r\n";
2192
- echo "</script>\r\n";
2193
- echo "<!-- End Subscribe2 Quicktags Javascript -->\r\n";
2194
- }
2195
-
2196
- /* ===== our variables ===== */
2197
- // cache variables
2198
- var $version = '';
2199
- var $all_public = '';
2200
- var $all_unconfirmed = '';
2201
- var $excluded_cats = '';
2202
- var $post_title = '';
2203
- var $permalink = '';
2204
- var $myname = '';
2205
- var $myemail = '';
2206
- var $s2_subject = '[BLOGNAME] TITLE';
2207
- var $signup_dates = array();
2208
- var $private = false;
2209
- var $filtered = 0;
2210
-
2211
- // state variables used to affect processing
2212
- var $action = '';
2213
- var $email = '';
2214
- var $message = '';
2215
- var $error = '';
2216
-
2217
- // some messages
2218
- var $please_log_in = '';
2219
- var $use_profile = '';
2220
- var $confirmation_sent = '';
2221
- var $already_subscribed = '';
2222
- var $not_subscribed ='';
2223
- var $not_an_email = '';
2224
- var $barred_domain = '';
2225
- var $mail_sent = '';
2226
- var $form = '';
2227
- var $no_such_email = '';
2228
- var $added = '';
2229
- var $deleted = '';
2230
- var $confirm_subject = '';
2231
- var $options_saved = '';
2232
- var $options_reset = '';
2233
- } // end class subscribe2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2234
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Subscribe2
4
+ Plugin URI: http://subscribe2.wordpress.com
5
+ Description: Notifies an email list when new entries are posted.
6
+ Version: 4.7
7
+ Author: Matthew Robinson
8
+ Author URI: http://subscribe2.wordpress.com
9
+ */
10
+
11
+ /*
12
+ Copyright (C) 2006-8 Matthew Robinson
13
+ Based on the Original Subscribe2 plugin by
14
+ Copyright (C) 2005 Scott Merrill (skippy@skippy.net)
15
+
16
+ This program is free software; you can redistribute it and/or
17
+ modify it under the terms of the GNU General Public License
18
+ as published by the Free Software Foundation; either version 2
19
+ of the License, or (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program; if not, write to the Free Software
28
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
+ http://www.gnu.org/licenses/gpl.html
30
+ */
31
+
32
+ // If you are on a host that limits the number of recipients
33
+ // permitted on each outgoing email message
34
+ // change the value on the line below to your hosts limit
35
+ define('BCCLIMIT', '0');
36
+
37
+ // by default, Subscribe2 grabs the first page from your database for use
38
+ // when displaying the confirmation screen to public subscribers.
39
+ // You can override this by specifying a page ID on the line below.
40
+ define('S2PAGE', '0');
41
+
42
+ // our version number. Don't touch this or any line below
43
+ // unless you know exacly what you are doing
44
+ define('S2VERSION', '4.7');
45
+ define ('S2PATH', trailingslashit(dirname(__FILE__)));
46
+
47
+ // use Owen's excellent ButtonSnap library
48
+ if (!function_exists(buttonsnap_textbutton)) {
49
+ require(ABSPATH . 'wp-content/plugins/subscribe2/include/buttonsnap.php');
50
+ }
51
+
52
+ $mysubscribe2 = new s2class;
53
+ $mysubscribe2->s2init();
54
+
55
+ // start our class
56
+ class s2class {
57
+ // variables and constructor are declared at the end
58
+
59
+ /**
60
+ Load all our strings
61
+ */
62
+ function load_strings() {
63
+ // adjust the output of Subscribe2 here
64
+
65
+ $this->please_log_in = "<p>" . __('To manage your subscription options please ', 'subscribe2') . "<a href=\"" . get_option('siteurl') . "/wp-login.php\">" . __('login', 'subscribe2') . "</a>.</p>";
66
+
67
+ $this->use_profile_admin = "<p>" . __('You may manage your subscription options from your ', 'subscribe2') . "<a href=\"" . get_option('siteurl') . "/wp-admin/users.php?page=" . plugin_basename(__FILE__) . "\">" . __('profile', 'subscribe2') . "</a>.</p>";
68
+
69
+ $this->use_profile_users = "<p>" . __('You may manage your subscription options from your ', 'subscribe2') . "<a href=\"" . get_option('siteurl') . "/wp-admin/profile.php?page=" . plugin_basename(__FILE__) . "\">" . __('profile', 'subscribe2') . "</a>.</p>";
70
+
71
+ $this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
72
+
73
+ $this->already_subscribed = "<p>" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
74
+
75
+ $this->not_subscribed = "<p>" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
76
+
77
+ $this->not_an_email = "<p>" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
78
+
79
+ $this->barred_domain = "<p>" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
80
+
81
+ $this->error = "<p>" . __('Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2') . "</p>";
82
+
83
+ $this->mail_sent = "<p>" . __('Message sent!', 'subscribe2') . "</p>";
84
+
85
+ $this->form = "<form method=\"post\" action=\"\">" . __('Your email:', 'subscribe2') . "&#160;<input type=\"text\" name=\"email\" value=\"\" size=\"20\" />&#160;<br /><input type=\"radio\" name=\"s2_action\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . " <input type=\"radio\" name=\"s2_action\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . " &#160;<input type=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></form>\r\n";
86
+
87
+ // confirmation messages
88
+ $this->no_such_email = "<p>" . __('No such email address is registered.', 'subscribe2') . "</p>";
89
+
90
+ $this->added = "<p>" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
91
+
92
+ $this->deleted = "<p>" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
93
+
94
+ $this->confirm_subject = "[" . get_option('blogname') . "] " . __('Please confirm your request', 'subscribe2');
95
+
96
+ $this->remind_subject = "[" . get_option('blogname') . "] " . __('Subscription Reminder', 'subscribe2');
97
+
98
+ $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
99
+
100
+ $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
101
+
102
+ // menu strings
103
+ $this->options_saved = __('Options saved!', 'subscribe2');
104
+ $this->options_reset = __('Options reset!', 'subscribe2');
105
+ } // end load_strings()
106
+
107
+ /* ===== WordPress menu registration ===== */
108
+ /**
109
+ Hook the menu
110
+ */
111
+ function admin_menu() {
112
+ add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", __FILE__, array(&$this, 'manage_menu'));
113
+ add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2','subscribe2'), "manage_options", __FILE__, array(&$this, 'options_menu'));
114
+ add_users_page(__('Subscriptions', 'subscribe2'), __('Subscriptions', 'subscribe2'), "read", __FILE__, array(&$this, 'user_menu'));
115
+ add_submenu_page('post-new.php', __('Mail Subscribers','subscribe2'), __('Mail Subscribers', 'subscribe2'),"manage_options", __FILE__, array(&$this, 'write_menu'));
116
+ $s2nonce = md5('subscribe2');
117
+ }
118
+
119
+ /**
120
+ Insert Javascript into admin_header
121
+ */
122
+ function admin_head() {
123
+ echo "<script type=\"text/javascript\">\r\n";
124
+ echo "<!--\r\n";
125
+ echo "function setAll(theElement) {\r\n";
126
+ echo " var theForm = theElement.form, z = 0;\r\n";
127
+ echo " for(z=0; z<theForm.length;z++){\r\n";
128
+ echo " if(theForm[z].type == 'checkbox' && theForm[z].name == 'category[]'){\r\n";
129
+ echo " theForm[z].checked = theElement.checked;\r\n";
130
+ echo " }\r\n";
131
+ echo " }\r\n";
132
+ echo "}\r\n";
133
+ echo "-->\r\n";
134
+ echo "</script>\r\n";
135
+ }
136
+
137
+ function add_weekly_sched($sched) {
138
+ $sched['weekly'] = array('interval' => 604800, 'display' => __('Once Weekly','subscribe2'));
139
+ return $sched;
140
+ }
141
+
142
+ /* ===== Install, upgrade, reset ===== */
143
+ /**
144
+ Install our table
145
+ */
146
+ function install() {
147
+ // include upgrade-functions for maybe_create_table;
148
+ if (!function_exists('maybe_create_table')) {
149
+ require_once(ABSPATH . 'wp-admin/install-helper.php');
150
+ }
151
+ $date = date('Y-m-d');
152
+ $sql = "CREATE TABLE $this->public (
153
+ id int(11) NOT NULL auto_increment,
154
+ email varchar(64) NOT NULL default '',
155
+ active tinyint(1) default 0,
156
+ date DATE default '$date' NOT NULL,
157
+ PRIMARY KEY (id) )";
158
+
159
+ // create the table, as needed
160
+ maybe_create_table($this->public, $sql);
161
+ $this->reset();
162
+ } // end install()
163
+
164
+ /**
165
+ Upgrade the database
166
+ */
167
+ function upgrade() {
168
+ global $wpdb;
169
+
170
+ // include upgrade-functions for maybe_create_table;
171
+ if (!function_exists('maybe_create_table')) {
172
+ require_once(ABSPATH . 'wp-admin/install-helper.php');
173
+ }
174
+ $date = date('Y-m-d');
175
+ maybe_add_column($this->public, 'date', "ALTER TABLE `$this->public` ADD `date` DATE DEFAULT '$date' NOT NULL AFTER `active`;");
176
+
177
+ // let's take the time to check process registered users
178
+ // existing public subscribers are subscribed to all categories
179
+ $users = $wpdb->get_col("SELECT ID FROM $wpdb->users");
180
+ if (!empty($users)) {
181
+ foreach ($users as $user) {
182
+ $this->register($user);
183
+ }
184
+ }
185
+ // update the options table to serialized format
186
+ $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
187
+
188
+ if (!empty($old_options)) {
189
+ foreach ($old_options as $option) {
190
+ $value = get_option($option);
191
+ $option_array = substr($option, 3);
192
+ $this->subscribe2_options[$option_array] = $value;
193
+ delete_option($option);
194
+ }
195
+ }
196
+ $this->subscribe2_options['version'] = S2VERSION;
197
+ //double check that the options are in the database
198
+ require(S2PATH . "include/options.php");
199
+ update_option('subscribe2_options', $this->subscribe2_options);
200
+ } // end upgrade()
201
+
202
+ /**
203
+ Reset our options
204
+ */
205
+ function reset() {
206
+ delete_option('subscribe2_options');
207
+ wp_clear_scheduled_hook('s2_digest_cron');
208
+ unset($this->subscribe2_options);
209
+ require(S2PATH . "include/options.php");
210
+ update_option('subscribe2_options', $this->subscribe2_options);
211
+ } // end reset()
212
+
213
+ /* ===== mail handling ===== */
214
+ /**
215
+ Performs string substitutions for subscribe2 mail texts
216
+ */
217
+ function substitute($string = '') {
218
+ if ('' == $string) {
219
+ return;
220
+ }
221
+ $string = str_replace("BLOGNAME", get_option('blogname'), $string);
222
+ $string = str_replace("BLOGLINK", get_bloginfo('url'), $string);
223
+ $string = str_replace("TITLE", stripslashes($this->post_title), $string);
224
+ $string = str_replace("PERMALINK", $this->permalink, $string);
225
+ $string = str_replace("MYNAME", stripslashes($this->myname), $string);
226
+ $string = str_replace("EMAIL", $this->myemail, $string);
227
+ $string = str_replace("AUTHORNAME", $this->authorname, $string);
228
+ return $string;
229
+ } // end substitute()
230
+
231
+ /**
232
+ Delivers email to recipients in HTML or plaintext
233
+ */
234
+ function mail ($recipients = array(), $subject = '', $message = '', $type='text') {
235
+ if ( (empty($recipients)) || ('' == $message) ) { return; }
236
+
237
+ // Set sender details
238
+ if ('' == $this->myname) {
239
+ $admin = $this->get_userdata();
240
+ $this->myname = $admin->display_name;
241
+ $this->myemail = $admin->user_email;
242
+ }
243
+ $headers = "From: \"" . $this->myname . "\" <" . $this->myemail . ">\n";
244
+ $headers .= "Return-path: <" . $this->myemail . ">\n";
245
+ $headers .= "Reply-To: \"" . $this->myname . "\" <" . $this->myemail . ">\n";
246
+ $headers .= "X-Mailer:PHP" . phpversion() . "\n";
247
+ $headers .= "Precedence: list\nList-Id: " . get_option('blogname') . "\n";
248
+
249
+ if ('html' == $type) {
250
+ // To send HTML mail, the Content-Type header must be set
251
+ $headers .= "MIME-Version: 1.0\n";
252
+ $headers .= "Content-Type: " . get_bloginfo('html_type') . "; charset=\"". get_bloginfo('charset') . "\"\n";
253
+ $mailtext = "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>";
254
+ } else {
255
+ $headers .= "MIME-Version: 1.0\n";
256
+ $headers .= "Content-Type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
257
+ $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
258
+ $message = preg_replace('|&amp;|', '&', $message);
259
+ $mailtext = wordwrap(strip_tags($message), 80, "\n");
260
+ }
261
+
262
+ // BCC all recipients
263
+ $bcc = '';
264
+ if ( (defined('BCCLIMIT')) && (BCCLIMIT > 0) && (count($recipients) > BCCLIMIT) ) {
265
+ // we're on Dreamhost, and have more than 30 susbcribers
266
+ $count = 1;
267
+ $batch = array();
268
+ foreach ($recipients as $recipient) {
269
+ // advance the array pointer by one, for use down below
270
+ // the array pointer _is not_ advanced by the foreach() loop itself
271
+ next($recipients);
272
+ $recipient = trim($recipient);
273
+ // sanity check -- make sure we have a valid email
274
+ if (!is_email($recipient)) { continue; }
275
+ // and NOT the sender's email, since they'll
276
+ // get a copy anyway
277
+ if ( (! empty($recipient)) && ($this->myemail != $recipient) ) {
278
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
279
+ // Bcc Headers now constructed by phpmailer class
280
+ }
281
+ if (BCCLIMIT == $count) {
282
+ $count = 1;
283
+ $batch[] = $bcc;
284
+ $bcc = '';
285
+ } else {
286
+ if (false == current($recipients)) {
287
+ // we've reached the end of the subscriber list
288
+ // add what we have to the batch, and move on
289
+ $batch[] = $bcc;
290
+ break;
291
+ } else {
292
+ $count++;
293
+ }
294
+ }
295
+ }
296
+ // rewind the array, just to be safe
297
+ reset($recipients);
298
+ } else {
299
+ // we're not on dreamhost, or have less than 30
300
+ // subscribers, so do it normal
301
+ foreach ($recipients as $recipient) {
302
+ $recipient = trim($recipient);
303
+ // sanity check -- make sure we have a valid email
304
+ if (!is_email($recipient)) { continue; }
305
+ // and NOT the sender's email, since they'll
306
+ // get a copy anyway
307
+ if ( (!empty($recipient)) && ($this->myemail != $recipient) ) {
308
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
309
+ // Bcc Headers now constructed by phpmailer class
310
+ }
311
+ }
312
+ $headers .= "$bcc\r\n";
313
+ }
314
+ // actually send mail
315
+ if ( (defined('BCCLIMIT')) && (BCCLIMIT > 0) && (isset($batch)) ) {
316
+ foreach ($batch as $bcc) {
317
+ $newheaders = $headers . "$bcc\r\n";
318
+ @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
319
+ }
320
+ } else {
321
+ @wp_mail($this->myemail, $subject, $mailtext, $headers);
322
+ }
323
+ return;
324
+ } // end mail()
325
+
326
+ /**
327
+ Sends an email notification of a new post
328
+ */
329
+ function publish($post = 0) {
330
+ if (!$post) { return $post; }
331
+ $s2mail = get_post_meta($post->ID, 's2mail', true);
332
+ if (strtolower(trim($s2mail)) == 'no') { return $post; }
333
+
334
+ // are we doing daily digests? If so, don't send anything now
335
+ if ($this->subscribe2_options['email_freq'] != 'never') { return $post; }
336
+
337
+ // is the current post a page
338
+ // and should this not generate a notification email?
339
+ if ( ($this->subscribe2_options['pages'] == 'no') && ($post->post_type == 'page') ) {
340
+ return $post;
341
+ }
342
+
343
+ // is this post set in the future?
344
+ if ($post->post_date > current_time('mysql')) {
345
+ // bail out
346
+ return $post;
347
+ }
348
+
349
+ //Are we sending notifications for password protected posts?
350
+ if ( ($this->subscribe2_options['password'] == "no") && ($post->post_password != '') ) {
351
+ return $post;
352
+ }
353
+
354
+ $post_cats = wp_get_post_categories($post->ID);
355
+ $post_cats_string = implode(',', $post_cats);
356
+ $check = false;
357
+ // is the current post assigned to any categories
358
+ // which should not generate a notification email?
359
+ foreach (explode(',', $this->subscribe2_options['exclude']) as $cat) {
360
+ if (in_array($cat, $post_cats)) {
361
+ $check = true;
362
+ }
363
+ }
364
+ // if so, bail out
365
+ if ($check) {
366
+ // hang on -- can registered users subscribe to
367
+ // excluded categories?
368
+ if ('0' == $this->subscribe2_options['reg_override']) {
369
+ // nope? okay, let's leave
370
+ return $post;
371
+ }
372
+ }
373
+
374
+ // Are we sending notifications for Private posts?
375
+ if ($this->subscribe2_options['private'] == "yes") {
376
+ // don't send notification to public users
377
+ $check = true;
378
+ }
379
+
380
+ // lets collect our public subscribers
381
+ // and all our registered subscribers for these categories
382
+ if (!$check) {
383
+ // if this post is assigned to an excluded
384
+ // category, then this test will prevent
385
+ // the public from receiving notification
386
+ $public = $this->get_public();
387
+ }
388
+ $registered = $this->get_registered("cats=$post_cats_string");
389
+
390
+ // do we have subscribers?
391
+ if ( (empty($public)) && (empty($registered)) ) {
392
+ // if not, no sense doing anything else
393
+ return $post;
394
+ }
395
+ // we set these class variables so that we can avoid
396
+ // passing them in function calls a little later
397
+ $this->post_title = $post->post_title;
398
+ $this->permalink = "<a href=\"" . get_permalink($post->ID) . "\">" . get_permalink($post->ID) . "</a>";
399
+
400
+ $author = get_userdata($post->post_author);
401
+ $this->authorname = $author->display_name;
402
+
403
+ // do we send as admin, or post author?
404
+ if ('author' == $this->subscribe2_options['sender']) {
405
+ // get author details
406
+ $user =& $author;
407
+ } else {
408
+ // get admin details
409
+ $user = $this->get_userdata();
410
+ }
411
+ $this->myemail = $user->user_email;
412
+ $this->myname = $user->display_name;
413
+ // Get email subject
414
+ $subject = $this->substitute(stripslashes($this->s2_subject));
415
+ // Get the message template
416
+ $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
417
+
418
+ $plaintext = $post->post_content;
419
+ $content = apply_filters('the_content', $post->post_content);
420
+ $content = str_replace("]]>", "]]&gt", $content);
421
+ $excerpt = $post->post_excerpt;
422
+ if ('' == $excerpt) {
423
+ // no excerpt, is there a <!--more--> ?
424
+ if (false !== strpos($plaintext, '<!--more-->')) {
425
+ list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
426
+ // strip leading and trailing whitespace
427
+ $excerpt = strip_tags($excerpt);
428
+ $excerpt = trim($excerpt);
429
+ } else {
430
+ // no <!--more-->, so grab the first 55 words
431
+ $excerpt = strip_tags($plaintext);
432
+ $excerpt_length = 55;
433
+ $words = explode(' ', $excerpt, $excerpt_length + 1);
434
+ if (count($words) > $excerpt_length) {
435
+ array_pop($words);
436
+ array_push($words, '[...]');
437
+ $excerpt = implode(' ', $words);
438
+ }
439
+ }
440
+ }
441
+
442
+ // first we send plaintext summary emails
443
+ $body = str_replace("POST", $excerpt, $mailtext);
444
+ $registered = $this->get_registered("cats=$post_cats_string&format=text&amount=excerpt");
445
+ if (empty($registered)) {
446
+ $recipients = (array)$public;
447
+ }
448
+ elseif (empty($public)) {
449
+ $recipients = (array)$registered;
450
+ } else {
451
+ $recipients = array_merge((array)$public, (array)$registered);
452
+ }
453
+ $this->mail($recipients, $subject, $body);
454
+ // next we send plaintext full content emails
455
+ $body = str_replace("POST", strip_tags($plaintext), $mailtext);
456
+ $this->mail($this->get_registered("cats=$post_cats_string&format=text&amount=post"), $subject, $body);
457
+ // finally we send html full content emails
458
+ $body = str_replace("\r\n", "<br />\r\n", $mailtext);
459
+ $body = str_replace("POST", $content, $body);
460
+ $this->mail($this->get_registered("cats=$post_cats_string&format=html"), $subject, $body, 'html');
461
+
462
+ return $id;
463
+ } // end publish()
464
+
465
+ /**
466
+ Send confirmation email to the user
467
+ */
468
+ function send_confirm($what = '', $is_remind = FALSE) {
469
+ if ($this->filtered == 1) { return; }
470
+ if ( (!$this->email) || (!$what) ) {
471
+ return false;
472
+ }
473
+ $id = $this->get_id($this->email);
474
+ if (!$id) {
475
+ return false;
476
+ }
477
+
478
+ // generate the URL "?s2=ACTION+HASH+ID"
479
+ // ACTION = 1 to subscribe, 0 to unsubscribe
480
+ // HASH = md5 hash of email address
481
+ // ID = user's ID in the subscribe2 table
482
+ //use home instead of siteurl incase index.php is not in core wordpress directory
483
+ $link = get_option('home') . "/?s2=";
484
+
485
+ if ('add' == $what) {
486
+ $link .= '1';
487
+ } elseif ('del' == $what) {
488
+ $link .= '0';
489
+ }
490
+ $link .= md5($this->email);
491
+ $link .= $id;
492
+
493
+ $admin = $this->get_userdata();
494
+ $this->myname = $admin->display_name;
495
+
496
+ if ($is_remind == TRUE) {
497
+ $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
498
+ $subject = stripslashes($this->remind_subject);
499
+ } else {
500
+ $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
501
+ if ('add' == $what) {
502
+ $body = str_replace("ACTION", $this->subscribe, $body);
503
+ } elseif ('del' == $what) {
504
+ $body = str_replace("ACTION", $this->unsubscribe, $body);
505
+ }
506
+ $subject = stripslashes($this->confirm_subject);
507
+ }
508
+
509
+ $body = str_replace("LINK", $link, $body);
510
+
511
+ $mailheaders .= "From: \"" . $admin->display_name . "\" <" . $admin->user_email . ">\n";
512
+ $mailheaders .= "Reply-To: \"" . $admin->display_name . "\" <" . $admin->user_email . ">\n";
513
+ $mailheaders .= "Return-path: <" . $admin->user_email . ">\n";
514
+ $mailheaders .= "X-Mailer:PHP" . phpversion() . "\n";
515
+ $mailheaders .= "Precedence: list\nList-Id: " . get_option('blogname') . "\n";
516
+ $mailheaders .= "MIME-Version: 1.0\n";
517
+ $mailheaders .= "Content-Type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
518
+
519
+ return @wp_mail($this->email, $subject, $body, $mailheaders);
520
+ } // end send_confirm()
521
+
522
+ /* ===== Subscriber functions ===== */
523
+ /**
524
+ Given a public subscriber ID, returns the email address
525
+ */
526
+ function get_email ($id = 0) {
527
+ global $wpdb;
528
+
529
+ if (!$id) {
530
+ return false;
531
+ }
532
+ return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
533
+ } // end get_email
534
+
535
+ /**
536
+ Given a public subscriber email, returns the subscriber ID
537
+ */
538
+ function get_id ($email = '') {
539
+ global $wpdb;
540
+
541
+ if (!$email) {
542
+ return false;
543
+ }
544
+ return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
545
+ } // end get_id()
546
+
547
+ /**
548
+ Activate an email address
549
+ If the address is not already present, it will be added
550
+ */
551
+ function activate ($email = '') {
552
+ global $wpdb;
553
+
554
+ if ('' == $email) {
555
+ if ('' != $this->email) {
556
+ $email = $this->email;
557
+ } else {
558
+ return false;
559
+ }
560
+ }
561
+
562
+ if (false !== $this->is_public($email)) {
563
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
564
+ if ($check) { return; }
565
+ $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
566
+ } else {
567
+ $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '1', NOW())");
568
+ }
569
+ } // end activate()
570
+
571
+ /**
572
+ Add an unconfirmed email address to the subscriber list
573
+ */
574
+ function add ($email = '') {
575
+ if ($this->filtered ==1) { return; }
576
+ global $wpdb;
577
+
578
+ if ('' == $email) {
579
+ if ('' != $this->email) {
580
+ $email = $this->email;
581
+ } else {
582
+ return false;
583
+ }
584
+ }
585
+
586
+ if (!is_email($email)) { return false; }
587
+
588
+ if (false !== $this->is_public($email)) {
589
+ $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE email='$email'");
590
+ } else {
591
+ $wpdb->get_results("INSERT INTO $this->public (email, active, date) VALUES ('$email', '0', NOW())");
592
+ }
593
+ } // end add()
594
+
595
+ /**
596
+ Remove a user from the subscription table
597
+ */
598
+ function delete($email = '') {
599
+ global $wpdb;
600
+
601
+ if ('' == $email) {
602
+ if ('' != $this->email) {
603
+ $email = $this->email;
604
+ } else {
605
+ return false;
606
+ }
607
+ }
608
+
609
+ if (!is_email($email)) { return false; }
610
+ $wpdb->get_results("DELETE FROM $this->public WHERE email='$email'");
611
+ } // end delete()
612
+
613
+ /**
614
+ Toggle a public subscriber's status
615
+ */
616
+ function toggle($email = '') {
617
+ global $wpdb;
618
+
619
+ if ( ('' == $email) || (! is_email($email)) ) { return false; }
620
+
621
+ // let's see if this is a public user
622
+ $status = $this->is_public($email);
623
+ if (false === $status) { return false; }
624
+
625
+ if ('0' == $status) {
626
+ $wpdb->get_results("UPDATE $this->public SET active='1' WHERE email='$email'");
627
+ } else {
628
+ $wpdb->get_results("UPDATE $this->public SET active='0' WHERE email='$email'");
629
+ }
630
+ } // end toggle()
631
+
632
+ /**
633
+ Send reminder email to unconfirmed public subscribers
634
+ */
635
+ function remind($emails = '') {
636
+ if ('' == $emails) { return false; }
637
+
638
+ $admin = $this->get_userdata();
639
+ $this->myname = $admin->display_name;
640
+
641
+ $recipients = explode(",", $emails);
642
+ if (!is_array($recipients)) { $recipients = array(); }
643
+ foreach ($recipients as $recipient) {
644
+ $this->email = $recipient;
645
+ $this->send_confirm('add', TRUE);
646
+ }
647
+ } //end remind()
648
+
649
+ /**
650
+ Check email is not from a barred domain
651
+ */
652
+ function is_barred($email='') {
653
+ $barred_option = $this->subscribe2_options['barred'];
654
+ list($user, $domain) = split('@', $email);
655
+ $bar_check = stristr($barred_option, $domain);
656
+
657
+ if(!empty($bar_check)) {
658
+ return true;
659
+ } else {
660
+ return false;
661
+ }
662
+ } //end is_barred()
663
+
664
+ /**
665
+ Confirm request from the link emailed to the user and email the admin
666
+ */
667
+ function confirm($content = '') {
668
+ global $wpdb;
669
+
670
+ if (1 == $this->filtered) { return $content; }
671
+
672
+ $code = $_GET['s2'];
673
+ $action = intval(substr($code, 0, 1));
674
+ $hash = substr($code, 1, 32);
675
+ $code = str_replace($hash, '', $code);
676
+ $id = intval(substr($code, 1));
677
+ if ($id) {
678
+ $this->email = $this->get_email($id);
679
+ if ( (!$this->email) || ($hash !== md5($this->email)) ) {
680
+ return $this->no_such_email;
681
+ }
682
+ } else {
683
+ return $this->no_such_email;
684
+ }
685
+
686
+ if ('1' == $action) {
687
+ // make this subscription active
688
+ $this->activate();
689
+ $this->message = $this->added;
690
+ $subject = '[' . get_option('blogname') . '] ' . __('New subscriber', 'subscribe2');
691
+ $message = $this->email . " " . __('subscribed to email notifications!', 'subscribe2');
692
+ $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value='10'");
693
+ $this->mail($recipients, $subject, $message);
694
+ $this->filtered = 1;
695
+ } elseif ('0' == $action) {
696
+ // remove this subscriber
697
+ $this->delete();
698
+ $this->message = $this->deleted;
699
+ $this->filtered = 1;
700
+ }
701
+
702
+ if ('' != $this->message) {
703
+ return $this->message;
704
+ }
705
+ } // end confirm
706
+
707
+ /**
708
+ Is the supplied email address a public subscriber?
709
+ */
710
+ function is_public($email = '') {
711
+ global $wpdb;
712
+
713
+ if ('' == $email) { return false; }
714
+
715
+ $check = $wpdb->get_var("SELECT active FROM $this->public WHERE email='$email'");
716
+ if ( ('0' == $check) || ('1' == $check) ) {
717
+ return $check;
718
+ } else {
719
+ return false;
720
+ }
721
+ } // end is_public
722
+
723
+ /**
724
+ Is the supplied email address a registered user of the blog?
725
+ */
726
+ function is_registered($email = '') {
727
+ global $wpdb;
728
+
729
+ if ('' == $email) { return false; }
730
+
731
+ $check = $wpdb->get_var("SELECT email FROM $wpdb->users WHERE user_email='$email'");
732
+ if ($check) {
733
+ return true;
734
+ } else {
735
+ return false;
736
+ }
737
+ }
738
+
739
+ /**
740
+ Return an array of all the public subscribers
741
+ */
742
+ function get_public ($confirmed = 1) {
743
+ global $wpdb;
744
+ if (1 == $confirmed) {
745
+ if ('' == $this->all_public) {
746
+ $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
747
+ }
748
+ return $this->all_public;
749
+ } else {
750
+ if ('' == $this->all_unconfirmed) {
751
+ $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
752
+ }
753
+ return $this->all_unconfirmed;
754
+ }
755
+ } // end get_public()
756
+
757
+ /**
758
+ Return an array of registered subscribers
759
+ Collect all the registered users of the blog who are subscribed to the specified categories
760
+ */
761
+ function get_registered ($args = '') {
762
+ global $wpdb, $wp_version, $wpmu_version;
763
+
764
+ // Is this WordPressMU or not?
765
+ if ( (isset($wpmu_version)) || (strpos($wp_version, 'wordpress-mu')) ) {
766
+ $s2_mu = true;
767
+ }
768
+
769
+ $format = '';
770
+ $amount = '';
771
+ $cats = '';
772
+ $subscribers = array();
773
+
774
+ parse_str($args, $r);
775
+ if (!isset($r['cats']))
776
+ $r['cats'] = '';
777
+ if (!isset($r['format']))
778
+ $r['format'] = 'all';
779
+ if (!isset($r['amount']))
780
+ $r['amount'] = 'all';
781
+
782
+ $JOIN = ''; $AND = '';
783
+ // text or HTML subscribers
784
+ if ('all' != $r['format']) {
785
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
786
+ $AND .= " AND b.meta_key='s2_format' AND b.meta_value=";
787
+ if ('html' == $r['format']) {
788
+ $AND .= "'html'";
789
+ } elseif ('text' == $r['format']) {
790
+ $AND .= "'text'";
791
+ }
792
+ }
793
+
794
+ // full post or excerpt subscribers
795
+ if ('all' != $r['amount']) {
796
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
797
+ $AND .= " AND c.meta_key='s2_excerpt' AND c.meta_value=";
798
+ if ('excerpt' == $r['amount']) {
799
+ $AND .= "'excerpt'";
800
+ } elseif ('post' == $r['amount']) {
801
+ $AND.= "'post'";
802
+ }
803
+ }
804
+
805
+ // specific category subscribers
806
+ if ('' != $r['cats']) {
807
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
808
+ foreach (explode(',', $r['cats']) as $cat) {
809
+ ('' == $and) ? $and = "d.meta_key='s2_cat$cat'" : $and .= " OR d.meta_key='s2_cat$cat'";
810
+ }
811
+ $AND .= " AND ($and)";
812
+ }
813
+
814
+ if ($s2_mu) {
815
+ $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities'" . $AND;
816
+ } else {
817
+ $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='s2_subscribed'" . $AND;
818
+ }
819
+ $result = $wpdb->get_col($sql);
820
+ if ($result) {
821
+ $ids = implode(',', $result);
822
+ return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
823
+ }
824
+ } // end get_registered()
825
+
826
+ /**
827
+ Collects the signup date for all public subscribers
828
+ */
829
+ function signup_date($email = '') {
830
+ if ('' == $email) { return false; }
831
+
832
+ global $wpdb;
833
+ if (!empty($this->signup_dates)) {
834
+ return $this->signup_dates[$email];
835
+ } else {
836
+ $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
837
+ foreach ($results as $result) {
838
+ $this->signup_dates[$result[0]] = $result[1];
839
+ }
840
+ return $this->signup_dates[$email];
841
+ }
842
+ } // end signup_date()
843
+
844
+ /**
845
+ Create the appropriate usermeta values when a user registers
846
+ If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
847
+ */
848
+ function register ($user_id = 0, $wpreg = '') {
849
+ global $wpdb;
850
+
851
+ if (0 == $user_id) { return $user_id; }
852
+ $user = get_userdata($user_id);
853
+ $all_cats = get_categories(array('hide_empty' => false));
854
+
855
+ if (0 == $this->subscribe2_options['reg_override']) {
856
+ // registered users are not allowed to subscribe to
857
+ // excluded categories
858
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
859
+ foreach ($all_cats as $cat => $term_id) {
860
+ if (in_array($all_cats[$cat]->term_id, $exclude)) {
861
+ $cat = (int)$cat;
862
+ unset($all_cats[$cat]);
863
+ }
864
+ }
865
+ }
866
+
867
+ foreach ($all_cats as $cat) {
868
+ ('' == $cats) ? $cats = "$cat->term_id" : $cats .= ",$cat->term_id";
869
+ }
870
+
871
+ if ('' == $cats) {
872
+ // sanity check, might occur if all cats excluded and reg_override = 0
873
+ return $user_id;
874
+ }
875
+
876
+ // has this user previously signed up for email notification?
877
+ if (false !== $this->is_public($user->user_email)) {
878
+ // delete this user from the public table, and subscribe them to all the categories
879
+ $this->delete($user->user_email);
880
+ update_usermeta($user_id, 's2_subscribed', $cats);
881
+ foreach(explode(',', $cats) as $cat) {
882
+ update_usermeta($user_id, 's2_cat' . $cat, "$cat");
883
+ }
884
+ update_usermeta($user_id, 's2_format', 'text');
885
+ update_usermeta($user_id, 's2_excerpt', 'excerpt');
886
+ update_usermeta($user_id, 's2_autosub', $this->subscribe2_options['autosub_def']);
887
+ } else {
888
+ // create post format entries for all users
889
+ $check = get_usermeta($user_id, 's2_format');
890
+ if (empty($check)) {
891
+ if ('html' == $this->subscribe2_options['autoformat']) {
892
+ update_usermeta($user_id, 's2_format', 'html');
893
+ update_usermeta($user_id, 's2_excerpt', 'post');
894
+ } elseif ('fulltext' == $this->subscribe2_options['autoformat']) {
895
+ update_usermeta($user_id, 's2_format', 'text');
896
+ update_usermeta($user_id, 's2_excerpt', 'post');
897
+ } else {
898
+ update_usermeta($user_id, 's2_format', 'text');
899
+ update_usermeta($user_id, 's2_excerpt', 'excerpt');
900
+ }
901
+ update_usermeta($user_id, 's2_autosub', $this->subscribe2_options['autosub_def']);
902
+ }
903
+ // ensure existing subscriptions are not overwritten on upgrade
904
+ $check = get_usermeta($user_id, 's2_subscribed');
905
+ // if the are no existing subscriptions, create them based on admin options
906
+ if (empty($check)) {
907
+ if ( ('yes' == $this->subscribe2_options['autosub']) || (('wpreg' == $this->subscribe2_options['autosub']) && (1 == $wpreg)) ) {
908
+ // don't add entries by default if autosub is off, messes up daily digests
909
+ update_usermeta($user_id, 's2_subscribed', $cats);
910
+ foreach(explode(',', $cats) as $cat) {
911
+ update_usermeta($user_id, 's2_cat' . $cat, "$cat");
912
+ }
913
+ } else {
914
+ update_usermeta($user_id, 's2_subscribed', '-1');
915
+ }
916
+ } else {
917
+ update_usermeta($user_id, 's2_autosub', 'no');
918
+ }
919
+ }
920
+ return $user_id;
921
+ } // end register()
922
+
923
+ /**
924
+ Subscribe all registered users to category selected on Admin Manage Page
925
+ */
926
+ function subscribe_registered_users ($emails = '', $cats = '') {
927
+ if ( ('' == $emails) || ('' == $cats) ) { return false; }
928
+ global $wpdb;
929
+
930
+ $useremails = explode(",", $emails);
931
+ $useremails = implode("', '", $useremails);
932
+
933
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
934
+ $user_IDs = $wpdb->get_col($sql);
935
+ if (!is_array($cats)) {
936
+ $cats = array($cats);
937
+ }
938
+
939
+ foreach ($user_IDs as $user_ID) {
940
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
941
+ if (!is_array($old_cats)) {
942
+ $old_cats = array($old_cats);
943
+ }
944
+ $new = array_diff($cats, $old_cats);
945
+ if (!empty($new)) {
946
+ // add subscription to these cat IDs
947
+ foreach ($new as $id) {
948
+ update_usermeta($user_ID, 's2_cat' . $id, "$id");
949
+ }
950
+ }
951
+ $newcats = array_merge($cats, $old_cats);
952
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
953
+ }
954
+ } // end subscribe_registered_users
955
+
956
+ /**
957
+ Unsubscribe all registered users to category selected on Admin Manage Page
958
+ */
959
+ function unsubscribe_registered_users ($emails = '', $cats = '') {
960
+ if ( ('' == $emails) || ('' == $cats) ) { return false; }
961
+ global $wpdb;
962
+
963
+ $useremails = explode(",", $emails);
964
+ $useremails = implode("', '", $useremails);
965
+
966
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
967
+ $user_IDs = $wpdb->get_col($sql);
968
+ if (!is_array($cats)) {
969
+ $cats = array($cats);
970
+ }
971
+
972
+ foreach ($user_IDs as $user_ID) {
973
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
974
+ if (!is_array($old_cats)) {
975
+ $old_cats = array($old_cats);
976
+ }
977
+ $remain = array_diff($old_cats, $cats);
978
+ if (!empty($remain)) {
979
+ // remove subscription to these cat IDs and update s2_subscribed
980
+ foreach ($cats as $id) {
981
+ delete_usermeta($user_ID, 's2_cat' . $id);
982
+ }
983
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $remain));
984
+ } else {
985
+ // remove subscription to these cat IDs and update s2_subscribed to ''
986
+ foreach ($cats as $id) {
987
+ delete_usermeta($user_ID, 's2_cat' . $id);
988
+ }
989
+ update_usermeta($user_ID, 's2_subscribed', '-1');
990
+ }
991
+ }
992
+ } // end unsubscribe_registered_users
993
+
994
+ /**
995
+ Autosubscribe registered users to newly created categories
996
+ if registered user has selected this option
997
+ */
998
+ function autosub_new_category ($new_category='') {
999
+ global $wpdb;
1000
+
1001
+ $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='s2_autosub' AND $wpdb->usermeta.meta_value='yes'";
1002
+ $user_IDs = $wpdb->get_col($sql);
1003
+ if ('' == $user_IDs) { return; }
1004
+
1005
+ foreach ($user_IDs as $user_ID) {
1006
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1007
+ if (!is_array($old_cats)) {
1008
+ $old_cats = array($old_cats);
1009
+ }
1010
+ // add subscription to these cat IDs
1011
+ update_usermeta($user_ID, 's2_cat' . $new_category, "$new_category");
1012
+ $newcats = array_merge($old_cats, (array)$new_category);
1013
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $newcats));
1014
+ }
1015
+ } // end autosub_new_category
1016
+
1017
+ /**
1018
+ Get admin data from record 1 or first user with admin rights
1019
+ */
1020
+ function get_userdata() {
1021
+ global $wpdb;
1022
+ $admin = get_userdata(1);
1023
+ if (empty($admin)) {
1024
+ $sql = "SELECT DISTINCT(ID) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value='10' LIMIT 1";
1025
+ $admin = get_userdata($wpdb->get_var($sql));
1026
+ }
1027
+ return $admin;
1028
+ } //end get_userdata
1029
+
1030
+ /* ===== Menus ===== */
1031
+ /**
1032
+ Our management page
1033
+ */
1034
+ function manage_menu() {
1035
+ global $wpdb, $s2nonce;
1036
+
1037
+ //Get Registered Subscribers for bulk management
1038
+ $registered = $this->get_registered();
1039
+ if (!empty($registered)) {
1040
+ $emails = implode(",", $registered);
1041
+ }
1042
+
1043
+ $what = '';
1044
+ $reminderform = false;
1045
+ $action = remove_query_arg(array('what', 's2page'));
1046
+ $this->action = attribute_escape($action);
1047
+ $urlpath = str_replace("\\","/",S2PATH);
1048
+ $urlpath = trailingslashit(get_option('siteurl')) . substr($urlpath,strpos($urlpath,"wp-content/"));
1049
+ if ( isset( $_GET['s2page'] ) ) {
1050
+ $page = (int) $_GET['s2page'];
1051
+ } else {
1052
+ $page = 1;
1053
+ }
1054
+
1055
+ // was anything POSTed ?
1056
+ if (isset($_POST['s2_admin'])) {
1057
+ check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
1058
+ if ('subscribe' == $_POST['s2_admin']) {
1059
+ foreach (preg_split ("/[\s,]+/", $_POST['addresses']) as $email) {
1060
+ if (is_email($email)) {
1061
+ $this->activate($email);
1062
+ }
1063
+ }
1064
+ $_POST['what'] = 'confirmed';
1065
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) subscribed!', 'subscribe2') . "</strong></p></div>";
1066
+ } elseif ('delete' == $_POST['s2_admin']) {
1067
+ $this->delete($_POST['email']);
1068
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . $_POST['email'] . ' ' . __('deleted!', 'subscribe2') . "</strong></p></div>";
1069
+ } elseif ('toggle' == $_POST['s2_admin']) {
1070
+ $this->toggle($_POST['email']);
1071
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . $_POST['email'] . ' ' . __('status changed!', 'subscribe2') . "</strong></p></div>";
1072
+ } elseif ('remind' == $_POST['s2_admin']) {
1073
+ $this->remind($_POST['reminderemails']);
1074
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Reminder Email(s) Sent!','subscribe2') . "</strong></p></div>";
1075
+ } elseif ( ('register' == $_POST['s2_admin']) && ('subscribe' == $_POST['manage']) ) {
1076
+ $this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1077
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Subscribed!','subscribe2') . "</strong></p></div>";
1078
+ } elseif ( ('register' == $_POST['s2_admin']) && ('unsubscribe' == $_POST['manage']) ) {
1079
+ $this->unsubscribe_registered_users($_POST['emails'], $_POST['category']);
1080
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Unsubscribed!','subscribe2') . "</strong></p></div>";
1081
+ }
1082
+ }
1083
+
1084
+ if (isset($_POST['what'])) {
1085
+ $page = 1;
1086
+ if ('all' == $_POST['what']) {
1087
+ $what = 'all';
1088
+ $confirmed = $this->get_public();
1089
+ $unconfirmed = $this->get_public(0);
1090
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$registered);
1091
+ } elseif ('public' == $_POST['what']) {
1092
+ $what = 'public';
1093
+ $confirmed = $this->get_public();
1094
+ $unconfirmed = $this->get_public(0);
1095
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1096
+ } elseif ('confirmed' == $_POST['what']) {
1097
+ $what = 'confirmed';
1098
+ $confirmed = $this->get_public();
1099
+ $subscribers = $confirmed;
1100
+ } elseif ('unconfirmed' == $_POST['what']) {
1101
+ $what = 'unconfirmed';
1102
+ $unconfirmed = $this->get_public(0);
1103
+ $subscribers = $unconfirmed;
1104
+ if (!empty($subscribers)) {
1105
+ $reminderemails = implode(",", $subscribers);
1106
+ $reminderform = true;
1107
+ }
1108
+ } elseif (is_numeric($_POST['what'])) {
1109
+ $what = intval($_POST['what']);
1110
+ $subscribers = $this->get_registered("cats=$what");
1111
+ } elseif ('registered' == $_POST['what']) {
1112
+ $what = 'registered';
1113
+ $subscribers = $registered;
1114
+ }
1115
+ } elseif (isset($_GET['what'])) {
1116
+ if ('all' == $_GET['what']) {
1117
+ $what = 'all';
1118
+ $confirmed = $this->get_public();
1119
+ $unconfirmed = $this->get_public(0);
1120
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$registered);
1121
+ } elseif ('public' == $_GET['what']) {
1122
+ $what = 'public';
1123
+ $confirmed = $this->get_public();
1124
+ $unconfirmed = $this->get_public(0);
1125
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1126
+ } elseif ('confirmed' == $_GET['what']) {
1127
+ $what = 'confirmed';
1128
+ $confirmed = $this->get_public();
1129
+ $subscribers = $confirmed;
1130
+ } elseif ('unconfirmed' == $_GET['what']) {
1131
+ $what = 'unconfirmed';
1132
+ $unconfirmed = $this->get_public(0);
1133
+ $subscribers = $unconfirmed;
1134
+ if (!empty($subscribers)) {
1135
+ $reminderemails = implode(",", $subscribers);
1136
+ $reminderform = true;
1137
+ }
1138
+ } elseif (is_numeric($_GET['what'])) {
1139
+ $what = intval($_GET['what']);
1140
+ $subscribers = $this->get_registered("cats=$what");
1141
+ } elseif ('registered' == $_GET['what']) {
1142
+ $what = 'registered';
1143
+ $subscribers = $registered;
1144
+ }
1145
+ } elseif ('' == $what) {
1146
+ $what = 'registered';
1147
+ $subscribers = $registered;
1148
+ $registermessage = '';
1149
+ if (empty($subscribers)) {
1150
+ $confirmed = $this->get_public();
1151
+ $subscribers = $confirmed;
1152
+ $what = 'confirmed';
1153
+ if (empty($subscribers)) {
1154
+ $unconfirmed = $this->get_public(0);
1155
+ $subscribers = $unconfirmed;
1156
+ $what = 'unconfirmed';
1157
+ if (empty($subscribers)) {
1158
+ $what = 'all';
1159
+ }
1160
+ }
1161
+ }
1162
+ }
1163
+ if (!empty($subscribers)) {
1164
+ natcasesort($subscribers);
1165
+ // Displays a page number strip - adapted from code in Akismet
1166
+ $args['what'] = $what;
1167
+ $total_subscribers = count($subscribers);
1168
+ $total_pages = ceil($total_subscribers / 50);
1169
+ $strip = '';
1170
+ if ( $page > 1 ) {
1171
+ $args['s2page'] = $page - 1;
1172
+ $strip .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">&laquo; '. __('Previous Page', 'subscribe2') .'</a>' . "\n";
1173
+ }
1174
+ if ( $total_pages > 1 ) {
1175
+ for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) {
1176
+ if ( $page == $page_num ) {
1177
+ $strip .= "<strong>" . $page_num . "</strong>\n";
1178
+ } else {
1179
+ if ( $page_num < 3 || ( $page_num >= $page - 2 && $page_num <= $page + 2 ) || $page_num > $total_pages - 2 ) {
1180
+ $args['s2page'] = $page_num;
1181
+ $strip .= "<a class=\"page-numbers\" href=\"" . clean_url(add_query_arg($args)) . "\">" . $page_num . "</a>\n";
1182
+ $trunc = true;
1183
+ } elseif ( $trunc == true ) {
1184
+ $strip .= "...\n";
1185
+ $trunc = false;
1186
+ }
1187
+ }
1188
+ }
1189
+ }
1190
+ if ( ( $page ) * 50 < $total_subscribers ) {
1191
+ $args['s2page'] = $page + 1;
1192
+ $strip .= "<a class=\"next\" href=\"" . clean_url(add_query_arg($args)) . "\">". __('Next Page', 'subscribe2') . " &raquo;</a>\n";
1193
+ }
1194
+ }
1195
+ // safety check for our arrays
1196
+ if ('' == $confirmed) { $confirmed = array(); }
1197
+ if ('' == $unconfirmed) { $unconfirmed = array(); }
1198
+ if ('' == $registered) { $registered = array(); }
1199
+
1200
+ // show our form
1201
+ echo "<div class=\"wrap\">";
1202
+ echo "<h2>" . __('Subscribe Addresses', 'subscribe2') . "</h2>\r\n";
1203
+ echo "<form method=\"post\" action=\"$this->action\">\r\n";
1204
+ echo "<p>";
1205
+ if (function_exists('wp_nonce_field')) {
1206
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1207
+ }
1208
+ echo __('Enter addresses, one per line or comma-seperated', 'subscribe2') . "<br />\r\n";
1209
+ echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea></p>\r\n";
1210
+ echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Subscribe', 'subscribe2') . "\"/>\r\n";
1211
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"subscribe\" /></p>";
1212
+ echo "</form></div>";
1213
+
1214
+ // subscriber lists
1215
+ echo "<div class=\"wrap\"><h2>" . __('Subscribers', 'subscribe2') . "</h2>\r\n";
1216
+ echo "<br />";
1217
+ $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1218
+ // show the selected subscribers
1219
+ $alternate = 'alternate';
1220
+ if (!empty($subscribers)) {
1221
+ echo "<p align=\"center\"><b>" . __('Registered on the left, confirmed in the middle, unconfirmed on the right', 'subscribe2') . "</b></p>\r\n";
1222
+ $exportcsv = implode(",\r\n", $subscribers);
1223
+ echo "<form method=\"post\" action=\"\">\r\n";
1224
+ if (function_exists('wp_nonce_field')) {
1225
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1226
+ }
1227
+ echo "<input type=\"hidden\" name=\"exportcsv\" value=\"$exportcsv\" />\r\n";
1228
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"exportcsv\" />\r\n";
1229
+ echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Save Emails to CSV File','subscribe2') . "\" /></p>\r\n";
1230
+ echo "</form>\r\n";
1231
+ }
1232
+ echo "<p>" . $strip . "</p>";
1233
+ echo "<table cellpadding=\"2\" cellspacing=\"2\">";
1234
+ if (!empty($subscribers)) {
1235
+ $subscriber_chunks = array_chunk($subscribers, 50);
1236
+ $chunk = $page - 1;
1237
+ $subscribers = $subscriber_chunks[$chunk];
1238
+ foreach ($subscribers as $subscriber) {
1239
+ echo "<tr class=\"$alternate\">";
1240
+ echo "<td width=\"75%\"";
1241
+ if (in_array($subscriber, $unconfirmed)) {
1242
+ echo " align=\"right\">";
1243
+ } elseif (in_array($subscriber, $confirmed)) {
1244
+ echo " align=\"center\">";
1245
+ } else {
1246
+ echo " align=\"left\" colspan=\"3\">";
1247
+ }
1248
+ echo "<a href=\"mailto:$subscriber\">$subscriber</a>\r\n";
1249
+ if (in_array($subscriber, $unconfirmed) || in_array($subscriber, $confirmed) ) {
1250
+ echo "(" . $this->signup_date($subscriber) . ")</td>\r\n";
1251
+ echo "<td width=\"5%\" align=\"center\">\r\n";
1252
+ echo "<form method=\"post\" action=\"$this->action\">";
1253
+ if (function_exists('wp_nonce_field')) {
1254
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1255
+ }
1256
+ echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1257
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"toggle\" />\r\n";
1258
+ echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1259
+ if (in_array($subscriber, $unconfirmed)) {
1260
+ $foo = '&lt;-';
1261
+ $image = 'include/arrow_left.png';
1262
+ } else {
1263
+ $foo = '-&gt;';
1264
+ $image = 'include/arrow_right.png';
1265
+ }
1266
+ echo "<input type=\"image\" src=\"" . $urlpath . $image . "\" name=\"submit\" value=\"$foo\" /></form></td>\r\n";
1267
+ echo "<td width=\"2%\" align=\"center\">\r\n";
1268
+ echo "<form method=\"post\" action=\"\">\r\n";
1269
+ if (function_exists('wp_nonce_field')) {
1270
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1271
+ }
1272
+ echo "<input type=\"hidden\" name=\"email\" value=\"$subscriber\" />\r\n";
1273
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"delete\" />\r\n";
1274
+ echo "<input type=\"hidden\" name=\"what\" value=\"$what\" />\r\n";
1275
+ echo "<p class=\"delete\">\r\n";
1276
+ echo "<input type=\"image\" src=\"" . $urlpath . "include/cross.png\" name=\"submit\" value=\"X\" />\r\n";
1277
+ echo "</p></form>";
1278
+ }
1279
+ echo "</td></tr>\r\n";
1280
+ ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1281
+ }
1282
+ } else {
1283
+ echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1284
+ }
1285
+ echo "</table>";
1286
+ echo "<p>" . $strip . "</p>";
1287
+ if ($reminderform) {
1288
+ echo "<form method=\"post\" action=\"$this->action\">\r\n";
1289
+ if (function_exists('wp_nonce_field')) {
1290
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1291
+ }
1292
+ echo "<input type=\"hidden\" name=\"reminderemails\" value=\"$reminderemails\" />\r\n";
1293
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"remind\" />\r\n";
1294
+ echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Send Reminder Email','subscribe2') . "\" /></p>\r\n";
1295
+ echo "</form>";
1296
+ }
1297
+ echo "</div>\r\n";
1298
+
1299
+ //show bulk managment form
1300
+ echo "<div class=\"wrap\">";
1301
+ echo "<h2>" . __('Categories', 'subscribe2') . "</h2>\r\n";
1302
+ echo "<p>";
1303
+ echo __('Existing Registered Users can be automatically (un)subscribed to categories using this section.', 'subscribe2') . "<br />\r\n";
1304
+ echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1305
+ echo "</p>";
1306
+ echo "<form method=\"post\" action=\"\">\r\n";
1307
+ if (function_exists('wp_nonce_field')) {
1308
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1309
+ }
1310
+ echo "<br />" . __('Action to perform', 'subscribe2') . ":\r\n";
1311
+ echo "<input type=\"radio\" name=\"manage\" value=\"subscribe\" checked=\"checked\" />" . __('Subscribe', 'subscribe2') . "\r\n";
1312
+ echo "<input type=\"radio\" name=\"manage\" value=\"unsubscribe\" />" . __('Unsubscribe', 'subscribe2') . "<br /><br />\r\n";
1313
+ echo "<input type=\"hidden\" name=\"emails\" value=\"$emails\" /><input type=\"hidden\" name=\"s2_admin\" value=\"register\" />\r\n";
1314
+ $this->display_category_form();
1315
+ echo "<p class=\"submit\"><input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p></form>";
1316
+
1317
+ echo "</div>\r\n";
1318
+ echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1319
+
1320
+ include(ABSPATH . 'wp-admin/admin-footer.php');
1321
+ // just to be sure
1322
+ die;
1323
+ } // end manage_menu()
1324
+
1325
+ /**
1326
+ Our options page
1327
+ */
1328
+ function options_menu() {
1329
+ global $s2nonce;
1330
+
1331
+ // was anything POSTed?
1332
+ if (isset($_POST['s2_admin'])) {
1333
+ check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
1334
+ if ('RESET' == $_POST['s2_admin']) {
1335
+ $this->reset();
1336
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_reset</strong></p></div>";
1337
+ } elseif ('options' == $_POST['s2_admin']) {
1338
+ // excluded categories
1339
+ if (!empty($_POST['category'])) {
1340
+ $exclude_cats = implode(',', $_POST['category']);
1341
+ } else {
1342
+ $exclude_cats = '';
1343
+ }
1344
+ $this->subscribe2_options['exclude'] = $exclude_cats;
1345
+ // allow override?
1346
+ (isset($_POST['reg_override'])) ? $override = '1' : $override = '0';
1347
+ $this->subscribe2_options['reg_override'] = $override;
1348
+
1349
+ // show button?
1350
+ ($_POST['show_button'] == '1') ? $showbutton = '1' : $showbutton = '0';
1351
+ $this->subscribe2_options['show_button'] = $showbutton;
1352
+
1353
+ // show widget in Presentation->Widgets
1354
+ ($_POST['widget'] == '1') ? $showwidget = '1' : $showwidget = '0';
1355
+ $this->subscribe2_options['widget'] = $showwidget;
1356
+
1357
+ // send as author or admin?
1358
+ $sender = 'author';
1359
+ if ('admin' == $_POST['sender']) {
1360
+ $sender = 'admin';
1361
+ }
1362
+ $this->subscribe2_options['sender'] = $sender;
1363
+
1364
+ // send email for pages, private and password protected posts
1365
+ $pages_option = $_POST['pages'];
1366
+ $this->subscribe2_options['pages']= $pages_option;
1367
+ $password_option = $_POST['password'];
1368
+ $this->subscribe2_options['password']= $password_option;
1369
+ $private_option = $_POST['private'];
1370
+ $this->subscribe2_options['private'] = $private_option;
1371
+
1372
+ // send per-post or digest emails
1373
+ $email_freq = $_POST['email_freq'];
1374
+ if ($email_freq != $this->subscribe2_options['email_freq']) {
1375
+ //ensure $timestamp is used if cron period changes
1376
+ $check = true;
1377
+ }
1378
+ $this->subscribe2_options['email_freq'] = $email_freq;
1379
+ $previous_time = wp_next_scheduled('s2_digest_cron');
1380
+ wp_clear_scheduled_hook('s2_digest_cron');
1381
+ $scheds = (array) wp_get_schedules();
1382
+ $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
1383
+ if ($interval == 0) {
1384
+ // if we are on per-post emails remove last_cron entry
1385
+ unset($this->subscribe2_options['last_s2cron']);
1386
+ } else {
1387
+ if (!wp_next_scheduled('s2_digest_cron')) {
1388
+ // if we are using digest schedule the event and prime last_cron as now
1389
+ $time = current_time('timestamp') + $interval;
1390
+ if ($interval < 86400) {
1391
+ // Schedule CRON events occurring less than daily starting now and periodically thereafter
1392
+ $timestamp = &$time;
1393
+ } else {
1394
+ // Schedule other CRON events starting at user defined hour and periodically thereafter
1395
+ $timestamp = gmmktime($_POST['hour'], 0, 0, date('m', $time), date('d', $time), date('Y', $time));
1396
+ }
1397
+ if ( ('on' == $_POST['reset_cron']) || $check ) {
1398
+ wp_schedule_event($timestamp, $email_freq, 's2_digest_cron');
1399
+ } else {
1400
+ wp_schedule_event($previous_time, $email_freq, 's2_digest_cron');
1401
+ }
1402
+ $this->subscribe2_options['last_s2cron'] = current_time('mysql');
1403
+ }
1404
+ }
1405
+
1406
+ // email templates
1407
+ $mailtext = $_POST['mailtext'];
1408
+ $this->subscribe2_options['mailtext'] = $mailtext;
1409
+ $confirm_email = $_POST['confirm_email'];
1410
+ $this->subscribe2_options['confirm_email'] = $confirm_email;
1411
+ $remind_email = $_POST['remind_email'];
1412
+ $this->subscribe2_options['remind_email'] = $remind_email;
1413
+
1414
+ //automatic subscription
1415
+ $autosub_option = $_POST['autosub'];
1416
+ $this->subscribe2_options['autosub'] = $autosub_option;
1417
+ $autosub_wpregdef_option = $_POST['wpregdef'];
1418
+ $this->subscribe2_options['wpregdef'] = $autosub_wpregdef_option;
1419
+ $autosub_format_option = $_POST['autoformat'];
1420
+ $this->subscribe2_options['autoformat'] = $autosub_format_option;
1421
+ $autosub_newcat_option = $_POST['autosub_def'];
1422
+ $this->subscribe2_options['autosub_def'] = $autosub_newcat_option;
1423
+
1424
+ //barred domains
1425
+ $barred_option = $_POST['barred'];
1426
+ $this->subscribe2_options['barred'] = $barred_option;
1427
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_saved</strong></p></div>";
1428
+ update_option('subscribe2_options', $this->subscribe2_options);
1429
+ }
1430
+ }
1431
+ // show our form
1432
+ echo "<div class=\"wrap\">";
1433
+ echo "<form method=\"post\" action=\"\">\r\n";
1434
+ if (function_exists('wp_nonce_field')) {
1435
+ wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1436
+ }
1437
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
1438
+ echo "<h2>" . __('Delivery Options', 'subscribe2') . ":</h2>\r\n";
1439
+ echo "<p>";
1440
+ echo __('Send Emails for Pages', 'subscribe2') . ': ';
1441
+ echo "<input type=\"radio\" name=\"pages\" value=\"yes\"";
1442
+ if ('yes' == $this->subscribe2_options['pages']) {
1443
+ echo " checked=\"checked\"";
1444
+ }
1445
+ echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1446
+ echo "<input type=\"radio\" name=\"pages\" value=\"no\"";
1447
+ if ('no' == $this->subscribe2_options['pages']) {
1448
+ echo " checked=\"checked\"";
1449
+ }
1450
+ echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1451
+ echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
1452
+ echo "<input type=\"radio\" name=\"password\" value=\"yes\"";
1453
+ if ('yes' == $this->subscribe2_options['password']) {
1454
+ echo " checked=\"checked\"";
1455
+ }
1456
+ echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1457
+ echo "<input type=\"radio\" name=\"password\" value=\"no\"";
1458
+ if ('no' == $this->subscribe2_options['password']) {
1459
+ echo " checked=\"checked\"";
1460
+ }
1461
+ echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1462
+ echo __('Send Emails for Private Posts', 'subscribe2') . ': ';
1463
+ echo "<input type=\"radio\" name=\"private\" value=\"yes\"";
1464
+ if ('yes' == $this->subscribe2_options['private']) {
1465
+ echo " checked=\"checked\"";
1466
+ }
1467
+ echo " /> " . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1468
+ echo "<input type=\"radio\" name=\"private\" value=\"no\"";
1469
+ if ('no' == $this->subscribe2_options['private']) {
1470
+ echo " checked=\"checked\"";
1471
+ }
1472
+ echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1473
+ echo __('Send Email From', 'subscribe2') . ': ';
1474
+ echo "<input type=\"radio\" name=\"sender\" value=\"author\"";
1475
+ if ('author' == $this->subscribe2_options['sender']) {
1476
+ echo " checked=\"checked\" ";
1477
+ }
1478
+ echo " /> " . __('Author of the post', 'subscribe2') . " &nbsp;&nbsp;";
1479
+ echo "<input type=\"radio\" name=\"sender\" value=\"admin\"";
1480
+ if ('admin' == $this->subscribe2_options['sender']) {
1481
+ echo " checked=\"checked\" ";
1482
+ }
1483
+ echo " /> " . __('Blog Admin', 'subscribe2') . "<br /><br />\r\n";
1484
+ if (function_exists('wp_schedule_event')) {
1485
+ echo __('Send Email as Digest', 'subscribe2') . ": <br /><br />\r\n";
1486
+ $this->display_digest_choices();
1487
+ }
1488
+ echo "</p>";
1489
+ echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
1490
+ echo"<br />";
1491
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
1492
+ echo "<tr><td>";
1493
+ echo __('New Post email (must not be empty)', 'subscribe2') . ":";
1494
+ echo "<br />\r\n";
1495
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
1496
+ echo "</td><td valign=\"top\" rowspan=\"3\">";
1497
+ echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
1498
+ echo "<dl>";
1499
+ echo "<dt><b>BLOGNAME</b></dt><dd>" . get_bloginfo('name') . "</dd>\r\n";
1500
+ echo "<dt><b>BLOGLINK</b></dt><dd>" . get_bloginfo('url') . "</dd>\r\n";
1501
+ echo "<dt><b>TITLE</b></dt><dd>" . __("the post's title<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
1502
+ echo "<dt><b>POST</b></dt><dd>" . __("the excerpt or the entire post<br />(<i>based on the subscriber's preferences</i>)", 'subscribe2') . "</dd>\r\n";
1503
+ echo "<dt><b>TABLE</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
1504
+ echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
1505
+ echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
1506
+ echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
1507
+ echo "<dt><b>AUTHORNAME</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
1508
+ 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";
1509
+ 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";
1510
+ echo "</dl></td></tr><tr><td>";
1511
+ echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
1512
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
1513
+ echo "</td></tr><tr valign=\"top\"><td>";
1514
+ echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
1515
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
1516
+ echo "</td></tr></table><br />\r\n";
1517
+
1518
+ // excluded categories
1519
+ echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
1520
+ echo"<p>";
1521
+ echo "<strong><em style=\"color: red\">" . __('Posts assigned to any Excluded Category do not generate notifications and are not included in digest notifications', 'subscribe2') . "</em></strong><br />\r\n";
1522
+ echo"</p>";
1523
+ $this->display_category_form(explode(',', $this->subscribe2_options['exclude']));
1524
+ echo "<center><input type=\"checkbox\" name=\"reg_override\" value=\"1\"";
1525
+ if ('1' == $this->subscribe2_options['reg_override']) {
1526
+ echo " checked=\"checked\"";
1527
+ }
1528
+ echo " /> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</center><br />\r\n";
1529
+
1530
+ // show button in QuickTags
1531
+ echo "<h2>" . __('Writing Options', 'subscribe2') . "</h2>\r\n";
1532
+ echo"<p>";
1533
+ echo "<input type=\"checkbox\" name=\"show_button\" value=\"1\"";
1534
+ if ('1' == $this->subscribe2_options['show_button']) {
1535
+ echo " checked=\"checked\"";
1536
+ }
1537
+ echo " /> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "<br /><br />\r\n";
1538
+
1539
+ // show Widget
1540
+ echo "<input type=\"checkbox\" name=\"widget\" value=\"1\"";
1541
+ if ('1' == $this->subscribe2_options['widget']) {
1542
+ echo " checked=\"checked\"";
1543
+ }
1544
+ echo " /> " . __('Enable Subscribe2 Widget?', 'subscribe2') . "<br /><br />\r\n";
1545
+ echo"</p>";
1546
+
1547
+ //Auto Subscription for new registrations
1548
+ echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
1549
+ echo"<p>";
1550
+ echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
1551
+ echo "<input type=\"radio\" name=\"autosub\" value=\"yes\"";
1552
+ if ('yes' == $this->subscribe2_options['autosub']) {
1553
+ echo " checked=\"checked\"";
1554
+ }
1555
+ echo " /> " . __('Automatically', 'subscribe2') . " &nbsp;&nbsp;";
1556
+ echo "<input type=\"radio\" name=\"autosub\" value=\"wpreg\"";
1557
+ if ('wpreg' == $this->subscribe2_options['autosub']) {
1558
+ echo " checked=\"checked\"";
1559
+ }
1560
+ echo " /> " . __('Display option on Registration Form', 'subscribe2') . " &nbsp;&nbsp;";
1561
+ echo "<input type=\"radio\" name=\"autosub\" value=\"no\"";
1562
+ if ('no' == $this->subscribe2_options['autosub']) {
1563
+ echo " checked=\"checked\"";
1564
+ }
1565
+ echo " /> " . __('No', 'subscribe2') . "<br /><br />\r\n";
1566
+ echo __('Registration Form option is checked by default', 'subscribe2') . ": &nbsp;&nbsp;";
1567
+ echo "<input type=\"radio\" name=\"wpregdef\" value=\"yes\"";
1568
+ if ('yes' == $this->subscribe2_options['wpregdef']) {
1569
+ echo " checked=\"checked\"";
1570
+ }
1571
+ echo " />" . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1572
+ echo "<input type=\"radio\" name=\"wpregdef\" value=\"no\"";
1573
+ if ('no' == $this->subscribe2_options['wpregdef']) {
1574
+ echo " checked=\"checked\"";
1575
+ }
1576
+ echo " />" . __('No', 'subscribe2') . "<br /><br />\r\n";
1577
+ echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
1578
+ echo "<input type=\"radio\" name=\"autoformat\" value=\"html\"";
1579
+ if ('html' == $this->subscribe2_options['autoformat']) {
1580
+ echo "checked=\"checked\" ";
1581
+ }
1582
+ echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1583
+ echo "<input type=\"radio\" name=\"autoformat\" value=\"fulltext\" ";
1584
+ if ('fulltext' == $this->subscribe2_options['autoformat']) {
1585
+ echo "checked=\"checked\" ";
1586
+ }
1587
+ echo "/> " . __('Plain Text - Full', 'subscribe2') . " &nbsp;&nbsp;";
1588
+ echo "<input type=\"radio\" name=\"autoformat\" value=\"text\" ";
1589
+ if ('text' == $this->subscribe2_options['autoformat']) {
1590
+ echo "checked=\"checked\" ";
1591
+ }
1592
+ echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . " <br /><br />";
1593
+ echo __('Auto Subscribe me to new categories is checked by default', 'subscribe2') . ": <br />\r\n";
1594
+ echo "<input type=\"radio\" name=\"autosub_def\" value=\"yes\"";
1595
+ if ('yes' == $this->subscribe2_options['autosub_def']) {
1596
+ echo " checked=\"checked\"";
1597
+ }
1598
+ echo " />" . __('Yes', 'subscribe2') . " &nbsp;&nbsp;";
1599
+ echo "<input type=\"radio\" name=\"autosub_def\" value=\"no\"";
1600
+ if ('no' == $this->subscribe2_options['autosub_def']) {
1601
+ echo " checked=\"checked\"";
1602
+ }
1603
+ echo " />" . __('No', 'subscribe2');
1604
+ echo"</p>";
1605
+
1606
+ //barred domains
1607
+ echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
1608
+ echo"<p>";
1609
+ 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');
1610
+ echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
1611
+ echo"</p>";
1612
+
1613
+ // submit
1614
+ echo "<p class=\"submit\" align=\"center\"><input type=\"submit\" id=\"save\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p>";
1615
+ echo "</form>\r\n";
1616
+ echo "</div><div class=\"wrap\">";
1617
+
1618
+ // reset
1619
+ echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
1620
+ 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";
1621
+ echo "<form method=\"post\" action=\"\">";
1622
+ if (function_exists('wp_nonce_field')) {
1623
+ wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
1624
+ }
1625
+ echo "<p class=\"submit\" align=\"center\">";
1626
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"RESET\" />";
1627
+ echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('RESET', 'subscribe2') .
1628
+ "\" />";
1629
+ echo "</p></form></div>\r\n";
1630
+
1631
+ include(ABSPATH . 'wp-admin/admin-footer.php');
1632
+ // just to be sure
1633
+ die;
1634
+ } // end options_menu()
1635
+
1636
+ /**
1637
+ Our profile menu
1638
+ */
1639
+ function user_menu() {
1640
+ global $user_ID, $s2nonce, $wp_version, $wpmu_version;
1641
+
1642
+ get_currentuserinfo();
1643
+
1644
+ // was anything POSTed?
1645
+ if ( (isset($_POST['s2_admin'])) && ('user' == $_POST['s2_admin']) ) {
1646
+ check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
1647
+
1648
+ // Is this WordPressMU or not?
1649
+ if ( (isset($wpmu_version)) || (strpos($wp_version, 'wordpress-mu')) ) {
1650
+ $s2_mu = true;
1651
+ }
1652
+
1653
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
1654
+ $format = 'text';
1655
+ $post = 'post';
1656
+ if ('html' == $_POST['s2_format']) {
1657
+ $format = 'html';
1658
+ }
1659
+ if ('excerpt' == $_POST['s2_excerpt']) {
1660
+ $post = 'excerpt';
1661
+ }
1662
+ update_usermeta($user_ID, 's2_excerpt', $post);
1663
+ update_usermeta($user_ID, 's2_format', $format);
1664
+ update_usermeta($user_ID, 's2_autosub', $_POST['new_category']);
1665
+
1666
+ if ($s2_mu) {
1667
+ $posted_cats = $_POST['category'];
1668
+ $other_blogs = array_diff(explode(',', get_usermeta($user_ID, 's2_subscribed')), get_all_category_ids());
1669
+ $cats = array_merge($posted_cats, $other_blogs);
1670
+ } else {
1671
+ $cats = $_POST['category'];
1672
+ }
1673
+
1674
+ if ( (empty($cats)) || ($cats == '-1') ) {
1675
+ $cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1676
+ if ($cats) {
1677
+ foreach ($cats as $cat) {
1678
+ delete_usermeta($user_ID, "s2_cat" . $cat);
1679
+ }
1680
+ }
1681
+ update_usermeta($user_ID, 's2_subscribed', '-1');
1682
+ } elseif ($cats == 'digest') {
1683
+ $all_cats = get_categories(array('hide_empty' => false));
1684
+ foreach ($all_cats as $cat) {
1685
+ ('' == $catids) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
1686
+ update_usermeta($user_ID, 's2_cat' . $cat->term_id, $cat->term_id);
1687
+ }
1688
+ update_usermeta($user_ID, 's2_subscribed', $catids);
1689
+ } else {
1690
+ if (!is_array($cats)) {
1691
+ $cats = array($_POST['category']);
1692
+ }
1693
+ $old_cats = explode(',', get_usermeta($user_ID, 's2_subscribed'));
1694
+ $remove = array_diff($old_cats, $cats);
1695
+ $new = array_diff($cats, $old_cats);
1696
+ if (!empty($remove)) {
1697
+ // remove subscription to these cat IDs
1698
+ foreach ($remove as $id) {
1699
+ delete_usermeta($user_ID, "s2_cat" . $id);
1700
+ }
1701
+ }
1702
+ if (!empty($new)) {
1703
+ // add subscription to these cat IDs
1704
+ foreach ($new as $id) {
1705
+ update_usermeta($user_ID, 's2_cat' . $id, $id);
1706
+ }
1707
+ }
1708
+ update_usermeta($user_ID, 's2_subscribed', implode(',', $cats));
1709
+ }
1710
+ }
1711
+
1712
+ // show our form
1713
+ echo "<div class=\"wrap\">";
1714
+ echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
1715
+ echo "<form method=\"post\" action=\"\">";
1716
+ echo "<p>";
1717
+ if (function_exists('wp_nonce_field')) {
1718
+ wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
1719
+ }
1720
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
1721
+ if ($this->subscribe2_options['email_freq'] == 'never') {
1722
+ echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
1723
+ echo "<input type=\"radio\" name=\"s2_format\" value=\"html\"";
1724
+ if ('html' == get_usermeta($user_ID, 's2_format')) {
1725
+ echo "checked=\"checked\" ";
1726
+ }
1727
+ echo "/> " . __('HTML', 'subscribe2') ." &nbsp;&nbsp;";
1728
+ echo "<input type=\"radio\" name=\"s2_format\" value=\"text\" ";
1729
+ if ('text' == get_usermeta($user_ID, 's2_format')) {
1730
+ echo "checked=\"checked\" ";
1731
+ }
1732
+ echo "/> " . __('Plain Text', 'subscribe2') . "<br /><br />\r\n";
1733
+
1734
+ echo __('Email contains', 'subscribe2') . ": &nbsp;&nbsp;";
1735
+ $amount = array ('excerpt' => __('Excerpt Only', 'subscribe2'), 'post' => __('Full Post', 'subscribe2'));
1736
+ foreach ($amount as $key => $value) {
1737
+ echo "<input type=\"radio\" name=\"s2_excerpt\" value=\"" . $key . "\"";
1738
+ if ($key == get_usermeta($user_ID, 's2_excerpt')) {
1739
+ echo " checked=\"checked\"";
1740
+ }
1741
+ echo " /> " . $value . "&nbsp;&nbsp;";
1742
+ }
1743
+ echo "<br /><span style=\"color: red;line-height: 300%;\">" . __('Note: HTML format will always deliver the full post', 'subscribe2') . ".</span><br />\r\n";
1744
+ echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
1745
+ echo "<input type=\"radio\" name=\"new_category\" value=\"yes\" ";
1746
+ if ('yes' == get_usermeta($user_ID, 's2_autosub')) {
1747
+ echo "checked=\"checked\" ";
1748
+ }
1749
+ echo "/> " . __('Yes', 'subscribe2') . "&nbsp;&nbsp;";
1750
+ echo "<input type=\"radio\" name=\"new_category\" value=\"no\" ";
1751
+ if ('no' == get_usermeta($user_ID, 's2_autosub')) {
1752
+ echo "checked=\"checked\" ";
1753
+ }
1754
+ echo "/> " . __('No', 'subscribe2') . "<br /><br />";
1755
+ echo "</p>";
1756
+
1757
+ // subscribed categories
1758
+ echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
1759
+ $this->display_category_form(explode(',', get_usermeta($user_ID, 's2_subscribed')), $this->subscribe2_options['reg_override']);
1760
+ } else {
1761
+ // we're doing daily digests, so just show
1762
+ // subscribe / unnsubscribe
1763
+ echo __('Receive daily summary of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
1764
+ echo "<p>";
1765
+ echo "<input type=\"radio\" name=\"category\" value=\"digest\" ";
1766
+ if (get_usermeta($user_ID, 's2_subscribed') != '-1') {
1767
+ echo "checked=\"yes\" ";
1768
+ }
1769
+ echo "/> " . __('Yes', 'subscribe2') . "<input type=\"radio\" name=\"category\" value=\"-1\" ";
1770
+ if (get_usermeta($user_ID, 's2_subscribed') == '-1') {
1771
+ echo "checked=\"yes\" ";
1772
+ }
1773
+ echo "/> " . __('No', 'subscribe2');
1774
+ echo "</p>";
1775
+ }
1776
+
1777
+
1778
+ // submit
1779
+ echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __("Update Preferences", 'subscribe2') . " &raquo;\" /></p>";
1780
+ echo "</form></div>\r\n";
1781
+
1782
+ include(ABSPATH . 'wp-admin/admin-footer.php');
1783
+ // just to be sure
1784
+ die;
1785
+ } // end user_menu()
1786
+
1787
+ /**
1788
+ Display the Write sub-menu
1789
+ */
1790
+ function write_menu() {
1791
+ global $wpdb, $s2nonce;
1792
+
1793
+ // was anything POSTed?
1794
+ if (isset($_POST['s2_admin']) && ('mail' == $_POST['s2_admin']) ) {
1795
+ check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
1796
+ if ('confirmed' == $_POST['what']) {
1797
+ $recipients = $this->get_public();
1798
+ } elseif ('unconfirmed' == $_POST['what']) {
1799
+ $recipients = $this->get_public(0);
1800
+ } elseif ('public' == $_POST['what']) {
1801
+ $confirmed = $this->get_public();
1802
+ $unconfirmed = $this->get_public(0);
1803
+ $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
1804
+ } elseif (is_numeric($_POST['what'])) {
1805
+ $cat = intval($_POST['what']);
1806
+ $recipients = $this->get_registered("cats=$cat");
1807
+ } else {
1808
+ $recipients = $this->get_registered();
1809
+ }
1810
+ $subject = stripslashes(strip_tags($_POST['subject']));
1811
+ $message = stripslashes($_POST['message']);
1812
+ $this->mail($recipients, $subject, $message, 'text');
1813
+ $message = $this->mail_sent;
1814
+ }
1815
+
1816
+ if ('' != $message) {
1817
+ echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
1818
+ }
1819
+ // show our form
1820
+ echo "<div class=\"wrap\"><h2>" . __('Send email to all subscribers', 'subscribe2') . "</h2>\r\n";
1821
+ echo "<form method=\"post\" action=\"\">\r\n";
1822
+ echo "<p>";
1823
+ if (function_exists('wp_nonce_field')) {
1824
+ wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
1825
+ }
1826
+ echo __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . __('A message from ', 'subscribe2') . get_option('blogname') . "\" /> <br /><br />";
1827
+ echo "<textarea rows=\"12\" cols=\"75\" name=\"message\"></textarea>";
1828
+ echo "<br /><br />\r\n";
1829
+ echo __('Recipients: ', 'subscribe2');
1830
+ $this->display_subscriber_dropdown('registered', false, array('all'));
1831
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
1832
+ echo "</p>";
1833
+ echo "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
1834
+ echo "</form></div>\r\n";
1835
+ echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
1836
+
1837
+ include(ABSPATH . 'wp-admin/admin-footer.php');
1838
+ // just to be sure
1839
+ die;
1840
+ } // end write_menu()
1841
+
1842
+ /* ===== helper functions: forms and stuff ===== */
1843
+ /**
1844
+ Display a table of categories with checkboxes
1845
+ Optionally pre-select those categories specified
1846
+ */
1847
+ function display_category_form($selected = array(), $override = 1) {
1848
+ global $wpdb;
1849
+
1850
+ $all_cats = get_categories(array('hide_empty' => false));
1851
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
1852
+
1853
+ if (0 == $override) {
1854
+ // registered users are not allowed to subscribe to
1855
+ // excluded categories
1856
+ foreach ($all_cats as $cat => $term_id) {
1857
+ if (in_array($all_cats[$cat]->term_id, $exclude)) {
1858
+ $cat = (int)$cat;
1859
+ unset($all_cats[$cat]);
1860
+ }
1861
+ }
1862
+ }
1863
+
1864
+ $half = (count($all_cats) / 2);
1865
+ $i = 0;
1866
+ $j = 0;
1867
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
1868
+ echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
1869
+ foreach ($all_cats as $cat) {
1870
+ if ( ($i >= $half) && (0 == $j) ){
1871
+ echo "</td><td width=\"50%\" align=\"left\">\r\n";
1872
+ $j++;
1873
+ }
1874
+ if (0 == $j) {
1875
+ echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
1876
+ if (in_array($cat->term_id, $selected)) {
1877
+ echo " checked=\"checked\" ";
1878
+ }
1879
+ echo " /> " . $cat->name . "<br />\r\n";
1880
+ } else {
1881
+
1882
+ echo "<input type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
1883
+ if (in_array($cat->term_id, $selected)) {
1884
+ echo " checked=\"checked\" ";
1885
+ }
1886
+ echo " /> " . $cat->name . "<br />\r\n";
1887
+ }
1888
+ $i++;
1889
+ }
1890
+ echo "</td></tr>\r\n";
1891
+ echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
1892
+ echo "<input type=\"checkbox\" name=\"checkall\" onclick=\"setAll(this)\" /> " . __('Select / Unselect All' ,'subscribe2') . "\r\n";
1893
+ echo "</td></tr>\r\n";
1894
+ echo "</table>\r\n";
1895
+ } // end display_category_form()
1896
+
1897
+ /**
1898
+ Display a drop-down form to select subscribers
1899
+ $selected is the option to select
1900
+ $submit is the text to use on the Submit button
1901
+ */
1902
+ function display_subscriber_dropdown ($selected = 'registered', $submit = '', $exclude = array()) {
1903
+ global $wpdb, $wp_version, $wpmu_version;
1904
+
1905
+ // Is this WordPressMU or not?
1906
+ if ( (isset($wpmu_version)) || (strpos($wp_version, 'wordpress-mu')) ) {
1907
+ $s2_mu = true;
1908
+ }
1909
+
1910
+ $who = array('all' => __('All Subscribers', 'subscribe2'),
1911
+ 'public' => __('Public Subscribers', 'subscribe2'),
1912
+ 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
1913
+ 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
1914
+ 'registered' => __('Registered Users', 'subscribe2'));
1915
+
1916
+ $all_cats = get_categories(array('hide_empty' => false));
1917
+
1918
+ // count the number of subscribers
1919
+ $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
1920
+ $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
1921
+ if (in_array('unconfirmed', $exclude)) {
1922
+ $count['public'] = $count['confirmed'];
1923
+ } elseif (in_array('confirmed', $exclude)) {
1924
+ $count['public'] = $count['unconfirmed'];
1925
+ } else {
1926
+ $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
1927
+ }
1928
+ if ($s2_mu) {
1929
+ $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
1930
+ } else {
1931
+ $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='s2_subscribed'");
1932
+ }
1933
+ $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['registered']);
1934
+ if ($s2_mu) {
1935
+ foreach ($all_cats as $cat) {
1936
+ $count[$cat->name] = $wpdb->get_var("SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key=('s2_cat$cat->term_id')");
1937
+ }
1938
+ } else {
1939
+ foreach ($all_cats as $cat) {
1940
+ $count[$cat->name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='s2_cat$cat->term_id'");
1941
+ }
1942
+ }
1943
+
1944
+ // do have actually have some subscribers?
1945
+ if ( (0 == $count['confirmed']) && (0 == $count['unconfirmed']) && (0 == $count['registered']) ) {
1946
+ // no? bail out
1947
+ return;
1948
+ }
1949
+
1950
+ if (false !== $submit) {
1951
+ echo "<form method=\"post\" action=\"$this->action\">";
1952
+ }
1953
+ echo "<select name=\"what\">\r\n";
1954
+ foreach ($who as $whom => $display) {
1955
+ if (in_array($whom, $exclude)) { continue; }
1956
+ if (0 == $count[$whom]) { continue; }
1957
+
1958
+ echo "<option value=\"" . $whom . "\"";
1959
+ if ($whom == $selected) { echo " selected=\"selected\" "; }
1960
+ echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
1961
+ }
1962
+
1963
+ if ($count['registered'] > 0) {
1964
+ foreach ($all_cats as $cat) {
1965
+ if (in_array($cat->term_id, $exclude)) { continue; }
1966
+ echo "<option value=\"" . $cat->term_id . "\"";
1967
+ if ($cat->term_id == $selected) { echo " selected=\"selected\" "; }
1968
+ echo "> &nbsp;&nbsp;" . $cat->name . "&nbsp;(" . $count[$cat->name] . ") </option>\r\n";
1969
+ }
1970
+ }
1971
+ echo "</select>";
1972
+ if (false !== $submit) {
1973
+ echo "<p class=\"submit\"><input type=\"submit\" value=\"$submit\" /></p></form>\r\n";
1974
+ }
1975
+ } // end display_subscriber_dropdown()
1976
+
1977
+ function display_digest_choices() {
1978
+ global $wpdb;
1979
+ $scheduled_time = wp_next_scheduled('s2_digest_cron');
1980
+ $schedule = (array)wp_get_schedules();
1981
+ $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('Per Post Email','subscribe2'))), $schedule);
1982
+ $sort = array();
1983
+ foreach ( (array)$schedule as $key => $value ) $sort[$key] = $value['interval'];
1984
+ asort($sort);
1985
+ $schedule_sorted = array();
1986
+ foreach ($sort as $key => $value) {
1987
+ $schedule_sorted[$key] = $schedule[$key];
1988
+ }
1989
+ foreach ($schedule_sorted as $key => $value) {
1990
+ echo "<input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"";
1991
+ if ($key == $this->subscribe2_options['email_freq']) {
1992
+ echo " checked=\"checked\" ";
1993
+ }
1994
+ echo " /> " . $value['display'] . "<br />\r\n";
1995
+ }
1996
+ echo "<br />" . __('Send Digest Notification at', 'subscribe2') . ": \r\n";
1997
+ $hours = array('12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am' ,'10am' ,'11am', '12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm');
1998
+ echo "<select name=\"hour\">\r\n";
1999
+ while ($hour = current($hours)) {
2000
+ echo "<option value=\"" . key($hours) . "\"";
2001
+ if (key($hours) == gmdate('H', $scheduled_time)) {
2002
+ echo " selected=\"selected\"";
2003
+ }
2004
+ echo ">" . $hour . "</option>\r\n";
2005
+ next($hours);
2006
+ }
2007
+ echo "</select>\r\n";
2008
+ echo "<strong><em style=\"color: red\">" . __('This option will work for digest notification sent daily or less frequently', 'subscribe2') . "</em></strong>\r\n";
2009
+ if ($scheduled_time) {
2010
+ echo "<p><input type=\"checkbox\" name=\"reset_cron\" /> " . __('Reset the schedule time and date for periodic email notifications', 'subscribe2') . "</p>\r\n";
2011
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
2012
+ echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
2013
+ echo "<strong>" . gmdate($datetime, current_time('timestamp', 1)) . "</strong></p>\r\n";
2014
+ echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
2015
+ echo "<strong>" . gmdate($datetime, current_time('timestamp')) . "</strong></p>\r\n";
2016
+ echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
2017
+ echo "<strong>" . gmdate($datetime, wp_next_scheduled('s2_digest_cron')) . "</strong></p>\r\n";
2018
+ } else {
2019
+ echo "<br />";
2020
+ }
2021
+ } // end display_digest_choices()
2022
+
2023
+ /**
2024
+ Adds information to the WordPress registration screen for new users
2025
+ */
2026
+ function register_form() {
2027
+ if ('wpreg' == $this->subscribe2_options['autosub']) {
2028
+ echo "<p>\r\n<label>";
2029
+ echo __('Check here to Subscribe to email notifications for new posts') . ":<br />\r\n";
2030
+ echo "<input type=\"checkbox\" name=\"subscribe\"";
2031
+ if ('yes' == $this->subscribe2_options['wpregdef']) {
2032
+ echo " checked=\"checked\"";
2033
+ }
2034
+ echo " /></label>\r\n";
2035
+ echo "</p>\r\n";
2036
+ } elseif ('yes' == $this->subscribe2_options['autosub']) {
2037
+ echo "<p>\r\n<center>\r\n";
2038
+ echo __('By Registering with this blog you are also agreeing to recieve email notifications for new posts', 'subscribe2') . "<br />\r\n";
2039
+ echo "</center></p>\r\n";
2040
+ }
2041
+ }
2042
+
2043
+ /**
2044
+ Process function to add action if user selects to subscribe to posts during registration
2045
+ */
2046
+ function register_post() {
2047
+ if ('on' == $_POST['subscribe']) {
2048
+ add_action('user_register', array(&$this, 'register_action'));
2049
+ }
2050
+ }
2051
+
2052
+ /**
2053
+ Action to process Subscribe2 registration from WordPress registration
2054
+ */
2055
+ function register_action($user_id = 0) {
2056
+ if (0 == $user_id) { return $user_id; }
2057
+ $this->register($user_id, 1);
2058
+ }
2059
+
2060
+ /* ===== template and filter functions ===== */
2061
+ /**
2062
+ Display our form; also handles (un)subscribe requests
2063
+ */
2064
+ function filter($content = '') {
2065
+ if ( ('' == $content) || (! strstr($content, '<!--subscribe2-->')) ) { return $content; }
2066
+ $this->s2form = $this->form;
2067
+
2068
+ global $user_ID;
2069
+ get_currentuserinfo();
2070
+ if ($user_ID) {
2071
+ if (current_user_can('manage_options')) {
2072
+ $this->s2form = $this->use_profile_admin;
2073
+ } else {
2074
+ $this->s2form = $this->use_profile_users;
2075
+ }
2076
+ }
2077
+ if (isset($_POST['s2_action'])) {
2078
+ global $wpdb, $user_email;
2079
+ if (!is_email($_POST['email'])) {
2080
+ $this->s2form = $this->form . $this->not_an_email;
2081
+ } elseif ($this->is_barred($_POST['email'])) {
2082
+ $this->s2form = $this->form . $this->barred_domain;
2083
+ } else {
2084
+ $this->email = $_POST['email'];
2085
+ // does the supplied email belong to a registered user?
2086
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
2087
+ if ('' != $check) {
2088
+ // this is a registered email
2089
+ $this->s2form = $this->please_log_in;
2090
+ } else {
2091
+ // this is not a registered email
2092
+ // what should we do?
2093
+ if ('subscribe' == $_POST['s2_action']) {
2094
+ // someone is trying to subscribe
2095
+ // lets see if they've tried to subscribe previously
2096
+ if ('1' !== $this->is_public($this->email)) {
2097
+ // the user is unknown or inactive
2098
+ $this->add();
2099
+ $status = $this->send_confirm('add');
2100
+ // set a variable to denote that we've already run, and shouldn't run again
2101
+ $this->filtered = 1; //set this to not send duplicate emails
2102
+ if ($status) {
2103
+ $this->s2form = $this->confirmation_sent;
2104
+ } else {
2105
+ $this->s2form = $this->error;
2106
+ }
2107
+ } else {
2108
+ // they're already subscribed
2109
+ $this->s2form = $this->already_subscribed;
2110
+ }
2111
+ $this->action = 'subscribe';
2112
+ } elseif ('unsubscribe' == $_POST['s2_action']) {
2113
+ // is this email a subscriber?
2114
+ if (false == $this->is_public($this->email)) {
2115
+ $this->s2form = $this->form . $this->not_subscribed;
2116
+ } else {
2117
+ $status = $this->send_confirm('del');
2118
+ // set a variable to denote that we've already run, and shouldn't run again
2119
+ $this->filtered = 1;
2120
+ if ($status) {
2121
+ $this->s2form = $this->confirmation_sent;
2122
+ } else {
2123
+ $this->s2form = $this->error;
2124
+ }
2125
+ }
2126
+ $this->action='unsubscribe';
2127
+ }
2128
+ }
2129
+ }
2130
+ }
2131
+ return preg_replace('|(<p>)?(\n)*<!--subscribe2-->(\n)*(</p>)?|', $this->s2form, $content);
2132
+ } // end filter()
2133
+
2134
+ /**
2135
+ Overrides the default query when handling a (un)subscription confirmation
2136
+ This is basically a trick: if the s2 variable is in the query string, just grab the first
2137
+ static page and override it's contents later with title_filter()
2138
+ */
2139
+ function query_filter() {
2140
+ // don't interfere if we've already done our thing
2141
+ if (1 == $this->filtered) { return; }
2142
+
2143
+ global $wpdb;
2144
+
2145
+ if ( (defined('S2PAGE')) && (0 != S2PAGE) ) {
2146
+ return "page_id=" . S2PAGE;
2147
+ } else {
2148
+ $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
2149
+ if ($id) {
2150
+ return "page_id=$id";
2151
+ } else {
2152
+ return "showposts=1";
2153
+ }
2154
+ }
2155
+ } // end query_filter()
2156
+
2157
+ /**
2158
+ Overrides the page title
2159
+ */
2160
+ function title_filter() {
2161
+ // don't interfere if we've already done our thing
2162
+ if (1 == $this->filtered) { return; }
2163
+ return __('Subscription Confirmation', 'subscribe2');
2164
+ } // end title_filter()
2165
+
2166
+ /* ===== widget functions ===== */
2167
+ /**
2168
+ Registers our widget so it appears with the other available
2169
+ widgets and can be dragged and dropped into any active sidebars
2170
+ */
2171
+ function widget_subscribe2widget($args) {
2172
+ extract($args);
2173
+ $options = get_option('widget_subscribe2widget');
2174
+ $title = empty($options['title']) ? __('Subscribe2') : $options['title'];
2175
+ echo $before_widget;
2176
+ echo $before_title . $title . $after_title;
2177
+ echo "<div class=\"search\">";
2178
+ $content = s2class::filter('<!--subscribe2-->');
2179
+ echo $content;
2180
+ echo "</div>";
2181
+ echo $after_widget;
2182
+ }
2183
+
2184
+ /**
2185
+ Register the optional widget control form
2186
+ */
2187
+ function widget_subscribe2widget_control() {
2188
+ $options = $newoptions = get_option('widget_subscribe2widget');
2189
+ if ($_POST["s2w-submit"]) {
2190
+ $newoptions['title'] = strip_tags(stripslashes($_POST["s2w-title"]));
2191
+ }
2192
+ if ($options != $newoptions) {
2193
+ $options = $newoptions;
2194
+ update_option('widget_subscribe2widget', $options);
2195
+ }
2196
+ $title = htmlspecialchars($options['title'], ENT_QUOTES);
2197
+ echo "<p><label for=\"s2w-title\">" . __('Title:');
2198
+ echo "<input style=\"width: 250px;\" id=\"s2w-title\" name=\"s2w-title\" type=\"text\" value=\"" . $title . "\" /></label></p>";
2199
+ echo "<input type=\"hidden\" id=\"s2w-submit\" name=\"s2w-submit\" value=\"1\" />";
2200
+ }
2201
+
2202
+ /**
2203
+ Actually register the Widget into the WordPress Widget API
2204
+ */
2205
+ function register_subscribe2widget() {
2206
+ //Check Sidebar Widget and Subscribe2 plugins are activated
2207
+ if ( !function_exists('register_sidebar_widget') || !class_exists('s2class')) {
2208
+ return;
2209
+ } else {
2210
+ register_sidebar_widget('Subscribe2Widget', array(&$this, 'widget_subscribe2widget'));
2211
+ register_widget_control('Subscribe2Widget', array(&$this, 'widget_subscribe2widget_control'));
2212
+ }
2213
+ }
2214
+
2215
+ /* ===== Write Toolbar Button Functions ===== */
2216
+
2217
+ /**
2218
+ Register our button in the QuickTags bar
2219
+ */
2220
+ function button_init() {
2221
+ if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) return;
2222
+ if ( 'true' == get_user_option('rich_editing') ) {
2223
+ global $wp_db_version;
2224
+ if ($wp_db_version >= 7098) {
2225
+ //check if we are using WordPress 2.5+
2226
+ add_filter('mce_external_plugins', array(&$this, 'mce3_plugin'));
2227
+ add_filter('mce_buttons', array(&$this, 'mce3_button'));
2228
+ } else {
2229
+ // Load and append our TinyMCE external plugin
2230
+ add_filter('mce_plugins', array(&$this, 'mce2_plugin'));
2231
+ add_filter('mce_buttons', array(&$this, 'mce2_button'));
2232
+ add_filter('tinymce_before_init', array(&$this, 'tinymce2_before_init'));
2233
+ }
2234
+ } else {
2235
+ //use buttonsnap to add button is not using RTE
2236
+ buttonsnap_separator();
2237
+ buttonsnap_jsbutton(get_option('siteurl') . '/wp-content/plugins/subscribe2/include/s2_button.png', __('Subscribe2', 'subscribe2'), 's2_insert_token();');
2238
+ }
2239
+ }
2240
+
2241
+ /**
2242
+ Add buttons for WordPress 2.5+ using built in hooks
2243
+ */
2244
+ function mce3_plugin($arr) {
2245
+ $path = get_option('siteurl') . '/wp-content/plugins/subscribe2/tinymce3/editor_plugin.js';
2246
+ $arr['subscribe2'] = $path;
2247
+ return $arr;
2248
+ }
2249
+
2250
+ function mce3_button($arr) {
2251
+ $arr[] = 'subscribe2';
2252
+ return $arr;
2253
+ }
2254
+
2255
+ // Add buttons in WordPress v2.1+, thanks to An-archos
2256
+ function mce2_plugin($plugins) {
2257
+ array_push($plugins, '-subscribe2quicktags');
2258
+ return $plugins;
2259
+ }
2260
+
2261
+ function mce2_button($buttons) {
2262
+ array_push($buttons, 'separator');
2263
+ array_push($buttons, 'subscribe2quicktags');
2264
+ return $buttons;
2265
+ }
2266
+
2267
+ function tinymce2_before_init() {
2268
+ $this->fullpath = get_option('siteurl') . '/wp-content/plugins/subscribe2/tinymce/';
2269
+ echo "tinyMCE.loadPlugin('subscribe2quicktags', '" . $this->fullpath . "');\n";
2270
+ }
2271
+
2272
+ function s2_edit_form() {
2273
+ echo "<!-- Start Subscribe2 Quicktags Javascript -->\r\n";
2274
+ echo "<script type=\"text/javascript\">\r\n";
2275
+ echo "//<![CDATA[\r\n";
2276
+ echo "function s2_insert_token() {
2277
+ buttonsnap_settext('<!--subscribe2-->');
2278
+ }\r\n";
2279
+ echo "//]]>\r\n";
2280
+ echo "</script>\r\n";
2281
+ echo "<!-- End Subscribe2 Quicktags Javascript -->\r\n";
2282
+ }
2283
+
2284
+ /* ===== wp-cron functions ===== */
2285
+ /**
2286
+ Send a daily digest of today's new posts
2287
+ */
2288
+ function subscribe2_cron() {
2289
+ global $wpdb;
2290
+
2291
+ // update last_s2cron execution time before completing or bailing
2292
+ $now = current_time('mysql');
2293
+ $prev = $this->subscribe2_options['last_s2cron'];
2294
+ $this->subscribe2_options['last_s2cron'] = $now;
2295
+ update_option('subscribe2_options', $this->subscribe2_options);
2296
+
2297
+ // collect posts
2298
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ('publish', 'private') AND post_type IN ('post', 'page')");
2299
+
2300
+ // do we have any posts?
2301
+ if (empty($posts)) { return; }
2302
+
2303
+ // if we have posts, let's prepare the digest
2304
+ $all_post_cats = array();
2305
+ foreach ($posts as $post) {
2306
+ $post_cats = wp_get_post_categories($post->ID);
2307
+ $post_cats_string = implode(',', $post_cats);
2308
+ $all_post_cats = array_unique(array_merge($all_post_cats, $post_cats));
2309
+ $check = false;
2310
+ // is the current post assigned to any categories
2311
+ // which should not generate a notification email?
2312
+ foreach (explode(',', $this->subscribe2_options['exclude']) as $cat) {
2313
+ if (in_array($cat, $post_cats)) {
2314
+ $check = true;
2315
+ }
2316
+ }
2317
+ //is the current post set by the user to
2318
+ // not generate a notification email?
2319
+ $s2mail = get_post_meta($post->ID, 's2mail', true);
2320
+ if (strtolower(trim($s2mail)) == 'no') {
2321
+ $check = true;
2322
+ }
2323
+ // is the current post private
2324
+ // and should this not generate a notification email?
2325
+ if ( ($this->subscribe2_options['password'] == "no") && ($post->post_password != '') ) {
2326
+ $check = true;
2327
+ }
2328
+ // is the current post a page
2329
+ // and should this not generate a notification email?
2330
+ if ( ($this->subscribe2_options['pages'] == 'no') && ($post->post_type == 'page') ) {
2331
+ $check = true;
2332
+ }
2333
+ // if this post is in an excluded category,
2334
+ // don't include it in the digest
2335
+ if ($check) {
2336
+ continue;
2337
+ }
2338
+ $table .= $post->post_title . "\r\n";
2339
+ $message .= $post->post_title . "\r\n";
2340
+ $message .= get_permalink($post->ID) . "\r\n";
2341
+ $excerpt = $post->post_excerpt;
2342
+ if ('' == $excerpt) {
2343
+ // no excerpt, is there a <!--more--> ?
2344
+ if (false !== strpos($post->post_content, '<!--more-->')) {
2345
+ list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
2346
+ // strip leading and trailing whitespace
2347
+ $excerpt = trim($excerpt);
2348
+ } else {
2349
+ $excerpt = strip_tags($post->post_content);
2350
+ $words = explode(' ', $excerpt, 56);
2351
+ if (count($words) > 55) {
2352
+ array_pop($words);
2353
+ array_push($words, '[...]');
2354
+ $excerpt = implode(' ', $words);
2355
+ }
2356
+ }
2357
+ }
2358
+ $message .= $excerpt . "\r\n\r\n";
2359
+ }
2360
+
2361
+ // get admin detailts
2362
+ $user = $this->get_userdata();
2363
+ $this->myemail = $user->user_email;
2364
+ $this->myname = $user->display_name;
2365
+
2366
+ $scheds = (array) wp_get_schedules();
2367
+ $email_freq = $this->subscribe2_options['email_freq'];
2368
+ $display = $scheds[$email_freq]['display'];
2369
+ $subject = '[' . stripslashes(get_option('blogname')) . '] ' . $display . ' ' . __('Digest Email', 'subscribe2');
2370
+ $public = $this->get_public();
2371
+ $all_post_cats_string = implode(',', $all_post_cats);
2372
+ $registered = $this->get_registered("cats=$all_post_cats_string");
2373
+ $recipients = array_merge((array)$public, (array)$registered);
2374
+ $mailtext = $this->substitute(stripslashes($this->subscribe2_options['mailtext']));
2375
+ $mailtext = str_replace("TABLE", $table, $mailtext);
2376
+ $mailtext = str_replace("POST", $message, $mailtext);
2377
+ $this->mail($recipients, $subject, $mailtext);
2378
+ } // end subscribe2_cron
2379
+
2380
+ /* ===== Our constructor ===== */
2381
+ /**
2382
+ Subscribe2 constructor
2383
+ */
2384
+ function s2init() {
2385
+ // load the options
2386
+ $this->subscribe2_options = get_option('subscribe2_options');
2387
+
2388
+ add_action('init', array(&$this, 'subscribe2'));
2389
+ if ('1' == $this->subscribe2_options['show_button']) {
2390
+ add_action('init', array(&$this, 'button_init'));
2391
+ }
2392
+ // add action to display widget if option is enabled
2393
+ if ('1' == $this->subscribe2_options['widget']) {
2394
+ add_action('plugins_loaded', array(&$this, 'register_subscribe2widget'));
2395
+ }
2396
+ }
2397
+
2398
+ function subscribe2() {
2399
+ global $table_prefix;
2400
+
2401
+ load_plugin_textdomain('subscribe2', 'wp-content/plugins/subscribe2');
2402
+
2403
+ // do we need to install anything?
2404
+ $this->public = $table_prefix . "subscribe2";
2405
+ if (!mysql_query("DESCRIBE " . $this->public)) { $this->install(); }
2406
+ //do we need to upgrade anything?
2407
+ if ($this->subscribe2_options['version'] !== S2VERSION) {
2408
+ add_action('shutdown', array(&$this, 'upgrade'));
2409
+ }
2410
+
2411
+ if (isset($_GET['s2'])) {
2412
+ // someone is confirming a request
2413
+ add_filter('query_string', array(&$this, 'query_filter'));
2414
+ add_filter('the_title', array(&$this, 'title_filter'));
2415
+ add_filter('the_content', array(&$this, 'confirm'));
2416
+ }
2417
+
2418
+ if ( (isset($_POST['s2_admin'])) && ('exportcsv' == $_POST['s2_admin']) ) {
2419
+ $date = date('Y-m-d');
2420
+ header('Content-Description: File Transfer');
2421
+ header("Content-type: application/octet-stream");
2422
+ header("Content-Disposition: attachment; filename=subscribe2_users_$date.csv");
2423
+ header("Pragma: no-cache");
2424
+ header("Expires: 0");
2425
+ echo $_POST['exportcsv'];
2426
+
2427
+ exit(0);
2428
+ }
2429
+
2430
+ //add regular actions and filters
2431
+ add_action('admin_head', array(&$this, 'admin_head'));
2432
+ add_action('admin_menu', array(&$this, 'admin_menu'));
2433
+ add_action('create_category', array(&$this, 'autosub_new_category'));
2434
+ add_action('register_form', array(&$this, 'register_form'));
2435
+ add_filter('the_content', array(&$this, 'filter'), 10);
2436
+ add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
2437
+
2438
+ // add action to display editor buttons if option is enabled
2439
+ if ('1' == $this->subscribe2_options['show_button']) {
2440
+ add_action('edit_page_form', array(&$this, 's2_edit_form'));
2441
+ add_action('edit_form_advanced', array(&$this, 's2_edit_form'));
2442
+ }
2443
+
2444
+ // add action for automatic subscription based on option settings
2445
+ add_action('user_register', array(&$this, 'register'));
2446
+ if ('wpreg' == $this->subscribe2_options['autosub']) {
2447
+ add_action('register_post', array(&$this, 'register_post'));
2448
+ }
2449
+
2450
+ // add actions for processing posts based on per-post or cron email settings
2451
+ if ($this->subscribe2_options['email_freq'] != 'never') {
2452
+ add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
2453
+ } else {
2454
+ add_action('new_to_publish', array(&$this, 'publish'));
2455
+ add_action('draft_to_publish', array(&$this, 'publish'));
2456
+ add_action('pending_to_publish', array(&$this, 'publish'));
2457
+ add_action('private_to_publish', array(&$this, 'publish'));
2458
+ add_action('future_to_publish', array(&$this, 'publish'));
2459
+ if ($this->subscribe2_options['private'] == "yes") {
2460
+ add_action('new_to_private', array(&$this, 'publish'));
2461
+ add_action('draft_to_private', array(&$this, 'publish'));
2462
+ add_action('pending_to_private', array(&$this, 'publish'));
2463
+ }
2464
+ }
2465
+
2466
+ // load our strings
2467
+ $this->load_strings();
2468
+ } // end subscribe2()
2469
+
2470
+ /* ===== our variables ===== */
2471
+ // cache variables
2472
+ var $subscribe2_options = array();
2473
+ var $all_public = '';
2474
+ var $all_unconfirmed = '';
2475
+ var $excluded_cats = '';
2476
+ var $post_title = '';
2477
+ var $permalink = '';
2478
+ var $myname = '';
2479
+ var $myemail = '';
2480
+ var $s2_subject = '[BLOGNAME] TITLE';
2481
+ var $signup_dates = array();
2482
+ var $private = false;
2483
+ var $filtered = 0;
2484
+
2485
+ // state variables used to affect processing
2486
+ var $action = '';
2487
+ var $email = '';
2488
+ var $message = '';
2489
+ var $error = '';
2490
+
2491
+ // some messages
2492
+ var $please_log_in = '';
2493
+ var $use_profile = '';
2494
+ var $confirmation_sent = '';
2495
+ var $already_subscribed = '';
2496
+ var $not_subscribed ='';
2497
+ var $not_an_email = '';
2498
+ var $barred_domain = '';
2499
+ var $mail_sent = '';
2500
+ var $form = '';
2501
+ var $no_such_email = '';
2502
+ var $added = '';
2503
+ var $deleted = '';
2504
+ var $confirm_subject = '';
2505
+ var $options_saved = '';
2506
+ var $options_reset = '';
2507
+ } // end class subscribe2
2508
  ?>
subscribe2/subscribe2.pot → subscribe2.pot RENAMED
@@ -8,7 +8,7 @@ msgid ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2007-09-13 20:45+0100\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,105 +16,118 @@ msgstr ""
16
  "Content-Type: text/plain; charset=CHARSET\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
 
19
- #: subscribe2.php:63
20
  msgid "To manage your subscription options please "
21
  msgstr ""
22
 
23
- #: subscribe2.php:65 subscribe2.php:67
 
 
 
 
24
  msgid "You may manage your subscription options from your "
25
  msgstr ""
26
 
27
- #: subscribe2.php:69
28
- msgid "A confirmation message is on its way!"
29
  msgstr ""
30
 
31
  #: subscribe2.php:71
32
- msgid "That email address is already subscribed."
33
  msgstr ""
34
 
35
  #: subscribe2.php:73
36
- msgid "That email address is not subscribed."
37
  msgstr ""
38
 
39
  #: subscribe2.php:75
40
- msgid "Sorry, but that does not look like an email address to me."
41
  msgstr ""
42
 
43
  #: subscribe2.php:77
 
 
 
 
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:79
 
 
 
 
 
50
  msgid "Message sent!"
51
  msgstr ""
52
 
53
- #: subscribe2.php:81
54
  msgid "Your email:"
55
  msgstr ""
56
 
57
- #: subscribe2.php:81 subscribe2.php:1139 subscribe2.php:1235
58
  msgid "Subscribe"
59
  msgstr ""
60
 
61
- #: subscribe2.php:81 subscribe2.php:1236
62
  msgid "Unsubscribe"
63
  msgstr ""
64
 
65
- #: subscribe2.php:81 subscribe2.php:1678
66
  msgid "Send"
67
  msgstr ""
68
 
69
- #: subscribe2.php:84
70
  msgid "No such email address is registered."
71
  msgstr ""
72
 
73
- #: subscribe2.php:86
74
  msgid "You have successfully subscribed!"
75
  msgstr ""
76
 
77
- #: subscribe2.php:88
78
  msgid "You have successfully unsubscribed."
79
  msgstr ""
80
 
81
- #: subscribe2.php:90
82
  msgid "Please confirm your request"
83
  msgstr ""
84
 
85
- #: subscribe2.php:92
86
  msgid "Subscription Reminder"
87
  msgstr ""
88
 
89
- #: subscribe2.php:94
90
  msgid "subscribe"
91
  msgstr ""
92
 
93
- #: subscribe2.php:96
94
  msgid "unsubscribe"
95
  msgstr ""
96
 
97
- #: subscribe2.php:99
98
  msgid "Options saved!"
99
  msgstr ""
100
 
101
- #: subscribe2.php:100
102
  msgid "Options reset!"
103
  msgstr ""
104
 
105
- #: subscribe2.php:108 subscribe2.php:1144
106
  msgid "Subscribers"
107
  msgstr ""
108
 
109
- #: subscribe2.php:109
110
  msgid "Subscribe2 Options"
111
  msgstr ""
112
 
113
- #: subscribe2.php:109 subscribe2.php:2144
114
  msgid "Subscribe2"
115
  msgstr ""
116
 
117
- #: subscribe2.php:111 subscribe2.php:113
118
  msgid "Subscriptions"
119
  msgstr ""
120
 
@@ -126,388 +139,473 @@ msgstr ""
126
  msgid "Once Weekly"
127
  msgstr ""
128
 
129
- #: subscribe2.php:714
130
  msgid "New subscriber"
131
  msgstr ""
132
 
133
- #: subscribe2.php:715
134
  msgid "subscribed to email notifications!"
135
  msgstr ""
136
 
137
- #: subscribe2.php:1052
138
  msgid "Address(es) subscribed!"
139
  msgstr ""
140
 
141
- #: subscribe2.php:1055
142
  msgid "deleted!"
143
  msgstr ""
144
 
145
- #: subscribe2.php:1058
146
  msgid "status changed!"
147
  msgstr ""
148
 
149
- #: subscribe2.php:1061
150
  msgid "Reminder Email(s) Sent!"
151
  msgstr ""
152
 
153
- #: subscribe2.php:1064
154
- msgid "CSV File Created in wp-content"
155
- msgstr ""
156
-
157
- #: subscribe2.php:1067
158
  msgid "Registered Users Subscribed!"
159
  msgstr ""
160
 
161
- #: subscribe2.php:1070
162
  msgid "Registered Users Unsubscribed!"
163
  msgstr ""
164
 
165
- #: subscribe2.php:1132
 
 
 
 
 
 
 
 
166
  msgid "Subscribe Addresses"
167
  msgstr ""
168
 
169
- #: subscribe2.php:1137
170
  msgid "Enter addresses, one per line or comma-seperated"
171
  msgstr ""
172
 
173
- #: subscribe2.php:1146
174
  msgid "Filter"
175
  msgstr ""
176
 
177
- #: subscribe2.php:1150
178
  msgid ""
179
  "Registered on the left, confirmed in the middle, unconfirmed on the right"
180
  msgstr ""
181
 
182
- #: subscribe2.php:1159
183
  msgid "Save Emails to CSV File"
184
  msgstr ""
185
 
186
- #: subscribe2.php:1210
187
  msgid "NONE"
188
  msgstr ""
189
 
190
- #: subscribe2.php:1220
191
  msgid "Send Reminder Email"
192
  msgstr ""
193
 
194
- #: subscribe2.php:1227
195
  msgid "Categories"
196
  msgstr ""
197
 
198
- #: subscribe2.php:1228
199
  msgid ""
200
  "Existing Registered Users can be automatically (un)subscribed to categories "
201
  "using this section."
202
  msgstr ""
203
 
204
- #: subscribe2.php:1229
205
  msgid "Consider User Privacy as changes cannot be undone"
206
  msgstr ""
207
 
208
- #: subscribe2.php:1234
209
  msgid "Action to perform"
210
  msgstr ""
211
 
212
- #: subscribe2.php:1239 subscribe2.php:1475
213
  msgid "Submit"
214
  msgstr ""
215
 
216
- #: subscribe2.php:1338
217
  msgid "Delivery Options"
218
  msgstr ""
219
 
220
- #: subscribe2.php:1339
221
  msgid "Send Emails for Pages"
222
  msgstr ""
223
 
224
- #: subscribe2.php:1344 subscribe2.php:1355 subscribe2.php:1446
 
 
225
  msgid "Yes"
226
  msgstr ""
227
 
228
- #: subscribe2.php:1349 subscribe2.php:1360 subscribe2.php:1440
229
- #: subscribe2.php:1451
 
230
  msgid "No"
231
  msgstr ""
232
 
233
- #: subscribe2.php:1350
234
  msgid "Send Emails for Password Protected Posts"
235
  msgstr ""
236
 
237
- #: subscribe2.php:1361
 
 
 
 
238
  msgid "Send Email From"
239
  msgstr ""
240
 
241
- #: subscribe2.php:1366
242
  msgid "Author of the post"
243
  msgstr ""
244
 
245
- #: subscribe2.php:1371
246
  msgid "Blog Admin"
247
  msgstr ""
248
 
249
- #: subscribe2.php:1373
250
  msgid "Send Email as Digest"
251
  msgstr ""
252
 
253
- #: subscribe2.php:1377
254
  msgid "Email Templates"
255
  msgstr ""
256
 
257
- #: subscribe2.php:1380
258
  msgid "New Post email (must not be empty)"
259
  msgstr ""
260
 
261
- #: subscribe2.php:1384
262
  msgid "Message substitions"
263
  msgstr ""
264
 
265
- #: subscribe2.php:1388
266
- msgid "the post's title"
267
  msgstr ""
268
 
269
- #: subscribe2.php:1389
270
  msgid ""
271
  "the excerpt or the entire post<br />(<i>based on the subscriber's "
272
  "preferences</i>)"
273
  msgstr ""
274
 
275
- #: subscribe2.php:1390
276
- msgid "a list of post titles (for digest emails)"
277
  msgstr ""
278
 
279
- #: subscribe2.php:1391
280
- msgid "the post's permalink"
281
  msgstr ""
282
 
283
- #: subscribe2.php:1392
284
  msgid "the admin or post author's name"
285
  msgstr ""
286
 
287
- #: subscribe2.php:1393
288
  msgid "the admin or post author's email"
289
  msgstr ""
290
 
291
- #: subscribe2.php:1394
292
  msgid "the post author's name"
293
  msgstr ""
294
 
295
- #: subscribe2.php:1395
296
  msgid ""
297
  "the generated link to confirm a request<br />(<i>only used in the "
298
  "confirmation email template</i>)"
299
  msgstr ""
300
 
301
- #: subscribe2.php:1396
302
  msgid ""
303
  "Action performed by LINK in confirmation email<br />(<i>only used in the "
304
  "confirmation email template</i>)"
305
  msgstr ""
306
 
307
- #: subscribe2.php:1398
308
  msgid "Subscribe / Unsubscribe confirmation email"
309
  msgstr ""
310
 
311
- #: subscribe2.php:1401
312
  msgid "Reminder email to Unconfirmed Subscribers"
313
  msgstr ""
314
 
315
- #: subscribe2.php:1406
316
  msgid "Excluded Categories"
317
  msgstr ""
318
 
319
- #: subscribe2.php:1407
320
  msgid ""
321
  "Posts assigned to any Excluded Category do not generate notifications and "
322
  "are not included in digest notifications"
323
  msgstr ""
324
 
325
- #: subscribe2.php:1413
326
  msgid "Allow registered users to subscribe to excluded categories?"
327
  msgstr ""
328
 
329
- #: subscribe2.php:1416
330
  msgid "Writing Options"
331
  msgstr ""
332
 
333
- #: subscribe2.php:1421
334
  msgid "Show the Subscribe2 button on the Write toolbar?"
335
  msgstr ""
336
 
337
- #: subscribe2.php:1424
 
 
 
 
338
  msgid "Auto Subscribe"
339
  msgstr ""
340
 
341
- #: subscribe2.php:1425
342
  msgid "Subscribe new users registering with your blog"
343
  msgstr ""
344
 
345
- #: subscribe2.php:1430
346
  msgid "Automatically"
347
  msgstr ""
348
 
349
- #: subscribe2.php:1435
350
  msgid "Display option on Registration Form"
351
  msgstr ""
352
 
353
- #: subscribe2.php:1441
354
  msgid "Registration Form option is checked by default"
355
  msgstr ""
356
 
357
- #: subscribe2.php:1452
358
  msgid "Auto-subscribe users to receive email as"
359
  msgstr ""
360
 
361
- #: subscribe2.php:1457 subscribe2.php:1574
362
  msgid "HTML"
363
  msgstr ""
364
 
365
- #: subscribe2.php:1462
366
  msgid "Plain Text - Full"
367
  msgstr ""
368
 
369
- #: subscribe2.php:1467
370
  msgid "Plain Text - Excerpt"
371
  msgstr ""
372
 
373
- #: subscribe2.php:1470
 
 
 
 
374
  msgid "Barred Domains"
375
  msgstr ""
376
 
377
- #: subscribe2.php:1471
378
  msgid ""
379
  "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
380
  "each entry and omit the \"@\" symbol, for example email.com)"
381
  msgstr ""
382
 
383
- #: subscribe2.php:1480
384
  msgid "Reset Default"
385
  msgstr ""
386
 
387
- #: subscribe2.php:1481
388
  msgid ""
389
  "Use this to reset all options to their defaults. This <strong><em>will not</"
390
  "em></strong> modify your list of subscribers."
391
  msgstr ""
392
 
393
- #: subscribe2.php:1488
394
  msgid "RESET"
395
  msgstr ""
396
 
397
- #: subscribe2.php:1508
398
  msgid "Subscription preferences updated."
399
  msgstr ""
400
 
401
- #: subscribe2.php:1562
402
  msgid "Notification Settings"
403
  msgstr ""
404
 
405
- #: subscribe2.php:1569
406
  msgid "Receive email as"
407
  msgstr ""
408
 
409
- #: subscribe2.php:1579
410
  msgid "Plain Text"
411
  msgstr ""
412
 
413
- #: subscribe2.php:1581
414
  msgid "Email contains"
415
  msgstr ""
416
 
417
- #: subscribe2.php:1582
418
  msgid "Excerpt Only"
419
  msgstr ""
420
 
421
- #: subscribe2.php:1582
422
  msgid "Full Post"
423
  msgstr ""
424
 
425
- #: subscribe2.php:1590
426
- msgid "Note: HTML format will always deliver the full post."
427
  msgstr ""
428
 
429
- #: subscribe2.php:1591
430
  msgid "Automatically subscribe me to newly created categories"
431
  msgstr ""
432
 
433
- #: subscribe2.php:1604
434
  msgid "Subscribed Categories"
435
  msgstr ""
436
 
437
- #: subscribe2.php:1609
438
  msgid "Receive daily summary of new posts?"
439
  msgstr ""
440
 
441
- #: subscribe2.php:1622
442
- msgid "Update Preferences &raquo;"
443
  msgstr ""
444
 
445
- #: subscribe2.php:1667
446
  msgid "Send email to all subscribers"
447
  msgstr ""
448
 
449
- #: subscribe2.php:1672
450
  msgid "Subject"
451
  msgstr ""
452
 
453
- #: subscribe2.php:1672
454
  msgid "A message from "
455
  msgstr ""
456
 
457
- #: subscribe2.php:1675
458
  msgid "Recipients: "
459
  msgstr ""
460
 
461
- #: subscribe2.php:1737
462
  msgid "Select / Unselect All"
463
  msgstr ""
464
 
465
- #: subscribe2.php:1750
466
  msgid "All Subscribers"
467
  msgstr ""
468
 
469
- #: subscribe2.php:1751
470
  msgid "Public Subscribers"
471
  msgstr ""
472
 
473
- #: subscribe2.php:1752
474
  msgid "Confirmed"
475
  msgstr ""
476
 
477
- #: subscribe2.php:1753
478
  msgid "Unconfirmed"
479
  msgstr ""
480
 
481
- #: subscribe2.php:1754
482
  msgid "Registered Users"
483
  msgstr ""
484
 
485
- #: subscribe2.php:1810
486
  msgid "Per Post Email"
487
  msgstr ""
488
 
489
- #: subscribe2.php:1828
490
- msgid "Current server time is"
491
  msgstr ""
492
 
493
- #: subscribe2.php:1830
494
- msgid "Next email notification will be sent"
 
495
  msgstr ""
496
 
497
- #: subscribe2.php:1841
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  msgid "Check here to Subscribe to email notifications for new posts"
499
  msgstr ""
500
 
501
- #: subscribe2.php:1850
502
  msgid ""
503
  "By Registering with this blog you are also agreeing to recieve email "
504
  "notifications for new posts"
505
  msgstr ""
506
 
507
- #: subscribe2.php:1967
508
  msgid "Subscription Confirmation"
509
  msgstr ""
510
 
511
- #: subscribe2.php:2046
 
 
 
 
512
  msgid "Digest Email"
513
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2008-05-25 15:37+0100\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
16
  "Content-Type: text/plain; charset=CHARSET\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
 
19
+ #: subscribe2.php:65
20
  msgid "To manage your subscription options please "
21
  msgstr ""
22
 
23
+ #: subscribe2.php:65
24
+ msgid "login"
25
+ msgstr ""
26
+
27
+ #: subscribe2.php:67 subscribe2.php:69
28
  msgid "You may manage your subscription options from your "
29
  msgstr ""
30
 
31
+ #: subscribe2.php:67 subscribe2.php:69
32
+ msgid "profile"
33
  msgstr ""
34
 
35
  #: subscribe2.php:71
36
+ msgid "A confirmation message is on its way!"
37
  msgstr ""
38
 
39
  #: subscribe2.php:73
40
+ msgid "That email address is already subscribed."
41
  msgstr ""
42
 
43
  #: subscribe2.php:75
44
+ msgid "That email address is not subscribed."
45
  msgstr ""
46
 
47
  #: subscribe2.php:77
48
+ msgid "Sorry, but that does not look like an email address to me."
49
+ msgstr ""
50
+
51
+ #: subscribe2.php:79
52
  msgid ""
53
  "Sorry, email addresses at that domain are currently barred due to spam, "
54
  "please use an alternative email address."
55
  msgstr ""
56
 
57
+ #: subscribe2.php:81
58
+ msgid ""
59
+ "Sorry, there seems to be an error on the server. Please try again later."
60
+ msgstr ""
61
+
62
+ #: subscribe2.php:83
63
  msgid "Message sent!"
64
  msgstr ""
65
 
66
+ #: subscribe2.php:85
67
  msgid "Your email:"
68
  msgstr ""
69
 
70
+ #: subscribe2.php:85 subscribe2.php:1210 subscribe2.php:1311
71
  msgid "Subscribe"
72
  msgstr ""
73
 
74
+ #: subscribe2.php:85 subscribe2.php:1312
75
  msgid "Unsubscribe"
76
  msgstr ""
77
 
78
+ #: subscribe2.php:85 subscribe2.php:1833
79
  msgid "Send"
80
  msgstr ""
81
 
82
+ #: subscribe2.php:88
83
  msgid "No such email address is registered."
84
  msgstr ""
85
 
86
+ #: subscribe2.php:90
87
  msgid "You have successfully subscribed!"
88
  msgstr ""
89
 
90
+ #: subscribe2.php:92
91
  msgid "You have successfully unsubscribed."
92
  msgstr ""
93
 
94
+ #: subscribe2.php:94
95
  msgid "Please confirm your request"
96
  msgstr ""
97
 
98
+ #: subscribe2.php:96
99
  msgid "Subscription Reminder"
100
  msgstr ""
101
 
102
+ #: subscribe2.php:98
103
  msgid "subscribe"
104
  msgstr ""
105
 
106
+ #: subscribe2.php:100
107
  msgid "unsubscribe"
108
  msgstr ""
109
 
110
+ #: subscribe2.php:103
111
  msgid "Options saved!"
112
  msgstr ""
113
 
114
+ #: subscribe2.php:104
115
  msgid "Options reset!"
116
  msgstr ""
117
 
118
+ #: subscribe2.php:112 subscribe2.php:1215
119
  msgid "Subscribers"
120
  msgstr ""
121
 
122
+ #: subscribe2.php:113
123
  msgid "Subscribe2 Options"
124
  msgstr ""
125
 
126
+ #: subscribe2.php:113 subscribe2.php:2174 subscribe2.php:2237
127
  msgid "Subscribe2"
128
  msgstr ""
129
 
130
+ #: subscribe2.php:114
131
  msgid "Subscriptions"
132
  msgstr ""
133
 
139
  msgid "Once Weekly"
140
  msgstr ""
141
 
142
+ #: subscribe2.php:690
143
  msgid "New subscriber"
144
  msgstr ""
145
 
146
+ #: subscribe2.php:691
147
  msgid "subscribed to email notifications!"
148
  msgstr ""
149
 
150
+ #: subscribe2.php:1065
151
  msgid "Address(es) subscribed!"
152
  msgstr ""
153
 
154
+ #: subscribe2.php:1068
155
  msgid "deleted!"
156
  msgstr ""
157
 
158
+ #: subscribe2.php:1071
159
  msgid "status changed!"
160
  msgstr ""
161
 
162
+ #: subscribe2.php:1074
163
  msgid "Reminder Email(s) Sent!"
164
  msgstr ""
165
 
166
+ #: subscribe2.php:1077
 
 
 
 
167
  msgid "Registered Users Subscribed!"
168
  msgstr ""
169
 
170
+ #: subscribe2.php:1080
171
  msgid "Registered Users Unsubscribed!"
172
  msgstr ""
173
 
174
+ #: subscribe2.php:1172
175
+ msgid "Previous Page"
176
+ msgstr ""
177
+
178
+ #: subscribe2.php:1192
179
+ msgid "Next Page"
180
+ msgstr ""
181
+
182
+ #: subscribe2.php:1202
183
  msgid "Subscribe Addresses"
184
  msgstr ""
185
 
186
+ #: subscribe2.php:1208
187
  msgid "Enter addresses, one per line or comma-seperated"
188
  msgstr ""
189
 
190
+ #: subscribe2.php:1217
191
  msgid "Filter"
192
  msgstr ""
193
 
194
+ #: subscribe2.php:1221
195
  msgid ""
196
  "Registered on the left, confirmed in the middle, unconfirmed on the right"
197
  msgstr ""
198
 
199
+ #: subscribe2.php:1229
200
  msgid "Save Emails to CSV File"
201
  msgstr ""
202
 
203
+ #: subscribe2.php:1283
204
  msgid "NONE"
205
  msgstr ""
206
 
207
+ #: subscribe2.php:1294
208
  msgid "Send Reminder Email"
209
  msgstr ""
210
 
211
+ #: subscribe2.php:1301
212
  msgid "Categories"
213
  msgstr ""
214
 
215
+ #: subscribe2.php:1303
216
  msgid ""
217
  "Existing Registered Users can be automatically (un)subscribed to categories "
218
  "using this section."
219
  msgstr ""
220
 
221
+ #: subscribe2.php:1304
222
  msgid "Consider User Privacy as changes cannot be undone"
223
  msgstr ""
224
 
225
+ #: subscribe2.php:1310
226
  msgid "Action to perform"
227
  msgstr ""
228
 
229
+ #: subscribe2.php:1315 subscribe2.php:1614
230
  msgid "Submit"
231
  msgstr ""
232
 
233
+ #: subscribe2.php:1438
234
  msgid "Delivery Options"
235
  msgstr ""
236
 
237
+ #: subscribe2.php:1440
238
  msgid "Send Emails for Pages"
239
  msgstr ""
240
 
241
+ #: subscribe2.php:1445 subscribe2.php:1456 subscribe2.php:1467
242
+ #: subscribe2.php:1571 subscribe2.php:1598 subscribe2.php:1749
243
+ #: subscribe2.php:1769
244
  msgid "Yes"
245
  msgstr ""
246
 
247
+ #: subscribe2.php:1450 subscribe2.php:1461 subscribe2.php:1472
248
+ #: subscribe2.php:1565 subscribe2.php:1576 subscribe2.php:1603
249
+ #: subscribe2.php:1754 subscribe2.php:1773
250
  msgid "No"
251
  msgstr ""
252
 
253
+ #: subscribe2.php:1451
254
  msgid "Send Emails for Password Protected Posts"
255
  msgstr ""
256
 
257
+ #: subscribe2.php:1462
258
+ msgid "Send Emails for Private Posts"
259
+ msgstr ""
260
+
261
+ #: subscribe2.php:1473
262
  msgid "Send Email From"
263
  msgstr ""
264
 
265
+ #: subscribe2.php:1478
266
  msgid "Author of the post"
267
  msgstr ""
268
 
269
+ #: subscribe2.php:1483
270
  msgid "Blog Admin"
271
  msgstr ""
272
 
273
+ #: subscribe2.php:1485
274
  msgid "Send Email as Digest"
275
  msgstr ""
276
 
277
+ #: subscribe2.php:1489
278
  msgid "Email Templates"
279
  msgstr ""
280
 
281
+ #: subscribe2.php:1493
282
  msgid "New Post email (must not be empty)"
283
  msgstr ""
284
 
285
+ #: subscribe2.php:1497
286
  msgid "Message substitions"
287
  msgstr ""
288
 
289
+ #: subscribe2.php:1501
290
+ msgid "the post's title<br />(<i>for per-post emails only</i>)"
291
  msgstr ""
292
 
293
+ #: subscribe2.php:1502
294
  msgid ""
295
  "the excerpt or the entire post<br />(<i>based on the subscriber's "
296
  "preferences</i>)"
297
  msgstr ""
298
 
299
+ #: subscribe2.php:1503
300
+ msgid "a list of post titles<br />(<i>for digest emails only</i>)"
301
  msgstr ""
302
 
303
+ #: subscribe2.php:1504
304
+ msgid "the post's permalink<br />(<i>for per-post emails only</i>)"
305
  msgstr ""
306
 
307
+ #: subscribe2.php:1505
308
  msgid "the admin or post author's name"
309
  msgstr ""
310
 
311
+ #: subscribe2.php:1506
312
  msgid "the admin or post author's email"
313
  msgstr ""
314
 
315
+ #: subscribe2.php:1507
316
  msgid "the post author's name"
317
  msgstr ""
318
 
319
+ #: subscribe2.php:1508
320
  msgid ""
321
  "the generated link to confirm a request<br />(<i>only used in the "
322
  "confirmation email template</i>)"
323
  msgstr ""
324
 
325
+ #: subscribe2.php:1509
326
  msgid ""
327
  "Action performed by LINK in confirmation email<br />(<i>only used in the "
328
  "confirmation email template</i>)"
329
  msgstr ""
330
 
331
+ #: subscribe2.php:1511
332
  msgid "Subscribe / Unsubscribe confirmation email"
333
  msgstr ""
334
 
335
+ #: subscribe2.php:1514
336
  msgid "Reminder email to Unconfirmed Subscribers"
337
  msgstr ""
338
 
339
+ #: subscribe2.php:1519
340
  msgid "Excluded Categories"
341
  msgstr ""
342
 
343
+ #: subscribe2.php:1521
344
  msgid ""
345
  "Posts assigned to any Excluded Category do not generate notifications and "
346
  "are not included in digest notifications"
347
  msgstr ""
348
 
349
+ #: subscribe2.php:1528
350
  msgid "Allow registered users to subscribe to excluded categories?"
351
  msgstr ""
352
 
353
+ #: subscribe2.php:1531
354
  msgid "Writing Options"
355
  msgstr ""
356
 
357
+ #: subscribe2.php:1537
358
  msgid "Show the Subscribe2 button on the Write toolbar?"
359
  msgstr ""
360
 
361
+ #: subscribe2.php:1544
362
+ msgid "Enable Subscribe2 Widget?"
363
+ msgstr ""
364
+
365
+ #: subscribe2.php:1548
366
  msgid "Auto Subscribe"
367
  msgstr ""
368
 
369
+ #: subscribe2.php:1550
370
  msgid "Subscribe new users registering with your blog"
371
  msgstr ""
372
 
373
+ #: subscribe2.php:1555
374
  msgid "Automatically"
375
  msgstr ""
376
 
377
+ #: subscribe2.php:1560
378
  msgid "Display option on Registration Form"
379
  msgstr ""
380
 
381
+ #: subscribe2.php:1566
382
  msgid "Registration Form option is checked by default"
383
  msgstr ""
384
 
385
+ #: subscribe2.php:1577
386
  msgid "Auto-subscribe users to receive email as"
387
  msgstr ""
388
 
389
+ #: subscribe2.php:1582 subscribe2.php:1727
390
  msgid "HTML"
391
  msgstr ""
392
 
393
+ #: subscribe2.php:1587
394
  msgid "Plain Text - Full"
395
  msgstr ""
396
 
397
+ #: subscribe2.php:1592
398
  msgid "Plain Text - Excerpt"
399
  msgstr ""
400
 
401
+ #: subscribe2.php:1593
402
+ msgid "Auto Subscribe me to new categories is checked by default"
403
+ msgstr ""
404
+
405
+ #: subscribe2.php:1607
406
  msgid "Barred Domains"
407
  msgstr ""
408
 
409
+ #: subscribe2.php:1609
410
  msgid ""
411
  "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
412
  "each entry and omit the \"@\" symbol, for example email.com)"
413
  msgstr ""
414
 
415
+ #: subscribe2.php:1619
416
  msgid "Reset Default"
417
  msgstr ""
418
 
419
+ #: subscribe2.php:1620
420
  msgid ""
421
  "Use this to reset all options to their defaults. This <strong><em>will not</"
422
  "em></strong> modify your list of subscribers."
423
  msgstr ""
424
 
425
+ #: subscribe2.php:1627
426
  msgid "RESET"
427
  msgstr ""
428
 
429
+ #: subscribe2.php:1653
430
  msgid "Subscription preferences updated."
431
  msgstr ""
432
 
433
+ #: subscribe2.php:1714
434
  msgid "Notification Settings"
435
  msgstr ""
436
 
437
+ #: subscribe2.php:1722
438
  msgid "Receive email as"
439
  msgstr ""
440
 
441
+ #: subscribe2.php:1732
442
  msgid "Plain Text"
443
  msgstr ""
444
 
445
+ #: subscribe2.php:1734
446
  msgid "Email contains"
447
  msgstr ""
448
 
449
+ #: subscribe2.php:1735
450
  msgid "Excerpt Only"
451
  msgstr ""
452
 
453
+ #: subscribe2.php:1735
454
  msgid "Full Post"
455
  msgstr ""
456
 
457
+ #: subscribe2.php:1743
458
+ msgid "Note: HTML format will always deliver the full post"
459
  msgstr ""
460
 
461
+ #: subscribe2.php:1744
462
  msgid "Automatically subscribe me to newly created categories"
463
  msgstr ""
464
 
465
+ #: subscribe2.php:1758
466
  msgid "Subscribed Categories"
467
  msgstr ""
468
 
469
+ #: subscribe2.php:1763
470
  msgid "Receive daily summary of new posts?"
471
  msgstr ""
472
 
473
+ #: subscribe2.php:1779
474
+ msgid "Update Preferences"
475
  msgstr ""
476
 
477
+ #: subscribe2.php:1820
478
  msgid "Send email to all subscribers"
479
  msgstr ""
480
 
481
+ #: subscribe2.php:1826
482
  msgid "Subject"
483
  msgstr ""
484
 
485
+ #: subscribe2.php:1826
486
  msgid "A message from "
487
  msgstr ""
488
 
489
+ #: subscribe2.php:1829
490
  msgid "Recipients: "
491
  msgstr ""
492
 
493
+ #: subscribe2.php:1892
494
  msgid "Select / Unselect All"
495
  msgstr ""
496
 
497
+ #: subscribe2.php:1910
498
  msgid "All Subscribers"
499
  msgstr ""
500
 
501
+ #: subscribe2.php:1911
502
  msgid "Public Subscribers"
503
  msgstr ""
504
 
505
+ #: subscribe2.php:1912
506
  msgid "Confirmed"
507
  msgstr ""
508
 
509
+ #: subscribe2.php:1913
510
  msgid "Unconfirmed"
511
  msgstr ""
512
 
513
+ #: subscribe2.php:1914
514
  msgid "Registered Users"
515
  msgstr ""
516
 
517
+ #: subscribe2.php:1981
518
  msgid "Per Post Email"
519
  msgstr ""
520
 
521
+ #: subscribe2.php:1996
522
+ msgid "Send Digest Notification at"
523
  msgstr ""
524
 
525
+ #: subscribe2.php:2008
526
+ msgid ""
527
+ "This option will work for digest notification sent daily or less frequently"
528
  msgstr ""
529
 
530
+ #: subscribe2.php:2010
531
+ msgid "Reset the schedule time and date for periodic email notifications"
532
+ msgstr ""
533
+
534
+ #: subscribe2.php:2012
535
+ msgid "Current UTC time is"
536
+ msgstr ""
537
+
538
+ #: subscribe2.php:2014
539
+ msgid "Current blog time is"
540
+ msgstr ""
541
+
542
+ #: subscribe2.php:2016
543
+ msgid "Next email notification will be sent when your blog time is after"
544
+ msgstr ""
545
+
546
+ #: subscribe2.php:2029
547
  msgid "Check here to Subscribe to email notifications for new posts"
548
  msgstr ""
549
 
550
+ #: subscribe2.php:2038
551
  msgid ""
552
  "By Registering with this blog you are also agreeing to recieve email "
553
  "notifications for new posts"
554
  msgstr ""
555
 
556
+ #: subscribe2.php:2163
557
  msgid "Subscription Confirmation"
558
  msgstr ""
559
 
560
+ #: subscribe2.php:2197
561
+ msgid "Title:"
562
+ msgstr ""
563
+
564
+ #: subscribe2.php:2369
565
  msgid "Digest Email"
566
  msgstr ""
567
+
568
+ #: include/options.php:63
569
+ msgid ""
570
+ "BLOGNAME has posted a new item, 'TITLE'\n"
571
+ "\n"
572
+ "POST\n"
573
+ "\n"
574
+ "You may view the latest post at\n"
575
+ "PERMALINK\n"
576
+ "\n"
577
+ "You received this e-mail because you asked to be notified when new updates "
578
+ "are posted.\n"
579
+ "Best regards,\n"
580
+ "MYNAME\n"
581
+ "EMAIL"
582
+ msgstr ""
583
+
584
+ #: include/options.php:67
585
+ msgid ""
586
+ "BLOGNAME has received a request to ACTION for this email address. To "
587
+ "complete your request please click on the link below:\n"
588
+ "\n"
589
+ "LINK\n"
590
+ "\n"
591
+ "If you did not request this, please feel free to disregard this notice!\n"
592
+ "\n"
593
+ "Thank you,\n"
594
+ "MYNAME."
595
+ msgstr ""
596
+
597
+ #: include/options.php:71
598
+ msgid ""
599
+ "This email address was subscribed for notifications at BLOGNAME (BLOGLINK) "
600
+ "but the subscription remains incomplete.\n"
601
+ "\n"
602
+ "If you wish to complete your subscription please click on the link below:\n"
603
+ "\n"
604
+ "LINK\n"
605
+ "\n"
606
+ "If you do not wish to complete your subscription please ignore this email "
607
+ "and your address will be removed from our database.\n"
608
+ "\n"
609
+ "Regards,\n"
610
+ "MYNAME"
611
+ msgstr ""
subscribe2debug.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Subscribe2 Debug
4
+ Plugin URI: http://subscribe2.wordpress.com
5
+ Description: Produces Debug Information for the Subscribe2 plugin.
6
+ Version: 4.7
7
+ Author: Matthew Robinson
8
+ Author URI: http://subscribe2.wordpress.com
9
+ */
10
+
11
+ /*
12
+ Copyright (C) 2006-7 Matthew Robinson
13
+
14
+ This program is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU General Public License
16
+ as published by the Free Software Foundation; either version 2
17
+ of the License, or (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
+ http://www.gnu.org/licenses/gpl.html
28
+ */
29
+
30
+ function add_debug_page() {
31
+ add_menu_page('Subscribe2 Debug', 'Subscribe2 Debug', 1, __FILE__, 'debug_menu');
32
+ }
33
+ add_action('admin_menu', 'add_debug_page');
34
+
35
+ function debug_menu() {
36
+ global $wp_filter;
37
+ echo "<div class=\"wrap\">";
38
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
39
+ echo "<p>Current Server time is: \r\n";
40
+ echo "<strong>" . gmdate($datetime, current_time('timestamp', 1)) . "</strong></p>\r\n";
41
+ echo "<p>Current Blog time is: \r\n";
42
+ echo "<strong>" . gmdate($datetime, current_time('timestamp')) . "</strong></p>\r\n";
43
+ echo "<p>Current Blog offset is: \r\n";
44
+ echo get_option('gmt_offset') . "\r\n";
45
+ echo "<pre>";
46
+ cron_jobs();
47
+ echo "</pre>";
48
+ echo "Current Subscribe 2 Options are:";
49
+ echo "<pre>";
50
+ print_r(get_option('subscribe2_options'));
51
+ echo "</pre>";
52
+ echo "</div>";
53
+ include(ABSPATH . 'wp-admin/admin-footer.php');
54
+ // just to be sure
55
+ die;
56
+ }
57
+
58
+ function cron_jobs() {
59
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
60
+ $jobs = _get_cron_array();
61
+ if (empty($jobs)) {
62
+ echo "No cron jobs scheduled";
63
+ } else {
64
+ foreach ( $jobs as $job => $tasks ) {
65
+ echo "Anytime after " . gmdate($datetime,$job) . " ";
66
+ foreach ($tasks as $procname => $task) {
67
+ echo $procname . " will execute\r\n";
68
+ }
69
+ }
70
+ }
71
+ return;
72
+ }
73
+ ?>
subscribe2uninstaller.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Subscribe2 Uninstaller
4
+ Plugin URI: http://subscribe2.wordpress.com
5
+ Description: Uninstalls the Subscribe2 plugin from Manage->S2 Uninstaller.
6
+ Version: 4.7
7
+ Author: Matthew Robinson
8
+ Author URI: http://subscribe2.wordpress.com
9
+ */
10
+
11
+ /*
12
+ Copyright (C) 2006-7 Matthew Robinson
13
+
14
+ This program is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU General Public License
16
+ as published by the Free Software Foundation; either version 2
17
+ of the License, or (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
+ http://www.gnu.org/licenses/gpl.html
28
+ */
29
+
30
+ $mys2uninst = new s2uninst;
31
+ $mys2uninst->s2uninst_init();
32
+
33
+ class s2uninst {
34
+ function manage_page() {
35
+ global $s2nonce;
36
+
37
+ if (isset($_POST['s2_uninst'])) {
38
+ check_admin_referer('s2uninst-uninstaller' . $s2nonce);
39
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscribe2 has been uninstalled.', 's2uninst') . "</strong></p></div>\n";
40
+ $this->uninstall();
41
+ }
42
+
43
+ echo "<div class=\"wrap\">";
44
+ echo "<h2>" . __('Subscribe2 Uninstaller', 's2uninst') . "</h2>\r\n";
45
+ if (class_exists('s2class')) {
46
+ echo "<p>" . __('The Subscribe2 plugin is still active on your system. Please deactivate the plugin before completing the uninstall process.', 's2uninst') . "</p>\r\n";
47
+ echo "<p>" . __('You can deactivate the plugin by using the ', 's2uninst') . "<a href=\"" . get_option('siteurl') . "/wp-admin/plugins.php\">" . __('WordPress Plugin Page', 's2uninst') . "</a>.</p>";
48
+ echo "</div>\r\n";
49
+ include(ABSPATH . 'wp-admin/admin-footer.php');
50
+ // just to be sure
51
+ die;
52
+ } else {
53
+ echo "<form method=\"post\" action=\"\">";
54
+ if (function_exists('wp_nonce_field')) {
55
+ wp_nonce_field('s2uninst-uninstaller' . $s2nonce);
56
+ }
57
+ echo "<p>" . __('Clicking on UNINSTALL will remove the following items from your WordPress install (these were installed by Subscribe2).', 's2uninst') . "</p>\r\n";
58
+ echo "<ul>\r\n";
59
+ echo "<li>" . __('Options Table Entries', 's2uninst') . "</li>\r\n";
60
+ echo "<li>" . __('Usermeta Table Entries', 's2uninst') . "</li>\r\n";
61
+ echo "<li>" . __('Subscribe2 Table', 's2uninst') . "</li>\r\n";
62
+ echo "<li>" . __('Events Schedules by Subscribe2', 's2uninst') . "</li>\r\n";
63
+ echo "</ul>\r\n";
64
+ echo "<p align=\"center\"><span class=\"submit\">\r\n";
65
+ echo "<input type=\"hidden\" name=\"s2_uninst\" value=\"RESET\" />\r\n";
66
+ echo "<input type=\"submit\" id=\"deletepost\" name=\"submit\" value=\"" . __('UNINSTALL', 's2uninst') . "\" />\r\n";
67
+ echo "</span></p></form></div>\r\n";
68
+ include(ABSPATH . 'wp-admin/admin-footer.php');
69
+ // just to be sure
70
+ die;
71
+ }
72
+ }
73
+
74
+ function uninstall() {
75
+ global $wpdb, $table_prefix;
76
+ // get name of subscribe2 table
77
+ $this->public = $table_prefix . "subscribe2";
78
+ // delete entry from wp_options table
79
+ delete_option('subscribe2_options');
80
+ // delete legacy entry from wp-options table
81
+ delete_option('s2_future_posts');
82
+ // remove and scheduled events
83
+ wp_clear_scheduled_hook('s2_digest_cron');
84
+ // delete usermeta data for registered users
85
+ $users = $wpdb->get_col("SELECT ID FROM $wpdb->users");
86
+ if (!empty($users)) {
87
+ foreach ($users as $user) {
88
+ $cats = explode(',', get_usermeta($user, 's2_subscribed'));
89
+ if ($cats) {
90
+ foreach ($cats as $cat) {
91
+ delete_usermeta($user, "s2_cat" . $cat);
92
+ }
93
+ }
94
+ delete_usermeta($user, 's2_subscribed');
95
+ }
96
+ }
97
+ // drop the subscribe2 table
98
+ $sql = "DROP TABLE IF EXISTS `" . $this->public . "`";
99
+ mysql_query($sql);
100
+ }
101
+
102
+ function s2uninst_init() {
103
+ load_plugin_textdomain('s2uninst', 'wp-content/plugins/');
104
+ add_action('admin_menu', array(&$this, 's2uninst_page'));
105
+ }
106
+
107
+ function s2uninst_page() {
108
+ add_management_page(__('S2 Uninstaller', 's2uninst'), __('S2 Uninstaller', 's2uninst'), "manage_options", __FILE__, array(&$this, 'manage_page'));
109
+ }
110
+ }
111
+ ?>
{subscribe2/tinymce → tinymce}/editor_plugin.js RENAMED
@@ -13,7 +13,7 @@ var TinyMCE_Subscribe2Quicktags = {
13
  getControlHTML : function(cn) {
14
  switch (cn) {
15
  case 'subscribe2quicktags':
16
- buttons = tinyMCE.getButtonHTML('subscribe2', 'lang_subscribe2quicktags_subscribe2', '{$pluginurl}/../s2_button.png', 'subscribe2');
17
  return buttons;
18
  }
19
  return '';
@@ -41,10 +41,10 @@ var TinyMCE_Subscribe2Quicktags = {
41
  }
42
 
43
  alt = "Placeholder for Subscribe2 form";
44
- cssstyle = 'background:url(../wp-content/plugins/subscribe2/s2_marker.png) no-repeat 5px 5px;';
45
 
46
  html = ''
47
- + '<img src="../wp-content/plugins/subscribe2/spacer.gif" '
48
  + 'width="210px" height="25px" '
49
  + 'alt="'+alt+'" title="'+alt+'" style="'+cssstyle+'" class="mce_plugin_s2_img" />';
50
 
@@ -64,14 +64,14 @@ var TinyMCE_Subscribe2Quicktags = {
64
  // Parse all <!--subscribe2--> tags and replace them with images
65
  var startPos = 0;
66
  var alt = "Placeholder for Subscribe2 form";
67
- var cssstyle = 'background:url(../wp-content/plugins/subscribe2/s2_marker.png) no-repeat 5px 5px;';
68
  while ((startPos = content.indexOf('<!--subscribe2', startPos)) != -1) {
69
  var endPos = content.indexOf('-->', startPos) + 3;
70
  // Insert image
71
  var moreText = content.substring(startPos + 14, endPos - 3);
72
  var contentAfter = content.substring(endPos);
73
  content = content.substring(0, startPos);
74
- content += '<img src="../wp-content/plugins/subscribe2/spacer.gif" ';
75
  content += ' width="210px" height="25px" moretext="'+moreText+'" ';
76
  content += 'alt="'+alt+'" title="'+alt+'" style="'+cssstyle+'" class="mce_plugin_s2_img" />';
77
  content += contentAfter;
13
  getControlHTML : function(cn) {
14
  switch (cn) {
15
  case 'subscribe2quicktags':
16
+ buttons = tinyMCE.getButtonHTML('subscribe2', 'lang_subscribe2quicktags_subscribe2', '{$pluginurl}/../include/s2_button.png', 'subscribe2');
17
  return buttons;
18
  }
19
  return '';
41
  }
42
 
43
  alt = "Placeholder for Subscribe2 form";
44
+ cssstyle = 'background:url(../wp-content/plugins/subscribe2/include/s2_marker.png) no-repeat 5px 5px;';
45
 
46
  html = ''
47
+ + '<img src="../wp-content/plugins/subscribe2/include/spacer.gif" '
48
  + 'width="210px" height="25px" '
49
  + 'alt="'+alt+'" title="'+alt+'" style="'+cssstyle+'" class="mce_plugin_s2_img" />';
50
 
64
  // Parse all <!--subscribe2--> tags and replace them with images
65
  var startPos = 0;
66
  var alt = "Placeholder for Subscribe2 form";
67
+ var cssstyle = 'background:url(../wp-content/plugins/subscribe2/include/s2_marker.png) no-repeat 5px 5px;';
68
  while ((startPos = content.indexOf('<!--subscribe2', startPos)) != -1) {
69
  var endPos = content.indexOf('-->', startPos) + 3;
70
  // Insert image
71
  var moreText = content.substring(startPos + 14, endPos - 3);
72
  var contentAfter = content.substring(endPos);
73
  content = content.substring(0, startPos);
74
+ content += '<img src="../wp-content/plugins/subscribe2/include/spacer.gif" ';
75
  content += ' width="210px" height="25px" moretext="'+moreText+'" ';
76
  content += 'alt="'+alt+'" title="'+alt+'" style="'+cssstyle+'" class="mce_plugin_s2_img" />';
77
  content += contentAfter;
subscribe2/tinymce/langs/en_us.js → tinymce/langs/en.js RENAMED
File without changes
tinymce/langs/en_us.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ // US lang variables
2
+
3
+ tinyMCE.addToLang('subscribe2quicktags',{
4
+ subscribe2 : 'Embed Subscribe2 token'
5
+ });
{subscribe2/tinymce → tinymce}/langs/nl_nl.js RENAMED
File without changes
tinymce3/css/content.css ADDED
@@ -0,0 +1 @@
 
1
+ .mceSubscribe2 {display:block;border:0;width:100%;height:12px;border-top:1px;margin-top:15px;background:#fff url(../../include/s2_marker.png) no-repeat center top;}
tinymce3/editor_plugin.js ADDED
@@ -0,0 +1 @@
 
1
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3(){6.1p(\'6.s.r\',{1o:3(2,f){1n k=\'<A 1m="\'+f+\'/../../G/1l.1k" z="c 1j" />\',9=\'c\',i=2.1i(\'1h\',\'<!--4-->\'),l;l=1g 1f(i.j(/[\\?\\.\\*\\[\\]\\(\\)\\{\\}\\+\\^\\$\\:]/g,3(a){h\'\\\\\'+a}),\'g\');2.1e(\'c\',3(){2.1d(\'1c\',0,k)});2.1b(\'4\',{1a:\'y x w\',19:f+\'/../G/18.17\',16:9});2.15.5(3(){2.d.14(f+"/F/8.F");7(2.E.D){2.E.D.5(3(13,o){7(o.C.q==\'p\'&&2.d.m(o.C,9))o.12=\'4\'})}});2.11.5(3(2,e){e=e.10;7(e.q===\'p\'&&2.d.m(e,9))2.Z.Y(e)});2.X.5(3(2,B,n){B.W(\'4\',n.q===\'p\'&&2.d.m(n,9))});2.V.5(3(2,o){o.8=o.8.j(l,k)});2.U.5(3(2,o){7(o.T)o.8=o.8.j(/<A[^>]+>/g,3(b){7(b.S(\'z="c\')!==-1)b=i;h b})})},R:3(){h{Q:\'y x w\',P:\'O N\',M:\'v://4.u.t\',L:\'v://4.u.t\',K:6.J+"."+6.I}}});6.H.5(\'4\',6.s.r)})();',62,88,'||ed|function|subscribe2|add|tinymce|if|content|cls||im|mceSubscribe2|dom||url||return|sep|replace|pb|pbRE|hasClass|||IMG|nodeName|Subscribe2Plugin|plugins|com|wordpress|http|Token|Subscribe2|Insert|class|img|cm|node|onResolveName|theme|css|include|PluginManager|minorVersion|majorVersion|version|infourl|authorurl|Robinson|Matthew|author|longname|getInfo|indexOf|get|onPostProcess|onBeforeSetContent|setActive|onNodeChange|select|selection|target|onClick|name|th|loadCSS|onInit|cmd|png|s2_button|image|title|addButton|mceInsertContent|execCommand|addCommand|RegExp|new|subscribe2_separator|getParam|mceItemNoResize|gif|trans|src|var|init|create'.split('|'),0,{}))
tinymce3/editor_plugin_src.js ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ tinymce.create('tinymce.plugins.Subscribe2Plugin', {
3
+ init : function(ed, url) {
4
+ var pb = '<img src="' + url + '/../../include/trans.gif" class="mceSubscribe2 mceItemNoResize" />', cls = 'mceSubscribe2', sep = ed.getParam('subscribe2_separator', '<!--subscribe2-->'), pbRE;
5
+
6
+ pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
7
+
8
+ // Register commands
9
+ ed.addCommand('mceSubscribe2', function() {
10
+ ed.execCommand('mceInsertContent', 0, pb);
11
+ });
12
+
13
+ // Register buttons
14
+ ed.addButton('subscribe2', {title : 'Insert Subscribe2 Token', image : url + '/../include/s2_button.png', cmd : cls});
15
+
16
+ ed.onInit.add(function() {
17
+ ed.dom.loadCSS(url + "/css/content.css");
18
+
19
+ if (ed.theme.onResolveName) {
20
+ ed.theme.onResolveName.add(function(th, o) {
21
+ if (o.node.nodeName == 'IMG' && ed.dom.hasClass(o.node, cls))
22
+ o.name = 'subscribe2';
23
+ });
24
+ }
25
+ });
26
+
27
+ ed.onClick.add(function(ed, e) {
28
+ e = e.target;
29
+
30
+ if (e.nodeName === 'IMG' && ed.dom.hasClass(e, cls))
31
+ ed.selection.select(e);
32
+ });
33
+
34
+ ed.onNodeChange.add(function(ed, cm, n) {
35
+ cm.setActive('subscribe2', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls));
36
+ });
37
+
38
+ ed.onBeforeSetContent.add(function(ed, o) {
39
+ o.content = o.content.replace(pbRE, pb);
40
+ });
41
+
42
+ ed.onPostProcess.add(function(ed, o) {
43
+ if (o.get)
44
+ o.content = o.content.replace(/<img[^>]+>/g, function(im) {
45
+ if (im.indexOf('class="mceSubscribe2') !== -1)
46
+ im = sep;
47
+
48
+ return im;
49
+ });
50
+ });
51
+ },
52
+
53
+ getInfo : function() {
54
+ return {
55
+ longname : 'Insert Subscribe2 Token',
56
+ author : 'Matthew Robinson',
57
+ authorurl : 'http://subscribe2.wordpress.com',
58
+ infourl : 'http://subscribe2.wordpress.com',
59
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
60
+ };
61
+ }
62
+ });
63
+
64
+ // Register plugin
65
+ tinymce.PluginManager.add('subscribe2', tinymce.plugins.Subscribe2Plugin);
66
+ })();