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