Subscribe2 - Version 6.1

Version Description

Download this release

Release Info

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

Code changes from version 6.0 to 6.1

Files changed (4) hide show
  1. ReadMe.txt +32 -6
  2. include/widget.php +42 -16
  3. subscribe2.php +3737 -3701
  4. subscribe2.pot +227 -210
ReadMe.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_butt
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 2.8
6
  Tested up to: 3.0.1
7
- Stable tag: 6.0
8
 
9
  Sends a list of subscribers an email notification when new posts are published to your blog
10
 
@@ -32,8 +32,8 @@ If you want to send HTML emails to Public Subscribers too then upgrade to [Subsc
32
  4. Configure the options to taste, including the email template and any categories which should be excluded from notification
33
  5. Click the "Tools" admin menu link, and select "Subscribers".
34
  6. Manually subscribe people as you see fit.
35
- 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:
36
- <!--subscribe2-->
37
  ***Ensure the token is on a line by itself and that it has a blank line above and below.***
38
  This token will automatically be replaced by dynamic subscription information and will display all forms and messages as necessary.
39
  8. In the WordPress "Settings" area for Subscribe2 select the page name in the "Appearance" section that of the WordPress page created in step 7.
@@ -115,9 +115,25 @@ The simple answer is yes you can but this is not supported so you need to figure
115
 
116
  Get them to register with your blog rather than using the Subscribe2 form. Additional fields would require much more intensive form processing, checking and entry into the database and since you won't then be able to easily use this information to persoanlise emails there really isn't any point in collecting this data.
117
 
118
- = I can't find or insert the Subscribe2 token, help! =
119
 
120
- If, for some reason the Subscribe2 button does not appear in your browser window try refreshing your browser and cache (Shift and Reload in Firefox). If this still fails then insert the token manually. In the Rich Text Editor (TinyMCE) make sure you switch to the "code" view and type in <!--subscribe2-->.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  = My digest email didn't send, how can I resend it? =
123
 
@@ -144,7 +160,7 @@ WordPress 2.0.x requires Subscribe2 from the 2.x stable branch. The most recent
144
  = Why doesn't the form appear in my WordPress page? =
145
  This is usually caused by one of two things. Firstly, it is possible that the form is there but because you haven't logged out of WordPress yourself you are seeing a message about managing your profile instead. Log out of WordPress and it will appear as the subscription form you are probably expecting.
146
 
147
- Secondly, make sure that the token (<!--subscribe2-->) is correctly entered in your page with a blank line above and below. The easient way to do this is to deactivate the plugin, visit your WordPress page and view the source. The token should be contained in the source code of the page. If it is not there you either have not correctly entered the token or you have another plugin that is stripping the token from the page code.
148
 
149
  == Screenshots ==
150
 
@@ -155,6 +171,16 @@ Secondly, make sure that the token (<!--subscribe2-->) is correctly entered in y
155
 
156
  == Changelog ==
157
 
 
 
 
 
 
 
 
 
 
 
158
  = Version 6.0 by Matthew Robinson =
159
 
160
  * Improved case sensitive SQL queries to avoid issues on some server configurations
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 2.8
6
  Tested up to: 3.0.1
7
+ Stable tag: 6.1
8
 
9
  Sends a list of subscribers an email notification when new posts are published to your blog
10
 
32
  4. Configure the options to taste, including the email template and any categories which should be excluded from notification
33
  5. Click the "Tools" admin menu link, and select "Subscribers".
34
  6. Manually subscribe people as you see fit.
35
+ 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 shortcode or token:
36
+ [subscribe2] or the HTML invisible <!--subscribe2-->
37
  ***Ensure the token is on a line by itself and that it has a blank line above and below.***
38
  This token will automatically be replaced by dynamic subscription information and will display all forms and messages as necessary.
39
  8. In the WordPress "Settings" area for Subscribe2 select the page name in the "Appearance" section that of the WordPress page created in step 7.
115
 
116
  Get them to register with your blog rather than using the Subscribe2 form. Additional fields would require much more intensive form processing, checking and entry into the database and since you won't then be able to easily use this information to persoanlise emails there really isn't any point in collecting this data.
117
 
118
+ = How do I use the Subscribe2 shortcode? =
119
 
120
+ In version 6.1 of Subscribe2 the new standard WordPress shortcode [subscribe2] was introduced. By default, it behaves same as old Subscribe2 token, <--subscribe2-->, which means that it will show the same Subscribe2 output in your chosen page in WordPress or in the Widget.
121
+
122
+ But it also has advanced options, which are related to form. The default form contains two buttons for subscribing and unsubscribing. You may, for example, only want form that handles unsubscribing, so the shortcode accepts a **hide** parameter to hide one of the buttons.
123
+
124
+ If you use the shortcode [subscribe2 hide="subscribe"] then the button for subscribing will be hidden and similarly if you use [subscribe2 hide="unsubscribe"], only button for subscribing will be shown.
125
+
126
+ The new shortcode also accepts two further attributes, these are **id** and **url**. To understand these parameters you need to understand that Subscribe2 returns a user to the default WordPress Page on your site where you use the shortcode or token however in some circumstances you may ant to override this behaviour. If you specify a WordPress page id using the id parameter or a full URL using the url parameter then the user would be returned to the alternative page.
127
+
128
+ There are many scenarios in which to use new options, but here is an example:
129
+
130
+ * Two separate WordPress pages, �Subscribe� that shows only Subscribe button, and �Unsubscibe�, that shows only Unsubscibe button. Both pages also have text that should help users in use of form.
131
+ * In the widget, show only Subscribe button and post form content to page �Subcribe�
132
+ * In the Subscribe2 email template for new post, add text �You can unsubscribe on a following page:� which is followed with link to �Unsubscribe� page
133
+
134
+ = I can't find or insert the Subscribe2 token or shortcode, help! =
135
+
136
+ If, for some reason the Subscribe2 button does not appear in your browser window try refreshing your browser and cache (Shift and Reload in Firefox). If this still fails then insert the token manually. In the Rich Text Editor (TinyMCE) make sure you switch to the "code" view and type in [subscribe2] or <!--subscribe2-->.
137
 
138
  = My digest email didn't send, how can I resend it? =
139
 
160
  = Why doesn't the form appear in my WordPress page? =
161
  This is usually caused by one of two things. Firstly, it is possible that the form is there but because you haven't logged out of WordPress yourself you are seeing a message about managing your profile instead. Log out of WordPress and it will appear as the subscription form you are probably expecting.
162
 
163
+ Secondly, make sure that the token ([subscribe2] or <!--subscribe2-->) is correctly entered in your page with a blank line above and below. The easient way to do this is to deactivate the plugin, visit your WordPress page and view the source. The token should be contained in the source code of the page. If it is not there you either have not correctly entered the token or you have another plugin that is stripping the token from the page code.
164
 
165
  == Screenshots ==
166
 
171
 
172
  == Changelog ==
173
 
174
+ = Version 6.1 by Matthew Robinson =
175
+
176
+ * Fixed a glitch in the HTML tags in the Subscribe2 Widget that affected drag and drop functions in WordPress - thanks to Marty McOmber
177
+ * Improved detection of Multisite installs - thanks to Nada Oneal
178
+ * Fixed precontent and postcontent in the Widget to retain entered HTML tags - reported by Rob Saxe
179
+ * Fixed a few small typos in the inline code comments and email subjects
180
+ * Fixed a bug where Bulk Management changes to move all users to Plain Text Full content would result in blank settings - reported by Sean @ GetSatisfaction
181
+ * Fixed issued with TIME and AUTHORNAME keywords in digest emails - thanks to Robert @ GetSatisfaction
182
+ * Introduced a more flexible Subscribe2 shortcode - thanks to Milan for the patch code
183
+
184
  = Version 6.0 by Matthew Robinson =
185
 
186
  * Improved case sensitive SQL queries to avoid issues on some server configurations
include/widget.php CHANGED
@@ -18,11 +18,19 @@ class S2_Form_widget extends WP_Widget {
18
  $div = empty($instance['div']) ? 'search' : $instance['div'];
19
  $widgetprecontent = empty($instance['widgetprecontent']) ? '' : $instance['widgetprecontent'];
20
  $widgetpostcontent = empty($instance['widgetpostcontent']) ? '' : $instance['widgetpostcontent'];
 
 
 
 
 
 
 
 
 
21
  echo $before_widget;
22
  echo $before_title . $title . $after_title;
23
  echo "<div class=\"" . $div . "\">";
24
- global $mysubscribe2;
25
- $content = $mysubscribe2->filter('<!--subscribe2-->');
26
  if ( !empty($widgetprecontent) ) {
27
  echo $widgetprecontent;
28
  }
@@ -41,8 +49,10 @@ class S2_Form_widget extends WP_Widget {
41
  $instance = $old_instance;
42
  $instance['title'] = strip_tags(stripslashes($new_instance['title']));
43
  $instance['div'] = strip_tags(stripslashes($new_instance['div']));
44
- $instance['widgetprecontent'] = strip_tags(stripslashes($new_instance['widgetprecontent']));
45
- $instance['widgetpostcontent'] = strip_tags(stripslashes($new_instance['widgetpostcontent']));
 
 
46
 
47
  return $instance;
48
  }
@@ -54,9 +64,9 @@ class S2_Form_widget extends WP_Widget {
54
  // set some defaults, getting any old options first
55
  $options = get_option('widget_subscribe2widget');
56
  if ( $options === false ) {
57
- $defaults = array('title' => 'Subscribe2', 'div' => 'search', 'widgetprecontent' => '', 'widgetpostcontent' => '');
58
  } else {
59
- $defaults = array('title' => $options['title'], 'div' => $options['div'], 'widgetprecontent' => $options['widgetprecontent'], 'widgetpostcontent' => $options['widgetpostcontent']);
60
  delete_option('widget_subscribe2widget');
61
  }
62
  // code to obtain old settings too
@@ -66,17 +76,33 @@ class S2_Form_widget extends WP_Widget {
66
  $div= htmlspecialchars($instance['div'], ENT_QUOTES);
67
  $widgetprecontent = htmlspecialchars($instance['widgetprecontent'], ENT_QUOTES);
68
  $widgetpostcontent = htmlspecialchars($instance['widgetpostcontent'], ENT_QUOTES);
 
 
69
 
70
- echo "<div\r\n";
71
- echo "<p><label for=\"" . $this->get_field_name('title') . "\">" . __('Title', 'subscribe2') . ":";
72
- echo "<input class=\"widefat\" id=\"" . $this->get_field_id('title') . "\" name=\"" . $this->get_field_name('title') . "\" type=\"text\" value=\"" . $title . "\" /></label></p>";
73
- echo "<p><label for=\"" . $this->get_field_name('div') . "\">" . __('Div class name', 'subscribe2') . ":";
74
- echo "<input class=\"widefat\" id=\"" . $this->get_field_id('div') . "\" name=\"" . $this->get_field_name('div') . "\" type=\"text\" value=\"" . $div . "\" /></label></p>";
75
- echo "<p><label for=\"" . $this->get_field_name('widgetprecontent') . "\">" . __('Pre-Content', 'subscribe2') . ":";
76
- echo "<input class=\"widefat\" id=\"" . $this->get_field_name('widgetprecontent') . "\" name=\"" . $this->get_field_name('widgetprecontent') . "\" type=\"text\" value=\"" . $widgetprecontent . "\" /></label></p>";
77
- echo "<p><label for=\"" . $this->get_field_name('widgetpostcontent') . "\">" . __('Post-Content', 'subscribe2') . ":";
78
- echo "<input class=\"widefat\" id=\"" . $this->get_field_id('widgetpostcontent') . "\" name=\"" . $this->get_field_name('widgetpostcontent') . "\" type=\"text\" value=\"" . $widgetpostcontent . "\" /></label></p>";
79
- echo "</div\r\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
  } // End S2_Form_widget class
82
  ?>
18
  $div = empty($instance['div']) ? 'search' : $instance['div'];
19
  $widgetprecontent = empty($instance['widgetprecontent']) ? '' : $instance['widgetprecontent'];
20
  $widgetpostcontent = empty($instance['widgetpostcontent']) ? '' : $instance['widgetpostcontent'];
21
+ $hidebutton = empty($instance['hidebutton']) ? 'none' : $instance['hidebutton'];
22
+ $postto = empty($instance['postto']) ? '' : $instance['postto'];
23
+ if ( $hidebutton == 'subscribe' || $hidebutton == 'unsubscribe' ) {
24
+ $hide = " hide=\"" . $hidebutton . "\"";
25
+ }
26
+ if ( $postto ) {
27
+ $postid = " id=\"" . $postto . "\"";
28
+ }
29
+ $shortcode = "[subscribe2" . $hide . $postid . "]";
30
  echo $before_widget;
31
  echo $before_title . $title . $after_title;
32
  echo "<div class=\"" . $div . "\">";
33
+ $content = do_shortcode( $shortcode );
 
34
  if ( !empty($widgetprecontent) ) {
35
  echo $widgetprecontent;
36
  }
49
  $instance = $old_instance;
50
  $instance['title'] = strip_tags(stripslashes($new_instance['title']));
51
  $instance['div'] = strip_tags(stripslashes($new_instance['div']));
52
+ $instance['widgetprecontent'] = stripslashes($new_instance['widgetprecontent']);
53
+ $instance['widgetpostcontent'] = stripslashes($new_instance['widgetpostcontent']);
54
+ $instance['hidebutton'] = strip_tags(stripslashes($new_instance['hidebutton']));
55
+ $instance['postto'] = stripslashes($new_instance['postto']);
56
 
57
  return $instance;
58
  }
64
  // set some defaults, getting any old options first
65
  $options = get_option('widget_subscribe2widget');
66
  if ( $options === false ) {
67
+ $defaults = array('title' => 'Subscribe2', 'div' => 'search', 'widgetprecontent' => '', 'widgetpostcontent' => '', 'hidebutton' => 'none', 'postto' => '');
68
  } else {
69
+ $defaults = array('title' => $options['title'], 'div' => $options['div'], 'widgetprecontent' => $options['widgetprecontent'], 'widgetpostcontent' => $options['widgetpostcontent'], 'hidebutton' => $options['hidebutton'], 'postto' => $options['postto']);
70
  delete_option('widget_subscribe2widget');
71
  }
72
  // code to obtain old settings too
76
  $div= htmlspecialchars($instance['div'], ENT_QUOTES);
77
  $widgetprecontent = htmlspecialchars($instance['widgetprecontent'], ENT_QUOTES);
78
  $widgetpostcontent = htmlspecialchars($instance['widgetpostcontent'], ENT_QUOTES);
79
+ $hidebutton = htmlspecialchars($instance['hidebutton'], ENT_QUOTES);
80
+ $postto = htmlspecialchars($instance['postto'], ENT_QUOTES);
81
 
82
+ global $wpdb;
83
+ $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
84
+ $pages = $wpdb->get_results($sql);
85
+
86
+ echo "<div>\r\n";
87
+ echo "<p><label for=\"" . $this->get_field_name('title') . "\">" . __('Title', 'subscribe2') . ":\r\n";
88
+ echo "<input class=\"widefat\" id=\"" . $this->get_field_id('title') . "\" name=\"" . $this->get_field_name('title') . "\" type=\"text\" value=\"" . $title . "\" /></label></p>\r\n";
89
+ echo "<p><label for=\"" . $this->get_field_name('div') . "\">" . __('Div class name', 'subscribe2') . ":\r\n";
90
+ echo "<input class=\"widefat\" id=\"" . $this->get_field_id('div') . "\" name=\"" . $this->get_field_name('div') . "\" type=\"text\" value=\"" . $div . "\" /></label></p>\r\n";
91
+ echo "<p><label for=\"" . $this->get_field_name('widgetprecontent') . "\">" . __('Pre-Content', 'subscribe2') . ":\r\n";
92
+ echo "<textarea class=\"widefat\" id=\"" . $this->get_field_name('widgetprecontent') . "\" name=\"" . $this->get_field_name('widgetprecontent') . "\" rows=\"2\" cols=\"25\">" . $widgetprecontent . "</textarea></label></p>\r\n";
93
+ echo "<p><label for=\"" . $this->get_field_name('widgetpostcontent') . "\">" . __('Post-Content', 'subscribe2') . ":\r\n";
94
+ echo "<textarea class=\"widefat\" id=\"" . $this->get_field_id('widgetpostcontent') . "\" name=\"" . $this->get_field_name('widgetpostcontent') . "\" rows=\"2\" cols=\"25\">" . $widgetpostcontent . "</textarea></label></p>\r\n";
95
+ echo "<p><label for=\"" . $this->get_field_name('hidebutton') . "\">" . __('Hide button', 'subscribe2') . ":<br />\r\n";
96
+ echo "<input name=\"" . $this->get_field_name('hidebutton') . "\" type=\"radio\" value=\"none\"". checked('none', $hidebutton, false) . "/>" . __('None', 'subscribe2') . "<br /><input name=\"" . $this->get_field_name('hidebutton') . "\" type=\"radio\" value=\"subscribe\"". checked('subscribe', $hidebutton, false) . "/>" . __('Subscribe', 'subscribe2') . "<br /><input name=\"" . $this->get_field_name('hidebutton') . "\" type=\"radio\" value=\"unsubscribe\"". checked('unsubscribe', $hidebutton, false) . "/>" . __('Unsubscribe', 'subscribe2') . "</label></p>\r\n";
97
+ if ( !empty($pages) ) {
98
+ echo "<p><label for=\"" . $this->get_field_name('postto') . "\">" . __('Post form content to page', 'subscribe2') . ":\r\n";
99
+ echo "<select id=\"" . $this->get_field_id('postto') . "\" name=\"" . $this->get_field_name('postto') . "\">\r\n";
100
+ echo "<option value=\"\">" . __('Use Subscribe2 Default', 'subscribe2') . "</option>\r\n";
101
+ global $mysubscribe2;
102
+ $mysubscribe2->pages_dropdown($postto);
103
+ echo "</select></label></p>\r\n";
104
+ }
105
+ echo "</div>\r\n";
106
  }
107
  } // End S2_Form_widget class
108
  ?>
subscribe2.php CHANGED
@@ -1,3702 +1,3738 @@
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: 6.0
7
- Author: Matthew Robinson
8
- Author URI: http://subscribe2.wordpress.com
9
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904
10
- */
11
-
12
- /*
13
- Copyright (C) 2006-10 Matthew Robinson
14
- Based on the Original Subscribe2 plugin by
15
- Copyright (C) 2005 Scott Merrill (skippy@skippy.net)
16
-
17
- This file is part of Subscribe2.
18
-
19
- Subscribe2 is free software: you can redistribute it and/or modify
20
- it under the terms of the GNU General Public License as published by
21
- the Free Software Foundation, either version 3 of the License, or
22
- (at your option) any later version.
23
-
24
- Subscribe2 is distributed in the hope that it will be useful,
25
- but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- GNU General Public License for more details.
28
-
29
- You should have received a copy of the GNU General Public License
30
- along with Subscribe2. If not, see <http://www.gnu.org/licenses/>.
31
- */
32
-
33
- // our version number. Don't touch this or any line below
34
- // unless you know exacly what you are doing
35
- define( 'S2VERSION', '6.0' );
36
- define( 'S2PATH', trailingslashit(dirname(__FILE__)) );
37
- define( 'S2DIR', plugin_basename(dirname(__FILE__)) );
38
-
39
- // Set minimum execution time to 5 minutes - won't affect safe mode
40
- $safe_mode = array('On', 'ON', 'on', 1);
41
- if ( !in_array(ini_get('safe_mode'), $safe_mode) && ini_get('max_execution_time') < 300 ) {
42
- @ini_set('max_execution_time', 300);
43
- }
44
-
45
- /* Include buttonsnap library by Owen Winckler */
46
- if ( !class_exists('buttonsnap') ) {
47
- require( WP_CONTENT_DIR . '/plugins/' . S2DIR . '/include/buttonsnap.php' );
48
- }
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', 'subscribe2') . "</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=s2_users\">" . __('profile', 'subscribe2') . "</a>.</p>";
66
- if ( $this->s2_mu === true) {
67
- global $blog_id, $user_ID;
68
- if ( !is_blog_user($blog_id) ) {
69
- // if we are on multisite and the user is not a member of this blog change the link
70
- $this->use_profile_admin = "<p><a href=\"" . get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id . "\">" . __('Subscribe', 'subscribe2') . "</a>" . __('to email notifications when this blog posts new content', 'subscribe2') . ".</p>";
71
- }
72
- }
73
-
74
- $this->use_profile_users = "<p>" . __('You may manage your subscription options from your', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-admin/profile.php?page=s2_users\">" . __('profile', 'subscribe2') . "</a>.</p>";
75
- if ( $this->s2_mu === true) {
76
- global $blog_id, $user_ID;
77
- if ( !is_blog_user($blog_id) ) {
78
- // if we are on multisite and the user is not a member of this blog change the link
79
- $this->use_profile_users = "<p><a href=\"" . get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id . "\">" . __('Subscribe', 'subscribe2') . "</a>" . __('to email notifications when this blog posts new content', 'subscribe2') . ".</p>";
80
- }
81
- }
82
-
83
- $this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
84
-
85
- $this->already_subscribed = "<p>" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
86
-
87
- $this->not_subscribed = "<p>" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
88
-
89
- $this->not_an_email = "<p>" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
90
-
91
- $this->barred_domain = "<p>" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
92
-
93
- $this->error = "<p>" . __('Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2') . "</p>";
94
-
95
- $this->no_page = "<p>" . __('You must to create a WordPress page for this plugin to work correctly.', 'subscribe2') . "<p>";
96
-
97
- $this->mail_sent = "<p>" . __('Message sent!', 'subscribe2') . "</p>";
98
-
99
- $this->mail_failed = "<p>" . __('Message failed! Check your settings and check with your hosting provider', 'subscribe2') . "</p>";
100
-
101
- $this->form = "<form method=\"post\" action=\"\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p>" . __('Your email:', 'subscribe2') . "<br /><input type=\"text\" name=\"email\" value=\"" . __('Enter email address...', 'subscribe2') . "\" size=\"20\" onfocus=\"if (this.value == '" . __('Enter email address...', 'subscribe2') . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . __('Enter email address...', 'subscribe2') . "';}\" /></p><p><input type=\"submit\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />&nbsp;<input type=\"submit\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" /></p></form>\r\n";
102
-
103
- // confirmation messages
104
- $this->no_such_email = "<p>" . __('No such email address is registered.', 'subscribe2') . "</p>";
105
-
106
- $this->added = "<p>" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
107
-
108
- $this->deleted = "<p>" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
109
-
110
- $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
111
-
112
- $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
113
-
114
- // menu strings
115
- $this->options_saved = __('Options saved!', 'subscribe2');
116
- $this->options_reset = __('Options reset!', 'subscribe2');
117
- } // end load_strings()
118
-
119
- /* ===== WordPress menu registration and scripts ===== */
120
- /**
121
- Hook the menu
122
- */
123
- function admin_menu() {
124
- $s2management = add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", 's2_tools', array(&$this, 'manage_menu'));
125
- add_action("admin_print_scripts-$s2management", array(&$this, 'checkbox_form_js'));
126
-
127
- $s2options = add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2', 'subscribe2'), "manage_options", 's2_settings', array(&$this, 'options_menu'));
128
- add_action("admin_print_scripts-$s2options", array(&$this, 'checkbox_form_js'));
129
- add_action("admin_print_scripts-$s2options", array(&$this, 'option_form_js'));
130
- add_filter('plugin_row_meta', array(&$this, 'plugin_links'), 10, 2);
131
-
132
- $s2user = add_users_page(__('Your Subscriptions', 'subscribe2'), __('Your Subscriptions', 'subscribe2'), "read", 's2_users', array(&$this, 'user_menu'));
133
- add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
134
- add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
135
-
136
- add_submenu_page('post-new.php', __('Mail Subscribers', 'subscribe2'), __('Mail Subscribers', 'subscribe2'), "publish_posts", 's2_posts', array(&$this, 'write_menu'));
137
-
138
- $s2nonce = md5('subscribe2');
139
- } // end admin_menu()
140
-
141
- /**
142
- Hook for Admin Drop Down Icons
143
- */
144
- function ozh_s2_icon() {
145
- return WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/email_edit.png';
146
- } // end ozh_s2_icon()
147
-
148
- /**
149
- Insert Javascript into admin_header
150
- */
151
- function checkbox_form_js() {
152
- wp_enqueue_script('s2_checkbox', WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/s2_checkbox.js', array('jquery'), '1.0');
153
- } //end checkbox_form_js()
154
-
155
- function user_admin_css() {
156
- wp_enqueue_style('s2_user_admin', WP_CONTENT_URL . '/plugins/ '. S2DIR . '/include/s2_user_admin.css', array(), '1.0');
157
- }
158
-
159
- function option_form_js() {
160
- wp_enqueue_script('s2_edit', WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/s2_edit.js', array('jquery'), '1.0');
161
- } // end option_form_js()
162
-
163
- /* ===== Install, upgrade, reset ===== */
164
- /**
165
- Install our table
166
- */
167
- function install() {
168
- // include upgrade-functions for maybe_create_table;
169
- if ( !function_exists('maybe_create_table') ) {
170
- require_once(ABSPATH . 'wp-admin/install-helper.php');
171
- }
172
- $date = date('Y-m-d');
173
- $sql = "CREATE TABLE $this->public (
174
- id int(11) NOT NULL auto_increment,
175
- email varchar(64) NOT NULL default '',
176
- active tinyint(1) default 0,
177
- date DATE default '$date' NOT NULL,
178
- ip char(64) NOT NULL default 'admin',
179
- PRIMARY KEY (id) )";
180
-
181
- // create the table, as needed
182
- maybe_create_table($this->public, $sql);
183
-
184
- // safety check if options exist and if not create them
185
- if ( !is_array($this->subscribe2_options) ) {
186
- $this->reset();
187
- }
188
- } // end install()
189
-
190
- /**
191
- Upgrade the database
192
- */
193
- function upgrade() {
194
- global $wpdb, $wp_version, $wpmu_version;
195
- // include upgrade-functions for maybe_add_column;
196
- if ( !function_exists('maybe_add_column') ) {
197
- require_once(ABSPATH . 'wp-admin/install-helper.php');
198
- }
199
- $date = date('Y-m-d');
200
- maybe_add_column($this->public, 'date', "ALTER TABLE $this->public ADD date DATE DEFAULT '$date' NOT NULL AFTER active;");
201
- maybe_add_column($this->public, 'ip', "ALTER TABLE $this->public ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date;");
202
-
203
- // let's take the time to check process registered users
204
- // existing public subscribers are subscribed to all categories
205
- $users = $this->get_all_registered('ID');
206
- if ( !empty($users) ) {
207
- foreach ( $users as $user ) {
208
- $this->register($user);
209
- }
210
- }
211
- // update the options table to serialized format
212
- $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
213
-
214
- if ( !empty($old_options) ) {
215
- foreach ( $old_options as $option ) {
216
- $value = get_option($option);
217
- $option_array = substr($option, 3);
218
- $this->subscribe2_options[$option_array] = $value;
219
- delete_option($option);
220
- }
221
- }
222
- $this->subscribe2_options['version'] = S2VERSION;
223
- // ensure that the options are in the database
224
- require(S2PATH . "include/options.php");
225
- // correct autoformat to upgrade from pre 5.6
226
- if ( $this->subscribe2_options['autoformat'] == 'text' ) {
227
- $this->subscribe2_options['autoformat'] = 'excerpt';
228
- }
229
- if ( $this->subscribe2_options['autoformat'] == 'full' ) {
230
- $this->subscribe2_options['autoformat'] = 'post';
231
- }
232
- update_option('subscribe2_options', $this->subscribe2_options);
233
-
234
- // upgrade old wpmu user meta data to new
235
- if ( $this->s2_mu === true ) {
236
- $this->namechange_subscribe2_widget();
237
- // loop through all users
238
- foreach ( $users as $user ) {
239
- // get categories which the user is subscribed to (old ones)
240
- $categories = get_usermeta($user, 's2_subscribed');
241
- $categories = explode(',', $categories);
242
-
243
- // load blogs of user (only if we need them)
244
- $blogs = array();
245
- if ( count($categories) > 0 && !in_array('-1', $categories) ) {
246
- $blogs = get_blogs_of_user($user, true);
247
- }
248
-
249
- foreach ( $blogs as $blog_id => $blog ) {
250
- switch_to_blog($blog_id);
251
-
252
- $blog_categories = (array)$wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category'");
253
- $subscribed_categories = array_intersect($categories, $blog_categories);
254
- if ( !empty($subscribed_categories) ) {
255
- foreach ( $subscribed_categories as $subscribed_category ) {
256
- update_usermeta($user, $this->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category);
257
- }
258
- update_usermeta($user, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories));
259
- }
260
- restore_current_blog();
261
- }
262
-
263
- // delete old user meta keys
264
- delete_usermeta($user, 's2_subscribed');
265
- foreach ( $categories as $cat ) {
266
- delete_usermeta($user, 's2_cat' . $cat);
267
- }
268
- }
269
- }
270
-
271
- // ensure existing public subscriber emails are all sanitized
272
- $confirmed = $this->get_public();
273
- $unconfirmed = $this->get_public(0);
274
- $public_subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
275
-
276
- foreach ( $public_subscribers as $email ) {
277
- $new_email = $this->sanitize_email($email);
278
- if ( $email !== $new_email ) {
279
- $wpdb->get_results("UPDATE $this->public SET email='$new_email' WHERE CAST(email as binary)='$email'");
280
- }
281
- }
282
- } // end upgrade()
283
-
284
- /**
285
- Reset our options
286
- */
287
- function reset() {
288
- delete_option('subscribe2_options');
289
- wp_clear_scheduled_hook('s2_digest_cron');
290
- unset($this->subscribe2_options);
291
- require(S2PATH . "include/options.php");
292
- update_option('subscribe2_options', $this->subscribe2_options);
293
- } // end reset()
294
-
295
- /* ===== mail handling ===== */
296
- /**
297
- Performs string substitutions for subscribe2 mail texts
298
- */
299
- function substitute($string = '') {
300
- if ( '' == $string ) {
301
- return;
302
- }
303
- $string = str_replace("BLOGNAME", html_entity_decode(get_option('blogname'), ENT_QUOTES), $string);
304
- $string = str_replace("BLOGLINK", get_option('home'), $string);
305
- $string = str_replace("TITLE", stripslashes($this->post_title), $string);
306
- $link = "<a href=\"" . $this->permalink . "\">" . $this->permalink . "</a>";
307
- $string = str_replace("PERMALINK", $link, $string);
308
- if ( strstr($string, "TINYLINK") ) {
309
- $tinylink = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode($this->permalink));
310
- if ( $tinylink !== 'Error' || $tinylink != false ) {
311
- $tlink = "<a href=\"" . $tinylink . "\">" . $tinylink . "</a>";
312
- $string = str_replace("TINYLINK", $tlink, $string);
313
- } else {
314
- $string = str_replace("TINYLINK", $link, $string);
315
- }
316
- }
317
- $string = str_replace("DATE", $this->post_date, $string);
318
- $string = str_replace("TIME", $this->post_time, $string);
319
- $string = str_replace("MYNAME", stripslashes($this->myname), $string);
320
- $string = str_replace("EMAIL", $this->myemail, $string);
321
- $string = str_replace("AUTHORNAME", stripslashes($this->authorname), $string);
322
- $string = str_replace("CATS", $this->post_cat_names, $string);
323
- $string = str_replace("TAGS", $this->post_tag_names, $string);
324
- $string = str_replace("COUNT", $this->post_count, $string);
325
-
326
- return $string;
327
- } // end substitute()
328
-
329
- /**
330
- Delivers email to recipients in HTML or plaintext
331
- */
332
- function mail($recipients = array(), $subject = '', $message = '', $type='text') {
333
- if ( empty($recipients) || '' == $message ) { return; }
334
-
335
- if ( 'html' == $type ) {
336
- $headers = $this->headers('html');
337
- if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
338
- $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title><link rel=\"stylesheet\" href=\"" . get_stylesheet_uri() . "\" type=\"text/css\" media=\"screen\" /></head><body>" . $message . "</body></html>");
339
- } else {
340
- $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>");
341
- }
342
- } else {
343
- $headers = $this->headers();
344
- $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
345
- $message = preg_replace('|&amp;|', '&', $message);
346
- $message = wordwrap(strip_tags($message), 80, "\n");
347
- $mailtext = apply_filters('s2_plain_email', $message);
348
- }
349
-
350
- // Replace any escaped html symbols in subject
351
- $subject = html_entity_decode($subject, ENT_QUOTES);
352
-
353
- // Construct BCC headers for sending or send individual emails
354
- $bcc = '';
355
- natcasesort($recipients);
356
- if ( function_exists('wpmq_mail') || $this->subscribe2_options['bcclimit'] == 1 ) {
357
- // BCCLimit is 1 so send individual emails
358
- foreach ( $recipients as $recipient ) {
359
- $recipient = trim($recipient);
360
- // sanity check -- make sure we have a valid email
361
- if ( !is_email($recipient) || empty($recipient) ) { continue; }
362
- // Use the mail queue provided we are not sending a preview
363
- if ( function_exists('wpmq_mail') && !$this->preview_email ) {
364
- @wp_mail($recipient, $subject, $mailtext, $headers, '', 0);
365
- } else {
366
- @wp_mail($recipient, $subject, $mailtext, $headers);
367
- }
368
- }
369
- return true;
370
- } elseif ( $this->subscribe2_options['bcclimit'] == 0 ) {
371
- // we're not using BCCLimit
372
- foreach ( $recipients as $recipient ) {
373
- $recipient = trim($recipient);
374
- // sanity check -- make sure we have a valid email
375
- if ( !is_email($recipient) ) { continue; }
376
- // and NOT the sender's email, since they'll get a copy anyway
377
- if ( !empty($recipient) && $this->myemail != $recipient ) {
378
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
379
- // Bcc Headers now constructed by phpmailer class
380
- }
381
- }
382
- $headers .= "$bcc\n";
383
- } else {
384
- // we're using BCCLimit
385
- $count = 1;
386
- $batch = array();
387
- foreach ( $recipients as $recipient ) {
388
- $recipient = trim($recipient);
389
- // sanity check -- make sure we have a valid email
390
- if ( !is_email($recipient) ) { continue; }
391
- // and NOT the sender's email, since they'll get a copy anyway
392
- if ( !empty($recipient) && $this->myemail != $recipient ) {
393
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
394
- // Bcc Headers now constructed by phpmailer class
395
- }
396
- if ( $this->subscribe2_options['bcclimit'] == $count ) {
397
- $count = 0;
398
- $batch[] = $bcc;
399
- $bcc = '';
400
- }
401
- $count++;
402
- }
403
- // add any partially completed batches to our batch array
404
- if ( '' != $bcc ) {
405
- $batch[] = $bcc;
406
- }
407
- }
408
- // rewind the array, just to be safe
409
- reset($recipients);
410
-
411
- // actually send mail
412
- if ( isset($batch) && !empty($batch) ) {
413
- foreach ( $batch as $bcc ) {
414
- $newheaders = $headers . "$bcc\n";
415
- $status = @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
416
- }
417
- } else {
418
- $status = @wp_mail($this->myemail, $subject, $mailtext, $headers);
419
- }
420
- return $status;
421
- } // end mail()
422
-
423
- /**
424
- Construct standard set of email headers
425
- */
426
- function headers($type='text') {
427
- if ( empty($this->myname) || empty($this->myemail) ) {
428
- $admin = $this->get_userdata($this->subscribe2_options['sender']);
429
- $this->myname = html_entity_decode($admin->display_name, ENT_QUOTES);
430
- $this->myemail = $admin->user_email;
431
- }
432
-
433
- $header['From'] = $this->myname . " <" . $this->myemail . ">";
434
- $header['Reply-To'] = $this->myname . " <" . $this->myemail . ">";
435
- $header['Return-path'] = "<" . $this->myemail . ">";
436
- $header['Precedence'] = "list\nList-Id: " . get_option('blogname') . "";
437
- $header['X-Mailer'] = "PHP" . phpversion() . "";
438
- if ( $type == 'html' ) {
439
- // To send HTML mail, the Content-Type header must be set
440
- $header['Content-Type'] = get_option('html_type') . "; charset=\"". get_option('blog_charset') . "\"";
441
- } else {
442
- $header['Content-Type'] = "text/plain; charset=\"". get_option('blog_charset') . "\"";
443
- }
444
-
445
- // apply header filter to allow on-the-fly amendments
446
- $header = apply_filters('s2_email_headers', $header);
447
- // collapse the headers using $key as the header name
448
- foreach ( $header as $key => $value ) {
449
- $headers[$key] = $key . ": " . $value;
450
- }
451
- $headers = implode("\n", $headers);
452
- $headers .= "\n";
453
-
454
- return $headers;
455
- } // end headers()
456
-
457
- /**
458
- Sends an email notification of a new post
459
- */
460
- function publish($post = 0, $preview = '') {
461
- if ( !$post ) { return $post; }
462
-
463
- if ( $preview == '' ) {
464
- // we aren't sending a Preview to the current user so carry out checks
465
- $s2mail = get_post_meta($post->ID, 's2mail', true);
466
- if ( (isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no') || strtolower(trim($s2mail)) == 'no' ) { return $post; }
467
-
468
- // are we doing daily digests? If so, don't send anything now
469
- if ( $this->subscribe2_options['email_freq'] != 'never' ) { return $post; }
470
-
471
- // is the current post of a type that should generate a notification email?
472
- // uses s2_post_types filter to allow for custom post types in WP 3.0
473
- if ( $this->subscribe2_options['pages'] == 'yes' ) {
474
- $s2_post_types = array('page', 'post');
475
- } else {
476
- $s2_post_types = array('post');
477
- }
478
- $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
479
- if ( !in_array($post->post_type, $s2_post_types) ) {
480
- return $post;
481
- }
482
-
483
- // is this post set in the future?
484
- if ( $post->post_date > current_time('mysql') ) {
485
- // bail out
486
- return $post;
487
- }
488
-
489
- //Are we sending notifications for password protected posts?
490
- if ( $this->subscribe2_options['password'] == "no" && $post->post_password != '' ) {
491
- return $post;
492
- }
493
-
494
- $post_cats = wp_get_post_categories($post->ID);
495
- $check = false;
496
- // is the current post assigned to any categories
497
- // which should not generate a notification email?
498
- foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
499
- if ( in_array($cat, $post_cats) ) {
500
- $check = true;
501
- }
502
- }
503
-
504
- if ( $check ) {
505
- // hang on -- can registered users subscribe to
506
- // excluded categories?
507
- if ( '0' == $this->subscribe2_options['reg_override'] ) {
508
- // nope? okay, let's leave
509
- return $post;
510
- }
511
- }
512
-
513
- // Are we sending notifications for Private posts?
514
- // Action is added if we are, but double check option and post status
515
- if ( $this->subscribe2_options['private'] == "yes" && $post->post_status == 'private' ) {
516
- // don't send notification to public users
517
- $check = true;
518
- }
519
-
520
- // lets collect our subscribers
521
- if ( !$check ) {
522
- // if this post is assigned to an excluded
523
- // category, or is a private post then
524
- // don't send public subscribers a notification
525
- $public = $this->get_public();
526
- }
527
- $post_cats_string = implode(',', $post_cats);
528
- $registered = $this->get_registered("cats=$post_cats_string");
529
-
530
- // do we have subscribers?
531
- if ( empty($public) && empty($registered) ) {
532
- // if not, no sense doing anything else
533
- return $post;
534
- }
535
- }
536
-
537
- // we set these class variables so that we can avoid
538
- // passing them in function calls a little later
539
- $this->post_title = "<a href=\"" . get_permalink($post->ID) . "\">" . html_entity_decode($post->post_title, ENT_QUOTES) . "</a>";
540
- $this->permalink = get_permalink($post->ID);
541
- $this->post_date = get_the_time(get_option('date_format'));
542
- $this->post_time = get_the_time();
543
-
544
- $author = get_userdata($post->post_author);
545
- $this->authorname = $author->display_name;
546
-
547
- // do we send as admin, or post author?
548
- if ( 'author' == $this->subscribe2_options['sender'] ) {
549
- // get author details
550
- $user = &$author;
551
- } else {
552
- // get admin details
553
- $user = $this->get_userdata($this->subscribe2_options['sender']);
554
- }
555
- $this->myemail = $user->user_email;
556
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
557
-
558
- $this->post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
559
- $this->post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
560
-
561
- // Get email subject
562
- $subject = stripslashes(strip_tags($this->substitute($this->subscribe2_options['notification_subject'])));
563
- // Get the message template
564
- $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
565
- $mailtext = stripslashes($this->substitute($mailtext));
566
-
567
- $plaintext = $post->post_content;
568
- if ( function_exists('strip_shortcodes') ) {
569
- $plaintext = strip_shortcodes($plaintext);
570
- }
571
- $gallid = '[gallery id="' . $post->ID . '"]';
572
- $post->post_content = str_replace('[gallery]', $gallid, $post->post_content);
573
- $content = apply_filters('the_content', $post->post_content);
574
- $content = str_replace("]]>", "]]&gt", $content);
575
- $excerpt = $post->post_excerpt;
576
- if ( '' == $excerpt ) {
577
- // no excerpt, is there a <!--more--> ?
578
- if ( false !== strpos($plaintext, '<!--more-->') ) {
579
- list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
580
- // strip leading and trailing whitespace
581
- $excerpt = strip_tags($excerpt);
582
- $excerpt = trim($excerpt);
583
- } else {
584
- // no <!--more-->, so grab the first 55 words
585
- $excerpt = strip_tags($plaintext);
586
- $words = explode(' ', $excerpt, $this->excerpt_length + 1);
587
- if (count($words) > $this->excerpt_length) {
588
- array_pop($words);
589
- array_push($words, '[...]');
590
- $excerpt = implode(' ', $words);
591
- }
592
- }
593
- }
594
- $html_excerpt = $post->post_excerpt;
595
- if ( '' == $html_excerpt ) {
596
- // no excerpt, is there a <!--more--> ?
597
- if ( false !== strpos($content, '<!--more-->') ) {
598
- list($html_excerpt, $more) = explode('<!--more-->', $content, 2);
599
- // strip leading and trailing whitespace
600
- $html_excerpt = balanceTags($html_excerpt);
601
- $html_excerpt = trim($html_excerpt);
602
- } else {
603
- // no <!--more-->, so grab the first 55 words
604
- $words = explode(' ', $content, $this->excerpt_length + 1);
605
- if (count($words) > $this->excerpt_length) {
606
- array_pop($words);
607
- array_push($words, '[...]');
608
- $html_excerpt = implode(' ', $words);
609
- $html_excerpt = trim(balanceTags($html_excerpt));
610
- }
611
- }
612
- }
613
-
614
- // prepare mail body texts
615
- $excerpt_body = str_replace("POST", $excerpt, $mailtext);
616
- $full_body = str_replace("POST", strip_tags($plaintext), $mailtext);
617
- $html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
618
- $html_body = str_replace("POST", $content, $html_body);
619
- $html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
620
- $html_excerpt_body = str_replace("POST", $html_excerpt, $html_excerpt_body);
621
-
622
- if ( $preview != '' ) {
623
- $this->myemail = $preview;
624
- $this->myname = "Preview";
625
- $this->mail(array($preview), $subject, $excerpt_body);
626
- $this->mail(array($preview), $subject, $full_body);
627
- $this->mail(array($preview), $subject, $html_body, 'html');
628
- $this->mail(array($preview), $subject, $html_excerpt_body, 'html');
629
- } else {
630
- // first we send plaintext summary emails
631
- $registered = $this->get_registered("cats=$post_cats_string&format=excerpt");
632
- if ( empty($registered) ) {
633
- $recipients = (array)$public;
634
- } elseif ( empty($public) ) {
635
- $recipients = (array)$registered;
636
- } else {
637
- $recipients = array_merge((array)$public, (array)$registered);
638
- }
639
- $this->mail($recipients, $subject, $excerpt_body);
640
-
641
- // next we send plaintext full content emails
642
- $this->mail($this->get_registered("cats=$post_cats_string&format=post"), $subject, $full_body);
643
-
644
- // next we send html excerpt content emails
645
- $this->mail($this->get_registered("cats=$post_cats_string&format=html_excerpt"), $subject, $html_excerpt_body, 'html');
646
-
647
- // finally we send html full content emails
648
- $this->mail($this->get_registered("cats=$post_cats_string&format=html"), $subject, $html_body, 'html');
649
- }
650
- } // end publish()
651
-
652
- /**
653
- Hook Subscribe2 into posts published via email
654
- */
655
- function publish_phone($id) {
656
- if ( !$id ) { return; }
657
-
658
- $post = get_post($id);
659
- $this->publish($post);
660
- return $post;
661
- } // end publish_phone()
662
-
663
- /**
664
- Send confirmation email to the user
665
- */
666
- function send_confirm($what = '', $is_remind = false) {
667
- if ( $this->filtered == 1 ) { return true; }
668
- if ( !$this->email || !$what ) {
669
- return false;
670
- }
671
- $id = $this->get_id($this->email);
672
- if ( !$id ) {
673
- return false;
674
- }
675
-
676
- // generate the URL "?s2=ACTION+HASH+ID"
677
- // ACTION = 1 to subscribe, 0 to unsubscribe
678
- // HASH = md5 hash of email address
679
- // ID = user's ID in the subscribe2 table
680
- // use home instead of siteurl incase index.php is not in core wordpress directory
681
- $link = get_option('home') . "/?s2=";
682
-
683
- if ( 'add' == $what ) {
684
- $link .= '1';
685
- } elseif ( 'del' == $what ) {
686
- $link .= '0';
687
- }
688
- $link .= md5($this->email);
689
- $link .= $id;
690
-
691
- // sort the headers now so we have all substitute information
692
- $mailheaders = $this->headers();
693
-
694
- if ( $is_remind == true ) {
695
- $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
696
- $subject = $this->substitute(stripslashes($this->subscribe2_options['remind_subject']));
697
- } else {
698
- $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
699
- if ( 'add' == $what ) {
700
- $body = str_replace("ACTION", $this->subscribe, $body);
701
- $subject = str_replace("ACTION", $this->subscribe, $this->subscribe2_options['confirm_subject']);
702
- } elseif ( 'del' == $what ) {
703
- $body = str_replace("ACTION", $this->unsubscribe, $body);
704
- $subject = str_replace("ACTION", $this->unsubscribe, $this->subscribe2_options['confirm_subject']);
705
- }
706
- $subject = html_entity_decode($this->substitute(stripslashes($subject)), ENT_QUOTES);
707
- }
708
-
709
- $body = str_replace("LINK", $link, $body);
710
-
711
- if ( $is_remind == true && function_exists('wpmq_mail') ) {
712
- // could be sending lots of reminders so queue them if wpmq is enabled
713
- @wp_mail($this->email, $subject, $body, $mailheaders, '', 0);
714
- } else {
715
- return @wp_mail($this->email, $subject, $body, $mailheaders);
716
- }
717
- } // end send_confirm()
718
-
719
- /* ===== Subscriber functions ===== */
720
- /**
721
- Given a public subscriber ID, returns the email address
722
- */
723
- function get_email($id = 0) {
724
- global $wpdb;
725
-
726
- if ( !$id ) {
727
- return false;
728
- }
729
- return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
730
- } // end get_email()
731
-
732
- /**
733
- Given a public subscriber email, returns the subscriber ID
734
- */
735
- function get_id($email = '') {
736
- global $wpdb;
737
-
738
- if ( !$email ) {
739
- return false;
740
- }
741
- return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
742
- } // end get_id()
743
-
744
- /**
745
- Activate an public subscriber email address
746
- If the address is not already present, it will be added
747
- */
748
- function activate($email = '') {
749
- global $wpdb;
750
-
751
- if ( '' == $email ) {
752
- if ( '' != $this->email ) {
753
- $email = $this->email;
754
- } else {
755
- return false;
756
- }
757
- }
758
-
759
- if ( false !== $this->is_public($email) ) {
760
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
761
- if ( $check ) { return; }
762
- $wpdb->get_results("UPDATE $this->public SET active='1', ip='$this->ip' WHERE CAST(email as binary)='$email'");
763
- } else {
764
- global $current_user;
765
- $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 1, $current_user->user_login));
766
- }
767
- } // end activate()
768
-
769
- /**
770
- Add an public subscriber to the subscriber table as unconfirmed
771
- */
772
- function add($email = '') {
773
- if ( $this->filtered ==1 ) { return; }
774
- global $wpdb;
775
-
776
- if ( '' == $email ) {
777
- if ( '' != $this->email ) {
778
- $email = $this->email;
779
- } else {
780
- return false;
781
- }
782
- }
783
-
784
- if ( !is_email($email) ) { return false; }
785
-
786
- if ( false !== $this->is_public($email) ) {
787
- $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE CAST(email as binary)='$email'");
788
- } else {
789
- $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 0, $this->ip));
790
- }
791
- } // end add()
792
-
793
- /**
794
- Remove a public subscriber user from the subscription table
795
- */
796
- function delete($email = '') {
797
- global $wpdb;
798
-
799
- if ( '' == $email ) {
800
- if ( '' != $this->email ) {
801
- $email = $this->email;
802
- } else {
803
- return false;
804
- }
805
- }
806
-
807
- if ( !is_email($email) ) { return false; }
808
- $wpdb->get_results("DELETE FROM $this->public WHERE CAST(email as binary)='$email'");
809
- } // end delete()
810
-
811
- /**
812
- Toggle a public subscriber's status
813
- */
814
- function toggle($email = '') {
815
- global $wpdb;
816
-
817
- if ( '' == $email || ! is_email($email) ) { return false; }
818
-
819
- // let's see if this is a public user
820
- $status = $this->is_public($email);
821
- if ( false === $status ) { return false; }
822
-
823
- if ( '0' == $status ) {
824
- $wpdb->get_results("UPDATE $this->public SET active='1' WHERE CAST(email as binary)='$email'");
825
- } else {
826
- $wpdb->get_results("UPDATE $this->public SET active='0' WHERE CAST(email as binary)='$email'");
827
- }
828
- } // end toggle()
829
-
830
- /**
831
- Send reminder email to unconfirmed public subscribers
832
- */
833
- function remind($emails = '') {
834
- if ( '' == $emails ) { return false; }
835
-
836
- $recipients = explode(",", $emails);
837
- if ( !is_array($recipients) ) { $recipients = (array)$recipients; }
838
- foreach ( $recipients as $recipient ) {
839
- $this->email = $recipient;
840
- $this->send_confirm('add', true);
841
- }
842
- } //end remind()
843
-
844
- /**
845
- Check email is not from a barred domain
846
- */
847
- function is_barred($email='') {
848
- $barred_option = $this->subscribe2_options['barred'];
849
- list($user, $domain) = split('@', $email);
850
- $bar_check = stristr($barred_option, $domain);
851
-
852
- if ( !empty($bar_check) ) {
853
- return true;
854
- } else {
855
- return false;
856
- }
857
- } //end is_barred()
858
-
859
- /**
860
- Confirm request from the link emailed to the user and email the admin
861
- */
862
- function confirm($content = '') {
863
- global $wpdb;
864
-
865
- if ( 1 == $this->filtered ) { return $content; }
866
-
867
- $code = $_GET['s2'];
868
- $action = intval(substr($code, 0, 1));
869
- $hash = substr($code, 1, 32);
870
- $code = str_replace($hash, '', $code);
871
- $id = intval(substr($code, 1));
872
- if ( $id ) {
873
- $this->email = $this->sanitize_email($this->get_email($id));
874
- if ( !$this->email || $hash !== md5($this->email) ) {
875
- return $this->no_such_email;
876
- }
877
- } else {
878
- return $this->no_such_email;
879
- }
880
-
881
- // get current status of email so messages are only sent once per emailed link
882
- $current = $this->is_public($this->email);
883
-
884
- if ( '1' == $action ) {
885
- // make this subscription active
886
- $this->message = $this->added;
887
- if ( '1' != $current ) {
888
- $this->ip = $_SERVER['REMOTE_ADDR'];
889
- $this->activate();
890
- if ( $this->subscribe2_options['admin_email'] == 'subs' || $this->subscribe2_options['admin_email'] == 'both' ) {
891
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(get_option('blogname')) . "] ";
892
- $subject .= __('New subscription', 'subscribe2');
893
- $subject = html_entity_decode($subject, ENT_QUOTES);
894
- $message = $this->email . " " . __('subscribed to email notifications!', 'subscribe2');
895
- $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value='10'");
896
- if ( empty($recipients) ) {
897
- $role = 'administrator';
898
- if ( !class_exists(WP_User_Search) ) {
899
- require(ABSPATH . 'wp-admin/includes/user.php');
900
- }
901
- $wp_user_search = new WP_User_Search( '', '', $role);
902
- $admins_string = implode(', ', $wp_user_search->get_results());
903
- $sql = "SELECT user_email FROM $wpdb->users WHERE ID IN (" . $admins_string . ")";
904
- $recipients = $wpdb->get_col($sql);
905
- }
906
- $headers = $this->headers();
907
- foreach ( $recipients as $recipient ) {
908
- @wp_mail($recipient, $subject, $message, $headers);
909
- }
910
- }
911
- }
912
- $this->filtered = 1;
913
- } elseif ( '0' == $action ) {
914
- // remove this subscriber
915
- $this->message = $this->deleted;
916
- if ( '0' != $current ) {
917
- $this->delete();
918
- if ( $this->subscribe2_options['admin_email'] == 'unsubs' || $this->subscribe2_options['admin_email'] == 'both' ) {
919
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(get_option('blogname')) . "] ";
920
- $subject .= __('New Unsubscription', 'subscribe2');
921
- $subject = html_entity_decode($subject, ENT_QUOTES);
922
- $message = $this->email . " " . __('unsubscribed from email notifications!', 'subscribe2');
923
- $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value='10'");
924
- if ( empty($recipients) ) {
925
- $role = 'administrator';
926
- if ( !class_exists(WP_User_Search) ) {
927
- require(ABSPATH . 'wp-admin/includes/user.php');
928
- }
929
- $wp_user_search = new WP_User_Search( '', '', $role);
930
- $admins_string = implode(', ', $wp_user_search->get_results());
931
- $sql = "SELECT user_email FROM $wpdb->users WHERE ID IN (" . $admins_string . ")";
932
- $recipients = $wpdb->get_col($sql);
933
- }
934
- $headers = $this->headers();
935
- foreach ( $recipients as $recipient ) {
936
- @wp_mail($recipient, $subject, $message, $headers);
937
- }
938
- }
939
- }
940
- $this->filtered = 1;
941
- }
942
-
943
- if ( '' != $this->message ) {
944
- return $this->message;
945
- }
946
- } // end confirm()
947
-
948
- /**
949
- Is the supplied email address a public subscriber?
950
- */
951
- function is_public($email = '') {
952
- global $wpdb;
953
-
954
- if ( '' == $email ) { return false; }
955
-
956
- // run the query and force case sensitivity
957
- $check = $wpdb->get_var("SELECT active FROM $this->public WHERE CAST(email as binary)='$email'");
958
- if ( '0' == $check || '1' == $check ) {
959
- return $check;
960
- } else {
961
- return false;
962
- }
963
- } // end is_public
964
-
965
- /**
966
- Is the supplied email address a registered user of the blog?
967
- */
968
- function is_registered($email = '') {
969
- global $wpdb;
970
-
971
- if ( '' == $email ) { return false; }
972
-
973
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$email'");
974
- if ( $check ) {
975
- return true;
976
- } else {
977
- return false;
978
- }
979
- } // end is_registered()
980
-
981
- /**
982
- Return Registered User ID from email
983
- */
984
- function get_user_id($email = '') {
985
- global $wpdb;
986
-
987
- if ( '' == $email ) { return false; }
988
-
989
- $id = $wpdb->get_var("SELECT id FROM $wpdb->users WHERE user_email='$email'");
990
-
991
- return $id;
992
- } // end get_user_id()
993
-
994
- /**
995
- Return an array of all the public subscribers
996
- */
997
- function get_public($confirmed = 1) {
998
- global $wpdb;
999
- if ( 1 == $confirmed ) {
1000
- if ( '' == $this->all_public ) {
1001
- $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
1002
- }
1003
- return $this->all_public;
1004
- } else {
1005
- if ( '' == $this->all_unconfirmed ) {
1006
- $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
1007
- }
1008
- return $this->all_unconfirmed;
1009
- }
1010
- } // end get_public()
1011
-
1012
- /**
1013
- Return an array of all subscribers
1014
- */
1015
- function get_all_registered($id = '') {
1016
- global $wpdb;
1017
-
1018
- if ( $this->s2_mu ) {
1019
- if ( $id ) {
1020
- return $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
1021
- } else {
1022
- $result = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
1023
- $ids = implode(',', $result);
1024
- return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
1025
- }
1026
- } else {
1027
- if ( $id ) {
1028
- return $wpdb->get_col("SELECT ID FROM $wpdb->users");
1029
- } else {
1030
- return $wpdb->get_col("SELECT user_email FROM $wpdb->users");
1031
- }
1032
- }
1033
- }
1034
-
1035
- /**
1036
- Return an array of registered subscribers
1037
- Collect all the registered users of the blog who are subscribed to the specified categories
1038
- */
1039
- function get_registered($args = '') {
1040
- global $wpdb;
1041
-
1042
- $format = '';
1043
- $cats = '';
1044
- $subscribers = array();
1045
-
1046
- parse_str($args, $r);
1047
- if ( !isset($r['format']) )
1048
- $r['format'] = 'all';
1049
- if ( !isset($r['cats']) )
1050
- $r['cats'] = '';
1051
-
1052
- $JOIN = ''; $AND = '';
1053
- // text or HTML subscribers
1054
- if ( 'all' != $r['format'] ) {
1055
- $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
1056
- $AND .= " AND b.meta_key='s2_format' AND b.meta_value=";
1057
- if ( 'html' == $r['format'] ) {
1058
- $AND .= "'html'";
1059
- } elseif ( 'html_excerpt' == $r['format'] ) {
1060
- $AND .= "'html_excerpt'";
1061
- } elseif ( 'post' == $r['format'] ) {
1062
- $AND .= "'post'";
1063
- } elseif ( 'excerpt' == $r['format'] ) {
1064
- $AND .= "'excerpt'";
1065
- }
1066
- }
1067
-
1068
- // specific category subscribers
1069
- if ( '' != $r['cats'] ) {
1070
- $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
1071
- $all = '';
1072
- foreach ( explode(',', $r['cats']) as $cat ) {
1073
- ('' == $and) ? $and = "c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'" : $and .= " OR c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'";
1074
- }
1075
- $AND .= " AND ($and)";
1076
- }
1077
-
1078
- if ( $this->s2_mu ) {
1079
- $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities'" . $AND;
1080
- } else {
1081
- $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'" . $AND;
1082
- }
1083
- $result = $wpdb->get_col($sql);
1084
- if ( $result ) {
1085
- $ids = implode(',', $result);
1086
- return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
1087
- }
1088
- } // end get_registered()
1089
-
1090
- /**
1091
- Collects the signup date for all public subscribers
1092
- */
1093
- function signup_date($email = '') {
1094
- if ( '' == $email ) { return false; }
1095
-
1096
- global $wpdb;
1097
- if ( !empty($this->signup_dates) ) {
1098
- return $this->signup_dates[$email];
1099
- } else {
1100
- $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
1101
- foreach ( $results as $result ) {
1102
- $this->signup_dates[$result[0]] = $result[1];
1103
- }
1104
- return $this->signup_dates[$email];
1105
- }
1106
- } // end signup_date()
1107
-
1108
- /**
1109
- Collects the ip address for all public subscribers
1110
- */
1111
- function signup_ip($email = '') {
1112
- if ( '' == $email ) {return false; }
1113
-
1114
- global $wpdb;
1115
- if ( !empty($this->signup_ips) ) {
1116
- return $this->signup_ips[$email];
1117
- } else {
1118
- $results = $wpdb->get_results("SELECT email, ip FROM $this->public", ARRAY_N);
1119
- foreach ( $results as $result ) {
1120
- $this->signup_ips[$result[0]] = $result[1];
1121
- }
1122
- return $this->signup_ips[$email];
1123
- }
1124
- } // end signup_ip()
1125
-
1126
- /**
1127
- function to ensure email is compliant with internet messaging standards
1128
- */
1129
- function sanitize_email($email) {
1130
- if ( !is_email($email) ) { return; }
1131
-
1132
- // ensure that domain is in lowercase as per internet email standards
1133
- list($name, $domain) = explode('@', $email, 2);
1134
- return $name . "@" . strtolower($domain);;
1135
- } // end sanitize_email()
1136
-
1137
- /**
1138
- Create the appropriate usermeta values when a user registers
1139
- If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
1140
- */
1141
- function register($user_ID = 0) {
1142
- global $wpdb;
1143
-
1144
- if ( 0 == $user_ID ) { return $user_ID; }
1145
- $user = get_userdata($user_ID);
1146
- $all_cats = get_categories(array('hide_empty' => false));
1147
-
1148
- // Are registered users are allowed to subscribe to excluded categories?
1149
- if ( 0 == $this->subscribe2_options['reg_override'] || 'no' == $this->subscribe2_options['newreg_override'] ) {
1150
- $exclude = explode(',', $this->subscribe2_options['exclude']);
1151
- foreach ( $all_cats as $cat => $term_id ) {
1152
- if ( in_array($all_cats[$cat]->term_id, $exclude) ) {
1153
- $cat = (int)$cat;
1154
- unset($all_cats[$cat]);
1155
- }
1156
- }
1157
- }
1158
-
1159
- foreach ( $all_cats as $cat ) {
1160
- ('' == $cats) ? $cats = "$cat->term_id" : $cats .= ",$cat->term_id";
1161
- }
1162
-
1163
- if ( '' == $cats ) {
1164
- // sanity check, might occur if all cats excluded and reg_override = 0
1165
- return $user_ID;
1166
- }
1167
-
1168
- // has this user previously signed up for email notification?
1169
- if ( false !== $this->is_public($this->sanitize_email($user->user_email)) ) {
1170
- // delete this user from the public table, and subscribe them to all the categories
1171
- $this->delete($user->user_email);
1172
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1173
- foreach ( explode(',', $cats) as $cat ) {
1174
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, "$cat");
1175
- }
1176
- update_usermeta($user_ID, 's2_format', 'excerpt');
1177
- update_usermeta($user_ID, 's2_autosub', $this->subscribe2_options['autosub_def']);
1178
- } else {
1179
- // create post format entries for all users
1180
- $check_format = get_usermeta($user_ID, 's2_format');
1181
- if ( empty($check_format) ) {
1182
- // ensure existing subscription options are not overwritten on upgrade
1183
- if ( in_array($this->subscribe2_options['autoformat'], array('html', 'html_excerpt', 'post', 'excerpt')) ) {
1184
- update_usermeta($user_ID, 's2_format', $this->subscribe2_options['autoformat']);
1185
- } else {
1186
- update_usermeta($user_ID, 's2_format', 'excerpt');
1187
- }
1188
- update_usermeta($user_ID, 's2_autosub', $this->subscribe2_options['autosub_def']);
1189
- // if the are no existing subscriptions, create them if, by default if autosub is on
1190
- if ( 'yes' == $this->subscribe2_options['autosub'] || ( 'wpreg' == $this->subscribe2_options['autosub'] && 'on' == $_POST['subscribe'] ) ) {
1191
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1192
- foreach ( explode(',', $cats) as $cat ) {
1193
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, "$cat");
1194
- }
1195
- }
1196
- } else {
1197
- // if user is already registered update format remove 's2_excerpt' field and update 's2_format'
1198
- if ( 'html' == $check_format ) {
1199
- delete_usermeta($user_ID, 's2_excerpt');
1200
- } elseif ( 'text' == $check_format ) {
1201
- update_usermeta($user_ID, 's2_format', get_usermeta($user_ID, 's2_excerpt'));
1202
- delete_usermeta($user_ID, 's2_excerpt');
1203
- }
1204
- }
1205
- $subscribed = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1206
- if ( strstr($subscribed, '-1') ) {
1207
- // make sure we remove '-1' from any settings
1208
- $old_cats = explode(',', $subscribed);
1209
- $pos = array_search('-1', $old_cats);
1210
- unset($old_cats[$pos]);
1211
- $cats = implode(',', $old_cats);
1212
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1213
- }
1214
- }
1215
- return $user_ID;
1216
- } // end register()
1217
-
1218
- /**
1219
- Subscribe all registered users to category selected on Admin Manage Page
1220
- */
1221
- function subscribe_registered_users($emails = '', $cats = array()) {
1222
- if ( '' == $emails || '' == $cats ) { return false; }
1223
- global $wpdb;
1224
-
1225
- $useremails = explode(",", $emails);
1226
- $useremails = implode("', '", $useremails);
1227
-
1228
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
1229
- $user_IDs = $wpdb->get_col($sql);
1230
-
1231
- foreach ( $user_IDs as $user_ID ) {
1232
- $old_cats = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1233
- if ( !empty($old_cats) ) {
1234
- $old_cats = explode(',', $old_cats);
1235
- $newcats = array_unique(array_merge($cats, $old_cats));
1236
- } else {
1237
- $newcats = $cats;
1238
- }
1239
- if ( !empty($newcats) ) {
1240
- // add subscription to these cat IDs
1241
- foreach ( $newcats as $id ) {
1242
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, "$id");
1243
- }
1244
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
1245
- }
1246
- unset($newcats);
1247
- }
1248
- } // end subscribe_registered_users()
1249
-
1250
- /**
1251
- Unsubscribe all registered users to category selected on Admin Manage Page
1252
- */
1253
- function unsubscribe_registered_users($emails = '', $cats = array()) {
1254
- if ( '' == $emails || '' == $cats ) { return false; }
1255
- global $wpdb;
1256
-
1257
- $useremails = explode(",", $emails);
1258
- $useremails = implode("', '", $useremails);
1259
-
1260
- $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
1261
- $user_IDs = $wpdb->get_col($sql);
1262
-
1263
- foreach ( $user_IDs as $user_ID ) {
1264
- $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
1265
- $remain = array_diff($old_cats, $cats);
1266
- if ( !empty($remain) ) {
1267
- // remove subscription to these cat IDs and update s2_subscribed
1268
- foreach ( $cats as $id ) {
1269
- delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1270
- }
1271
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
1272
- } else {
1273
- // remove subscription to these cat IDs and update s2_subscribed to ''
1274
- foreach ( $cats as $id ) {
1275
- delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1276
- }
1277
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
1278
- }
1279
- unset($remain);
1280
- }
1281
- } // end unsubscribe_registered_users()
1282
-
1283
- /**
1284
- Handles bulk changes to email format for Registered Subscribers
1285
- */
1286
- function format_change($format, $subscribers_string) {
1287
- if ( empty($format) ) { return; }
1288
-
1289
- global $wpdb;
1290
- $emails ='';
1291
- $subscribers = explode(',', $subscribers_string);
1292
- foreach ( $subscribers as $subscriber ) {
1293
- ( '' == $emails) ? $emails = "'$subscriber'" : $emails .= ",'$subscriber'";
1294
- }
1295
- $ids = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_email IN ($emails)");
1296
- $ids = implode(',', $ids);
1297
- $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='s2_format' AND user_id IN ($ids)";
1298
- $wpdb->get_results("UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='s2_format' AND user_id IN ($ids)");
1299
- } // end bulk_manage()
1300
-
1301
- /**
1302
- Handles subscriptions and unsubscriptions for different blogs on WPMU installs
1303
- */
1304
- function wpmu_subscribe() {
1305
- $redirect_to_subscriptionpage = false;
1306
-
1307
- // subscribe to new blog
1308
- if ( !empty($_GET['s2mu_subscribe']) ) {
1309
- $blog_id = intval($_GET['s2mu_subscribe']);
1310
- if ( $blog_id >= 0 ) {
1311
- switch_to_blog($blog_id);
1312
-
1313
- $user_ID = get_current_user_id();
1314
-
1315
- // if user is not a user of the current blog
1316
- if ( !is_blog_user($blog_id) ) {
1317
- // add user to current blog as subscriber
1318
- add_user_to_blog($blog_id, $user_ID, 'subscriber');
1319
- // add an action hook for external manipulation of blog and user data
1320
- do_action_ref_array('subscribe2_wpmu_subscribe', array($user_ID, $blog_id));
1321
- }
1322
-
1323
- // subscribe to all categories by default
1324
- $all_cats = get_categories(array('hide_empty' => false));
1325
-
1326
- if ( 0 == $this->subscribe2_options['reg_override'] ) {
1327
- // registered users are not allowed to subscribe to excluded categories
1328
- $exclude = explode(',', $this->subscribe2_options['exclude']);
1329
- foreach ( $all_cats as $cat => $term ) {
1330
- if ( in_array($all_cats[$cat]->term_id, $exclude) ) {
1331
- $cat = (int)$cat;
1332
- unset($all_cats[$cat]);
1333
- }
1334
- }
1335
- }
1336
-
1337
- $cats = array();
1338
- foreach ( $all_cats as $cat => $term ) {
1339
- $term_id = $term->term_id;
1340
- $cats[] = $term_id;
1341
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $term_id, $term_id);
1342
- }
1343
- if ( empty($cats) ) {
1344
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
1345
- } else {
1346
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $cats));
1347
- }
1348
-
1349
- // don't restore_current_blog(); -> redirect to new subscription page
1350
- $redirect_to_subscriptionpage = true;
1351
- }
1352
- } elseif ( !empty($_GET['s2mu_unsubscribe']) ) {
1353
- // unsubscribe from a blog
1354
- $blog_id = intval($_GET['s2mu_unsubscribe']);
1355
- if ( $blog_id >= 0 ) {
1356
- switch_to_blog($blog_id);
1357
-
1358
- $user_ID = get_current_user_id();
1359
-
1360
- // delete subscription to all categories on that blog
1361
- $cats = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1362
- $cats = explode(',', $cats);
1363
- if ( !is_array($cats) ) {
1364
- $cats = array($cats);
1365
- }
1366
-
1367
- foreach ( $cats as $id ) {
1368
- delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1369
- }
1370
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
1371
-
1372
- // add an action hook for external manipulation of blog and user data
1373
- do_action_ref_array('subscribe2_wpmu_unsubscribe', array($user_ID, $blog_id));
1374
-
1375
- restore_current_blog();
1376
- $redirect_to_subscriptionpage = true;
1377
- }
1378
- }
1379
-
1380
- if ( $redirect_to_subscriptionpage == true ) {
1381
- if ( !is_user_member_of_blog($user_ID) ) {
1382
- $user_blogs = get_active_blog_for_user($user_ID);
1383
- if ( is_array($user_blogs) ) {
1384
- switch_to_blog(key($user_blogs));
1385
- } else {
1386
- // no longer a member of a blog
1387
- wp_redirect(get_option('siteurl')); // redirect to front page
1388
- exit();
1389
- }
1390
- }
1391
-
1392
- // redirect to profile page
1393
- if ( current_user_can('manage_options') ) {
1394
- $url = get_option('siteurl') . '/wp-admin/users.php?page=s2_users';
1395
- wp_redirect($url);
1396
- exit();
1397
- } else {
1398
- $url = get_option('siteurl') . '/wp-admin/profile.php?page=s2_users';
1399
- wp_redirect($url);
1400
- exit();
1401
- }
1402
- }
1403
- } // end wpmu_subscribe()
1404
-
1405
- /**
1406
- Autosubscribe registered users to newly created categories
1407
- if registered user has selected this option
1408
- */
1409
- function new_category($new_category='') {
1410
- if ( 'no' == $this->subscribe2_options['show_autosub'] ) { return; }
1411
- global $wpdb;
1412
-
1413
- if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
1414
- $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='s2_autosub' AND $wpdb->usermeta.meta_value='yes'";
1415
- $user_IDs = $wpdb->get_col($sql);
1416
- if ( '' == $user_IDs ) { return; }
1417
-
1418
- foreach ( $user_IDs as $user_ID ) {
1419
- $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
1420
- if ( !is_array($old_cats) ) {
1421
- $old_cats = array($old_cats);
1422
- }
1423
- // add subscription to these cat IDs
1424
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $new_category, "$new_category");
1425
- $newcats = array_merge($old_cats, (array)$new_category);
1426
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
1427
- }
1428
- } elseif ( 'exclude' == $this->subscribe2_options['show_autosub'] ) {
1429
- $excluded_cats = explode(',', $this->subscribe2_options['exclude']);
1430
- $excluded_cats[] = $new_category;
1431
- $this->subscribe2_options['exclude'] = implode(',', $excluded_cats);
1432
- update_option('subscribe2_options', $this->subscribe2_options);
1433
- }
1434
- } // end new_category()
1435
-
1436
- function delete_category($deleted_category='') {
1437
- global $wpdb;
1438
-
1439
- $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$deleted_category'";
1440
- $user_IDs = $wpdb->get_col($sql);
1441
- if ( '' == $user_IDs ) { return; }
1442
-
1443
- foreach ( $user_IDs as $user_ID ) {
1444
- $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
1445
- if ( !is_array($old_cats) ) {
1446
- $old_cats = array($old_cats);
1447
- }
1448
- // add subscription to these cat IDs
1449
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $deleted_category, '');
1450
- $remain = array_diff($old_cats, (array)$deleted_category);
1451
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
1452
- }
1453
- }
1454
-
1455
- /**
1456
- Get admin data from record 1 or first user with admin rights
1457
- */
1458
- function get_userdata($admin_id) {
1459
- global $wpdb, $userdata;
1460
-
1461
- if ( is_numeric($admin_id) ) {
1462
- $admin = get_userdata($admin_id);
1463
- } elseif ( $admin_id == 'admin' ) {
1464
- //ensure compatibility with < 4.16
1465
- $admin = get_userdata('1');
1466
- } else {
1467
- $admin = &$userdata;
1468
- }
1469
-
1470
- // if user record is empty grab the first admin from the database
1471
- if ( empty($admin) ) {
1472
- $sql = "SELECT DISTINCT(ID) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value IN (8, 9, 10) LIMIT 1";
1473
- $admin = get_userdata($wpdb->get_var($sql));
1474
- }
1475
-
1476
- // handle issues from WordPress core where user_level is not set or set low
1477
- if ( empty($admin) ) {
1478
- $role = 'administrator';
1479
- if ( !class_exists(WP_User_Search) ) {
1480
- require(ABSPATH . 'wp-admin/includes/user.php');
1481
- }
1482
- $wp_user_search = new WP_User_Search( '', '', $role);
1483
- $results = $wp_user_search->get_results();
1484
- $admin = $results[0];
1485
- }
1486
-
1487
- return $admin;
1488
- } //end get_userdata()
1489
-
1490
- /* ===== Menus ===== */
1491
- /**
1492
- Our management page
1493
- */
1494
- function manage_menu() {
1495
- global $wpdb, $s2nonce;
1496
-
1497
- //Get Registered Subscribers for bulk management
1498
- $registered = $this->get_registered();
1499
- $all_users = $this->get_all_registered();
1500
-
1501
- // was anything POSTed ?
1502
- if ( isset($_POST['s2_admin']) ) {
1503
- check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
1504
- if ( $_POST['addresses'] ) {
1505
- $sub_error = '';
1506
- $unsub_error = '';
1507
- foreach ( preg_split ("/[\s,]+/", $_POST['addresses']) as $email ) {
1508
- $email = $this->sanitize_email($email);
1509
- if ( is_email($email) && $_POST['subscribe'] ) {
1510
- if ( $this->is_public($email) !== false ) {
1511
- ('' == $sub_error) ? $sub_error = "$email" : $sub_error .= ", $email";
1512
- continue;
1513
- }
1514
- $this->activate($email);
1515
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) subscribed!', 'subscribe2') . "</strong></p></div>";
1516
- } elseif ( is_email($email) && $_POST['unsubscribe'] ) {
1517
- if ( $this->is_public($email) === false ) {
1518
- ('' == $unsub_error) ? $unsub_error = "$email" : $unsub_error .= ", $email";
1519
- continue;
1520
- }
1521
- $this->delete($email);
1522
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) unsubscribed!', 'subscribe2') . "</strong></p></div>";
1523
- }
1524
- }
1525
- if ( $sub_error != '' ) {
1526
- echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were already subscribed' , 'subscribe2') . ":<br />$sub_error</strong></p></div>";
1527
- }
1528
- if ( $unsub_error != '' ) {
1529
- echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were not in the database' , 'subscribe2') . ":<br />$unsub_error</strong></p></div>";
1530
- }
1531
- echo $message;
1532
- $_POST['what'] = 'confirmed';
1533
- } elseif ( $_POST['process'] ) {
1534
- if ( $_POST['delete'] ) {
1535
- foreach ( $_POST['delete'] as $address ) {
1536
- $this->delete($address);
1537
- }
1538
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) deleted!', 'subscribe2') . "</strong></p></div>";
1539
- }
1540
- if ( $_POST['confirm'] ) {
1541
- foreach ( $_POST['confirm'] as $address ) {
1542
- $this->toggle($this->sanitize_email($address));
1543
- }
1544
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
1545
- }
1546
- if ( $_POST['unconfirm'] ) {
1547
- foreach ( $_POST['unconfirm'] as $address ) {
1548
- $this->toggle($this->sanitize_email($address));
1549
- }
1550
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
1551
- }
1552
- echo $message;
1553
- } elseif ( $_POST['searchterm'] ) {
1554
- $confirmed = $this->get_public();
1555
- $unconfirmed = $this->get_public(0);
1556
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1557
- foreach ( $subscribers as $subscriber ) {
1558
- if ( is_numeric(stripos($subscriber, $_POST['searchterm'])) ) {
1559
- $result[] = $subscriber;
1560
- }
1561
- }
1562
- } elseif ( $_POST['remind'] ) {
1563
- $this->remind($_POST['reminderemails']);
1564
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Reminder Email(s) Sent!', 'subscribe2') . "</strong></p></div>";
1565
- } elseif ( $_POST['sub_categories'] && 'subscribe' == $_POST['manage'] ) {
1566
- $this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1567
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Subscribed!', 'subscribe2') . "</strong></p></div>";
1568
- } elseif ( $_POST['sub_categories'] && 'unsubscribe' == $_POST['manage'] ) {
1569
- $this->unsubscribe_registered_users($_POST['emails'], $_POST['category']);
1570
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Unsubscribed!', 'subscribe2') . "</strong></p></div>";
1571
- } elseif ( $_POST['sub_format'] ) {
1572
- $this->format_change( $_POST['format'], $_POST['emails'] );
1573
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Format updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
1574
- }
1575
- }
1576
-
1577
- //Get Public Subscribers once for filter
1578
- $confirmed = $this->get_public();
1579
- $unconfirmed = $this->get_public(0);
1580
- // safety check for our arrays
1581
- if ( '' == $confirmed ) { $confirmed = array(); }
1582
- if ( '' == $unconfirmed ) { $unconfirmed = array(); }
1583
- if ( '' == $registered ) { $registered = array(); }
1584
- if ( '' == $all_users ) { $all_users = array(); }
1585
-
1586
- $reminderform = false;
1587
- $urlpath = str_replace("\\", "/", S2PATH);
1588
- $urlpath = trailingslashit(get_option('siteurl')) . substr($urlpath,strpos($urlpath, "wp-content/"));
1589
- if ( isset($_GET['s2page']) ) {
1590
- $page = (int) $_GET['s2page'];
1591
- } else {
1592
- $page = 1;
1593
- }
1594
-
1595
- if ( isset($_POST['what']) ) {
1596
- $page = 1;
1597
- if ( 'all' == $_POST['what'] ) {
1598
- $what = 'all';
1599
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1600
- } elseif ( 'public' == $_POST['what'] ) {
1601
- $what = 'public';
1602
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1603
- } elseif ( 'confirmed' == $_POST['what'] ) {
1604
- $what = 'confirmed';
1605
- $subscribers = $confirmed;
1606
- } elseif ( 'unconfirmed' == $_POST['what'] ) {
1607
- $what = 'unconfirmed';
1608
- $subscribers = $unconfirmed;
1609
- if ( !empty($subscribers) ) {
1610
- $reminderemails = implode(",", $subscribers);
1611
- $reminderform = true;
1612
- }
1613
- } elseif ( is_numeric($_POST['what']) ) {
1614
- $what = intval($_POST['what']);
1615
- $subscribers = $this->get_registered("cats=$what");
1616
- } elseif ( 'registered' == $_POST['what'] ) {
1617
- $what = 'registered';
1618
- $subscribers = $registered;
1619
- } elseif ( 'all_users' == $_POST['what'] ) {
1620
- $what = 'all_users';
1621
- $subscribers = $all_users;
1622
- }
1623
- } elseif ( isset($_GET['what']) ) {
1624
- if ( 'all' == $_GET['what'] ) {
1625
- $what = 'all';
1626
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1627
- } elseif ( 'public' == $_GET['what'] ) {
1628
- $what = 'public';
1629
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1630
- } elseif ( 'confirmed' == $_GET['what'] ) {
1631
- $what = 'confirmed';
1632
- $subscribers = $confirmed;
1633
- } elseif ( 'unconfirmed' == $_GET['what'] ) {
1634
- $what = 'unconfirmed';
1635
- $subscribers = $unconfirmed;
1636
- if ( !empty($subscribers) ) {
1637
- $reminderemails = implode(",", $subscribers);
1638
- $reminderform = true;
1639
- }
1640
- } elseif ( is_numeric($_GET['what']) ) {
1641
- $what = intval($_GET['what']);
1642
- $subscribers = $this->get_registered("cats=$what");
1643
- } elseif ( 'registered' == $_GET['what'] ) {
1644
- $what = 'registered';
1645
- $subscribers = $registered;
1646
- } elseif ( 'all_users' == $_GET['what'] ) {
1647
- $what = 'all_users';
1648
- $subscribers = $all_users;
1649
- }
1650
- } else {
1651
- $what = 'all';
1652
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1653
- }
1654
- if ( $_POST['searchterm'] ) {
1655
- $subscribers = &$result;
1656
- $what = 'public';
1657
- }
1658
-
1659
- if ( !empty($subscribers) ) {
1660
- natcasesort($subscribers);
1661
- // Displays a page number strip - adapted from code in Akismet
1662
- $args['what'] = $what;
1663
- $total_subscribers = count($subscribers);
1664
- $total_pages = ceil($total_subscribers / $this->subscribe2_options['entries']);
1665
- $strip = '';
1666
- if ( $page > 1 ) {
1667
- $args['s2page'] = $page - 1;
1668
- $strip .= '<a class="prev" href="' . clean_url(add_query_arg($args)) . '">&laquo; '. __('Previous Page', 'subscribe2') .'</a>' . "\n";
1669
- }
1670
- if ( $total_pages > 1 ) {
1671
- for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) {
1672
- if ( $page == $page_num ) {
1673
- $strip .= "<strong>Page " . $page_num . "</strong>\n";
1674
- } else {
1675
- if ( $page_num < 3 || ( $page_num >= $page - 2 && $page_num <= $page + 2 ) || $page_num > $total_pages - 2 ) {
1676
- $args['s2page'] = $page_num;
1677
- $strip .= "<a class=\"page-numbers\" href=\"" . clean_url(add_query_arg($args)) . "\">" . $page_num . "</a>\n";
1678
- $trunc = true;
1679
- } elseif ( $trunc == true ) {
1680
- $strip .= "...\n";
1681
- $trunc = false;
1682
- }
1683
- }
1684
- }
1685
- }
1686
- if ( ( $page ) * $this->subscribe2_options['entries'] < $total_subscribers ) {
1687
- $args['s2page'] = $page + 1;
1688
- $strip .= "<a class=\"next\" href=\"" . clean_url(add_query_arg($args)) . "\">". __('Next Page', 'subscribe2') . " &raquo;</a>\n";
1689
- }
1690
- }
1691
-
1692
- // show our form
1693
- echo "<div class=\"wrap\">";
1694
- screen_icon();
1695
- echo "<h2>" . __('Manage Subscribers', 'subscribe2') . "</h2>\r\n";
1696
- echo "<form method=\"post\" action=\"\">\r\n";
1697
- if ( function_exists('wp_nonce_field') ) {
1698
- wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1699
- }
1700
- echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
1701
- echo "<p>" . __('Enter addresses, one per line or comma-separated', 'subscribe2') . "<br />\r\n";
1702
- echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea></p>\r\n";
1703
- echo "<input type=\"hidden\" name=\"s2_admin\" />\r\n";
1704
- echo "<p class=\"submit\" style=\"border-top: none;\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
1705
- echo "&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" /></p>\r\n";
1706
-
1707
- // subscriber lists
1708
- echo "<h2>" . __('Current Subscribers', 'subscribe2') . "</h2>\r\n";
1709
- echo "<br />";
1710
- $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1711
- // show the selected subscribers
1712
- $alternate = '';
1713
- echo "<table cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">";
1714
- echo "<tr class=\"alternate\"><td width=\"50%\"><input type=\"text\" name=\"searchterm\" value=\"\" />&nbsp;\r\n";
1715
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"search\" value=\"" . __('Search Subscribers', 'subscribe2') . "\" /></td>\r\n";
1716
- if ( $reminderform ) {
1717
- echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"reminderemails\" value=\"" . $reminderemails . "\" />\r\n";
1718
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"remind\" value=\"" . __('Send Reminder Email', 'subscribe2') . "\" /></td>\r\n";
1719
- } else {
1720
- echo "<td width=\"25%\"></td>";
1721
- }
1722
- if ( !empty($subscribers) ) {
1723
- $exportcsv = implode(",\r\n", $subscribers);
1724
- echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"exportcsv\" value=\"" . $what . "\" />\r\n";
1725
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"csv\" value=\"" . __('Save Emails to CSV File', 'subscribe2') . "\" /></td>\r\n";
1726
- }
1727
- echo "</tr></table>";
1728
-
1729
- echo "<table class=\"widefat\" cellpadding=\"2\" cellspacing=\"2\">";
1730
- if ( !empty($subscribers) ) {
1731
- echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
1732
- echo "<td align=\"right\">" . $strip . "</td></tr>\r\n";
1733
- }
1734
- if ( !empty($subscribers) ) {
1735
- if ( is_int($this->subscribe2_options['entries']) ) {
1736
- $subscriber_chunks = array_chunk($subscribers, $this->subscribe2_options['entries']);
1737
- } else {
1738
- $subscriber_chunks = array_chunk($subscribers, 25);
1739
- }
1740
- $chunk = $page - 1;
1741
- $subscribers = $subscriber_chunks[$chunk];
1742
- echo "<tr class=\"alternate\" style=\"height:1.5em;\">\r\n";
1743
- echo "<td width=\"4%\" align=\"center\">";
1744
- echo "<img src=\"" . $urlpath . "include/accept.png\" alt=\"&lt;\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" /></td>\r\n";
1745
- echo "<td width=\"4%\" align=\"center\">";
1746
- echo "<img src=\"" . $urlpath . "include/exclamation.png\" alt=\"&gt;\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" /></td>\r\n";
1747
- echo "<td width=\"4%\" align=\"center\">";
1748
- echo "<img src=\"" . $urlpath . "include/cross.png\" alt=\"X\" title=\"" . __('Delete this email address', 'subscribe2') . "\" /></td><td></td></tr>\r\n";
1749
- echo "<tr><td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"confirm_checkall\" /></td>\r\n";
1750
- echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"unconfirm_checkall\" /></td>\r\n";
1751
- echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"delete_checkall\" /></td>\r\n";
1752
- echo "<td align=\"left\"><strong>" . __('Select / Unselect All', 'subscribe2') . "</strong></td></tr>\r\n";
1753
-
1754
- foreach ( $subscribers as $subscriber ) {
1755
- echo "<tr class=\"$alternate\" style=\"height:1.5em;\">";
1756
- echo "<td align=\"center\">\r\n";
1757
- if ( in_array($subscriber, $confirmed) ) {
1758
- echo "</td><td align=\"center\">\r\n";
1759
- echo "<input class=\"unconfirm_checkall\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"unconfirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
1760
- echo "<td align=\"center\">\r\n";
1761
- echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
1762
- echo "</td>\r\n";
1763
- echo "<td><span style=\"color:#006600\">&#x221A;&nbsp;&nbsp;</span><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a>\r\n";
1764
- echo "(<span style=\"color:#006600\"><abbr title=\"" . $this->signup_ip($subscriber) . "\">" . $this->signup_date($subscriber) . "</abbr></span>)\r\n";
1765
- } elseif ( in_array($subscriber, $unconfirmed) ) {
1766
- echo "<input class=\"confirm_checkall\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"confirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
1767
- echo "<td align=\"center\"></td>\r\n";
1768
- echo "<td align=\"center\">\r\n";
1769
- echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
1770
- echo "</td>\r\n";
1771
- echo "<td><span style=\"color:#FF0000\">&nbsp;!&nbsp;&nbsp;&nbsp;</span><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a>\r\n";
1772
- echo "(<span style=\"color:#FF0000\"><abbr title=\"" . $this->signup_ip($subscriber) . "\">" . $this->signup_date($subscriber) . "</abbr></span>)\r\n";
1773
- } elseif ( in_array($subscriber, $all_users) ) {
1774
- echo "</td><td align=\"center\"></td><td align=\"center\"></td>\r\n";
1775
- echo "<td><span style=\"color:#006600\">&reg;&nbsp;&nbsp;</span><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a>\r\n";
1776
- echo "(<a href=\"" . get_option('siteurl') . "/wp-admin/users.php?page=s2_users&amp;email=" . urlencode($subscriber) . "\">" . __('edit', 'subscribe2') . "</a>)\r\n";
1777
- }
1778
- echo "</td></tr>\r\n";
1779
- ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1780
- }
1781
- } else {
1782
- if ( $_POST['searchterm'] ) {
1783
- echo "<tr><td align=\"center\"><b>" . __('No matching subscribers found', 'subscribe2') . "</b></td></tr>\r\n";
1784
- } else {
1785
- echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1786
- }
1787
- }
1788
- if ( !empty($subscribers) ) {
1789
- echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
1790
- echo "<td align=\"right\">" . $strip . "</td></tr>\r\n";
1791
- }
1792
- echo "</table>\r\n";
1793
-
1794
- // show bulk managment form if filtered in some Registered Users
1795
- if ( in_array($what, array('registered', 'all_users')) || is_numeric($what) ) {
1796
- $subscribers_string = implode(',', $subscribers);
1797
- echo "<h2>" . __('Categories', 'subscribe2') . "</h2>\r\n";
1798
- echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
1799
- echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1800
- echo "<br />" . __('Action to perform', 'subscribe2') . ":\r\n";
1801
- echo "<label><input type=\"radio\" name=\"manage\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1802
- echo "<label><input type=\"radio\" name=\"manage\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . "</label><br /><br />\r\n";
1803
- echo "<input type=\"hidden\" name=\"emails\" value=\"$subscribers_string\" />\r\n";
1804
- $this->display_category_form();
1805
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_categories\" value=\"" . __('Bulk Update Categories', 'subscribe2') . "\" /></p>";
1806
-
1807
- echo "<br />" . __('Send email as', 'subscribe2') . ":\r\n";
1808
- echo "<label><input type=\"radio\" name=\"format\" value=\"html\" /> " . __('HTML - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1809
- echo "<label><input type=\"radio\" name=\"format\" value=\"html_excerpt\" /> " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1810
- echo "<label><input type=\"radio\" name=\"format\" value=\"full\" /> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1811
- echo "<label><input type=\"radio\" name=\"format\" value=\"excerpt\" checked=\"checked\" /> " . __('Plain Text - Excerpt', 'subscribe2') . "</label>\r\n";
1812
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_format\" value=\"" . __('Bulk Update Format', 'subscribe2') . "\" /></p>";
1813
- }
1814
- echo "</form></div>\r\n";
1815
-
1816
- include(ABSPATH . 'wp-admin/admin-footer.php');
1817
- // just to be sure
1818
- die;
1819
- } // end manage_menu()
1820
-
1821
- /**
1822
- Our options page
1823
- */
1824
- function options_menu() {
1825
- global $s2nonce, $wpdb;
1826
-
1827
- // send error message if no WordPress page exists
1828
- $sql = "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1";
1829
- $id = $wpdb->get_var($sql);
1830
- if ( empty($id) ) {
1831
- echo "<div id=\"message\" class=\"error\"><p><strong>$this->no_page</strong></p></div>";
1832
- }
1833
-
1834
- // was anything POSTed?
1835
- if ( isset( $_POST['s2_admin']) ) {
1836
- check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
1837
- if ( $_POST['reset'] ) {
1838
- $this->reset();
1839
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_reset</strong></p></div>";
1840
- } elseif ( $_POST['preview'] ) {
1841
- global $user_email;
1842
- $this->preview_email = true;
1843
- if ( 'never' == $this->subscribe2_options['email_freq'] ) {
1844
- $post = get_posts('numberposts=1');
1845
- $this->publish($post[0], $user_email);
1846
- } else {
1847
- $this->subscribe2_cron($user_email);
1848
- }
1849
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Preview message(s) sent to logged in user', 'subscribe2') . "</strong></p></div>";
1850
- } elseif ( $_POST['resend'] ) {
1851
- $status = $this->subscribe2_cron('', 'resend');
1852
- if ( $status === false ) {
1853
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('The Digest Notification email contained no post information. No email was sent', 'subscribe2') . "</strong></p></div>";
1854
- } else {
1855
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Attempt made to resend the Digest Notification email', 'subscribe2') . "</strong></p></div>";
1856
- }
1857
- } elseif ( $_POST['submit'] ) {
1858
- // BCClimit
1859
- if ( is_numeric($_POST['bcc']) && $_POST['bcc'] >= 0 ) {
1860
- $this->subscribe2_options['bcclimit'] = $_POST['bcc'];
1861
- }
1862
- // admin_email
1863
- $this->subscribe2_options['admin_email'] = $_POST['admin_email'];
1864
-
1865
- // send as author or admin?
1866
- $sender = 'author';
1867
- if ( is_numeric($_POST['sender']) ) {
1868
- $sender = $_POST['sender'];
1869
- }
1870
- $this->subscribe2_options['sender'] = $sender;
1871
-
1872
- // send email for pages, private and password protected posts
1873
- $this->subscribe2_options['stylesheet'] = $_POST['stylesheet'];
1874
- $this->subscribe2_options['pages'] = $_POST['pages'];
1875
- $this->subscribe2_options['password'] = $_POST['password'];
1876
- $this->subscribe2_options['private'] = $_POST['private'];
1877
- $this->subscribe2_options['cron_order'] = $_POST['cron_order'];
1878
-
1879
- // send per-post or digest emails
1880
- $email_freq = $_POST['email_freq'];
1881
- $scheduled_time = wp_next_scheduled('s2_digest_cron');
1882
- if ( $email_freq != $this->subscribe2_options['email_freq'] || $_POST['hour'] != date('H', $scheduled_time) ) {
1883
- $this->subscribe2_options['email_freq'] = $email_freq;
1884
- wp_clear_scheduled_hook('s2_digest_cron');
1885
- $scheds = (array)wp_get_schedules();
1886
- $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
1887
- if ( $interval == 0 ) {
1888
- // if we are on per-post emails remove last_cron entry
1889
- unset($this->subscribe2_options['last_s2cron']);
1890
- } else {
1891
- // if we are using digest schedule the event and prime last_cron as now
1892
- $time = time() + $interval;
1893
- if ( $interval < 86400 ) {
1894
- // Schedule CRON events occurring less than daily starting now and periodically thereafter
1895
- $maybe_time = mktime($_POST['hour'], 0, 0, date('m', time()), date('d', time()), date('Y', time()));
1896
- // is maybe_time in the future
1897
- $offset = $maybe_time - time();
1898
- // is maybe_time + $interval in the future
1899
- $offset2 = ($maybe_time + $interval) - time();
1900
- if ( $offset < 0 ) {
1901
- if ( $offset2 < 0 ) {
1902
- $timestamp = &$time;
1903
- } else {
1904
- $timestamp = $maybe_time + $interval;
1905
- }
1906
- } else {
1907
- $timestamp = &$maybe_time;
1908
- }
1909
- } else {
1910
- // Schedule other CRON events starting at user defined hour and periodically thereafter
1911
- $timestamp = mktime($_POST['hour'], 0, 0, date('m', $time), date('d', $time), date('Y', $time));
1912
- }
1913
- wp_schedule_event($timestamp, $email_freq, 's2_digest_cron');
1914
- if ( !isset($this->subscribe2_options['last_s2cron']) ) {
1915
- $this->subscribe2_options['last_s2cron'] = current_time('mysql');
1916
- }
1917
- }
1918
- }
1919
-
1920
- // email subject and body templates
1921
- // ensure that are not empty before updating
1922
- if ( !empty($_POST['notification_subject']) ) {
1923
- $this->subscribe2_options['notification_subject'] = $_POST['notification_subject'];
1924
- }
1925
- if ( !empty($_POST['mailtext']) ) {
1926
- $this->subscribe2_options['mailtext'] = $_POST['mailtext'];
1927
- }
1928
- if ( !empty($_POST['confirm_subject']) ) {
1929
- $this->subscribe2_options['confirm_subject'] = $_POST['confirm_subject'];
1930
- }
1931
- if ( !empty($_POST['confirm_email']) ) {
1932
- $this->subscribe2_options['confirm_email'] = $_POST['confirm_email'];
1933
- }
1934
- if ( !empty($_POST['remind_subject']) ) {
1935
- $this->subscribe2_options['remind_subject'] = $_POST['remind_subject'];
1936
- }
1937
- if ( !empty($_POST['remind_email']) ) {
1938
- $this->subscribe2_options['remind_email'] = $_POST['remind_email'];
1939
- }
1940
-
1941
- // excluded categories
1942
- if ( !empty($_POST['category']) ) {
1943
- $exclude_cats = implode(',', $_POST['category']);
1944
- } else {
1945
- $exclude_cats = '';
1946
- }
1947
- $this->subscribe2_options['exclude'] = $exclude_cats;
1948
- // allow override?
1949
- ( isset($_POST['reg_override']) ) ? $override = '1' : $override = '0';
1950
- $this->subscribe2_options['reg_override'] = $override;
1951
-
1952
- // default WordPress page where Subscribe2 token is placed
1953
- if ( is_numeric($_POST['page']) && $_POST['page'] >= 0 ) {
1954
- $this->subscribe2_options['s2page'] = $_POST['page'];
1955
- }
1956
-
1957
- // Number of subscriber per page
1958
- if ( is_numeric($_POST['entries']) && $_POST['entries'] > 0 ) {
1959
- $this->subscribe2_options['entries'] = (int)$_POST['entries'];
1960
- }
1961
-
1962
- // show meta link?
1963
- ( $_POST['show_meta'] == '1' ) ? $showmeta = '1' : $showmeta = '0';
1964
- $this->subscribe2_options['show_meta'] = $showmeta;
1965
-
1966
- // show button?
1967
- ( $_POST['show_button'] == '1' ) ? $showbutton = '1' : $showbutton = '0';
1968
- $this->subscribe2_options['show_button'] = $showbutton;
1969
-
1970
- // show widget in Presentation->Widgets
1971
- ( $_POST['widget'] == '1' ) ? $showwidget = '1' : $showwidget = '0';
1972
- $this->subscribe2_options['widget'] = $showwidget;
1973
-
1974
- // show counterwidget in Presentation->Widgets
1975
- ( $_POST['counterwidget'] == '1' ) ? $showcounterwidget = '1' : $showcounterwidget = '0';
1976
- $this->subscribe2_options['counterwidget'] = $showcounterwidget;
1977
-
1978
- // Subscribe2 over ride postmeta checked by default
1979
- ( $_POST['s2meta_default'] == '1' ) ? $s2meta_default = '1' : $s2meta_default = '0';
1980
- $this->subscribe2_options['s2meta_default'] = $s2meta_default;
1981
-
1982
- //automatic subscription
1983
- $this->subscribe2_options['autosub'] = $_POST['autosub'];
1984
- $this->subscribe2_options['newreg_override'] = $_POST['newreg_override'];
1985
- $this->subscribe2_options['wpregdef'] = $_POST['wpregdef'];
1986
- $this->subscribe2_options['autoformat'] = $_POST['autoformat'];
1987
- $this->subscribe2_options['show_autosub'] = $_POST['show_autosub'];
1988
- $this->subscribe2_options['autosub_def'] = $_POST['autosub_def'];
1989
-
1990
- //barred domains
1991
- $this->subscribe2_options['barred'] = $_POST['barred'];
1992
-
1993
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_saved</strong></p></div>";
1994
- update_option('subscribe2_options', $this->subscribe2_options);
1995
- }
1996
- }
1997
- // show our form
1998
- echo "<div class=\"wrap\">";
1999
- screen_icon();
2000
- echo "<h2>" . __('Subscribe2 Settings', 'subscribe2') . "</h2>\r\n";
2001
- echo "<a href=\"http://subscribe2.wordpress.com/\">" . __('Plugin Blog', 'subscribe2') . "</a> | ";
2002
- echo "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904\">" . __('Make a donation via PayPal', 'subscribe2') . "</a>";
2003
- echo "<form method=\"post\" action=\"\">\r\n";
2004
- if ( function_exists('wp_nonce_field') ) {
2005
- wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
2006
- }
2007
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
2008
- echo "<input type=\"hidden\" id=\"jsbcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" />";
2009
- echo "<input type=\"hidden\" id=\"jspage\" value=\"" . $this->subscribe2_options['s2page'] . "\" />";
2010
- echo "<input type=\"hidden\" id=\"jsentries\" value=\"" . $this->subscribe2_options['entries'] . "\" />";
2011
-
2012
- // settings for outgoing emails
2013
- echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
2014
- echo __('Restrict the number of recipients per email to (0 for unlimited)', 'subscribe2') . ': ';
2015
- echo "<span id=\"s2bcc_1\"><span id=\"s2bcc\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['bcclimit'] . "</span> ";
2016
- echo "<a href=\"#\" onclick=\"s2_show('bcc'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
2017
- echo "<span id=\"s2bcc_2\">\r\n";
2018
- echo "<input type=\"text\" name=\"bcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" size=\"3\" />\r\n";
2019
- echo "<a href=\"#\" onclick=\"s2_update('bcc'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
2020
- echo "<a href=\"#\" onclick=\"s2_revert('bcc'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
2021
-
2022
- echo "<br /><br />" . __('Send Admins notifications for new', 'subscribe2') . ': ';
2023
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"subs\"";
2024
- if ( 'subs' == $this->subscribe2_options['admin_email'] ) {
2025
- echo " checked=\"checked\"";
2026
- }
2027
- echo " /> " . __('Subscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
2028
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"unsubs\"";
2029
- if ( 'unsubs' == $this->subscribe2_options['admin_email'] ) {
2030
- echo " checked=\"checked\"";
2031
- }
2032
- echo " /> " . __('Unsubscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
2033
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"both\"";
2034
- if ( 'both' == $this->subscribe2_options['admin_email'] ) {
2035
- echo " checked=\"checked\"";
2036
- }
2037
- echo " /> " . __('Both', 'subscribe2') . "</label>&nbsp;&nbsp;";
2038
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"none\"";
2039
- if ( 'none' == $this->subscribe2_options['admin_email'] ) {
2040
- echo " checked=\"checked\"";
2041
- }
2042
- echo " /> " . __('Neither', 'subscribe2') . "</label><br /><br />\r\n";
2043
-
2044
- echo __('Include theme CSS stylesheet in HTML notifications', 'subscribe2') . ': ';
2045
- echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"yes\"";
2046
- if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
2047
- echo " checked=\"checked\"";
2048
- }
2049
- echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2050
- echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"no\"";
2051
- if ( 'no' == $this->subscribe2_options['stylesheet'] ) {
2052
- echo " checked=\"checked\"";
2053
- }
2054
- echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2055
-
2056
- echo __('Send Emails for Pages', 'subscribe2') . ': ';
2057
- echo "<label><input type=\"radio\" name=\"pages\" value=\"yes\"";
2058
- if ( 'yes' == $this->subscribe2_options['pages'] ) {
2059
- echo " checked=\"checked\"";
2060
- }
2061
- echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2062
- echo "<label><input type=\"radio\" name=\"pages\" value=\"no\"";
2063
- if ( 'no' == $this->subscribe2_options['pages'] ) {
2064
- echo " checked=\"checked\"";
2065
- }
2066
- echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2067
- echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
2068
- echo "<label><input type=\"radio\" name=\"password\" value=\"yes\"";
2069
- if ( 'yes' == $this->subscribe2_options['password'] ) {
2070
- echo " checked=\"checked\"";
2071
- }
2072
- echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2073
- echo "<label><input type=\"radio\" name=\"password\" value=\"no\"";
2074
- if ( 'no' == $this->subscribe2_options['password'] ) {
2075
- echo " checked=\"checked\"";
2076
- }
2077
- echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2078
- echo __('Send Emails for Private Posts', 'subscribe2') . ': ';
2079
- echo "<label><input type=\"radio\" name=\"private\" value=\"yes\"";
2080
- if ( 'yes' == $this->subscribe2_options['private'] ) {
2081
- echo " checked=\"checked\"";
2082
- }
2083
- echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2084
- echo "<label><input type=\"radio\" name=\"private\" value=\"no\"";
2085
- if ( 'no' == $this->subscribe2_options['private'] ) {
2086
- echo " checked=\"checked\"";
2087
- }
2088
- echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2089
- echo __('Send Email From', 'subscribe2') . ': ';
2090
- echo "<label>\r\n";
2091
- $this->admin_dropdown(true);
2092
- echo "</label><br /><br />\r\n";
2093
- if ( function_exists('wp_schedule_event') ) {
2094
- echo __('Send Emails', 'subscribe2') . ": <br /><br />\r\n";
2095
- $this->display_digest_choices();
2096
- echo __('For digest notifications, date order for posts is', 'subscribe2') . ": \r\n";
2097
- echo "<label><input type=\"radio\" name=\"cron_order\" value=\"desc\"";
2098
- if ( 'desc' == $this->subscribe2_options['cron_order'] ) {
2099
- echo " checked=\"checked\"";
2100
- }
2101
- echo " /> " . __('Descending', 'subscribe2') . "</label>&nbsp;&nbsp;";
2102
- echo "<label><input type=\"radio\" name=\"cron_order\" value=\"asc\"";
2103
- if ( 'asc' == $this->subscribe2_options['cron_order'] ) {
2104
- echo " checked=\"checked\"";
2105
- }
2106
- echo " /> " . __('Ascending', 'subscribe2') . "</label><br /><br />\r\n";
2107
- }
2108
-
2109
- // email templates
2110
- echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
2111
- echo"<br />";
2112
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
2113
- echo "<tr><td>";
2114
- echo __('New Post email (must not be empty)', 'subscribe2') . ":<br />\r\n";
2115
- echo __('Subject Line', 'subscribe2') . ": ";
2116
- echo "<input type=\"text\" name=\"notification_subject\" value=\"" . stripslashes($this->subscribe2_options['notification_subject']) . "\" size=\"30\" />";
2117
- echo "<br />\r\n";
2118
- echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
2119
- echo "</td><td valign=\"top\" rowspan=\"3\">";
2120
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Send Email Preview', 'subscribe2') . "\" /></p>\r\n";
2121
- echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
2122
- echo "<dl>";
2123
- echo "<dt><b>BLOGNAME</b></dt><dd>" . get_option('blogname') . "</dd>\r\n";
2124
- echo "<dt><b>BLOGLINK</b></dt><dd>" . get_option('home') . "</dd>\r\n";
2125
- echo "<dt><b>TITLE</b></dt><dd>" . __("the post's title<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2126
- 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";
2127
- echo "<dt><b>POSTTIME</b></dt><dd>" . __("the excerpt of the post and the time it was posted<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2128
- echo "<dt><b>TABLE</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2129
- echo "<dt><b>TABLELINKS</b></dt><dd>" . __("a list of post titles followed by links to the atricles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2130
- echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2131
- echo "<dt><b>TINYLINK</b></dt><dd>" . __("the post's permalink after conversion by TinyURL<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2132
- echo "<dt><b>DATE</b></dt><dd>" . __("the date the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
2133
- echo "<dt><b>TIME</b></dt><dd>" . __("the time the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
2134
- echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
2135
- echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
2136
- echo "<dt><b>AUTHORNAME</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
2137
- 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";
2138
- 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";
2139
- echo "<dt><b>CATS</b></dt><dd>" . __("the post's assigned categories", 'subscribe2') . "</dd>\r\n";
2140
- echo "<dt><b>TAGS</b></dt><dd>" . __("the post's assigned Tags", 'subscribe2') . "</dd>\r\n";
2141
- echo "<dt><b>COUNT</b></dt><dd>" . __("the number of posts included in the digest email<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2142
- echo "</dl></td></tr><tr><td>";
2143
- echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
2144
- echo __('Subject Line', 'subscribe2') . ": ";
2145
- echo "<input type=\"text\" name=\"confirm_subject\" value=\"" . stripslashes($this->subscribe2_options['confirm_subject']) . "\" size=\"30\" /><br />\r\n";
2146
- echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
2147
- echo "</td></tr><tr valign=\"top\"><td>";
2148
- echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
2149
- echo __('Subject Line', 'subscribe2') . ": ";
2150
- echo "<input type=\"text\" name=\"remind_subject\" value=\"" . stripslashes($this->subscribe2_options['remind_subject']) . "\" size=\"30\" /><br />\r\n";
2151
- echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
2152
- echo "</td></tr></table><br />\r\n";
2153
-
2154
- // excluded categories
2155
- echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
2156
- echo"<p>";
2157
- 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";
2158
- echo"</p>";
2159
- $this->display_category_form(explode(',', $this->subscribe2_options['exclude']));
2160
- echo "<center><label><input type=\"checkbox\" name=\"reg_override\" value=\"1\"";
2161
- if ( '1' == $this->subscribe2_options['reg_override'] ) {
2162
- echo " checked=\"checked\"";
2163
- }
2164
- echo " /> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</label></center><br />\r\n";
2165
-
2166
- // Appearance options
2167
- echo "<h2>" . __('Appearance', 'subscribe2') . "</h2>\r\n";
2168
- echo"<p>";
2169
-
2170
- // WordPress page ID where subscribe2 token is used
2171
- echo __('Set default Subscribe2 page as ID', 'subscribe2') . ': ';
2172
- $this->pages_dropdown();
2173
-
2174
- // Number of subscribers per page
2175
- echo "<br /><br />" . __('Set the number of Subscribers displayed per page', 'subscribe2') . ': ';
2176
- echo "<span id=\"s2entries_1\"><span id=\"s2entries\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['entries'] . "</span> ";
2177
- echo "<a href=\"#\" onclick=\"s2_show('entries'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
2178
- echo "<span id=\"s2entries_2\">\r\n";
2179
- echo "<input type=\"text\" name=\"entries\" value=\"" . $this->subscribe2_options['entries'] . "\" size=\"3\" />\r\n";
2180
- echo "<a href=\"#\" onclick=\"s2_update('entries'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
2181
- echo "<a href=\"#\" onclick=\"s2_revert('entries'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
2182
-
2183
- // show link to WordPress page in meta
2184
- echo "<br /><br /><label><input type=\"checkbox\" name=\"show_meta\" value=\"1\"";
2185
- if ( '1' == $this->subscribe2_options['show_meta'] ) {
2186
- echo " checked=\"checked\"";
2187
- }
2188
- echo " /> " . __('Show a link to your subscription page in "meta"?', 'subscribe2') . "</label><br /><br />\r\n";
2189
-
2190
- // show QuickTag button
2191
- echo "<label><input type=\"checkbox\" name=\"show_button\" value=\"1\"";
2192
- if ( '1' == $this->subscribe2_options['show_button'] ) {
2193
- echo " checked=\"checked\"";
2194
- }
2195
- echo " /> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "</label><br /><br />\r\n";
2196
-
2197
- // show Widget
2198
- echo "<label><input type=\"checkbox\" name=\"widget\" value=\"1\"";
2199
- if ( '1' == $this->subscribe2_options['widget'] ) {
2200
- echo " checked=\"checked\"";
2201
- }
2202
- echo " /> " . __('Enable Subscribe2 Widget?', 'subscribe2') . "</label><br /><br />\r\n";
2203
-
2204
- // show Counter Widget
2205
- echo "<label><input type=\"checkbox\" name=\"counterwidget\" value=\"1\"";
2206
- if ( '1' == $this->subscribe2_options['counterwidget'] ) {
2207
- echo " checked=\"checked\"";
2208
- }
2209
- echo " /> " . __('Enable Subscribe2 Counter Widget?', 'subscribe2') . "</label><br /><br />\r\n";
2210
-
2211
- // s2_meta checked by default
2212
- echo "<label><input type =\"checkbox\" name=\"s2meta_default\" value=\"1\"";
2213
- if ( "1" == $this->subscribe2_options['s2meta_default'] ) {
2214
- echo " checked=\"checked\"";
2215
- }
2216
- echo " /> " . __('Disable email notifications is checked by default on authoring pages?', 'subscribe2') . "</label>\r\n";
2217
- echo "</p>";
2218
-
2219
- //Auto Subscription for new registrations
2220
- echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
2221
- echo"<p>";
2222
- echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
2223
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"yes\"";
2224
- if ( 'yes' == $this->subscribe2_options['autosub'] ) {
2225
- echo " checked=\"checked\"";
2226
- }
2227
- echo " /> " . __('Automatically', 'subscribe2') . "</label>&nbsp;&nbsp;";
2228
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"wpreg\"";
2229
- if ( 'wpreg' == $this->subscribe2_options['autosub'] ) {
2230
- echo " checked=\"checked\"";
2231
- }
2232
- echo " /> " . __('Display option on Registration Form', 'subscribe2') . "</label>&nbsp;&nbsp;";
2233
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"no\"";
2234
- if ( 'no' == $this->subscribe2_options['autosub'] ) {
2235
- echo " checked=\"checked\"";
2236
- }
2237
- echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2238
- echo __('Auto-subscribe includes any excluded categories', 'subscribe2') . ":<br />\r\n";
2239
- echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"yes\"";
2240
- if ( 'yes' == $this->subscribe2_options['newreg_override'] ) {
2241
- echo " checked=\"checked\"";
2242
- }
2243
- echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2244
- echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"no\"";
2245
- if ( 'no' == $this->subscribe2_options['newreg_override'] ) {
2246
- echo " checked=\"checked\"";
2247
- }
2248
- echo " />" . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2249
- echo __('Registration Form option is checked by default', 'subscribe2') . ":<br />\r\n";
2250
- echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"yes\"";
2251
- if ( 'yes' == $this->subscribe2_options['wpregdef'] ) {
2252
- echo " checked=\"checked\"";
2253
- }
2254
- echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2255
- echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"no\"";
2256
- if ( 'no' == $this->subscribe2_options['wpregdef'] ) {
2257
- echo " checked=\"checked\"";
2258
- }
2259
- echo " />" . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2260
- echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
2261
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html\"";
2262
- if ( 'html' == $this->subscribe2_options['autoformat'] ) {
2263
- echo "checked=\"checked\" ";
2264
- }
2265
- echo "/> " . __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
2266
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html_excerpt\"";
2267
- if ( 'html_excerpt' == $this->subscribe2_options['autoformat'] ) {
2268
- echo "checked=\"checked\" ";
2269
- }
2270
- echo "/> " . __('HTML - Excerpt', 'subscribe2') ."</label>&nbsp;&nbsp;";
2271
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"post\" ";
2272
- if ( 'post' == $this->subscribe2_options['autoformat'] ) {
2273
- echo "checked=\"checked\" ";
2274
- }
2275
- echo "/> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
2276
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"excerpt\" ";
2277
- if ( 'excerpt' == $this->subscribe2_options['autoformat'] ) {
2278
- echo "checked=\"checked\" ";
2279
- }
2280
- echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />";
2281
- echo __('Registered Users have the option to auto-subscribe to new categories', 'subscribe2') . ": <br />\r\n";
2282
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"yes\"";
2283
- if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
2284
- echo " checked=\"checked\"";
2285
- }
2286
- echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2287
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"no\"";
2288
- if ( 'no' == $this->subscribe2_options['show_autosub'] ) {
2289
- echo " checked=\"checked\"";
2290
- }
2291
- echo " />" . __('No', 'subscribe2') . "</label>&nbsp;&nbsp;";
2292
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"exclude\"";
2293
- if ( 'exclude' == $this->subscribe2_options['show_autosub'] ) {
2294
- echo " checked=\"checked\"";
2295
- }
2296
- echo " />" .__('New categories are immediately excluded', 'subscribe2') . "</label><br /><br />";
2297
- echo __('Option for Registered Users to auto-subscribe to new categories is checked by default', 'subscribe2') . ": <br />\r\n";
2298
- echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"yes\"";
2299
- if ( 'yes' == $this->subscribe2_options['autosub_def'] ) {
2300
- echo " checked=\"checked\"";
2301
- }
2302
- echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2303
- echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"no\"";
2304
- if ( 'no' == $this->subscribe2_options['autosub_def'] ) {
2305
- echo " checked=\"checked\"";
2306
- }
2307
- echo " />" . __('No', 'subscribe2');
2308
- echo"</label></p>";
2309
-
2310
- //barred domains
2311
- echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
2312
- echo"<p>";
2313
- 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');
2314
- echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
2315
- echo"</p>";
2316
-
2317
- // submit
2318
- echo "<p class=\"submit\" align=\"center\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p>";
2319
-
2320
- // reset
2321
- echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
2322
- 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";
2323
- echo "<p class=\"submit\" align=\"center\">";
2324
- echo "<input type=\"submit\" id=\"deletepost\" name=\"reset\" value=\"" . __('RESET', 'subscribe2') .
2325
- "\" />";
2326
- echo "</p></form></div>\r\n";
2327
-
2328
- include(ABSPATH . 'wp-admin/admin-footer.php');
2329
- // just to be sure
2330
- die;
2331
- } // end options_menu()
2332
-
2333
- /**
2334
- Our profile menu
2335
- */
2336
- function user_menu() {
2337
- global $user_ID, $s2nonce;
2338
-
2339
- if ( isset($_GET['email']) ) {
2340
- global $wpdb;
2341
- $user_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . urldecode($_GET['email']) . "'");
2342
- } else {
2343
- get_currentuserinfo();
2344
- }
2345
-
2346
- // was anything POSTed?
2347
- if ( isset($_POST['s2_admin']) && 'user' == $_POST['s2_admin'] ) {
2348
- check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
2349
-
2350
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
2351
- update_usermeta($user_ID, 's2_format', $_POST['s2_format']);
2352
- update_usermeta($user_ID, 's2_autosub', $_POST['new_category']);
2353
-
2354
- $cats = $_POST['category'];
2355
-
2356
- if ( empty($cats) || $cats == '-1' ) {
2357
- $oldcats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
2358
- if ( $oldcats ) {
2359
- foreach ( $oldcats as $cat ) {
2360
- delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat);
2361
- }
2362
- }
2363
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
2364
- } elseif ( $cats == 'digest' ) {
2365
- $all_cats = get_categories(array('hide_empty' => false));
2366
- foreach ( $all_cats as $cat ) {
2367
- ('' == $catids) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
2368
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
2369
- }
2370
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $catids);
2371
- } else {
2372
- if ( !is_array($cats) ) {
2373
- $cats = array($_POST['category']);
2374
- }
2375
- $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
2376
- $remove = array_diff($old_cats, $cats);
2377
- $new = array_diff($cats, $old_cats);
2378
- if ( !empty($remove) ) {
2379
- // remove subscription to these cat IDs
2380
- foreach ( $remove as $id ) {
2381
- delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
2382
- }
2383
- }
2384
- if ( !empty($new) ) {
2385
- // add subscription to these cat IDs
2386
- foreach ( $new as $id ) {
2387
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
2388
- }
2389
- }
2390
- update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $cats));
2391
- }
2392
- }
2393
-
2394
- // show our form
2395
- echo "<div class=\"wrap\">";
2396
- screen_icon();
2397
- echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
2398
- if ( isset($_GET['email']) ) {
2399
- $user = get_userdata($user_ID);
2400
- echo "<span style=\"color: red;line-height: 300%;\">" . __('Editing Subscribe2 preferences for user', 'subscribe2') . ": " . $user->display_name . "</span>";
2401
- }
2402
- echo "<form method=\"post\" action=\"\">";
2403
- echo "<p>";
2404
- if ( function_exists('wp_nonce_field') ) {
2405
- wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
2406
- }
2407
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
2408
- if ( $this->subscribe2_options['email_freq'] == 'never' ) {
2409
- echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
2410
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html\"";
2411
- if ( 'html' == get_usermeta($user_ID, 's2_format') ) {
2412
- echo "checked=\"checked\" ";
2413
- }
2414
- echo "/> " . __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
2415
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html_excerpt\" ";
2416
- if ( 'html_excerpt' == get_usermeta($user_ID, 's2_format') ) {
2417
- echo "checked=\"checked\" ";
2418
- }
2419
- echo "/> " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;";
2420
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"post\" ";
2421
- if ( 'post' == get_usermeta($user_ID, 's2_format') ) {
2422
- echo "checked=\"checked\" ";
2423
- }
2424
- echo "/> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
2425
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"excerpt\" ";
2426
- if ( 'excerpt' == get_usermeta($user_ID, 's2_format') ) {
2427
- echo "checked=\"checked\" ";
2428
- }
2429
- echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />\r\n";
2430
-
2431
- if ( $this->subscribe2_options['show_autosub'] == 'yes' ) {
2432
- echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
2433
- echo "<label><input type=\"radio\" name=\"new_category\" value=\"yes\" ";
2434
- if ( 'yes' == get_usermeta($user_ID, 's2_autosub') ) {
2435
- echo "checked=\"checked\" ";
2436
- }
2437
- echo "/> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2438
- echo "<label><input type=\"radio\" name=\"new_category\" value=\"no\" ";
2439
- if ( 'no' == get_usermeta($user_ID, 's2_autosub') ) {
2440
- echo "checked=\"checked\" ";
2441
- }
2442
- echo "/> " . __('No', 'subscribe2') . "</label>";
2443
- echo "</p>";
2444
- }
2445
-
2446
- // subscribed categories
2447
- if ( $this->s2_mu ) {
2448
- global $blog_id;
2449
- $subscribed = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
2450
- // if we are subscribed to the current blog display an "unsubscribe" link
2451
- if ( !empty($subscribed) ) {
2452
- $unsubscribe_link = get_option('home') . "/wp-admin/?s2mu_unsubscribe=". $blog_id;
2453
- echo "<p><a href=\"". $unsubscribe_link ."\" class=\"button\">" . __('Unsubscribe me from this blog', 'subscribe2') . "</a></p>";
2454
- } else {
2455
- // else we show a "subscribe" link
2456
- $subscribe_link = get_option('home') . "/wp-admin/?s2mu_subscribe=". $blog_id;
2457
- echo "<p><a href=\"". $subscribe_link ."\" class=\"button\">" . __('Subscribe to all categories', 'subscribe2') . "</a></p>";
2458
- }
2459
- echo "<h2>" . __('Subscribed Categories on', 'subscribe2') . " " . get_option('blogname') . " </h2>\r\n";
2460
- } else {
2461
- echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
2462
- }
2463
- $this->display_category_form(explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'))), $this->subscribe2_options['reg_override']);
2464
- } else {
2465
- // we're doing daily digests, so just show
2466
- // subscribe / unnsubscribe
2467
- echo __('Receive periodic summaries of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
2468
- echo "<label>";
2469
- echo "<input type=\"radio\" name=\"category\" value=\"digest\" ";
2470
- if ( get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')) ) {
2471
- echo "checked=\"checked\" ";
2472
- }
2473
- echo "/> " . __('Yes', 'subscribe2') . "</label> <label><input type=\"radio\" name=\"category\" value=\"-1\" ";
2474
- if ( !get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')) ) {
2475
- echo "checked=\"checked\" ";
2476
- }
2477
- echo "/> " . __('No', 'subscribe2');
2478
- echo "</label></p>";
2479
- }
2480
-
2481
- // submit
2482
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __("Update Preferences", 'subscribe2') . " &raquo;\" /></p>";
2483
- echo "</form>\r\n";
2484
-
2485
- // list of subscribed blogs on wordpress mu
2486
- if ( $this->s2_mu && !isset($_GET['email']) ) {
2487
- global $blog_id;
2488
- $s2blog_id = $blog_id;
2489
- $blogs = $this->get_mu_blog_list();
2490
-
2491
- $blogs_subscribed = array();
2492
- $blogs_notsubscribed = array();
2493
-
2494
- foreach ( $blogs as $key => $blog ) {
2495
- // switch to blog
2496
- switch_to_blog($blog['blog_id']);
2497
-
2498
- // check that the plugin is active on the current blog
2499
- $current_plugins = get_option('active_plugins');
2500
- if ( !is_array($current_plugins) ) {
2501
- $current_plugins = (array)$current_plugins;
2502
- }
2503
- if ( !in_array(S2DIR . '/subscribe2.php', $current_plugins) ) {
2504
- continue;
2505
- }
2506
-
2507
- // check if we're subscribed to the blog
2508
- $subscribed = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
2509
-
2510
- $blogname = get_option('blogname');
2511
- if ( strlen($blogname) > 30 ) {
2512
- $blog['blogname'] = wp_html_excerpt($blogname, 30) . "..";
2513
- } else {
2514
- $blog['blogname'] = $blogname;
2515
- }
2516
- $blog['description'] = get_option('blogdescription');
2517
- $blog['blogurl'] = get_option('home');
2518
- $blog['subscribe_page'] = get_option('home') . "/wp-admin/users.php?page=s2_users";
2519
-
2520
- $key = strtolower($blog['blogname'] . "-" . $blog['blog_id']);
2521
- if ( !empty($subscribed) ) {
2522
- $blogs_subscribed[$key] = $blog;
2523
- } else {
2524
- $blogs_notsubscribed[$key] = $blog;
2525
- }
2526
- restore_current_blog();
2527
- }
2528
-
2529
- if ( !empty($blogs_subscribed) ) {
2530
- ksort($blogs_subscribed);
2531
- echo "<h2>" . __('Subscribed Blogs', 'subscribe2') . "</h2>\r\n";
2532
- echo "<ul class=\"s2_blogs\">\r\n";
2533
- foreach ( $blogs_subscribed as $blog ) {
2534
- echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
2535
- if ( $s2blog_id == $blog['blog_id'] ) {
2536
- echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
2537
- } else {
2538
- echo "<span class=\"buttons\">";
2539
- if ( is_blog_user($blog['blog_id']) ) {
2540
- echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
2541
- }
2542
- echo "<a href=\"" . $blog['blogurl'] . "/wp-admin/?s2mu_unsubscribe=" . $blog['blog_id'] . "\">" . __('Unsubscribe', 'subscribe2') . "</a></span>\r\n";
2543
- }
2544
- echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
2545
- echo "</li>";
2546
- }
2547
- echo "</ul>\r\n";
2548
- }
2549
-
2550
- if ( !empty($blogs_notsubscribed) ) {
2551
- ksort($blogs_notsubscribed);
2552
- echo "<h2>" . __('Subscribe to new blogs', 'subscribe2') . "</h2>\r\n";
2553
- echo "<ul class=\"s2_blogs\">";
2554
- foreach ( $blogs_notsubscribed as $blog ) {
2555
- echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
2556
- if ( $s2blog_id == $blog['blog_id'] ) {
2557
- echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
2558
- } else {
2559
- echo "<span class=\"buttons\">";
2560
- if ( is_blog_user($blog['blog_id']) ) {
2561
- echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
2562
- }
2563
- echo "<a href=\"" . $blog['blogurl'] . "/wp-admin/?s2mu_subscribe=" . $blog['blog_id'] . "\">" . __('Subscribe', 'subscribe2') . "</a></span>\r\n";
2564
- }
2565
- echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
2566
- echo "</li>";
2567
- }
2568
- echo "</ul>\r\n";
2569
- }
2570
- }
2571
-
2572
- echo "</div>\r\n";
2573
-
2574
- include(ABSPATH . 'wp-admin/admin-footer.php');
2575
- // just to be sure
2576
- die;
2577
- } // end user_menu()
2578
-
2579
- /**
2580
- Display the Write sub-menu
2581
- */
2582
- function write_menu() {
2583
- global $wpdb, $s2nonce, $current_user;
2584
-
2585
- // was anything POSTed?
2586
- if ( isset($_POST['s2_admin']) && 'mail' == $_POST['s2_admin'] ) {
2587
- check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
2588
- $subject = $this->substitute(stripslashes(strip_tags($_POST['subject'])));
2589
- $body = $this->substitute(stripslashes($_POST['content']));
2590
- if ( '' != $current_user->display_name || '' != $current_user->user_email ) {
2591
- $this->myname = html_entity_decode($current_user->display_name, ENT_QUOTES);
2592
- $this->myemail = $current_user->user_email;
2593
- }
2594
- if ( isset($_POST['send']) ) {
2595
- if ( 'confirmed' == $_POST['what'] ) {
2596
- $recipients = $this->get_public();
2597
- } elseif ( 'unconfirmed' == $_POST['what'] ) {
2598
- $recipients = $this->get_public(0);
2599
- } elseif ( 'public' == $_POST['what'] ) {
2600
- $confirmed = $this->get_public();
2601
- $unconfirmed = $this->get_public(0);
2602
- $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
2603
- } elseif ( is_numeric($_POST['what']) ) {
2604
- $cat = intval($_POST['what']);
2605
- $recipients = $this->get_registered("cats=$cat");
2606
- } elseif ( 'all_users' == $_POST['what'] ) {
2607
- $recipients = $this->get_all_registered();
2608
- } else {
2609
- $recipients = $this->get_registered();
2610
- }
2611
- } elseif ( isset($_POST['preview']) ) {
2612
- global $user_email;
2613
- $recipients[] = $user_email;
2614
- }
2615
- $status = $this->mail($recipients, $subject, $body, 'text');
2616
- if ( $status ) {
2617
- $message = $this->mail_sent;
2618
- } else {
2619
- global $phpmailer;
2620
- $message = $this->mail_failed . $phpmailer->ErrorInfo;
2621
- }
2622
- }
2623
-
2624
- if ( '' != $message ) {
2625
- echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
2626
- }
2627
- // show our form
2628
- echo "<div class=\"wrap\">";
2629
- screen_icon();
2630
- echo "<h2>" . __('Send an email to subscribers', 'subscribe2') . "</h2>\r\n";
2631
- echo "<form method=\"post\" action=\"\">\r\n";
2632
- if ( function_exists('wp_nonce_field') ) {
2633
- wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
2634
- }
2635
- if ( isset($_POST['subject']) ) {
2636
- $subject = $_POST['subject'];
2637
- } else {
2638
- $subject = __('A message from', 'subscribe2') . " " . get_option('blogname');
2639
- }
2640
- echo "<p>" . __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . $subject . "\" /> <br /><br />";
2641
- echo "<textarea rows=\"12\" cols=\"75\" name=\"content\">" . $body . "</textarea>";
2642
- echo "<br /><br />\r\n";
2643
- echo __('Recipients:', 'subscribe2') . " ";
2644
- $this->display_subscriber_dropdown('registered', false, array('all'));
2645
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
2646
- echo "</p>";
2647
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Preview', 'subscribe2') . "\" \><input type=\"submit\" class=\"button-primary\" name=\"send\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
2648
- echo "</form></div>\r\n";
2649
- echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
2650
-
2651
- include(ABSPATH . 'wp-admin/admin-footer.php');
2652
- // just to be sure
2653
- die;
2654
- } // end write_menu()
2655
-
2656
- /* ===== helper functions: forms and stuff ===== */
2657
- /**
2658
- Display a table of categories with checkboxes
2659
- Optionally pre-select those categories specified
2660
- */
2661
- function display_category_form($selected = array(), $override = 1) {
2662
- global $wpdb;
2663
-
2664
- $all_cats = get_categories(array('hide_empty' => false, 'orderby' => 'slug'));
2665
- $exclude = explode(',', $this->subscribe2_options['exclude']);
2666
-
2667
- if ( 0 == $override ) {
2668
- // registered users are not allowed to subscribe to
2669
- // excluded categories
2670
- foreach ( $all_cats as $cat => $term_id ) {
2671
- if ( in_array($all_cats[$cat]->term_id, $exclude) ) {
2672
- $cat = (int)$cat;
2673
- unset($all_cats[$cat]);
2674
- }
2675
- }
2676
- }
2677
-
2678
- $half = (count($all_cats) / 2);
2679
- $i = 0;
2680
- $j = 0;
2681
- echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
2682
- echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
2683
- echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"cat_checkall\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
2684
- echo "</td></tr>\r\n";
2685
- echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
2686
- foreach ( $all_cats as $cat ) {
2687
- if ( $i >= $half && 0 == $j ){
2688
- echo "</td><td width=\"50%\" align=\"left\">\r\n";
2689
- $j++;
2690
- }
2691
- if ( 0 == $j ) {
2692
- echo "<label><input class=\"cat_checkall\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
2693
- if ( in_array($cat->term_id, $selected) ) {
2694
- echo " checked=\"checked\"";
2695
- }
2696
- echo " /> <abbr title=\"" . $cat->slug . "\">" . rtrim(get_category_parents($cat->term_id, false, ' &#187; '), ' &#187; ') . "</abbr></label><br />\r\n";
2697
- } else {
2698
- echo "<label><input class=\"cat_checkall\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
2699
- if ( in_array($cat->term_id, $selected) ) {
2700
- echo " checked=\"checked\"";
2701
- }
2702
- echo " /> <abbr title=\"" . $cat->slug . "\">" . rtrim(get_category_parents($cat->term_id, false, ' &#187; '), ' &#187; ') . "</abbr></label><br />\r\n";
2703
- }
2704
- $i++;
2705
- }
2706
- echo "</td></tr>\r\n";
2707
- echo "</table>\r\n";
2708
- } // end display_category_form()
2709
-
2710
- /**
2711
- Display a drop-down form to select subscribers
2712
- $selected is the option to select
2713
- $submit is the text to use on the Submit button
2714
- */
2715
- function display_subscriber_dropdown($selected = 'registered', $submit = '', $exclude = array()) {
2716
- global $wpdb;
2717
-
2718
- $who = array('all' => __('All Users and Subscribers', 'subscribe2'),
2719
- 'public' => __('Public Subscribers', 'subscribe2'),
2720
- 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
2721
- 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
2722
- 'all_users' => __('All Registered Users', 'subscribe2'),
2723
- 'registered' => __('Registered Subscribers', 'subscribe2'));
2724
-
2725
- $all_cats = get_categories(array('hide_empty' => false));
2726
-
2727
- // count the number of subscribers
2728
- $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
2729
- $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
2730
- if ( in_array('unconfirmed', $exclude) ) {
2731
- $count['public'] = $count['confirmed'];
2732
- } elseif ( in_array('confirmed', $exclude) ) {
2733
- $count['public'] = $count['unconfirmed'];
2734
- } else {
2735
- $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
2736
- }
2737
- if ( $this->s2_mu ) {
2738
- $count['all_users'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
2739
- } else {
2740
- $count['all_users'] = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
2741
- }
2742
- if ( $this->s2_mu ) {
2743
- $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities' AND meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
2744
- } else {
2745
- $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
2746
- }
2747
- $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
2748
- if ( $this->s2_mu ) {
2749
- foreach ( $all_cats as $cat ) {
2750
- $count[$cat->name] = $wpdb->get_var("SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
2751
- }
2752
- } else {
2753
- foreach ( $all_cats as $cat ) {
2754
- $count[$cat->name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
2755
- }
2756
- }
2757
-
2758
- // do have actually have some subscribers?
2759
- if ( 0 == $count['confirmed'] && 0 == $count['unconfirmed'] && 0 == $count['all_users'] ) {
2760
- // no? bail out
2761
- return;
2762
- }
2763
-
2764
- echo "<select name=\"what\">\r\n";
2765
- foreach ( $who as $whom => $display ) {
2766
- if ( in_array($whom, $exclude) ) { continue; }
2767
- if ( 0 == $count[$whom] ) { continue; }
2768
-
2769
- echo "<option value=\"" . $whom . "\"";
2770
- if ( $whom == $selected ) { echo " selected=\"selected\" "; }
2771
- echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
2772
- }
2773
-
2774
- if ( $count['registered'] > 0 ) {
2775
- foreach ( $all_cats as $cat ) {
2776
- if ( in_array($cat->term_id, $exclude) ) { continue; }
2777
- echo "<option value=\"" . $cat->term_id . "\"";
2778
- if ( $cat->term_id == $selected ) { echo " selected=\"selected\" "; }
2779
- echo "> &nbsp;&nbsp;" . $cat->name . "&nbsp;(" . $count[$cat->name] . ") </option>\r\n";
2780
- }
2781
- }
2782
- echo "</select>";
2783
- if ( false !== $submit ) {
2784
- echo "&nbsp;<input type=\"submit\" class=\"button-secondary\" value=\"$submit\" />\r\n";
2785
- }
2786
- } // end display_subscriber_dropdown()
2787
-
2788
- /**
2789
- Display a drop down lisy of administrator level users and
2790
- optionally include a choice for Post Author
2791
- */
2792
- function admin_dropdown($inc_author = false) {
2793
- global $wpdb;
2794
-
2795
- $sql = "SELECT ID, display_name FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value IN (8, 9, 10)";
2796
- $admins = $wpdb->get_results($sql);
2797
-
2798
- // handle issues from WordPress core where user_level is not set or set low
2799
- if ( empty($admins) ) {
2800
- $role = 'administrator';
2801
- if ( !class_exists(WP_User_Search) ) {
2802
- require(ABSPATH . 'wp-admin/includes/user.php');
2803
- }
2804
- $wp_user_search = new WP_User_Search( '', '', $role);
2805
- $admins_string = implode(', ', $wp_user_search->get_results());
2806
- $sql = "SELECT ID, display_name FROM $wpdb->users WHERE ID IN (" . $admins_string . ")";
2807
- $admins = $wpdb->get_results($sql);
2808
- }
2809
-
2810
- if ( $inc_author ) {
2811
- $author[] = (object)array('ID' => 'author', 'display_name' => 'Post Author');
2812
- $admins = array_merge($author, $admins);
2813
- }
2814
-
2815
- echo "<select name=\"sender\">\r\n";
2816
- foreach ( $admins as $admin ) {
2817
- echo "<option value=\"" . $admin->ID . "\"";
2818
- if ( $admin->ID == $this->subscribe2_options['sender'] ) {
2819
- echo " selected=\"selected\"";
2820
- }
2821
- echo ">" . $admin->display_name . "</option>\r\n";
2822
- }
2823
- echo "</select>\r\n";
2824
- } // end admin_dropdown()
2825
-
2826
- /**
2827
- Display a dropdown of choices for digest email frequency
2828
- and give user details of timings when event is scheduled
2829
- */
2830
- function display_digest_choices() {
2831
- global $wpdb;
2832
- $scheduled_time = wp_next_scheduled('s2_digest_cron');
2833
- $schedule = (array)wp_get_schedules();
2834
- $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('For each Post', 'subscribe2'))), $schedule);
2835
- $sort = array();
2836
- foreach ( (array)$schedule as $key => $value ) {
2837
- $sort[$key] = $value['interval'];
2838
- }
2839
- asort($sort);
2840
- $schedule_sorted = array();
2841
- foreach ( $sort as $key => $value ) {
2842
- $schedule_sorted[$key] = $schedule[$key];
2843
- }
2844
- foreach ( $schedule_sorted as $key => $value ) {
2845
- echo "<label><input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"";
2846
- if ( $key == $this->subscribe2_options['email_freq'] ) {
2847
- echo " checked=\"checked\" ";
2848
- }
2849
- echo " /> " . $value['display'] . "</label><br />\r\n";
2850
- }
2851
- echo "<br />" . __('Send Digest Notification at', 'subscribe2') . ": \r\n";
2852
- $hours = array('12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am', '10am', '11am', '12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm');
2853
- echo "<select name=\"hour\">\r\n";
2854
- while ( $hour = current($hours) ) {
2855
- echo "<option value=\"" . key($hours) . "\"";
2856
- if ( key($hours) == date('H', $scheduled_time) && !empty($scheduled_time) ){
2857
- echo " selected=\"selected\"";
2858
- }
2859
- echo ">" . $hour . "</option>\r\n";
2860
- next($hours);
2861
- }
2862
- echo "</select>\r\n";
2863
- echo "<strong><em style=\"color: red\">" . __('This option will be ignored if the time selected is not in the future in relation to the current time', 'subscribe2') . "</em></strong>\r\n";
2864
- if ( $scheduled_time ) {
2865
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
2866
- echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
2867
- echo "<strong>" . date_i18n($datetime, false, 'gmt') . "</strong></p>\r\n";
2868
- echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
2869
- echo "<strong>" . date_i18n($datetime) . "</strong></p>\r\n";
2870
- echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
2871
- echo "<strong>" . date_i18n($datetime, $scheduled_time) . "</strong></p>\r\n";
2872
- if ( !empty($this->subscribe2_options['previous_s2cron']) ) {
2873
- echo "<p>" . __('Attempt to resend the last Digest Notification email', 'subscribe2') . ": ";
2874
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"resend\" value=\"" . __('Resend Digest', 'subscribe2') . "\" /></p>\r\n";
2875
- }
2876
- } else {
2877
- echo "<br />";
2878
- }
2879
- } // end display_digest_choices()
2880
-
2881
- /**
2882
- Create and display a dropdown list of pages
2883
- */
2884
- function pages_dropdown() {
2885
- global $wpdb;
2886
- $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
2887
- $pages = $wpdb->get_results($sql);
2888
-
2889
- if ( empty($pages) ) { return; }
2890
-
2891
- echo "<select name=\"page\">\r\n";
2892
- foreach ( $pages as $page ) {
2893
- echo "<option value=\"" . $page->ID . "\"";
2894
- if ( $page->ID == $this->subscribe2_options['s2page'] ) {
2895
- echo " selected=\"selected\"";
2896
- }
2897
- echo ">" . $page->post_title . "</option>\r\n";
2898
- }
2899
- echo "</select>\r\n";
2900
- } // end pages_dropdown()
2901
-
2902
- /**
2903
- Export subscriber emails and other details to CSV
2904
- */
2905
- function prepare_export( $what ) {
2906
- $confirmed = $this->get_public();
2907
- $unconfirmed = $this->get_public(0);
2908
- if ( 'all' == $what ) {
2909
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$this->get_all_registered());
2910
- } elseif ( 'public' == $what ) {
2911
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
2912
- } elseif ( 'confirmed' == $what ) {
2913
- $subscribers = $confirmed;
2914
- } elseif ( 'unconfirmed' == $what ) {
2915
- $subscribers = $unconfirmed;
2916
- } elseif ( is_numeric($what) ) {
2917
- $subscribers = $this->get_registered("cats=$what");
2918
- } elseif ( 'registered' == $what ) {
2919
- $subscribers = $this->get_registered();
2920
- } elseif ( 'all_users' == $what ) {
2921
- $subscribers = $this->get_all_registered();
2922
- }
2923
-
2924
- natcasesort($subscribers);
2925
-
2926
- $exportcsv = "User Email,User Name";
2927
- $all_cats = get_categories(array('hide_empty' => false, 'orderby' => 'ID'));
2928
- foreach ($all_cats as $cat) {
2929
- $exportcsv .= "," . $cat->cat_name;
2930
- $cat_ids[] = $cat->term_id;
2931
- }
2932
- $exportcsv .= "\r\n";
2933
-
2934
- foreach ( $subscribers as $subscriber ) {
2935
- if ( $this->is_registered($subscriber) ) {
2936
- $user_id = $this->get_user_id( $subscriber );
2937
- $user_info = get_userdata($user_id);
2938
-
2939
- $cats = explode(',', get_usermeta($user_info->ID, $this->get_usermeta_keyname('s2_subscribed')));
2940
- $subscribed_cats = '';
2941
- foreach ( $cat_ids as $cat ) {
2942
- (in_array($cat, $cats)) ? $subscribed_cats .= ",Yes" : $subscribed_cats .= ", No";
2943
- }
2944
-
2945
- $exportcsv .= $user_info->user_email . ',';
2946
- $exportcsv .= $user_info->display_name;
2947
- $exportcsv .= $subscribed_cats . "\r\n";
2948
- } else {
2949
- if ( in_array($subscriber, $confirmed) ) {
2950
- $exportcsv .= $subscriber . ',' . __('Confirmed Public Subscriber', 'subscribe2') . "\r\n";
2951
- } elseif ( in_array($subscriber, $unconfirmed) ) {
2952
- $exportcsv .= $subscriber . ',' . __('Unconfirmed Public Subscriber', 'subscribe2') . "\r\n";
2953
- }
2954
- }
2955
- }
2956
-
2957
- return $exportcsv;
2958
- } // end prepare_export()
2959
-
2960
- /**
2961
- Filter for usermeta table key names to adjust them if needed for WPMU blogs
2962
- */
2963
- function get_usermeta_keyname($metaname) {
2964
- global $wpdb;
2965
-
2966
- // Is this WordPressMU or not?
2967
- if ( $this->s2_mu === true ) {
2968
- switch( $metaname ) {
2969
- case 's2_subscribed':
2970
- case 's2_cat':
2971
- return $wpdb->prefix . $metaname;
2972
- break;
2973
- }
2974
- }
2975
- // Not MU or not a prefixed option name
2976
- return $metaname;
2977
- }
2978
-
2979
- /**
2980
- Obtain a list of current WordPress multiuser blogs
2981
- Note this may affect performance but there is no alternative
2982
- */
2983
- function get_mu_blog_list() {
2984
- global $wpdb;
2985
- $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
2986
-
2987
- foreach ( (array) $blogs as $details ) {
2988
- $blog_list[$details['blog_id']] = $details;
2989
- }
2990
-
2991
- if ( false == is_array( $blog_list ) ) {
2992
- return array();
2993
- }
2994
-
2995
- return $blog_list;
2996
- } // end get_mu_blog_list()
2997
-
2998
- /**
2999
- Adds a links directly to the settings page from the plugin page
3000
- */
3001
- function plugin_links($links, $file) {
3002
- if ( $file == S2DIR.'/subscribe2.php' ) {
3003
- $links[] = "<a href='options-general.php?page=s2_settings'>" . __('Settings', 'subscribe2') . "</a>";
3004
- $links[] = "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904'><b>" . __('Donate', 'subscribe2') . "</b></a>";
3005
- }
3006
- return $links;
3007
- } // end plugin_links()
3008
-
3009
- /**
3010
- Adds information to the WordPress registration screen for new users
3011
- */
3012
- function register_form() {
3013
- if ( 'wpreg' == $this->subscribe2_options['autosub'] ) {
3014
- echo "<p>\r\n<label>";
3015
- echo __('Check here to Subscribe to email notifications for new posts', 'subscribe2') . ":<br />\r\n";
3016
- echo "<input type=\"checkbox\" name=\"subscribe\"";
3017
- if ( 'yes' == $this->subscribe2_options['wpregdef'] ) {
3018
- echo " checked=\"checked\"";
3019
- }
3020
- echo " /></label>\r\n";
3021
- echo "</p>\r\n";
3022
- } elseif ( 'yes' == $this->subscribe2_options['autosub'] ) {
3023
- echo "<p>\r\n<center>\r\n";
3024
- echo __('By registering with this blog you are also agreeing to receive email notifications for new posts but you can unsubscribe at anytime', 'subscribe2') . ".<br />\r\n";
3025
- echo "</center></p>\r\n";
3026
- }
3027
- }
3028
-
3029
- /**
3030
- Process function to add action if user selects to subscribe to posts during registration
3031
- */
3032
- function register_post() {
3033
- if ( 'on' == $_POST['subscribe'] ) {
3034
- $user = get_userdatabylogin($_POST['user_login']);
3035
- if ( 0 == $user->ID ) { return; }
3036
- $this->register($user->ID);
3037
- }
3038
- }
3039
-
3040
- /**
3041
- Create meta box on write pages
3042
- */
3043
- function s2_meta_init() {
3044
- add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'post', 'advanced');
3045
- add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'page', 'advanced');
3046
- } // end s2_meta_init()
3047
-
3048
- /**
3049
- Meta box code for WordPress 2.5+
3050
- */
3051
- function s2_meta_box() {
3052
- global $post_ID;
3053
- $s2mail = get_post_meta($post_ID, 's2mail', true);
3054
- echo "<input type=\"hidden\" name=\"s2meta_nonce\" id=\"s2meta_nonce\" value=\"" . wp_create_nonce(md5(plugin_basename(__FILE__))) . "\" />";
3055
- echo __("Check here to disable sending of an email notification for this post/page", 'subscribe2');
3056
- echo "&nbsp;&nbsp;<input type=\"checkbox\" name=\"s2_meta_field\" value=\"no\"";
3057
- if ( $s2mail == 'no' || ($this->subscribe2_options['s2meta_default'] == "1" && $s2mail == "") ) {
3058
- echo " checked=\"checked\"";
3059
- }
3060
- echo " />";
3061
- } // end s2_meta_box()
3062
-
3063
- /**
3064
- Meta box form handler
3065
- */
3066
- function s2_meta_handler($post_id) {
3067
- if ( !isset($_POST['s2meta_nonce']) || !wp_verify_nonce($_POST['s2meta_nonce'], md5(plugin_basename(__FILE__))) ) { return $post_id; }
3068
-
3069
- if ( 'page' == $_POST['post_type'] ) {
3070
- if ( !current_user_can('edit_page', $post_id) ) { return $post_id; }
3071
- } else {
3072
- if ( !current_user_can('edit_post', $post_id) ) { return $post_id; }
3073
- }
3074
-
3075
- if ( isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no' ) {
3076
- update_post_meta($post_id, 's2mail', $_POST['s2_meta_field']);
3077
- } else {
3078
- update_post_meta($post_id, 's2mail', 'yes');
3079
- }
3080
- } // end s2_meta_box_handler()
3081
-
3082
- /* ===== template and filter functions ===== */
3083
- /**
3084
- Display our form; also handles (un)subscribe requests
3085
- */
3086
- function filter($content = '') {
3087
- if ( '' == $content || !strstr($content, '<!--subscribe2-->') ) { return $content; }
3088
- $this->s2form = $this->form;
3089
-
3090
- global $user_ID;
3091
- get_currentuserinfo();
3092
- if ( $user_ID ) {
3093
- if ( current_user_can('manage_options') ) {
3094
- $this->s2form = $this->use_profile_admin;
3095
- } else {
3096
- $this->s2form = $this->use_profile_users;
3097
- }
3098
- }
3099
- if ( isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) {
3100
- global $wpdb, $user_email;
3101
- if ( !is_email($_POST['email']) ) {
3102
- $this->s2form = $this->form . $this->not_an_email;
3103
- } elseif ( $this->is_barred($_POST['email']) ) {
3104
- $this->s2form = $this->form . $this->barred_domain;
3105
- } else {
3106
- $this->email = $this->sanitize_email($_POST['email']);
3107
- $this->ip = $_POST['ip'];
3108
- // does the supplied email belong to a registered user?
3109
- $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
3110
- if ( '' != $check ) {
3111
- // this is a registered email
3112
- $this->s2form = $this->please_log_in;
3113
- } else {
3114
- // this is not a registered email
3115
- // what should we do?
3116
- if ( isset($_POST['subscribe']) ) {
3117
- // someone is trying to subscribe
3118
- // lets see if they've tried to subscribe previously
3119
- if ( '1' !== $this->is_public($this->email) ) {
3120
- // the user is unknown or inactive
3121
- $this->add();
3122
- $status = $this->send_confirm('add');
3123
- // set a variable to denote that we've already run, and shouldn't run again
3124
- $this->filtered = 1;
3125
- if ( $status ) {
3126
- $this->s2form = $this->confirmation_sent;
3127
- } else {
3128
- $this->s2form = $this->error;
3129
- }
3130
- } else {
3131
- // they're already subscribed
3132
- $this->s2form = $this->already_subscribed;
3133
- }
3134
- $this->action = 'subscribe';
3135
- } elseif ( isset($_POST['unsubscribe']) ) {
3136
- // is this email a subscriber?
3137
- if ( false == $this->is_public($this->email) ) {
3138
- $this->s2form = $this->form . $this->not_subscribed;
3139
- } else {
3140
- $status = $this->send_confirm('del');
3141
- // set a variable to denote that we've already run, and shouldn't run again
3142
- $this->filtered = 1;
3143
- if ( $status ) {
3144
- $this->s2form = $this->confirmation_sent;
3145
- } else {
3146
- $this->s2form = $this->error;
3147
- }
3148
- }
3149
- $this->action='unsubscribe';
3150
- }
3151
- }
3152
- }
3153
- }
3154
- return preg_replace('|(<p>)?(\n)*<!--subscribe2-->(\n)*(</p>)?|', $this->s2form, $content);
3155
- } // end filter()
3156
-
3157
- /**
3158
- Overrides the default query when handling a (un)subscription confirmation
3159
- This is basically a trick: if the s2 variable is in the query string, just grab the first
3160
- static page and override it's contents later with title_filter()
3161
- */
3162
- function query_filter() {
3163
- // don't interfere if we've already done our thing
3164
- if ( 1 == $this->filtered ) { return; }
3165
-
3166
- global $wpdb;
3167
-
3168
- if ( 0 != $this->subscribe2_options['s2page'] ) {
3169
- return "page_id=" . $this->subscribe2_options['s2page'];
3170
- } else {
3171
- $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
3172
- if ( $id ) {
3173
- return "page_id=$id";
3174
- } else {
3175
- return "showposts=1";
3176
- }
3177
- }
3178
- } // end query_filter()
3179
-
3180
- /**
3181
- Overrides the page title
3182
- */
3183
- function title_filter($title) {
3184
- // don't interfere if we've already done our thing
3185
- if ( in_the_loop() ) {
3186
- return __('Subscription Confirmation', 'subscribe2');
3187
- } else {
3188
- return $title;
3189
- }
3190
- } // end title_filter()
3191
-
3192
- /* ===== widget functions ===== */
3193
- /**
3194
- Register the form widget
3195
- */
3196
- function subscribe2_widget() {
3197
- require_once( WP_CONTENT_DIR . '/plugins/' . S2DIR . '/include/widget.php');
3198
- register_widget('S2_Form_widget');
3199
- } // end subscribe2_widget()
3200
-
3201
- /**
3202
- Register the counter widget
3203
- */
3204
- function counter_widget() {
3205
- require_once( WP_CONTENT_DIR . '/plugins/' . S2DIR . '/include/counterwidget.php');
3206
- register_widget('S2_Counter_widget');
3207
- } // end counter_widget()
3208
-
3209
- /**
3210
- Function to add js files to admin header
3211
- */
3212
- function widget_s2counter_js() {
3213
- echo '<script type="text/javascript" src="' . WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/colorpicker/js/colorpicker.js"></script>' . "\r\n";
3214
- echo "<script type=\"text/javascript\">
3215
- jQuery(document).ready(function() {
3216
- jQuery('.colorpickerField').focusin(function() {
3217
- jQuery(this).ColorPickerShow();
3218
- });
3219
- jQuery('.colorpickerField').focusout(function() {
3220
- jQuery(this).ColorPickerHide();
3221
- });
3222
- jQuery('.colorpickerField').ColorPicker({
3223
- onSubmit: function(hsb, hex, rgb, el) {
3224
- jQuery(el).val(hex);
3225
- jQuery(el).ColorPickerHide();
3226
- },
3227
- onBeforeShow: function () {
3228
- jQuery(this).ColorPickerSetColor(this.value);
3229
- }
3230
- })
3231
- .bind('keyup', function(){
3232
- jQuery(this).ColorPickerSetColor(this.value);
3233
- });
3234
- });
3235
- </script>";
3236
- } // end widget_s2_counter_js()
3237
-
3238
- /**
3239
- Function to add css files to admin header
3240
- */
3241
- function widget_s2counter_css() {
3242
- echo '<link rel="stylesheet" href="' . WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/colorpicker/css/colorpicker.css" type="text/css" />' . "\r\n";
3243
- } // end widget_s2counter_css
3244
-
3245
- function namechange_subscribe2_widget() {
3246
- // rename WPMU widgets without requiring user to re-enable
3247
- global $wpdb;
3248
- $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
3249
-
3250
- foreach ( $blogs as $blog ) {
3251
- switch_to_blog($blog);
3252
-
3253
- $sidebars = get_option('sidebars_widgets');
3254
- if ( empty($sidebars) || !is_array($sidebars) ) { return; }
3255
- $changed = false;
3256
- foreach ( $sidebars as $s =>$sidebar ) {
3257
- if ( empty($sidebar) || !is_array($sidebar) ) { break; }
3258
- foreach ( $sidebar as $w => $widget ) {
3259
- if ( $widget == 'subscribe2widget' ) {
3260
- $sidebars[$s][$w] = 'subscribe2';
3261
- $changed = true;
3262
- }
3263
- }
3264
- }
3265
- if ( $changed ) {
3266
- update_option('sidebar_widgets', $sidebars);
3267
- }
3268
- }
3269
- restore_current_blog();
3270
- } // end namechange_subscribe2_widget()
3271
-
3272
- /**
3273
- Add hook for Minimeta Widget plugin
3274
- */
3275
- function add_minimeta() {
3276
- if ( $this->subscribe2_options['s2page'] != 0 ) {
3277
- echo "<li><a href=\"" . get_option('siteurl') . "/?page_id=" . $this->subscribe2_options['s2page'] . "\">" . __('[Un]Subscribe to Posts', 'subscribe2') . "</a></li>\r\n";
3278
- }
3279
- } // end add_minimeta()
3280
-
3281
- /* ===== Write Toolbar Button Functions ===== */
3282
-
3283
- /**
3284
- Register our button in the QuickTags bar
3285
- */
3286
- function button_init() {
3287
- if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) { return; }
3288
- if ( 'true' == get_user_option('rich_editing') ) {
3289
- // Use WordPress 2.5+ hooks
3290
- add_filter('mce_external_plugins', array(&$this, 'mce3_plugin'));
3291
- add_filter('mce_buttons', array(&$this, 'mce3_button'));
3292
- } else {
3293
- buttonsnap_separator();
3294
- buttonsnap_jsbutton(WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/s2_button.png', __('Subscribe2', 'subscribe2'), 's2_insert_token();');
3295
- }
3296
- } // end button_init()
3297
-
3298
- /**
3299
- Add buttons for WordPress 2.5+ using built in hooks
3300
- */
3301
- function mce3_plugin($arr) {
3302
- $path = WP_CONTENT_URL . '/plugins/' . S2DIR . '/tinymce3/editor_plugin.js';
3303
- $arr['subscribe2'] = $path;
3304
- return $arr;
3305
- }
3306
-
3307
- function mce3_button($arr) {
3308
- $arr[] = 'subscribe2';
3309
- return $arr;
3310
- }
3311
-
3312
- function s2_edit_form() {
3313
- echo "<!-- Start Subscribe2 Quicktags Javascript -->\r\n";
3314
- echo "<script type=\"text/javascript\">\r\n";
3315
- echo "//<![CDATA[\r\n";
3316
- echo "function s2_insert_token() {
3317
- buttonsnap_settext('<!--subscribe2-->');
3318
- }\r\n";
3319
- echo "//]]>\r\n";
3320
- echo "</script>\r\n";
3321
- echo "<!-- End Subscribe2 Quicktags Javascript -->\r\n";
3322
- }
3323
-
3324
- /* ===== wp-cron functions ===== */
3325
- /**
3326
- Add a weekly event to cron
3327
- */
3328
- function add_weekly_sched($sched) {
3329
- $sched['weekly'] = array('interval' => 604800, 'display' => __('Weekly', 'subscribe2'));
3330
- return $sched;
3331
- } // end add_weekly_sched()
3332
-
3333
- /**
3334
- Send a daily digest of today's new posts
3335
- */
3336
- function subscribe2_cron($preview = '', $resend = '') {
3337
- if ( defined('DOING_S2_CRON') && DOING_S2_CRON ) { return; }
3338
- define( 'DOING_S2_CRON', true );
3339
- global $wpdb;
3340
-
3341
- if ( '' == $preview ) {
3342
- // update last_s2cron execution time before completing or bailing
3343
- $now = current_time('mysql');
3344
- $prev = $this->subscribe2_options['last_s2cron'];
3345
- $last = $this->subscribe2_options['previous_s2cron'];
3346
- $this->subscribe2_options['last_s2cron'] = $now;
3347
- $this->subscribe2_options['previous_s2cron'] = $prev;
3348
- if ( '' == $resend ) {
3349
- // update sending times provided this is not a resend
3350
- update_option('subscribe2_options', $this->subscribe2_options);
3351
- }
3352
-
3353
- // set up SQL query based on options
3354
- if ( $this->subscribe2_options['private'] == 'yes' ) {
3355
- $status = "'publish', 'private'";
3356
- } else {
3357
- $status = "'publish'";
3358
- }
3359
-
3360
- // send notifications for allowed post type (defaults for posts and pages)
3361
- // uses s2_post_types filter to allow for custom post types in WP 3.0
3362
- if ( $this->subscribe2_options['pages'] == 'yes' ) {
3363
- $s2_post_types = array('page', 'post');
3364
- } else {
3365
- $s2_post_types = array('post');
3366
- }
3367
- $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
3368
- foreach( $s2_post_types as $post_type ) {
3369
- ('' == $type) ? $type = "'$post_type'" : $type .= ", '$post_type'";
3370
- }
3371
-
3372
- // collect posts
3373
- if ( $resend == 'resend' ) {
3374
- if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
3375
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
3376
- } else {
3377
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
3378
- }
3379
- } else {
3380
- if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
3381
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
3382
- } else {
3383
- $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
3384
- }
3385
- }
3386
- } else {
3387
- // we are sending a preview
3388
- $posts = get_posts('numberposts=1');
3389
- }
3390
-
3391
- // do we have any posts?
3392
- if ( empty($posts) ) { return false; }
3393
- $this->post_count = count($posts);
3394
-
3395
- // if we have posts, let's prepare the digest
3396
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
3397
- $all_post_cats = array();
3398
- $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
3399
- $table = '';
3400
- $tablelinks = '';
3401
- $message_post= '';
3402
- $message_posttime = '';
3403
- foreach ( $posts as $post ) {
3404
- $post_cats = wp_get_post_categories($post->ID);
3405
- $post_cats_string = implode(',', $post_cats);
3406
- $all_post_cats = array_unique(array_merge($all_post_cats, $post_cats));
3407
- $check = false;
3408
- // Pages are put into category 1 so make sure we don't exclude
3409
- // pages if category 1 is excluded
3410
- if ( $post->post_type != 'page' ) {
3411
- // is the current post assigned to any categories
3412
- // which should not generate a notification email?
3413
- foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
3414
- if ( in_array($cat, $post_cats) ) {
3415
- $check = true;
3416
- }
3417
- }
3418
- }
3419
- // is the current post set by the user to
3420
- // not generate a notification email?
3421
- $s2mail = get_post_meta($post->ID, 's2mail', true);
3422
- if ( strtolower(trim($s2mail)) == 'no' ) {
3423
- $check = true;
3424
- }
3425
- // is the current post private
3426
- // and should this not generate a notification email?
3427
- if ( $this->subscribe2_options['password'] == 'no' && $post->post_password != '' ) {
3428
- $check = true;
3429
- }
3430
- // if this post is excluded
3431
- // don't include it in the digest
3432
- if ( $check ) {
3433
- continue;
3434
- }
3435
- $post_title = html_entity_decode($post->post_title, ENT_QUOTES);
3436
- ('' == $table) ? $table .= "* " . $post_title : $table .= "\r\n* " . $post_title;
3437
- ('' == $tablelinks) ? $tablelinks .= "* " . $post_title : $tablelinks .= "\r\n* " . $post_title;
3438
- $message_post .= $post_title;
3439
- $message_posttime .= $post_title;
3440
- if ( strstr($mailtext, "AUTHORNAME") ) {
3441
- $author = get_userdata($post->post_author);
3442
- if ( $author->display_name != '' ) {
3443
- $message_post .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
3444
- $message_posttime .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
3445
- }
3446
- }
3447
- $message_post .= "\r\n";
3448
- $message_posttime .= "\r\n";
3449
-
3450
- $tablelinks .= "\r\n" . get_permalink($post->ID) . "\r\n";
3451
- $message_post .= get_permalink($post->ID) . "\r\n";
3452
- $message_posttime .= __('Posted on', 'subscribe2') . ": " . mysql2date($datetime, $post->post_date) . "\r\n";
3453
- $message_posttime .= get_permalink($post->ID) . "\r\n";
3454
- if ( strstr($mailtext, "CATS") ) {
3455
- $post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
3456
- $message_post .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
3457
- $message_posttime .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
3458
- }
3459
- if ( strstr($mailtext, "TAGS") ) {
3460
- $post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
3461
- if ( $post_tag_names != '' ) {
3462
- $message_post .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
3463
- $message_posttime .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
3464
- }
3465
- }
3466
- $message_post .= "\r\n";
3467
- $message_posttime .= "\r\n";
3468
-
3469
- $excerpt = $post->post_excerpt;
3470
- if ( '' == $excerpt ) {
3471
- // no excerpt, is there a <!--more--> ?
3472
- if ( false !== strpos($post->post_content, '<!--more-->') ) {
3473
- list($excerpt, $more) = explode('<!--more-->', $post->post_content, 2);
3474
- $excerpt = strip_tags($excerpt);
3475
- if ( function_exists('strip_shortcodes') ) {
3476
- $excerpt = strip_shortcodes($excerpt);
3477
- }
3478
- } else {
3479
- $excerpt = strip_tags($post->post_content);
3480
- if ( function_exists('strip_shortcodes') ) {
3481
- $excerpt = strip_shortcodes($excerpt);
3482
- }
3483
- $words = explode(' ', $excerpt, $this->excerpt_length + 1);
3484
- if ( count($words) > $this->excerpt_length ) {
3485
- array_pop($words);
3486
- array_push($words, '[...]');
3487
- $excerpt = implode(' ', $words);
3488
- }
3489
- }
3490
- // strip leading and trailing whitespace
3491
- $excerpt = trim($excerpt);
3492
- }
3493
- $message_post .= $excerpt . "\r\n\r\n";
3494
- $message_posttime .= $excerpt . "\r\n\r\n";
3495
- }
3496
-
3497
- // we add a blank line after each post excerpt now trim white space that occurs for the last post
3498
- $message_post = trim($message_post);
3499
- $message_posttime = trim($message_posttime);
3500
-
3501
- //sanity check - don't send a mail if the content is empty
3502
- if ( !$message_post && !$message_posttime && !$table && !$tablelinks ) {
3503
- return;
3504
- }
3505
-
3506
- // get admin details
3507
- $user = $this->get_userdata($this->subscribe2_options['sender']);
3508
- $this->myemail = $user->user_email;
3509
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
3510
-
3511
- $scheds = (array)wp_get_schedules();
3512
- $email_freq = $this->subscribe2_options['email_freq'];
3513
- $display = $scheds[$email_freq]['display'];
3514
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(get_option('blogname')) . "] ";
3515
- $subject .= $display . " " . __('Digest Email', 'subscribe2');
3516
- $mailtext = stripslashes($this->substitute($mailtext));
3517
- $mailtext = str_replace("TABLELINKS", $tablelinks, $mailtext);
3518
- $mailtext = str_replace("TABLE", $table, $mailtext);
3519
- $mailtext = str_replace("POSTTIME", $message_posttime, $mailtext);
3520
- $mailtext = str_replace("POST", $message_post, $mailtext);
3521
-
3522
- // prepare recipients
3523
- if ( $preview != '' ) {
3524
- $this->myemail = $preview;
3525
- $this->myname = "Preview";
3526
- $this->mail(array($preview), $subject, $mailtext);
3527
- } else {
3528
- $public = $this->get_public();
3529
- $all_post_cats_string = implode(',', $all_post_cats);
3530
- $registered = $this->get_registered("cats=$all_post_cats_string");
3531
- $recipients = array_merge((array)$public, (array)$registered);
3532
- $this->mail($recipients, $subject, $mailtext);
3533
- }
3534
- } // end subscribe2_cron
3535
-
3536
- /* ===== Our constructor ===== */
3537
- /**
3538
- Subscribe2 constructor
3539
- */
3540
- function s2init() {
3541
- // load the options
3542
- $this->subscribe2_options = get_option('subscribe2_options');
3543
-
3544
- add_action('init', array(&$this, 'subscribe2'));
3545
- if ( '1' == $this->subscribe2_options['show_button'] ) {
3546
- add_action('init', array(&$this, 'button_init'));
3547
- }
3548
-
3549
- // add action to display widget if option is enabled
3550
- if ( '1' == $this->subscribe2_options['widget'] ) {
3551
- add_action('widgets_init', array(&$this, 'subscribe2_widget'));
3552
- }
3553
-
3554
- // add action to display counter widget if option is enabled
3555
- if ( '1' == $this->subscribe2_options['counterwidget'] ) {
3556
- add_action('admin_print_styles', array(&$this, 'widget_s2counter_css'), 20);
3557
- add_action('admin_print_scripts', array(&$this, 'widget_s2counter_js'), 20);
3558
- add_action('widgets_init', array(&$this, 'counter_widget'));
3559
- }
3560
-
3561
- // add action to handle WPMU subscriptions and unsubscriptions
3562
- if ( isset($_GET['s2mu_subscribe']) || isset($_GET['s2mu_unsubscribe']) ) {
3563
- add_action('init', array(&$this, 'wpmu_subscribe'));
3564
- }
3565
- } // end s2init()
3566
-
3567
- function subscribe2() {
3568
- global $wpdb, $table_prefix, $wp_version, $wpmu_version;
3569
-
3570
- load_plugin_textdomain('subscribe2', 'wp-content/plugins/' . S2DIR, '/' . S2DIR);
3571
-
3572
- // Is this WordPressMU or not?
3573
- $this->s2_mu = false;
3574
- if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
3575
- $this->s2_mu = true;
3576
- }
3577
- if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE === true ) {
3578
- $this->s2_mu = true;
3579
- }
3580
-
3581
- // do we need to install anything?
3582
- $this->public = $table_prefix . "subscribe2";
3583
- if ( $wpdb->get_var("SHOW TABLES LIKE '{$this->public}'") != $this->public ) { $this->install(); }
3584
- //do we need to upgrade anything?
3585
- if ( is_array($this->subscribe2_options) && $this->subscribe2_options['version'] !== S2VERSION ) {
3586
- add_action('shutdown', array(&$this, 'upgrade'));
3587
- }
3588
-
3589
- if ( isset($_GET['s2']) ) {
3590
- // someone is confirming a request
3591
- if ( defined('DOING_S2_CONFIRM') && DOING_S2_CONFIRM ) { return; }
3592
- define( 'DOING_S2_CONFIRM', true );
3593
- add_filter('query_string', array(&$this, 'query_filter'));
3594
- add_filter('the_title', array(&$this, 'title_filter'));
3595
- add_filter('the_content', array(&$this, 'confirm'));
3596
- }
3597
-
3598
- if ( isset($_POST['s2_admin']) && $_POST['csv'] ) {
3599
- $date = date('Y-m-d');
3600
- header("Content-Description: File Transfer");
3601
- header("Content-type: application/octet-stream");
3602
- header("Content-Disposition: attachment; filename=subscribe2_users_$date.csv");
3603
- header("Pragma: no-cache");
3604
- header("Expires: 0");
3605
- echo $this->prepare_export($_POST['exportcsv']);
3606
-
3607
- exit(0);
3608
- }
3609
-
3610
- //add regular actions and filters
3611
- add_action('admin_menu', array(&$this, 'admin_menu'));
3612
- add_action('admin_menu', array(&$this, 's2_meta_init'));
3613
- add_action('save_post', array(&$this, 's2_meta_handler'));
3614
- add_action('create_category', array(&$this, 'new_category'));
3615
- add_action('delete_category', array(&$this, 'delete_category'));
3616
- add_filter('the_content', array(&$this, 'filter'), 10);
3617
- add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
3618
-
3619
- // add actions for other plugins
3620
- if ( '1' == $this->subscribe2_options['show_meta'] ) {
3621
- add_action('wp_meta', array(&$this, 'add_minimeta'), 0);
3622
- }
3623
- // Add filters for Ozh Admin Menu
3624
- add_filter('ozh_adminmenu_icon_s2_posts', array(&$this, 'ozh_s2_icon'));
3625
- add_filter('ozh_adminmenu_icon_s2_users', array(&$this, 'ozh_s2_icon'));
3626
- add_filter('ozh_adminmenu_icon_s2_tools', array(&$this, 'ozh_s2_icon'));
3627
- add_filter('ozh_adminmenu_icon_s2_settings', array(&$this, 'ozh_s2_icon'));
3628
-
3629
- // add action to display editor buttons if option is enabled
3630
- if ( '1' == $this->subscribe2_options['show_button'] ) {
3631
- add_action('edit_page_form', array(&$this, 's2_edit_form'));
3632
- add_action('edit_form_advanced', array(&$this, 's2_edit_form'));
3633
- }
3634
-
3635
- // add actions for automatic subscription based on option settings
3636
- add_action('register_form', array(&$this, 'register_form'));
3637
- add_action('user_register', array(&$this, 'register'));
3638
- add_action('add_user_to_blog', array(&$this, 'register'), 10, 1);
3639
-
3640
- // add actions for processing posts based on per-post or cron email settings
3641
- if ( $this->subscribe2_options['email_freq'] != 'never' ) {
3642
- add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
3643
- } else {
3644
- add_action('new_to_publish', array(&$this, 'publish'));
3645
- add_action('draft_to_publish', array(&$this, 'publish'));
3646
- add_action('pending_to_publish', array(&$this, 'publish'));
3647
- add_action('private_to_publish', array(&$this, 'publish'));
3648
- add_action('future_to_publish', array(&$this, 'publish'));
3649
- if ( $this->subscribe2_options['private'] == 'yes' ) {
3650
- add_action('new_to_private', array(&$this, 'publish'));
3651
- add_action('draft_to_private', array(&$this, 'publish'));
3652
- add_action('pending_to_private', array(&$this, 'publish'));
3653
- }
3654
- }
3655
-
3656
- // load our strings
3657
- $this->load_strings();
3658
- } // end subscribe2()
3659
-
3660
- /* ===== our variables ===== */
3661
- // cache variables
3662
- var $subscribe2_options = array();
3663
- var $all_public = '';
3664
- var $all_unconfirmed = '';
3665
- var $excluded_cats = '';
3666
- var $post_title = '';
3667
- var $permalink = '';
3668
- var $myname = '';
3669
- var $myemail = '';
3670
- var $signup_dates = array();
3671
- var $filtered = 0;
3672
- var $preview_email = false;
3673
-
3674
- // state variables used to affect processing
3675
- var $action = '';
3676
- var $email = '';
3677
- var $message = '';
3678
- var $excerpt_length = 55;
3679
-
3680
- // some messages
3681
- var $please_log_in = '';
3682
- var $use_profile_admin = '';
3683
- var $use_profile_users = '';
3684
- var $confirmation_sent = '';
3685
- var $already_subscribed = '';
3686
- var $not_subscribed ='';
3687
- var $not_an_email = '';
3688
- var $barred_domain = '';
3689
- var $error = '';
3690
- var $mail_sent = '';
3691
- var $mail_failed = '';
3692
- var $form = '';
3693
- var $no_such_email = '';
3694
- var $added = '';
3695
- var $deleted = '';
3696
- var $subscribe = '';
3697
- var $unsubscribe = '';
3698
- var $confirm_subject = '';
3699
- var $options_saved = '';
3700
- var $options_reset = '';
3701
- } // end class subscribe2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3702
  ?>
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: 6.1
7
+ Author: Matthew Robinson
8
+ Author URI: http://subscribe2.wordpress.com
9
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2006-10 Matthew Robinson
14
+ Based on the Original Subscribe2 plugin by
15
+ Copyright (C) 2005 Scott Merrill (skippy@skippy.net)
16
+
17
+ This file is part of Subscribe2.
18
+
19
+ Subscribe2 is free software: you can redistribute it and/or modify
20
+ it under the terms of the GNU General Public License as published by
21
+ the Free Software Foundation, either version 3 of the License, or
22
+ (at your option) any later version.
23
+
24
+ Subscribe2 is distributed in the hope that it will be useful,
25
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ GNU General Public License for more details.
28
+
29
+ You should have received a copy of the GNU General Public License
30
+ along with Subscribe2. If not, see <http://www.gnu.org/licenses/>.
31
+ */
32
+
33
+ // our version number. Don't touch this or any line below
34
+ // unless you know exactly what you are doing
35
+ define( 'S2VERSION', '6.1' );
36
+ define( 'S2PATH', trailingslashit(dirname(__FILE__)) );
37
+ define( 'S2DIR', plugin_basename(dirname(__FILE__)) );
38
+
39
+ // Set minimum execution time to 5 minutes - won't affect safe mode
40
+ $safe_mode = array('On', 'ON', 'on', 1);
41
+ if ( !in_array(ini_get('safe_mode'), $safe_mode) && ini_get('max_execution_time') < 300 ) {
42
+ @ini_set('max_execution_time', 300);
43
+ }
44
+
45
+ /* Include buttonsnap library by Owen Winckler */
46
+ if ( !class_exists('buttonsnap') ) {
47
+ require( WP_CONTENT_DIR . '/plugins/' . S2DIR . '/include/buttonsnap.php' );
48
+ }
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', 'subscribe2') . "</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=s2_users\">" . __('profile', 'subscribe2') . "</a>.</p>";
66
+ if ( $this->s2_mu === true ) {
67
+ global $blog_id, $user_ID;
68
+ if ( !is_blog_user($blog_id) ) {
69
+ // if we are on multisite and the user is not a member of this blog change the link
70
+ $this->use_profile_admin = "<p><a href=\"" . get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id . "\">" . __('Subscribe', 'subscribe2') . "</a>" . __('to email notifications when this blog posts new content', 'subscribe2') . ".</p>";
71
+ }
72
+ }
73
+
74
+ $this->use_profile_users = "<p>" . __('You may manage your subscription options from your', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-admin/profile.php?page=s2_users\">" . __('profile', 'subscribe2') . "</a>.</p>";
75
+ if ( $this->s2_mu === true ) {
76
+ global $blog_id, $user_ID;
77
+ if ( !is_blog_user($blog_id) ) {
78
+ // if we are on multisite and the user is not a member of this blog change the link
79
+ $this->use_profile_users = "<p><a href=\"" . get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id . "\">" . __('Subscribe', 'subscribe2') . "</a>" . __('to email notifications when this blog posts new content', 'subscribe2') . ".</p>";
80
+ }
81
+ }
82
+
83
+ $this->confirmation_sent = "<p>" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
84
+
85
+ $this->already_subscribed = "<p>" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
86
+
87
+ $this->not_subscribed = "<p>" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
88
+
89
+ $this->not_an_email = "<p>" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
90
+
91
+ $this->barred_domain = "<p>" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
92
+
93
+ $this->error = "<p>" . __('Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2') . "</p>";
94
+
95
+ $this->no_page = "<p>" . __('You must to create a WordPress page for this plugin to work correctly.', 'subscribe2') . "<p>";
96
+
97
+ $this->mail_sent = "<p>" . __('Message sent!', 'subscribe2') . "</p>";
98
+
99
+ $this->mail_failed = "<p>" . __('Message failed! Check your settings and check with your hosting provider', 'subscribe2') . "</p>";
100
+
101
+ // confirmation messages
102
+ $this->no_such_email = "<p>" . __('No such email address is registered.', 'subscribe2') . "</p>";
103
+
104
+ $this->added = "<p>" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
105
+
106
+ $this->deleted = "<p>" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
107
+
108
+ $this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
109
+
110
+ $this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
111
+
112
+ // menu strings
113
+ $this->options_saved = __('Options saved!', 'subscribe2');
114
+ $this->options_reset = __('Options reset!', 'subscribe2');
115
+ } // end load_strings()
116
+
117
+ /* ===== WordPress menu registration and scripts ===== */
118
+ /**
119
+ Hook the menu
120
+ */
121
+ function admin_menu() {
122
+ $s2management = add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), "manage_options", 's2_tools', array(&$this, 'manage_menu'));
123
+ add_action("admin_print_scripts-$s2management", array(&$this, 'checkbox_form_js'));
124
+
125
+ $s2options = add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2', 'subscribe2'), "manage_options", 's2_settings', array(&$this, 'options_menu'));
126
+ add_action("admin_print_scripts-$s2options", array(&$this, 'checkbox_form_js'));
127
+ add_action("admin_print_scripts-$s2options", array(&$this, 'option_form_js'));
128
+ add_filter('plugin_row_meta', array(&$this, 'plugin_links'), 10, 2);
129
+
130
+ $s2user = add_users_page(__('Your Subscriptions', 'subscribe2'), __('Your Subscriptions', 'subscribe2'), "read", 's2_users', array(&$this, 'user_menu'));
131
+ add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
132
+ add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
133
+
134
+ add_submenu_page('post-new.php', __('Mail Subscribers', 'subscribe2'), __('Mail Subscribers', 'subscribe2'), "publish_posts", 's2_posts', array(&$this, 'write_menu'));
135
+
136
+ $s2nonce = md5('subscribe2');
137
+ } // end admin_menu()
138
+
139
+ /**
140
+ Hook for Admin Drop Down Icons
141
+ */
142
+ function ozh_s2_icon() {
143
+ return WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/email_edit.png';
144
+ } // end ozh_s2_icon()
145
+
146
+ /**
147
+ Insert Javascript into admin_header
148
+ */
149
+ function checkbox_form_js() {
150
+ wp_enqueue_script('s2_checkbox', WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/s2_checkbox.js', array('jquery'), '1.0');
151
+ } //end checkbox_form_js()
152
+
153
+ function user_admin_css() {
154
+ wp_enqueue_style('s2_user_admin', WP_CONTENT_URL . '/plugins/ '. S2DIR . '/include/s2_user_admin.css', array(), '1.0');
155
+ }
156
+
157
+ function option_form_js() {
158
+ wp_enqueue_script('s2_edit', WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/s2_edit.js', array('jquery'), '1.0');
159
+ } // end option_form_js()
160
+
161
+ /* ===== Install, upgrade, reset ===== */
162
+ /**
163
+ Install our table
164
+ */
165
+ function install() {
166
+ // include upgrade-functions for maybe_create_table;
167
+ if ( !function_exists('maybe_create_table') ) {
168
+ require_once(ABSPATH . 'wp-admin/install-helper.php');
169
+ }
170
+ $date = date('Y-m-d');
171
+ $sql = "CREATE TABLE $this->public (
172
+ id int(11) NOT NULL auto_increment,
173
+ email varchar(64) NOT NULL default '',
174
+ active tinyint(1) default 0,
175
+ date DATE default '$date' NOT NULL,
176
+ ip char(64) NOT NULL default 'admin',
177
+ PRIMARY KEY (id) )";
178
+
179
+ // create the table, as needed
180
+ maybe_create_table($this->public, $sql);
181
+
182
+ // safety check if options exist and if not create them
183
+ if ( !is_array($this->subscribe2_options) ) {
184
+ $this->reset();
185
+ }
186
+ } // end install()
187
+
188
+ /**
189
+ Upgrade the database
190
+ */
191
+ function upgrade() {
192
+ global $wpdb, $wp_version, $wpmu_version;
193
+ // include upgrade-functions for maybe_add_column;
194
+ if ( !function_exists('maybe_add_column') ) {
195
+ require_once(ABSPATH . 'wp-admin/install-helper.php');
196
+ }
197
+ $date = date('Y-m-d');
198
+ maybe_add_column($this->public, 'date', "ALTER TABLE $this->public ADD date DATE DEFAULT '$date' NOT NULL AFTER active;");
199
+ maybe_add_column($this->public, 'ip', "ALTER TABLE $this->public ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date;");
200
+
201
+ // let's take the time to check process registered users
202
+ // existing public subscribers are subscribed to all categories
203
+ $users = $this->get_all_registered('ID');
204
+ if ( !empty($users) ) {
205
+ foreach ( $users as $user ) {
206
+ $this->register($user);
207
+ }
208
+ }
209
+ // update the options table to serialized format
210
+ $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
211
+
212
+ if ( !empty($old_options) ) {
213
+ foreach ( $old_options as $option ) {
214
+ $value = get_option($option);
215
+ $option_array = substr($option, 3);
216
+ $this->subscribe2_options[$option_array] = $value;
217
+ delete_option($option);
218
+ }
219
+ }
220
+ $this->subscribe2_options['version'] = S2VERSION;
221
+ // ensure that the options are in the database
222
+ require(S2PATH . "include/options.php");
223
+ // correct autoformat to upgrade from pre 5.6
224
+ if ( $this->subscribe2_options['autoformat'] == 'text' ) {
225
+ $this->subscribe2_options['autoformat'] = 'excerpt';
226
+ }
227
+ if ( $this->subscribe2_options['autoformat'] == 'full' ) {
228
+ $this->subscribe2_options['autoformat'] = 'post';
229
+ }
230
+ update_option('subscribe2_options', $this->subscribe2_options);
231
+
232
+ // upgrade old wpmu user meta data to new
233
+ if ( $this->s2_mu === true ) {
234
+ $this->namechange_subscribe2_widget();
235
+ // loop through all users
236
+ foreach ( $users as $user ) {
237
+ // get categories which the user is subscribed to (old ones)
238
+ $categories = get_usermeta($user, 's2_subscribed');
239
+ $categories = explode(',', $categories);
240
+
241
+ // load blogs of user (only if we need them)
242
+ $blogs = array();
243
+ if ( count($categories) > 0 && !in_array('-1', $categories) ) {
244
+ $blogs = get_blogs_of_user($user, true);
245
+ }
246
+
247
+ foreach ( $blogs as $blog_id => $blog ) {
248
+ switch_to_blog($blog_id);
249
+
250
+ $blog_categories = (array)$wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category'");
251
+ $subscribed_categories = array_intersect($categories, $blog_categories);
252
+ if ( !empty($subscribed_categories) ) {
253
+ foreach ( $subscribed_categories as $subscribed_category ) {
254
+ update_usermeta($user, $this->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category);
255
+ }
256
+ update_usermeta($user, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories));
257
+ }
258
+ restore_current_blog();
259
+ }
260
+
261
+ // delete old user meta keys
262
+ delete_usermeta($user, 's2_subscribed');
263
+ foreach ( $categories as $cat ) {
264
+ delete_usermeta($user, 's2_cat' . $cat);
265
+ }
266
+ }
267
+ }
268
+
269
+ // ensure existing public subscriber emails are all sanitized
270
+ $confirmed = $this->get_public();
271
+ $unconfirmed = $this->get_public(0);
272
+ $public_subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
273
+
274
+ foreach ( $public_subscribers as $email ) {
275
+ $new_email = $this->sanitize_email($email);
276
+ if ( $email !== $new_email ) {
277
+ $wpdb->get_results("UPDATE $this->public SET email='$new_email' WHERE CAST(email as binary)='$email'");
278
+ }
279
+ }
280
+ } // end upgrade()
281
+
282
+ /**
283
+ Reset our options
284
+ */
285
+ function reset() {
286
+ delete_option('subscribe2_options');
287
+ wp_clear_scheduled_hook('s2_digest_cron');
288
+ unset($this->subscribe2_options);
289
+ require(S2PATH . "include/options.php");
290
+ update_option('subscribe2_options', $this->subscribe2_options);
291
+ } // end reset()
292
+
293
+ /* ===== mail handling ===== */
294
+ /**
295
+ Performs string substitutions for subscribe2 mail texts
296
+ */
297
+ function substitute($string = '') {
298
+ if ( '' == $string ) {
299
+ return;
300
+ }
301
+ $string = str_replace("BLOGNAME", html_entity_decode(get_option('blogname'), ENT_QUOTES), $string);
302
+ $string = str_replace("BLOGLINK", get_option('home'), $string);
303
+ $string = str_replace("TITLE", stripslashes($this->post_title), $string);
304
+ $link = "<a href=\"" . $this->permalink . "\">" . $this->permalink . "</a>";
305
+ $string = str_replace("PERMALINK", $link, $string);
306
+ if ( strstr($string, "TINYLINK") ) {
307
+ $tinylink = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode($this->permalink));
308
+ if ( $tinylink !== 'Error' || $tinylink != false ) {
309
+ $tlink = "<a href=\"" . $tinylink . "\">" . $tinylink . "</a>";
310
+ $string = str_replace("TINYLINK", $tlink, $string);
311
+ } else {
312
+ $string = str_replace("TINYLINK", $link, $string);
313
+ }
314
+ }
315
+ $string = str_replace("DATE", $this->post_date, $string);
316
+ $string = str_replace("TIME", $this->post_time, $string);
317
+ $string = str_replace("MYNAME", stripslashes($this->myname), $string);
318
+ $string = str_replace("EMAIL", $this->myemail, $string);
319
+ $string = str_replace("AUTHORNAME", stripslashes($this->authorname), $string);
320
+ $string = str_replace("CATS", $this->post_cat_names, $string);
321
+ $string = str_replace("TAGS", $this->post_tag_names, $string);
322
+ $string = str_replace("COUNT", $this->post_count, $string);
323
+
324
+ return $string;
325
+ } // end substitute()
326
+
327
+ /**
328
+ Delivers email to recipients in HTML or plaintext
329
+ */
330
+ function mail($recipients = array(), $subject = '', $message = '', $type='text') {
331
+ if ( empty($recipients) || '' == $message ) { return; }
332
+
333
+ if ( 'html' == $type ) {
334
+ $headers = $this->headers('html');
335
+ if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
336
+ $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title><link rel=\"stylesheet\" href=\"" . get_stylesheet_uri() . "\" type=\"text/css\" media=\"screen\" /></head><body>" . $message . "</body></html>");
337
+ } else {
338
+ $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>");
339
+ }
340
+ } else {
341
+ $headers = $this->headers();
342
+ $message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
343
+ $message = preg_replace('|&amp;|', '&', $message);
344
+ $message = wordwrap(strip_tags($message), 80, "\n");
345
+ $mailtext = apply_filters('s2_plain_email', $message);
346
+ }
347
+
348
+ // Replace any escaped html symbols in subject
349
+ $subject = html_entity_decode($subject, ENT_QUOTES);
350
+
351
+ // Construct BCC headers for sending or send individual emails
352
+ $bcc = '';
353
+ natcasesort($recipients);
354
+ if ( function_exists('wpmq_mail') || $this->subscribe2_options['bcclimit'] == 1 ) {
355
+ // BCCLimit is 1 so send individual emails
356
+ foreach ( $recipients as $recipient ) {
357
+ $recipient = trim($recipient);
358
+ // sanity check -- make sure we have a valid email
359
+ if ( !is_email($recipient) || empty($recipient) ) { continue; }
360
+ // Use the mail queue provided we are not sending a preview
361
+ if ( function_exists('wpmq_mail') && !$this->preview_email ) {
362
+ @wp_mail($recipient, $subject, $mailtext, $headers, '', 0);
363
+ } else {
364
+ @wp_mail($recipient, $subject, $mailtext, $headers);
365
+ }
366
+ }
367
+ return true;
368
+ } elseif ( $this->subscribe2_options['bcclimit'] == 0 ) {
369
+ // we're not using BCCLimit
370
+ foreach ( $recipients as $recipient ) {
371
+ $recipient = trim($recipient);
372
+ // sanity check -- make sure we have a valid email
373
+ if ( !is_email($recipient) ) { continue; }
374
+ // and NOT the sender's email, since they'll get a copy anyway
375
+ if ( !empty($recipient) && $this->myemail != $recipient ) {
376
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
377
+ // Bcc Headers now constructed by phpmailer class
378
+ }
379
+ }
380
+ $headers .= "$bcc\n";
381
+ } else {
382
+ // we're using BCCLimit
383
+ $count = 1;
384
+ $batch = array();
385
+ foreach ( $recipients as $recipient ) {
386
+ $recipient = trim($recipient);
387
+ // sanity check -- make sure we have a valid email
388
+ if ( !is_email($recipient) ) { continue; }
389
+ // and NOT the sender's email, since they'll get a copy anyway
390
+ if ( !empty($recipient) && $this->myemail != $recipient ) {
391
+ ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
392
+ // Bcc Headers now constructed by phpmailer class
393
+ }
394
+ if ( $this->subscribe2_options['bcclimit'] == $count ) {
395
+ $count = 0;
396
+ $batch[] = $bcc;
397
+ $bcc = '';
398
+ }
399
+ $count++;
400
+ }
401
+ // add any partially completed batches to our batch array
402
+ if ( '' != $bcc ) {
403
+ $batch[] = $bcc;
404
+ }
405
+ }
406
+ // rewind the array, just to be safe
407
+ reset($recipients);
408
+
409
+ // actually send mail
410
+ if ( isset($batch) && !empty($batch) ) {
411
+ foreach ( $batch as $bcc ) {
412
+ $newheaders = $headers . "$bcc\n";
413
+ $status = @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
414
+ }
415
+ } else {
416
+ $status = @wp_mail($this->myemail, $subject, $mailtext, $headers);
417
+ }
418
+ return $status;
419
+ } // end mail()
420
+
421
+ /**
422
+ Construct standard set of email headers
423
+ */
424
+ function headers($type='text') {
425
+ if ( empty($this->myname) || empty($this->myemail) ) {
426
+ $admin = $this->get_userdata($this->subscribe2_options['sender']);
427
+ $this->myname = html_entity_decode($admin->display_name, ENT_QUOTES);
428
+ $this->myemail = $admin->user_email;
429
+ }
430
+
431
+ $header['From'] = $this->myname . " <" . $this->myemail . ">";
432
+ $header['Reply-To'] = $this->myname . " <" . $this->myemail . ">";
433
+ $header['Return-path'] = "<" . $this->myemail . ">";
434
+ $header['Precedence'] = "list\nList-Id: " . get_option('blogname') . "";
435
+ $header['X-Mailer'] = "PHP" . phpversion() . "";
436
+ if ( $type == 'html' ) {
437
+ // To send HTML mail, the Content-Type header must be set
438
+ $header['Content-Type'] = get_option('html_type') . "; charset=\"". get_option('blog_charset') . "\"";
439
+ } else {
440
+ $header['Content-Type'] = "text/plain; charset=\"". get_option('blog_charset') . "\"";
441
+ }
442
+
443
+ // apply header filter to allow on-the-fly amendments
444
+ $header = apply_filters('s2_email_headers', $header);
445
+ // collapse the headers using $key as the header name
446
+ foreach ( $header as $key => $value ) {
447
+ $headers[$key] = $key . ": " . $value;
448
+ }
449
+ $headers = implode("\n", $headers);
450
+ $headers .= "\n";
451
+
452
+ return $headers;
453
+ } // end headers()
454
+
455
+ /**
456
+ Sends an email notification of a new post
457
+ */
458
+ function publish($post = 0, $preview = '') {
459
+ if ( !$post ) { return $post; }
460
+
461
+ if ( $this->s2_mu ) {
462
+ global $switched;
463
+ if ( $switched ) { return; }
464
+ }
465
+
466
+ if ( $preview == '' ) {
467
+ // we aren't sending a Preview to the current user so carry out checks
468
+ $s2mail = get_post_meta($post->ID, 's2mail', true);
469
+ if ( (isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no') || strtolower(trim($s2mail)) == 'no' ) { return $post; }
470
+
471
+ // are we doing daily digests? If so, don't send anything now
472
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) { return $post; }
473
+
474
+ // is the current post of a type that should generate a notification email?
475
+ // uses s2_post_types filter to allow for custom post types in WP 3.0
476
+ if ( $this->subscribe2_options['pages'] == 'yes' ) {
477
+ $s2_post_types = array('page', 'post');
478
+ } else {
479
+ $s2_post_types = array('post');
480
+ }
481
+ $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
482
+ if ( !in_array($post->post_type, $s2_post_types) ) {
483
+ return $post;
484
+ }
485
+
486
+ // is this post set in the future?
487
+ if ( $post->post_date > current_time('mysql') ) {
488
+ // bail out
489
+ return $post;
490
+ }
491
+
492
+ //Are we sending notifications for password protected posts?
493
+ if ( $this->subscribe2_options['password'] == "no" && $post->post_password != '' ) {
494
+ return $post;
495
+ }
496
+
497
+ $post_cats = wp_get_post_categories($post->ID);
498
+ $check = false;
499
+ // is the current post assigned to any categories
500
+ // which should not generate a notification email?
501
+ foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
502
+ if ( in_array($cat, $post_cats) ) {
503
+ $check = true;
504
+ }
505
+ }
506
+
507
+ if ( $check ) {
508
+ // hang on -- can registered users subscribe to
509
+ // excluded categories?
510
+ if ( '0' == $this->subscribe2_options['reg_override'] ) {
511
+ // nope? okay, let's leave
512
+ return $post;
513
+ }
514
+ }
515
+
516
+ // Are we sending notifications for Private posts?
517
+ // Action is added if we are, but double check option and post status
518
+ if ( $this->subscribe2_options['private'] == "yes" && $post->post_status == 'private' ) {
519
+ // don't send notification to public users
520
+ $check = true;
521
+ }
522
+
523
+ // lets collect our subscribers
524
+ if ( !$check ) {
525
+ // if this post is assigned to an excluded
526
+ // category, or is a private post then
527
+ // don't send public subscribers a notification
528
+ $public = $this->get_public();
529
+ }
530
+ $post_cats_string = implode(',', $post_cats);
531
+ $registered = $this->get_registered("cats=$post_cats_string");
532
+
533
+ // do we have subscribers?
534
+ if ( empty($public) && empty($registered) ) {
535
+ // if not, no sense doing anything else
536
+ return $post;
537
+ }
538
+ }
539
+
540
+ // we set these class variables so that we can avoid
541
+ // passing them in function calls a little later
542
+ $this->post_title = "<a href=\"" . get_permalink($post->ID) . "\">" . html_entity_decode($post->post_title, ENT_QUOTES) . "</a>";
543
+ $this->permalink = get_permalink($post->ID);
544
+ $this->post_date = get_the_time(get_option('date_format'));
545
+ $this->post_time = get_the_time();
546
+
547
+ $author = get_userdata($post->post_author);
548
+ $this->authorname = $author->display_name;
549
+
550
+ // do we send as admin, or post author?
551
+ if ( 'author' == $this->subscribe2_options['sender'] ) {
552
+ // get author details
553
+ $user = &$author;
554
+ } else {
555
+ // get admin details
556
+ $user = $this->get_userdata($this->subscribe2_options['sender']);
557
+ }
558
+ $this->myemail = $user->user_email;
559
+ $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
560
+
561
+ $this->post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
562
+ $this->post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
563
+
564
+ // Get email subject
565
+ $subject = stripslashes(strip_tags($this->substitute($this->subscribe2_options['notification_subject'])));
566
+ // Get the message template
567
+ $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
568
+ $mailtext = stripslashes($this->substitute($mailtext));
569
+
570
+ $plaintext = $post->post_content;
571
+ if ( function_exists('strip_shortcodes') ) {
572
+ $plaintext = strip_shortcodes($plaintext);
573
+ }
574
+ $gallid = '[gallery id="' . $post->ID . '"]';
575
+ $post->post_content = str_replace('[gallery]', $gallid, $post->post_content);
576
+ $content = apply_filters('the_content', $post->post_content);
577
+ $content = str_replace("]]>", "]]&gt", $content);
578
+ $excerpt = $post->post_excerpt;
579
+ if ( '' == $excerpt ) {
580
+ // no excerpt, is there a <!--more--> ?
581
+ if ( false !== strpos($plaintext, '<!--more-->') ) {
582
+ list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
583
+ // strip leading and trailing whitespace
584
+ $excerpt = strip_tags($excerpt);
585
+ $excerpt = trim($excerpt);
586
+ } else {
587
+ // no <!--more-->, so grab the first 55 words
588
+ $excerpt = strip_tags($plaintext);
589
+ $words = explode(' ', $excerpt, $this->excerpt_length + 1);
590
+ if (count($words) > $this->excerpt_length) {
591
+ array_pop($words);
592
+ array_push($words, '[...]');
593
+ $excerpt = implode(' ', $words);
594
+ }
595
+ }
596
+ }
597
+ $html_excerpt = $post->post_excerpt;
598
+ if ( '' == $html_excerpt ) {
599
+ // no excerpt, is there a <!--more--> ?
600
+ if ( false !== strpos($content, '<!--more-->') ) {
601
+ list($html_excerpt, $more) = explode('<!--more-->', $content, 2);
602
+ // strip leading and trailing whitespace
603
+ $html_excerpt = balanceTags($html_excerpt);
604
+ $html_excerpt = trim($html_excerpt);
605
+ } else {
606
+ // no <!--more-->, so grab the first 55 words
607
+ $words = explode(' ', $content, $this->excerpt_length + 1);
608
+ if (count($words) > $this->excerpt_length) {
609
+ array_pop($words);
610
+ array_push($words, '[...]');
611
+ $html_excerpt = implode(' ', $words);
612
+ $html_excerpt = trim(balanceTags($html_excerpt));
613
+ }
614
+ }
615
+ }
616
+
617
+ // prepare mail body texts
618
+ $excerpt_body = str_replace("POST", $excerpt, $mailtext);
619
+ $full_body = str_replace("POST", strip_tags($plaintext), $mailtext);
620
+ $html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
621
+ $html_body = str_replace("POST", $content, $html_body);
622
+ $html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
623
+ $html_excerpt_body = str_replace("POST", $html_excerpt, $html_excerpt_body);
624
+
625
+ if ( $preview != '' ) {
626
+ $this->myemail = $preview;
627
+ $this->myname = "Preview";
628
+ $this->mail(array($preview), $subject, $excerpt_body);
629
+ $this->mail(array($preview), $subject, $full_body);
630
+ $this->mail(array($preview), $subject, $html_body, 'html');
631
+ $this->mail(array($preview), $subject, $html_excerpt_body, 'html');
632
+ } else {
633
+ // first we send plaintext summary emails
634
+ $registered = $this->get_registered("cats=$post_cats_string&format=excerpt");
635
+ if ( empty($registered) ) {
636
+ $recipients = (array)$public;
637
+ } elseif ( empty($public) ) {
638
+ $recipients = (array)$registered;
639
+ } else {
640
+ $recipients = array_merge((array)$public, (array)$registered);
641
+ }
642
+ $this->mail($recipients, $subject, $excerpt_body);
643
+
644
+ // next we send plaintext full content emails
645
+ $this->mail($this->get_registered("cats=$post_cats_string&format=post"), $subject, $full_body);
646
+
647
+ // next we send html excerpt content emails
648
+ $this->mail($this->get_registered("cats=$post_cats_string&format=html_excerpt"), $subject, $html_excerpt_body, 'html');
649
+
650
+ // finally we send html full content emails
651
+ $this->mail($this->get_registered("cats=$post_cats_string&format=html"), $subject, $html_body, 'html');
652
+ }
653
+ } // end publish()
654
+
655
+ /**
656
+ Hook Subscribe2 into posts published via email
657
+ */
658
+ function publish_phone($id) {
659
+ if ( !$id ) { return; }
660
+
661
+ $post = get_post($id);
662
+ $this->publish($post);
663
+ return $post;
664
+ } // end publish_phone()
665
+
666
+ /**
667
+ Send confirmation email to the user
668
+ */
669
+ function send_confirm($what = '', $is_remind = false) {
670
+ if ( $this->filtered == 1 ) { return true; }
671
+ if ( !$this->email || !$what ) {
672
+ return false;
673
+ }
674
+ $id = $this->get_id($this->email);
675
+ if ( !$id ) {
676
+ return false;
677
+ }
678
+
679
+ // generate the URL "?s2=ACTION+HASH+ID"
680
+ // ACTION = 1 to subscribe, 0 to unsubscribe
681
+ // HASH = md5 hash of email address
682
+ // ID = user's ID in the subscribe2 table
683
+ // use home instead of siteurl incase index.php is not in core wordpress directory
684
+ $link = get_option('home') . "/?s2=";
685
+
686
+ if ( 'add' == $what ) {
687
+ $link .= '1';
688
+ } elseif ( 'del' == $what ) {
689
+ $link .= '0';
690
+ }
691
+ $link .= md5($this->email);
692
+ $link .= $id;
693
+
694
+ // sort the headers now so we have all substitute information
695
+ $mailheaders = $this->headers();
696
+
697
+ if ( $is_remind == true ) {
698
+ $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
699
+ $subject = $this->substitute(stripslashes($this->subscribe2_options['remind_subject']));
700
+ } else {
701
+ $body = $this->substitute(stripslashes($this->subscribe2_options['confirm_email']));
702
+ if ( 'add' == $what ) {
703
+ $body = str_replace("ACTION", $this->subscribe, $body);
704
+ $subject = str_replace("ACTION", $this->subscribe, $this->subscribe2_options['confirm_subject']);
705
+ } elseif ( 'del' == $what ) {
706
+ $body = str_replace("ACTION", $this->unsubscribe, $body);
707
+ $subject = str_replace("ACTION", $this->unsubscribe, $this->subscribe2_options['confirm_subject']);
708
+ }
709
+ $subject = html_entity_decode($this->substitute(stripslashes($subject)), ENT_QUOTES);
710
+ }
711
+
712
+ $body = str_replace("LINK", $link, $body);
713
+
714
+ if ( $is_remind == true && function_exists('wpmq_mail') ) {
715
+ // could be sending lots of reminders so queue them if wpmq is enabled
716
+ @wp_mail($this->email, $subject, $body, $mailheaders, '', 0);
717
+ } else {
718
+ return @wp_mail($this->email, $subject, $body, $mailheaders);
719
+ }
720
+ } // end send_confirm()
721
+
722
+ /* ===== Subscriber functions ===== */
723
+ /**
724
+ Given a public subscriber ID, returns the email address
725
+ */
726
+ function get_email($id = 0) {
727
+ global $wpdb;
728
+
729
+ if ( !$id ) {
730
+ return false;
731
+ }
732
+ return $wpdb->get_var("SELECT email FROM $this->public WHERE id=$id");
733
+ } // end get_email()
734
+
735
+ /**
736
+ Given a public subscriber email, returns the subscriber ID
737
+ */
738
+ function get_id($email = '') {
739
+ global $wpdb;
740
+
741
+ if ( !$email ) {
742
+ return false;
743
+ }
744
+ return $wpdb->get_var("SELECT id FROM $this->public WHERE email='$email'");
745
+ } // end get_id()
746
+
747
+ /**
748
+ Activate an public subscriber email address
749
+ If the address is not already present, it will be added
750
+ */
751
+ function activate($email = '') {
752
+ global $wpdb;
753
+
754
+ if ( '' == $email ) {
755
+ if ( '' != $this->email ) {
756
+ $email = $this->email;
757
+ } else {
758
+ return false;
759
+ }
760
+ }
761
+
762
+ if ( false !== $this->is_public($email) ) {
763
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$this->email'");
764
+ if ( $check ) { return; }
765
+ $wpdb->get_results("UPDATE $this->public SET active='1', ip='$this->ip' WHERE CAST(email as binary)='$email'");
766
+ } else {
767
+ global $current_user;
768
+ $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 1, $current_user->user_login));
769
+ }
770
+ } // end activate()
771
+
772
+ /**
773
+ Add an public subscriber to the subscriber table as unconfirmed
774
+ */
775
+ function add($email = '') {
776
+ if ( $this->filtered ==1 ) { return; }
777
+ global $wpdb;
778
+
779
+ if ( '' == $email ) {
780
+ if ( '' != $this->email ) {
781
+ $email = $this->email;
782
+ } else {
783
+ return false;
784
+ }
785
+ }
786
+
787
+ if ( !is_email($email) ) { return false; }
788
+
789
+ if ( false !== $this->is_public($email) ) {
790
+ $wpdb->get_results("UPDATE $this->public SET date=NOW() WHERE CAST(email as binary)='$email'");
791
+ } else {
792
+ $wpdb->get_results($wpdb->prepare("INSERT INTO $this->public (email, active, date, ip) VALUES (%s, %d, NOW(), %s)", $email, 0, $this->ip));
793
+ }
794
+ } // end add()
795
+
796
+ /**
797
+ Remove a public subscriber user from the subscription table
798
+ */
799
+ function delete($email = '') {
800
+ global $wpdb;
801
+
802
+ if ( '' == $email ) {
803
+ if ( '' != $this->email ) {
804
+ $email = $this->email;
805
+ } else {
806
+ return false;
807
+ }
808
+ }
809
+
810
+ if ( !is_email($email) ) { return false; }
811
+ $wpdb->get_results("DELETE FROM $this->public WHERE CAST(email as binary)='$email'");
812
+ } // end delete()
813
+
814
+ /**
815
+ Toggle a public subscriber's status
816
+ */
817
+ function toggle($email = '') {
818
+ global $wpdb;
819
+
820
+ if ( '' == $email || ! is_email($email) ) { return false; }
821
+
822
+ // let's see if this is a public user
823
+ $status = $this->is_public($email);
824
+ if ( false === $status ) { return false; }
825
+
826
+ if ( '0' == $status ) {
827
+ $wpdb->get_results("UPDATE $this->public SET active='1' WHERE CAST(email as binary)='$email'");
828
+ } else {
829
+ $wpdb->get_results("UPDATE $this->public SET active='0' WHERE CAST(email as binary)='$email'");
830
+ }
831
+ } // end toggle()
832
+
833
+ /**
834
+ Send reminder email to unconfirmed public subscribers
835
+ */
836
+ function remind($emails = '') {
837
+ if ( '' == $emails ) { return false; }
838
+
839
+ $recipients = explode(",", $emails);
840
+ if ( !is_array($recipients) ) { $recipients = (array)$recipients; }
841
+ foreach ( $recipients as $recipient ) {
842
+ $this->email = $recipient;
843
+ $this->send_confirm('add', true);
844
+ }
845
+ } //end remind()
846
+
847
+ /**
848
+ Check email is not from a barred domain
849
+ */
850
+ function is_barred($email='') {
851
+ $barred_option = $this->subscribe2_options['barred'];
852
+ list($user, $domain) = split('@', $email);
853
+ $bar_check = stristr($barred_option, $domain);
854
+
855
+ if ( !empty($bar_check) ) {
856
+ return true;
857
+ } else {
858
+ return false;
859
+ }
860
+ } //end is_barred()
861
+
862
+ /**
863
+ Confirm request from the link emailed to the user and email the admin
864
+ */
865
+ function confirm($content = '') {
866
+ global $wpdb;
867
+
868
+ if ( 1 == $this->filtered ) { return $content; }
869
+
870
+ $code = $_GET['s2'];
871
+ $action = intval(substr($code, 0, 1));
872
+ $hash = substr($code, 1, 32);
873
+ $code = str_replace($hash, '', $code);
874
+ $id = intval(substr($code, 1));
875
+ if ( $id ) {
876
+ $this->email = $this->sanitize_email($this->get_email($id));
877
+ if ( !$this->email || $hash !== md5($this->email) ) {
878
+ return $this->no_such_email;
879
+ }
880
+ } else {
881
+ return $this->no_such_email;
882
+ }
883
+
884
+ // get current status of email so messages are only sent once per emailed link
885
+ $current = $this->is_public($this->email);
886
+
887
+ if ( '1' == $action ) {
888
+ // make this subscription active
889
+ $this->message = $this->added;
890
+ if ( '1' != $current ) {
891
+ $this->ip = $_SERVER['REMOTE_ADDR'];
892
+ $this->activate();
893
+ if ( $this->subscribe2_options['admin_email'] == 'subs' || $this->subscribe2_options['admin_email'] == 'both' ) {
894
+ ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(get_option('blogname')) . "] ";
895
+ $subject .= __('New Subscription', 'subscribe2');
896
+ $subject = html_entity_decode($subject, ENT_QUOTES);
897
+ $message = $this->email . " " . __('subscribed to email notifications!', 'subscribe2');
898
+ $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value='10'");
899
+ if ( empty($recipients) ) {
900
+ $role = 'administrator';
901
+ if ( !class_exists(WP_User_Search) ) {
902
+ require(ABSPATH . 'wp-admin/includes/user.php');
903
+ }
904
+ $wp_user_search = new WP_User_Search( '', '', $role);
905
+ $admins_string = implode(', ', $wp_user_search->get_results());
906
+ $sql = "SELECT user_email FROM $wpdb->users WHERE ID IN (" . $admins_string . ")";
907
+ $recipients = $wpdb->get_col($sql);
908
+ }
909
+ $headers = $this->headers();
910
+ foreach ( $recipients as $recipient ) {
911
+ @wp_mail($recipient, $subject, $message, $headers);
912
+ }
913
+ }
914
+ }
915
+ $this->filtered = 1;
916
+ } elseif ( '0' == $action ) {
917
+ // remove this subscriber
918
+ $this->message = $this->deleted;
919
+ if ( '0' != $current ) {
920
+ $this->delete();
921
+ if ( $this->subscribe2_options['admin_email'] == 'unsubs' || $this->subscribe2_options['admin_email'] == 'both' ) {
922
+ ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(get_option('blogname')) . "] ";
923
+ $subject .= __('New Unsubscription', 'subscribe2');
924
+ $subject = html_entity_decode($subject, ENT_QUOTES);
925
+ $message = $this->email . " " . __('unsubscribed from email notifications!', 'subscribe2');
926
+ $recipients = $wpdb->get_col("SELECT DISTINCT(user_email) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value='10'");
927
+ if ( empty($recipients) ) {
928
+ $role = 'administrator';
929
+ if ( !class_exists(WP_User_Search) ) {
930
+ require(ABSPATH . 'wp-admin/includes/user.php');
931
+ }
932
+ $wp_user_search = new WP_User_Search( '', '', $role);
933
+ $admins_string = implode(', ', $wp_user_search->get_results());
934
+ $sql = "SELECT user_email FROM $wpdb->users WHERE ID IN (" . $admins_string . ")";
935
+ $recipients = $wpdb->get_col($sql);
936
+ }
937
+ $headers = $this->headers();
938
+ foreach ( $recipients as $recipient ) {
939
+ @wp_mail($recipient, $subject, $message, $headers);
940
+ }
941
+ }
942
+ }
943
+ $this->filtered = 1;
944
+ }
945
+
946
+ if ( '' != $this->message ) {
947
+ return $this->message;
948
+ }
949
+ } // end confirm()
950
+
951
+ /**
952
+ Is the supplied email address a public subscriber?
953
+ */
954
+ function is_public($email = '') {
955
+ global $wpdb;
956
+
957
+ if ( '' == $email ) { return false; }
958
+
959
+ // run the query and force case sensitivity
960
+ $check = $wpdb->get_var("SELECT active FROM $this->public WHERE CAST(email as binary)='$email'");
961
+ if ( '0' == $check || '1' == $check ) {
962
+ return $check;
963
+ } else {
964
+ return false;
965
+ }
966
+ } // end is_public
967
+
968
+ /**
969
+ Is the supplied email address a registered user of the blog?
970
+ */
971
+ function is_registered($email = '') {
972
+ global $wpdb;
973
+
974
+ if ( '' == $email ) { return false; }
975
+
976
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email='$email'");
977
+ if ( $check ) {
978
+ return true;
979
+ } else {
980
+ return false;
981
+ }
982
+ } // end is_registered()
983
+
984
+ /**
985
+ Return Registered User ID from email
986
+ */
987
+ function get_user_id($email = '') {
988
+ global $wpdb;
989
+
990
+ if ( '' == $email ) { return false; }
991
+
992
+ $id = $wpdb->get_var("SELECT id FROM $wpdb->users WHERE user_email='$email'");
993
+
994
+ return $id;
995
+ } // end get_user_id()
996
+
997
+ /**
998
+ Return an array of all the public subscribers
999
+ */
1000
+ function get_public($confirmed = 1) {
1001
+ global $wpdb;
1002
+ if ( 1 == $confirmed ) {
1003
+ if ( '' == $this->all_public ) {
1004
+ $this->all_public = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
1005
+ }
1006
+ return $this->all_public;
1007
+ } else {
1008
+ if ( '' == $this->all_unconfirmed ) {
1009
+ $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
1010
+ }
1011
+ return $this->all_unconfirmed;
1012
+ }
1013
+ } // end get_public()
1014
+
1015
+ /**
1016
+ Return an array of all subscribers
1017
+ */
1018
+ function get_all_registered($id = '') {
1019
+ global $wpdb;
1020
+
1021
+ if ( $this->s2_mu ) {
1022
+ if ( $id ) {
1023
+ return $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
1024
+ } else {
1025
+ $result = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
1026
+ $ids = implode(',', $result);
1027
+ return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
1028
+ }
1029
+ } else {
1030
+ if ( $id ) {
1031
+ return $wpdb->get_col("SELECT ID FROM $wpdb->users");
1032
+ } else {
1033
+ return $wpdb->get_col("SELECT user_email FROM $wpdb->users");
1034
+ }
1035
+ }
1036
+ }
1037
+
1038
+ /**
1039
+ Return an array of registered subscribers
1040
+ Collect all the registered users of the blog who are subscribed to the specified categories
1041
+ */
1042
+ function get_registered($args = '') {
1043
+ global $wpdb;
1044
+
1045
+ $format = '';
1046
+ $cats = '';
1047
+ $subscribers = array();
1048
+
1049
+ parse_str($args, $r);
1050
+ if ( !isset($r['format']) )
1051
+ $r['format'] = 'all';
1052
+ if ( !isset($r['cats']) )
1053
+ $r['cats'] = '';
1054
+
1055
+ $JOIN = ''; $AND = '';
1056
+ // text or HTML subscribers
1057
+ if ( 'all' != $r['format'] ) {
1058
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
1059
+ $AND .= " AND b.meta_key='s2_format' AND b.meta_value=";
1060
+ if ( 'html' == $r['format'] ) {
1061
+ $AND .= "'html'";
1062
+ } elseif ( 'html_excerpt' == $r['format'] ) {
1063
+ $AND .= "'html_excerpt'";
1064
+ } elseif ( 'post' == $r['format'] ) {
1065
+ $AND .= "'post'";
1066
+ } elseif ( 'excerpt' == $r['format'] ) {
1067
+ $AND .= "'excerpt'";
1068
+ }
1069
+ }
1070
+
1071
+ // specific category subscribers
1072
+ if ( '' != $r['cats'] ) {
1073
+ $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
1074
+ $all = '';
1075
+ foreach ( explode(',', $r['cats']) as $cat ) {
1076
+ ('' == $and) ? $and = "c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'" : $and .= " OR c.meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$cat'";
1077
+ }
1078
+ $AND .= " AND ($and)";
1079
+ }
1080
+
1081
+ if ( $this->s2_mu ) {
1082
+ $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities'" . $AND;
1083
+ } else {
1084
+ $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'" . $AND;
1085
+ }
1086
+ $result = $wpdb->get_col($sql);
1087
+ if ( $result ) {
1088
+ $ids = implode(',', $result);
1089
+ return $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
1090
+ }
1091
+ } // end get_registered()
1092
+
1093
+ /**
1094
+ Collects the signup date for all public subscribers
1095
+ */
1096
+ function signup_date($email = '') {
1097
+ if ( '' == $email ) { return false; }
1098
+
1099
+ global $wpdb;
1100
+ if ( !empty($this->signup_dates) ) {
1101
+ return $this->signup_dates[$email];
1102
+ } else {
1103
+ $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
1104
+ foreach ( $results as $result ) {
1105
+ $this->signup_dates[$result[0]] = $result[1];
1106
+ }
1107
+ return $this->signup_dates[$email];
1108
+ }
1109
+ } // end signup_date()
1110
+
1111
+ /**
1112
+ Collects the ip address for all public subscribers
1113
+ */
1114
+ function signup_ip($email = '') {
1115
+ if ( '' == $email ) {return false; }
1116
+
1117
+ global $wpdb;
1118
+ if ( !empty($this->signup_ips) ) {
1119
+ return $this->signup_ips[$email];
1120
+ } else {
1121
+ $results = $wpdb->get_results("SELECT email, ip FROM $this->public", ARRAY_N);
1122
+ foreach ( $results as $result ) {
1123
+ $this->signup_ips[$result[0]] = $result[1];
1124
+ }
1125
+ return $this->signup_ips[$email];
1126
+ }
1127
+ } // end signup_ip()
1128
+
1129
+ /**
1130
+ function to ensure email is compliant with internet messaging standards
1131
+ */
1132
+ function sanitize_email($email) {
1133
+ if ( !is_email($email) ) { return; }
1134
+
1135
+ // ensure that domain is in lowercase as per internet email standards
1136
+ list($name, $domain) = explode('@', $email, 2);
1137
+ return $name . "@" . strtolower($domain);;
1138
+ } // end sanitize_email()
1139
+
1140
+ /**
1141
+ Create the appropriate usermeta values when a user registers
1142
+ If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
1143
+ */
1144
+ function register($user_ID = 0) {
1145
+ global $wpdb;
1146
+
1147
+ if ( 0 == $user_ID ) { return $user_ID; }
1148
+ $user = get_userdata($user_ID);
1149
+ $all_cats = get_categories(array('hide_empty' => false));
1150
+
1151
+ // Are registered users are allowed to subscribe to excluded categories?
1152
+ if ( 0 == $this->subscribe2_options['reg_override'] || 'no' == $this->subscribe2_options['newreg_override'] ) {
1153
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
1154
+ foreach ( $all_cats as $cat => $term_id ) {
1155
+ if ( in_array($all_cats[$cat]->term_id, $exclude) ) {
1156
+ $cat = (int)$cat;
1157
+ unset($all_cats[$cat]);
1158
+ }
1159
+ }
1160
+ }
1161
+
1162
+ foreach ( $all_cats as $cat ) {
1163
+ ('' == $cats) ? $cats = "$cat->term_id" : $cats .= ",$cat->term_id";
1164
+ }
1165
+
1166
+ if ( '' == $cats ) {
1167
+ // sanity check, might occur if all cats excluded and reg_override = 0
1168
+ return $user_ID;
1169
+ }
1170
+
1171
+ // has this user previously signed up for email notification?
1172
+ if ( false !== $this->is_public($this->sanitize_email($user->user_email)) ) {
1173
+ // delete this user from the public table, and subscribe them to all the categories
1174
+ $this->delete($user->user_email);
1175
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1176
+ foreach ( explode(',', $cats) as $cat ) {
1177
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, "$cat");
1178
+ }
1179
+ update_usermeta($user_ID, 's2_format', 'excerpt');
1180
+ update_usermeta($user_ID, 's2_autosub', $this->subscribe2_options['autosub_def']);
1181
+ } else {
1182
+ // create post format entries for all users
1183
+ $check_format = get_usermeta($user_ID, 's2_format');
1184
+ if ( empty($check_format) ) {
1185
+ // ensure existing subscription options are not overwritten on upgrade
1186
+ if ( in_array($this->subscribe2_options['autoformat'], array('html', 'html_excerpt', 'post', 'excerpt')) ) {
1187
+ update_usermeta($user_ID, 's2_format', $this->subscribe2_options['autoformat']);
1188
+ } else {
1189
+ update_usermeta($user_ID, 's2_format', 'excerpt');
1190
+ }
1191
+ update_usermeta($user_ID, 's2_autosub', $this->subscribe2_options['autosub_def']);
1192
+ // if the are no existing subscriptions, create them if, by default if autosub is on
1193
+ if ( 'yes' == $this->subscribe2_options['autosub'] || ( 'wpreg' == $this->subscribe2_options['autosub'] && 'on' == $_POST['subscribe'] ) ) {
1194
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1195
+ foreach ( explode(',', $cats) as $cat ) {
1196
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, "$cat");
1197
+ }
1198
+ }
1199
+ } else {
1200
+ // if user is already registered update format remove 's2_excerpt' field and update 's2_format'
1201
+ if ( 'html' == $check_format ) {
1202
+ delete_usermeta($user_ID, 's2_excerpt');
1203
+ } elseif ( 'text' == $check_format ) {
1204
+ update_usermeta($user_ID, 's2_format', get_usermeta($user_ID, 's2_excerpt'));
1205
+ delete_usermeta($user_ID, 's2_excerpt');
1206
+ }
1207
+ }
1208
+ $subscribed = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1209
+ if ( strstr($subscribed, '-1') ) {
1210
+ // make sure we remove '-1' from any settings
1211
+ $old_cats = explode(',', $subscribed);
1212
+ $pos = array_search('-1', $old_cats);
1213
+ unset($old_cats[$pos]);
1214
+ $cats = implode(',', $old_cats);
1215
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1216
+ }
1217
+ }
1218
+ return $user_ID;
1219
+ } // end register()
1220
+
1221
+ /**
1222
+ Subscribe all registered users to category selected on Admin Manage Page
1223
+ */
1224
+ function subscribe_registered_users($emails = '', $cats = array()) {
1225
+ if ( '' == $emails || '' == $cats ) { return false; }
1226
+ global $wpdb;
1227
+
1228
+ $useremails = explode(",", $emails);
1229
+ $useremails = implode("', '", $useremails);
1230
+
1231
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
1232
+ $user_IDs = $wpdb->get_col($sql);
1233
+
1234
+ foreach ( $user_IDs as $user_ID ) {
1235
+ $old_cats = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1236
+ if ( !empty($old_cats) ) {
1237
+ $old_cats = explode(',', $old_cats);
1238
+ $newcats = array_unique(array_merge($cats, $old_cats));
1239
+ } else {
1240
+ $newcats = $cats;
1241
+ }
1242
+ if ( !empty($newcats) ) {
1243
+ // add subscription to these cat IDs
1244
+ foreach ( $newcats as $id ) {
1245
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, "$id");
1246
+ }
1247
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
1248
+ }
1249
+ unset($newcats);
1250
+ }
1251
+ } // end subscribe_registered_users()
1252
+
1253
+ /**
1254
+ Unsubscribe all registered users to category selected on Admin Manage Page
1255
+ */
1256
+ function unsubscribe_registered_users($emails = '', $cats = array()) {
1257
+ if ( '' == $emails || '' == $cats ) { return false; }
1258
+ global $wpdb;
1259
+
1260
+ $useremails = explode(",", $emails);
1261
+ $useremails = implode("', '", $useremails);
1262
+
1263
+ $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ('$useremails')";
1264
+ $user_IDs = $wpdb->get_col($sql);
1265
+
1266
+ foreach ( $user_IDs as $user_ID ) {
1267
+ $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
1268
+ $remain = array_diff($old_cats, $cats);
1269
+ if ( !empty($remain) ) {
1270
+ // remove subscription to these cat IDs and update s2_subscribed
1271
+ foreach ( $cats as $id ) {
1272
+ delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1273
+ }
1274
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
1275
+ } else {
1276
+ // remove subscription to these cat IDs and update s2_subscribed to ''
1277
+ foreach ( $cats as $id ) {
1278
+ delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1279
+ }
1280
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
1281
+ }
1282
+ unset($remain);
1283
+ }
1284
+ } // end unsubscribe_registered_users()
1285
+
1286
+ /**
1287
+ Handles bulk changes to email format for Registered Subscribers
1288
+ */
1289
+ function format_change($format, $subscribers_string) {
1290
+ if ( empty($format) ) { return; }
1291
+
1292
+ global $wpdb;
1293
+ $emails ='';
1294
+ $subscribers = explode(',', $subscribers_string);
1295
+ foreach ( $subscribers as $subscriber ) {
1296
+ ( '' == $emails) ? $emails = "'$subscriber'" : $emails .= ",'$subscriber'";
1297
+ }
1298
+ $ids = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_email IN ($emails)");
1299
+ $ids = implode(',', $ids);
1300
+ $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='s2_format' AND user_id IN ($ids)";
1301
+ $wpdb->get_results("UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='s2_format' AND user_id IN ($ids)");
1302
+ } // end bulk_manage()
1303
+
1304
+ /**
1305
+ Handles subscriptions and unsubscriptions for different blogs on WPMU installs
1306
+ */
1307
+ function wpmu_subscribe() {
1308
+ $redirect_to_subscriptionpage = false;
1309
+
1310
+ // subscribe to new blog
1311
+ if ( !empty($_GET['s2mu_subscribe']) ) {
1312
+ $blog_id = intval($_GET['s2mu_subscribe']);
1313
+ if ( $blog_id >= 0 ) {
1314
+ switch_to_blog($blog_id);
1315
+
1316
+ $user_ID = get_current_user_id();
1317
+
1318
+ // if user is not a user of the current blog
1319
+ if ( !is_blog_user($blog_id) ) {
1320
+ // add user to current blog as subscriber
1321
+ add_user_to_blog($blog_id, $user_ID, 'subscriber');
1322
+ // add an action hook for external manipulation of blog and user data
1323
+ do_action_ref_array('subscribe2_wpmu_subscribe', array($user_ID, $blog_id));
1324
+ }
1325
+
1326
+ // subscribe to all categories by default
1327
+ $all_cats = get_categories(array('hide_empty' => false));
1328
+
1329
+ if ( 0 == $this->subscribe2_options['reg_override'] ) {
1330
+ // registered users are not allowed to subscribe to excluded categories
1331
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
1332
+ foreach ( $all_cats as $cat => $term ) {
1333
+ if ( in_array($all_cats[$cat]->term_id, $exclude) ) {
1334
+ $cat = (int)$cat;
1335
+ unset($all_cats[$cat]);
1336
+ }
1337
+ }
1338
+ }
1339
+
1340
+ $cats = array();
1341
+ foreach ( $all_cats as $cat => $term ) {
1342
+ $term_id = $term->term_id;
1343
+ $cats[] = $term_id;
1344
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $term_id, $term_id);
1345
+ }
1346
+ if ( empty($cats) ) {
1347
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
1348
+ } else {
1349
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $cats));
1350
+ }
1351
+
1352
+ // don't restore_current_blog(); -> redirect to new subscription page
1353
+ $redirect_to_subscriptionpage = true;
1354
+ }
1355
+ } elseif ( !empty($_GET['s2mu_unsubscribe']) ) {
1356
+ // unsubscribe from a blog
1357
+ $blog_id = intval($_GET['s2mu_unsubscribe']);
1358
+ if ( $blog_id >= 0 ) {
1359
+ switch_to_blog($blog_id);
1360
+
1361
+ $user_ID = get_current_user_id();
1362
+
1363
+ // delete subscription to all categories on that blog
1364
+ $cats = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1365
+ $cats = explode(',', $cats);
1366
+ if ( !is_array($cats) ) {
1367
+ $cats = array($cats);
1368
+ }
1369
+
1370
+ foreach ( $cats as $id ) {
1371
+ delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
1372
+ }
1373
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
1374
+
1375
+ // add an action hook for external manipulation of blog and user data
1376
+ do_action_ref_array('subscribe2_wpmu_unsubscribe', array($user_ID, $blog_id));
1377
+
1378
+ restore_current_blog();
1379
+ $redirect_to_subscriptionpage = true;
1380
+ }
1381
+ }
1382
+
1383
+ if ( $redirect_to_subscriptionpage == true ) {
1384
+ if ( !is_user_member_of_blog($user_ID) ) {
1385
+ $user_blogs = get_active_blog_for_user($user_ID);
1386
+ if ( is_array($user_blogs) ) {
1387
+ switch_to_blog(key($user_blogs));
1388
+ } else {
1389
+ // no longer a member of a blog
1390
+ wp_redirect(get_option('siteurl')); // redirect to front page
1391
+ exit();
1392
+ }
1393
+ }
1394
+
1395
+ // redirect to profile page
1396
+ if ( current_user_can('manage_options') ) {
1397
+ $url = get_option('siteurl') . '/wp-admin/users.php?page=s2_users';
1398
+ wp_redirect($url);
1399
+ exit();
1400
+ } else {
1401
+ $url = get_option('siteurl') . '/wp-admin/profile.php?page=s2_users';
1402
+ wp_redirect($url);
1403
+ exit();
1404
+ }
1405
+ }
1406
+ } // end wpmu_subscribe()
1407
+
1408
+ /**
1409
+ Autosubscribe registered users to newly created categories
1410
+ if registered user has selected this option
1411
+ */
1412
+ function new_category($new_category='') {
1413
+ if ( 'no' == $this->subscribe2_options['show_autosub'] ) { return; }
1414
+ global $wpdb;
1415
+
1416
+ if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
1417
+ $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key='s2_autosub' AND $wpdb->usermeta.meta_value='yes'";
1418
+ $user_IDs = $wpdb->get_col($sql);
1419
+ if ( '' == $user_IDs ) { return; }
1420
+
1421
+ foreach ( $user_IDs as $user_ID ) {
1422
+ $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
1423
+ if ( !is_array($old_cats) ) {
1424
+ $old_cats = array($old_cats);
1425
+ }
1426
+ // add subscription to these cat IDs
1427
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $new_category, "$new_category");
1428
+ $newcats = array_merge($old_cats, (array)$new_category);
1429
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
1430
+ }
1431
+ } elseif ( 'exclude' == $this->subscribe2_options['show_autosub'] ) {
1432
+ $excluded_cats = explode(',', $this->subscribe2_options['exclude']);
1433
+ $excluded_cats[] = $new_category;
1434
+ $this->subscribe2_options['exclude'] = implode(',', $excluded_cats);
1435
+ update_option('subscribe2_options', $this->subscribe2_options);
1436
+ }
1437
+ } // end new_category()
1438
+
1439
+ function delete_category($deleted_category='') {
1440
+ global $wpdb;
1441
+
1442
+ $sql = "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . "$deleted_category'";
1443
+ $user_IDs = $wpdb->get_col($sql);
1444
+ if ( '' == $user_IDs ) { return; }
1445
+
1446
+ foreach ( $user_IDs as $user_ID ) {
1447
+ $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
1448
+ if ( !is_array($old_cats) ) {
1449
+ $old_cats = array($old_cats);
1450
+ }
1451
+ // add subscription to these cat IDs
1452
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $deleted_category, '');
1453
+ $remain = array_diff($old_cats, (array)$deleted_category);
1454
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
1455
+ }
1456
+ }
1457
+
1458
+ /**
1459
+ Get admin data from record 1 or first user with admin rights
1460
+ */
1461
+ function get_userdata($admin_id) {
1462
+ global $wpdb, $userdata;
1463
+
1464
+ if ( is_numeric($admin_id) ) {
1465
+ $admin = get_userdata($admin_id);
1466
+ } elseif ( $admin_id == 'admin' ) {
1467
+ //ensure compatibility with < 4.16
1468
+ $admin = get_userdata('1');
1469
+ } else {
1470
+ $admin = &$userdata;
1471
+ }
1472
+
1473
+ // if user record is empty grab the first admin from the database
1474
+ if ( empty($admin) ) {
1475
+ $sql = "SELECT DISTINCT(ID) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value IN (8, 9, 10) LIMIT 1";
1476
+ $admin = get_userdata($wpdb->get_var($sql));
1477
+ }
1478
+
1479
+ // handle issues from WordPress core where user_level is not set or set low
1480
+ if ( empty($admin) ) {
1481
+ $role = 'administrator';
1482
+ if ( !class_exists(WP_User_Search) ) {
1483
+ require(ABSPATH . 'wp-admin/includes/user.php');
1484
+ }
1485
+ $wp_user_search = new WP_User_Search( '', '', $role);
1486
+ $results = $wp_user_search->get_results();
1487
+ $admin = $results[0];
1488
+ }
1489
+
1490
+ return $admin;
1491
+ } //end get_userdata()
1492
+
1493
+ /* ===== Menus ===== */
1494
+ /**
1495
+ Our management page
1496
+ */
1497
+ function manage_menu() {
1498
+ global $wpdb, $s2nonce;
1499
+
1500
+ //Get Registered Subscribers for bulk management
1501
+ $registered = $this->get_registered();
1502
+ $all_users = $this->get_all_registered();
1503
+
1504
+ // was anything POSTed ?
1505
+ if ( isset($_POST['s2_admin']) ) {
1506
+ check_admin_referer('subscribe2-manage_subscribers' . $s2nonce);
1507
+ if ( $_POST['addresses'] ) {
1508
+ $sub_error = '';
1509
+ $unsub_error = '';
1510
+ foreach ( preg_split ("/[\s,]+/", $_POST['addresses']) as $email ) {
1511
+ $email = $this->sanitize_email($email);
1512
+ if ( is_email($email) && $_POST['subscribe'] ) {
1513
+ if ( $this->is_public($email) !== false ) {
1514
+ ('' == $sub_error) ? $sub_error = "$email" : $sub_error .= ", $email";
1515
+ continue;
1516
+ }
1517
+ $this->activate($email);
1518
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) subscribed!', 'subscribe2') . "</strong></p></div>";
1519
+ } elseif ( is_email($email) && $_POST['unsubscribe'] ) {
1520
+ if ( $this->is_public($email) === false ) {
1521
+ ('' == $unsub_error) ? $unsub_error = "$email" : $unsub_error .= ", $email";
1522
+ continue;
1523
+ }
1524
+ $this->delete($email);
1525
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) unsubscribed!', 'subscribe2') . "</strong></p></div>";
1526
+ }
1527
+ }
1528
+ if ( $sub_error != '' ) {
1529
+ echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were already subscribed' , 'subscribe2') . ":<br />$sub_error</strong></p></div>";
1530
+ }
1531
+ if ( $unsub_error != '' ) {
1532
+ echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following were not in the database' , 'subscribe2') . ":<br />$unsub_error</strong></p></div>";
1533
+ }
1534
+ echo $message;
1535
+ $_POST['what'] = 'confirmed';
1536
+ } elseif ( $_POST['process'] ) {
1537
+ if ( $_POST['delete'] ) {
1538
+ foreach ( $_POST['delete'] as $address ) {
1539
+ $this->delete($address);
1540
+ }
1541
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) deleted!', 'subscribe2') . "</strong></p></div>";
1542
+ }
1543
+ if ( $_POST['confirm'] ) {
1544
+ foreach ( $_POST['confirm'] as $address ) {
1545
+ $this->toggle($this->sanitize_email($address));
1546
+ }
1547
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
1548
+ }
1549
+ if ( $_POST['unconfirm'] ) {
1550
+ foreach ( $_POST['unconfirm'] as $address ) {
1551
+ $this->toggle($this->sanitize_email($address));
1552
+ }
1553
+ $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
1554
+ }
1555
+ echo $message;
1556
+ } elseif ( $_POST['searchterm'] ) {
1557
+ $confirmed = $this->get_public();
1558
+ $unconfirmed = $this->get_public(0);
1559
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1560
+ foreach ( $subscribers as $subscriber ) {
1561
+ if ( is_numeric(stripos($subscriber, $_POST['searchterm'])) ) {
1562
+ $result[] = $subscriber;
1563
+ }
1564
+ }
1565
+ } elseif ( $_POST['remind'] ) {
1566
+ $this->remind($_POST['reminderemails']);
1567
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Reminder Email(s) Sent!', 'subscribe2') . "</strong></p></div>";
1568
+ } elseif ( $_POST['sub_categories'] && 'subscribe' == $_POST['manage'] ) {
1569
+ $this->subscribe_registered_users($_POST['emails'], $_POST['category']);
1570
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Subscribed!', 'subscribe2') . "</strong></p></div>";
1571
+ } elseif ( $_POST['sub_categories'] && 'unsubscribe' == $_POST['manage'] ) {
1572
+ $this->unsubscribe_registered_users($_POST['emails'], $_POST['category']);
1573
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Unsubscribed!', 'subscribe2') . "</strong></p></div>";
1574
+ } elseif ( $_POST['sub_format'] ) {
1575
+ $this->format_change( $_POST['format'], $_POST['emails'] );
1576
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Format updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
1577
+ }
1578
+ }
1579
+
1580
+ //Get Public Subscribers once for filter
1581
+ $confirmed = $this->get_public();
1582
+ $unconfirmed = $this->get_public(0);
1583
+ // safety check for our arrays
1584
+ if ( '' == $confirmed ) { $confirmed = array(); }
1585
+ if ( '' == $unconfirmed ) { $unconfirmed = array(); }
1586
+ if ( '' == $registered ) { $registered = array(); }
1587
+ if ( '' == $all_users ) { $all_users = array(); }
1588
+
1589
+ $reminderform = false;
1590
+ $urlpath = str_replace("\\", "/", S2PATH);
1591
+ $urlpath = trailingslashit(get_option('siteurl')) . substr($urlpath,strpos($urlpath, "wp-content/"));
1592
+ if ( isset($_GET['s2page']) ) {
1593
+ $page = (int) $_GET['s2page'];
1594
+ } else {
1595
+ $page = 1;
1596
+ }
1597
+
1598
+ if ( isset($_POST['what']) ) {
1599
+ $page = 1;
1600
+ if ( 'all' == $_POST['what'] ) {
1601
+ $what = 'all';
1602
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1603
+ } elseif ( 'public' == $_POST['what'] ) {
1604
+ $what = 'public';
1605
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1606
+ } elseif ( 'confirmed' == $_POST['what'] ) {
1607
+ $what = 'confirmed';
1608
+ $subscribers = $confirmed;
1609
+ } elseif ( 'unconfirmed' == $_POST['what'] ) {
1610
+ $what = 'unconfirmed';
1611
+ $subscribers = $unconfirmed;
1612
+ if ( !empty($subscribers) ) {
1613
+ $reminderemails = implode(",", $subscribers);
1614
+ $reminderform = true;
1615
+ }
1616
+ } elseif ( is_numeric($_POST['what']) ) {
1617
+ $what = intval($_POST['what']);
1618
+ $subscribers = $this->get_registered("cats=$what");
1619
+ } elseif ( 'registered' == $_POST['what'] ) {
1620
+ $what = 'registered';
1621
+ $subscribers = $registered;
1622
+ } elseif ( 'all_users' == $_POST['what'] ) {
1623
+ $what = 'all_users';
1624
+ $subscribers = $all_users;
1625
+ }
1626
+ } elseif ( isset($_GET['what']) ) {
1627
+ if ( 'all' == $_GET['what'] ) {
1628
+ $what = 'all';
1629
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1630
+ } elseif ( 'public' == $_GET['what'] ) {
1631
+ $what = 'public';
1632
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
1633
+ } elseif ( 'confirmed' == $_GET['what'] ) {
1634
+ $what = 'confirmed';
1635
+ $subscribers = $confirmed;
1636
+ } elseif ( 'unconfirmed' == $_GET['what'] ) {
1637
+ $what = 'unconfirmed';
1638
+ $subscribers = $unconfirmed;
1639
+ if ( !empty($subscribers) ) {
1640
+ $reminderemails = implode(",", $subscribers);
1641
+ $reminderform = true;
1642
+ }
1643
+ } elseif ( is_numeric($_GET['what']) ) {
1644
+ $what = intval($_GET['what']);
1645
+ $subscribers = $this->get_registered("cats=$what");
1646
+ } elseif ( 'registered' == $_GET['what'] ) {
1647
+ $what = 'registered';
1648
+ $subscribers = $registered;
1649
+ } elseif ( 'all_users' == $_GET['what'] ) {
1650
+ $what = 'all_users';
1651
+ $subscribers = $all_users;
1652
+ }
1653
+ } else {
1654
+ $what = 'all';
1655
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$all_users);
1656
+ }
1657
+ if ( $_POST['searchterm'] ) {
1658
+ $subscribers = &$result;
1659
+ $what = 'public';
1660
+ }
1661
+
1662
+ if ( !empty($subscribers) ) {
1663
+ natcasesort($subscribers);
1664
+ // Displays a page number strip - adapted from code in Akismet
1665
+ $args['what'] = $what;
1666
+ $total_subscribers = count($subscribers);
1667
+ $total_pages = ceil($total_subscribers / $this->subscribe2_options['entries']);
1668
+ $strip = '';
1669
+ if ( $page > 1 ) {
1670
+ $args['s2page'] = $page - 1;
1671
+ $strip .= '<a class="prev" href="' . clean_url(add_query_arg($args)) . '">&laquo; '. __('Previous Page', 'subscribe2') .'</a>' . "\n";
1672
+ }
1673
+ if ( $total_pages > 1 ) {
1674
+ for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) {
1675
+ if ( $page == $page_num ) {
1676
+ $strip .= "<strong>Page " . $page_num . "</strong>\n";
1677
+ } else {
1678
+ if ( $page_num < 3 || ( $page_num >= $page - 2 && $page_num <= $page + 2 ) || $page_num > $total_pages - 2 ) {
1679
+ $args['s2page'] = $page_num;
1680
+ $strip .= "<a class=\"page-numbers\" href=\"" . clean_url(add_query_arg($args)) . "\">" . $page_num . "</a>\n";
1681
+ $trunc = true;
1682
+ } elseif ( $trunc == true ) {
1683
+ $strip .= "...\n";
1684
+ $trunc = false;
1685
+ }
1686
+ }
1687
+ }
1688
+ }
1689
+ if ( ( $page ) * $this->subscribe2_options['entries'] < $total_subscribers ) {
1690
+ $args['s2page'] = $page + 1;
1691
+ $strip .= "<a class=\"next\" href=\"" . clean_url(add_query_arg($args)) . "\">". __('Next Page', 'subscribe2') . " &raquo;</a>\n";
1692
+ }
1693
+ }
1694
+
1695
+ // show our form
1696
+ echo "<div class=\"wrap\">";
1697
+ screen_icon();
1698
+ echo "<h2>" . __('Manage Subscribers', 'subscribe2') . "</h2>\r\n";
1699
+ echo "<form method=\"post\" action=\"\">\r\n";
1700
+ if ( function_exists('wp_nonce_field') ) {
1701
+ wp_nonce_field('subscribe2-manage_subscribers' . $s2nonce);
1702
+ }
1703
+ echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
1704
+ echo "<p>" . __('Enter addresses, one per line or comma-separated', 'subscribe2') . "<br />\r\n";
1705
+ echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea></p>\r\n";
1706
+ echo "<input type=\"hidden\" name=\"s2_admin\" />\r\n";
1707
+ echo "<p class=\"submit\" style=\"border-top: none;\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
1708
+ echo "&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" /></p>\r\n";
1709
+
1710
+ // subscriber lists
1711
+ echo "<h2>" . __('Current Subscribers', 'subscribe2') . "</h2>\r\n";
1712
+ echo "<br />";
1713
+ $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'));
1714
+ // show the selected subscribers
1715
+ $alternate = '';
1716
+ echo "<table cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">";
1717
+ echo "<tr class=\"alternate\"><td width=\"50%\"><input type=\"text\" name=\"searchterm\" value=\"\" />&nbsp;\r\n";
1718
+ echo "<input type=\"submit\" class=\"button-secondary\" name=\"search\" value=\"" . __('Search Subscribers', 'subscribe2') . "\" /></td>\r\n";
1719
+ if ( $reminderform ) {
1720
+ echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"reminderemails\" value=\"" . $reminderemails . "\" />\r\n";
1721
+ echo "<input type=\"submit\" class=\"button-secondary\" name=\"remind\" value=\"" . __('Send Reminder Email', 'subscribe2') . "\" /></td>\r\n";
1722
+ } else {
1723
+ echo "<td width=\"25%\"></td>";
1724
+ }
1725
+ if ( !empty($subscribers) ) {
1726
+ $exportcsv = implode(",\r\n", $subscribers);
1727
+ echo "<td width=\"25%\" align=\"right\"><input type=\"hidden\" name=\"exportcsv\" value=\"" . $what . "\" />\r\n";
1728
+ echo "<input type=\"submit\" class=\"button-secondary\" name=\"csv\" value=\"" . __('Save Emails to CSV File', 'subscribe2') . "\" /></td>\r\n";
1729
+ }
1730
+ echo "</tr></table>";
1731
+
1732
+ echo "<table class=\"widefat\" cellpadding=\"2\" cellspacing=\"2\">";
1733
+ if ( !empty($subscribers) ) {
1734
+ echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
1735
+ echo "<td align=\"right\">" . $strip . "</td></tr>\r\n";
1736
+ }
1737
+ if ( !empty($subscribers) ) {
1738
+ if ( is_int($this->subscribe2_options['entries']) ) {
1739
+ $subscriber_chunks = array_chunk($subscribers, $this->subscribe2_options['entries']);
1740
+ } else {
1741
+ $subscriber_chunks = array_chunk($subscribers, 25);
1742
+ }
1743
+ $chunk = $page - 1;
1744
+ $subscribers = $subscriber_chunks[$chunk];
1745
+ echo "<tr class=\"alternate\" style=\"height:1.5em;\">\r\n";
1746
+ echo "<td width=\"4%\" align=\"center\">";
1747
+ echo "<img src=\"" . $urlpath . "include/accept.png\" alt=\"&lt;\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" /></td>\r\n";
1748
+ echo "<td width=\"4%\" align=\"center\">";
1749
+ echo "<img src=\"" . $urlpath . "include/exclamation.png\" alt=\"&gt;\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" /></td>\r\n";
1750
+ echo "<td width=\"4%\" align=\"center\">";
1751
+ echo "<img src=\"" . $urlpath . "include/cross.png\" alt=\"X\" title=\"" . __('Delete this email address', 'subscribe2') . "\" /></td><td></td></tr>\r\n";
1752
+ echo "<tr><td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"confirm_checkall\" /></td>\r\n";
1753
+ echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"unconfirm_checkall\" /></td>\r\n";
1754
+ echo "<td align=\"center\"><input type=\"checkbox\" name=\"checkall\" value=\"delete_checkall\" /></td>\r\n";
1755
+ echo "<td align=\"left\"><strong>" . __('Select / Unselect All', 'subscribe2') . "</strong></td></tr>\r\n";
1756
+
1757
+ foreach ( $subscribers as $subscriber ) {
1758
+ echo "<tr class=\"$alternate\" style=\"height:1.5em;\">";
1759
+ echo "<td align=\"center\">\r\n";
1760
+ if ( in_array($subscriber, $confirmed) ) {
1761
+ echo "</td><td align=\"center\">\r\n";
1762
+ echo "<input class=\"unconfirm_checkall\" title=\"" . __('Unconfirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"unconfirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
1763
+ echo "<td align=\"center\">\r\n";
1764
+ echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
1765
+ echo "</td>\r\n";
1766
+ echo "<td><span style=\"color:#006600\">&#x221A;&nbsp;&nbsp;</span><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a>\r\n";
1767
+ echo "(<span style=\"color:#006600\"><abbr title=\"" . $this->signup_ip($subscriber) . "\">" . $this->signup_date($subscriber) . "</abbr></span>)\r\n";
1768
+ } elseif ( in_array($subscriber, $unconfirmed) ) {
1769
+ echo "<input class=\"confirm_checkall\" title=\"" . __('Confirm this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"confirm[]\" value=\"" . $subscriber . "\" /></td>\r\n";
1770
+ echo "<td align=\"center\"></td>\r\n";
1771
+ echo "<td align=\"center\">\r\n";
1772
+ echo "<input class=\"delete_checkall\" title=\"" . __('Delete this email address', 'subscribe2') . "\" type=\"checkbox\" name=\"delete[]\" value=\"" . $subscriber . "\" />\r\n";
1773
+ echo "</td>\r\n";
1774
+ echo "<td><span style=\"color:#FF0000\">&nbsp;!&nbsp;&nbsp;&nbsp;</span><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a>\r\n";
1775
+ echo "(<span style=\"color:#FF0000\"><abbr title=\"" . $this->signup_ip($subscriber) . "\">" . $this->signup_date($subscriber) . "</abbr></span>)\r\n";
1776
+ } elseif ( in_array($subscriber, $all_users) ) {
1777
+ echo "</td><td align=\"center\"></td><td align=\"center\"></td>\r\n";
1778
+ echo "<td><span style=\"color:#006600\">&reg;&nbsp;&nbsp;</span><a href=\"mailto:" . $subscriber . "\">" . $subscriber . "</a>\r\n";
1779
+ echo "(<a href=\"" . get_option('siteurl') . "/wp-admin/users.php?page=s2_users&amp;email=" . urlencode($subscriber) . "\">" . __('edit', 'subscribe2') . "</a>)\r\n";
1780
+ }
1781
+ echo "</td></tr>\r\n";
1782
+ ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
1783
+ }
1784
+ } else {
1785
+ if ( $_POST['searchterm'] ) {
1786
+ echo "<tr><td align=\"center\"><b>" . __('No matching subscribers found', 'subscribe2') . "</b></td></tr>\r\n";
1787
+ } else {
1788
+ echo "<tr><td align=\"center\"><b>" . __('NONE', 'subscribe2') . "</b></td></tr>\r\n";
1789
+ }
1790
+ }
1791
+ if ( !empty($subscribers) ) {
1792
+ echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" class=\"button-secondary\" name=\"process\" value=\"" . __('Process', 'subscribe2') . "\" /></td>\r\n";
1793
+ echo "<td align=\"right\">" . $strip . "</td></tr>\r\n";
1794
+ }
1795
+ echo "</table>\r\n";
1796
+
1797
+ // show bulk managment form if filtered in some Registered Users
1798
+ if ( in_array($what, array('registered', 'all_users')) || is_numeric($what) ) {
1799
+ $subscribers_string = implode(',', $subscribers);
1800
+ echo "<h2>" . __('Categories', 'subscribe2') . "</h2>\r\n";
1801
+ echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
1802
+ echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
1803
+ echo "<br />" . __('Action to perform', 'subscribe2') . ":\r\n";
1804
+ echo "<label><input type=\"radio\" name=\"manage\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1805
+ echo "<label><input type=\"radio\" name=\"manage\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . "</label><br /><br />\r\n";
1806
+ echo "<input type=\"hidden\" name=\"emails\" value=\"$subscribers_string\" />\r\n";
1807
+ $this->display_category_form();
1808
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_categories\" value=\"" . __('Bulk Update Categories', 'subscribe2') . "\" /></p>";
1809
+
1810
+ echo "<br />" . __('Send email as', 'subscribe2') . ":\r\n";
1811
+ echo "<label><input type=\"radio\" name=\"format\" value=\"html\" /> " . __('HTML - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1812
+ echo "<label><input type=\"radio\" name=\"format\" value=\"html_excerpt\" /> " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1813
+ echo "<label><input type=\"radio\" name=\"format\" value=\"post\" /> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
1814
+ echo "<label><input type=\"radio\" name=\"format\" value=\"excerpt\" checked=\"checked\" /> " . __('Plain Text - Excerpt', 'subscribe2') . "</label>\r\n";
1815
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_format\" value=\"" . __('Bulk Update Format', 'subscribe2') . "\" /></p>";
1816
+ }
1817
+ echo "</form></div>\r\n";
1818
+
1819
+ include(ABSPATH . 'wp-admin/admin-footer.php');
1820
+ // just to be sure
1821
+ die;
1822
+ } // end manage_menu()
1823
+
1824
+ /**
1825
+ Our options page
1826
+ */
1827
+ function options_menu() {
1828
+ global $s2nonce, $wpdb;
1829
+
1830
+ // send error message if no WordPress page exists
1831
+ $sql = "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1";
1832
+ $id = $wpdb->get_var($sql);
1833
+ if ( empty($id) ) {
1834
+ echo "<div id=\"message\" class=\"error\"><p><strong>$this->no_page</strong></p></div>";
1835
+ }
1836
+
1837
+ // was anything POSTed?
1838
+ if ( isset( $_POST['s2_admin']) ) {
1839
+ check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
1840
+ if ( $_POST['reset'] ) {
1841
+ $this->reset();
1842
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_reset</strong></p></div>";
1843
+ } elseif ( $_POST['preview'] ) {
1844
+ global $user_email;
1845
+ $this->preview_email = true;
1846
+ if ( 'never' == $this->subscribe2_options['email_freq'] ) {
1847
+ $post = get_posts('numberposts=1');
1848
+ $this->publish($post[0], $user_email);
1849
+ } else {
1850
+ $this->subscribe2_cron($user_email);
1851
+ }
1852
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Preview message(s) sent to logged in user', 'subscribe2') . "</strong></p></div>";
1853
+ } elseif ( $_POST['resend'] ) {
1854
+ $status = $this->subscribe2_cron('', 'resend');
1855
+ if ( $status === false ) {
1856
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('The Digest Notification email contained no post information. No email was sent', 'subscribe2') . "</strong></p></div>";
1857
+ } else {
1858
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Attempt made to resend the Digest Notification email', 'subscribe2') . "</strong></p></div>";
1859
+ }
1860
+ } elseif ( $_POST['submit'] ) {
1861
+ // BCClimit
1862
+ if ( is_numeric($_POST['bcc']) && $_POST['bcc'] >= 0 ) {
1863
+ $this->subscribe2_options['bcclimit'] = $_POST['bcc'];
1864
+ }
1865
+ // admin_email
1866
+ $this->subscribe2_options['admin_email'] = $_POST['admin_email'];
1867
+
1868
+ // send as author or admin?
1869
+ $sender = 'author';
1870
+ if ( is_numeric($_POST['sender']) ) {
1871
+ $sender = $_POST['sender'];
1872
+ }
1873
+ $this->subscribe2_options['sender'] = $sender;
1874
+
1875
+ // send email for pages, private and password protected posts
1876
+ $this->subscribe2_options['stylesheet'] = $_POST['stylesheet'];
1877
+ $this->subscribe2_options['pages'] = $_POST['pages'];
1878
+ $this->subscribe2_options['password'] = $_POST['password'];
1879
+ $this->subscribe2_options['private'] = $_POST['private'];
1880
+ $this->subscribe2_options['cron_order'] = $_POST['cron_order'];
1881
+
1882
+ // send per-post or digest emails
1883
+ $email_freq = $_POST['email_freq'];
1884
+ $scheduled_time = wp_next_scheduled('s2_digest_cron');
1885
+ if ( $email_freq != $this->subscribe2_options['email_freq'] || $_POST['hour'] != date('H', $scheduled_time) ) {
1886
+ $this->subscribe2_options['email_freq'] = $email_freq;
1887
+ wp_clear_scheduled_hook('s2_digest_cron');
1888
+ $scheds = (array)wp_get_schedules();
1889
+ $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int) $scheds[$email_freq]['interval'] : 0;
1890
+ if ( $interval == 0 ) {
1891
+ // if we are on per-post emails remove last_cron entry
1892
+ unset($this->subscribe2_options['last_s2cron']);
1893
+ } else {
1894
+ // if we are using digest schedule the event and prime last_cron as now
1895
+ $time = time() + $interval;
1896
+ if ( $interval < 86400 ) {
1897
+ // Schedule CRON events occurring less than daily starting now and periodically thereafter
1898
+ $maybe_time = mktime($_POST['hour'], 0, 0, date('m', time()), date('d', time()), date('Y', time()));
1899
+ // is maybe_time in the future
1900
+ $offset = $maybe_time - time();
1901
+ // is maybe_time + $interval in the future
1902
+ $offset2 = ($maybe_time + $interval) - time();
1903
+ if ( $offset < 0 ) {
1904
+ if ( $offset2 < 0 ) {
1905
+ $timestamp = &$time;
1906
+ } else {
1907
+ $timestamp = $maybe_time + $interval;
1908
+ }
1909
+ } else {
1910
+ $timestamp = &$maybe_time;
1911
+ }
1912
+ } else {
1913
+ // Schedule other CRON events starting at user defined hour and periodically thereafter
1914
+ $timestamp = mktime($_POST['hour'], 0, 0, date('m', $time), date('d', $time), date('Y', $time));
1915
+ }
1916
+ wp_schedule_event($timestamp, $email_freq, 's2_digest_cron');
1917
+ if ( !isset($this->subscribe2_options['last_s2cron']) ) {
1918
+ $this->subscribe2_options['last_s2cron'] = current_time('mysql');
1919
+ }
1920
+ }
1921
+ }
1922
+
1923
+ // email subject and body templates
1924
+ // ensure that are not empty before updating
1925
+ if ( !empty($_POST['notification_subject']) ) {
1926
+ $this->subscribe2_options['notification_subject'] = $_POST['notification_subject'];
1927
+ }
1928
+ if ( !empty($_POST['mailtext']) ) {
1929
+ $this->subscribe2_options['mailtext'] = $_POST['mailtext'];
1930
+ }
1931
+ if ( !empty($_POST['confirm_subject']) ) {
1932
+ $this->subscribe2_options['confirm_subject'] = $_POST['confirm_subject'];
1933
+ }
1934
+ if ( !empty($_POST['confirm_email']) ) {
1935
+ $this->subscribe2_options['confirm_email'] = $_POST['confirm_email'];
1936
+ }
1937
+ if ( !empty($_POST['remind_subject']) ) {
1938
+ $this->subscribe2_options['remind_subject'] = $_POST['remind_subject'];
1939
+ }
1940
+ if ( !empty($_POST['remind_email']) ) {
1941
+ $this->subscribe2_options['remind_email'] = $_POST['remind_email'];
1942
+ }
1943
+
1944
+ // excluded categories
1945
+ if ( !empty($_POST['category']) ) {
1946
+ $exclude_cats = implode(',', $_POST['category']);
1947
+ } else {
1948
+ $exclude_cats = '';
1949
+ }
1950
+ $this->subscribe2_options['exclude'] = $exclude_cats;
1951
+ // allow override?
1952
+ ( isset($_POST['reg_override']) ) ? $override = '1' : $override = '0';
1953
+ $this->subscribe2_options['reg_override'] = $override;
1954
+
1955
+ // default WordPress page where Subscribe2 token is placed
1956
+ if ( is_numeric($_POST['page']) && $_POST['page'] >= 0 ) {
1957
+ $this->subscribe2_options['s2page'] = $_POST['page'];
1958
+ }
1959
+
1960
+ // Number of subscriber per page
1961
+ if ( is_numeric($_POST['entries']) && $_POST['entries'] > 0 ) {
1962
+ $this->subscribe2_options['entries'] = (int)$_POST['entries'];
1963
+ }
1964
+
1965
+ // show meta link?
1966
+ ( $_POST['show_meta'] == '1' ) ? $showmeta = '1' : $showmeta = '0';
1967
+ $this->subscribe2_options['show_meta'] = $showmeta;
1968
+
1969
+ // show button?
1970
+ ( $_POST['show_button'] == '1' ) ? $showbutton = '1' : $showbutton = '0';
1971
+ $this->subscribe2_options['show_button'] = $showbutton;
1972
+
1973
+ // show widget in Presentation->Widgets
1974
+ ( $_POST['widget'] == '1' ) ? $showwidget = '1' : $showwidget = '0';
1975
+ $this->subscribe2_options['widget'] = $showwidget;
1976
+
1977
+ // show counterwidget in Presentation->Widgets
1978
+ ( $_POST['counterwidget'] == '1' ) ? $showcounterwidget = '1' : $showcounterwidget = '0';
1979
+ $this->subscribe2_options['counterwidget'] = $showcounterwidget;
1980
+
1981
+ // Subscribe2 over ride postmeta checked by default
1982
+ ( $_POST['s2meta_default'] == '1' ) ? $s2meta_default = '1' : $s2meta_default = '0';
1983
+ $this->subscribe2_options['s2meta_default'] = $s2meta_default;
1984
+
1985
+ //automatic subscription
1986
+ $this->subscribe2_options['autosub'] = $_POST['autosub'];
1987
+ $this->subscribe2_options['newreg_override'] = $_POST['newreg_override'];
1988
+ $this->subscribe2_options['wpregdef'] = $_POST['wpregdef'];
1989
+ $this->subscribe2_options['autoformat'] = $_POST['autoformat'];
1990
+ $this->subscribe2_options['show_autosub'] = $_POST['show_autosub'];
1991
+ $this->subscribe2_options['autosub_def'] = $_POST['autosub_def'];
1992
+
1993
+ //barred domains
1994
+ $this->subscribe2_options['barred'] = $_POST['barred'];
1995
+
1996
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>$this->options_saved</strong></p></div>";
1997
+ update_option('subscribe2_options', $this->subscribe2_options);
1998
+ }
1999
+ }
2000
+ // show our form
2001
+ echo "<div class=\"wrap\">";
2002
+ screen_icon();
2003
+ echo "<h2>" . __('Subscribe2 Settings', 'subscribe2') . "</h2>\r\n";
2004
+ echo "<a href=\"http://subscribe2.wordpress.com/\">" . __('Plugin Blog', 'subscribe2') . "</a> | ";
2005
+ echo "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904\">" . __('Make a donation via PayPal', 'subscribe2') . "</a>";
2006
+ echo "<form method=\"post\" action=\"\">\r\n";
2007
+ if ( function_exists('wp_nonce_field') ) {
2008
+ wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
2009
+ }
2010
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
2011
+ echo "<input type=\"hidden\" id=\"jsbcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" />";
2012
+ echo "<input type=\"hidden\" id=\"jspage\" value=\"" . $this->subscribe2_options['s2page'] . "\" />";
2013
+ echo "<input type=\"hidden\" id=\"jsentries\" value=\"" . $this->subscribe2_options['entries'] . "\" />";
2014
+
2015
+ // settings for outgoing emails
2016
+ echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
2017
+ echo __('Restrict the number of recipients per email to (0 for unlimited)', 'subscribe2') . ': ';
2018
+ echo "<span id=\"s2bcc_1\"><span id=\"s2bcc\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['bcclimit'] . "</span> ";
2019
+ echo "<a href=\"#\" onclick=\"s2_show('bcc'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
2020
+ echo "<span id=\"s2bcc_2\">\r\n";
2021
+ echo "<input type=\"text\" name=\"bcc\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" size=\"3\" />\r\n";
2022
+ echo "<a href=\"#\" onclick=\"s2_update('bcc'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
2023
+ echo "<a href=\"#\" onclick=\"s2_revert('bcc'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
2024
+
2025
+ echo "<br /><br />" . __('Send Admins notifications for new', 'subscribe2') . ': ';
2026
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"subs\"";
2027
+ if ( 'subs' == $this->subscribe2_options['admin_email'] ) {
2028
+ echo " checked=\"checked\"";
2029
+ }
2030
+ echo " /> " . __('Subscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
2031
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"unsubs\"";
2032
+ if ( 'unsubs' == $this->subscribe2_options['admin_email'] ) {
2033
+ echo " checked=\"checked\"";
2034
+ }
2035
+ echo " /> " . __('Unsubscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
2036
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"both\"";
2037
+ if ( 'both' == $this->subscribe2_options['admin_email'] ) {
2038
+ echo " checked=\"checked\"";
2039
+ }
2040
+ echo " /> " . __('Both', 'subscribe2') . "</label>&nbsp;&nbsp;";
2041
+ echo "<label><input type=\"radio\" name=\"admin_email\" value=\"none\"";
2042
+ if ( 'none' == $this->subscribe2_options['admin_email'] ) {
2043
+ echo " checked=\"checked\"";
2044
+ }
2045
+ echo " /> " . __('Neither', 'subscribe2') . "</label><br /><br />\r\n";
2046
+
2047
+ echo __('Include theme CSS stylesheet in HTML notifications', 'subscribe2') . ': ';
2048
+ echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"yes\"";
2049
+ if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
2050
+ echo " checked=\"checked\"";
2051
+ }
2052
+ echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2053
+ echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"no\"";
2054
+ if ( 'no' == $this->subscribe2_options['stylesheet'] ) {
2055
+ echo " checked=\"checked\"";
2056
+ }
2057
+ echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2058
+
2059
+ echo __('Send Emails for Pages', 'subscribe2') . ': ';
2060
+ echo "<label><input type=\"radio\" name=\"pages\" value=\"yes\"";
2061
+ if ( 'yes' == $this->subscribe2_options['pages'] ) {
2062
+ echo " checked=\"checked\"";
2063
+ }
2064
+ echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2065
+ echo "<label><input type=\"radio\" name=\"pages\" value=\"no\"";
2066
+ if ( 'no' == $this->subscribe2_options['pages'] ) {
2067
+ echo " checked=\"checked\"";
2068
+ }
2069
+ echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2070
+ echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
2071
+ echo "<label><input type=\"radio\" name=\"password\" value=\"yes\"";
2072
+ if ( 'yes' == $this->subscribe2_options['password'] ) {
2073
+ echo " checked=\"checked\"";
2074
+ }
2075
+ echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2076
+ echo "<label><input type=\"radio\" name=\"password\" value=\"no\"";
2077
+ if ( 'no' == $this->subscribe2_options['password'] ) {
2078
+ echo " checked=\"checked\"";
2079
+ }
2080
+ echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2081
+ echo __('Send Emails for Private Posts', 'subscribe2') . ': ';
2082
+ echo "<label><input type=\"radio\" name=\"private\" value=\"yes\"";
2083
+ if ( 'yes' == $this->subscribe2_options['private'] ) {
2084
+ echo " checked=\"checked\"";
2085
+ }
2086
+ echo " /> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2087
+ echo "<label><input type=\"radio\" name=\"private\" value=\"no\"";
2088
+ if ( 'no' == $this->subscribe2_options['private'] ) {
2089
+ echo " checked=\"checked\"";
2090
+ }
2091
+ echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2092
+ echo __('Send Email From', 'subscribe2') . ': ';
2093
+ echo "<label>\r\n";
2094
+ $this->admin_dropdown(true);
2095
+ echo "</label><br /><br />\r\n";
2096
+ if ( function_exists('wp_schedule_event') ) {
2097
+ echo __('Send Emails', 'subscribe2') . ": <br /><br />\r\n";
2098
+ $this->display_digest_choices();
2099
+ echo __('For digest notifications, date order for posts is', 'subscribe2') . ": \r\n";
2100
+ echo "<label><input type=\"radio\" name=\"cron_order\" value=\"desc\"";
2101
+ if ( 'desc' == $this->subscribe2_options['cron_order'] ) {
2102
+ echo " checked=\"checked\"";
2103
+ }
2104
+ echo " /> " . __('Descending', 'subscribe2') . "</label>&nbsp;&nbsp;";
2105
+ echo "<label><input type=\"radio\" name=\"cron_order\" value=\"asc\"";
2106
+ if ( 'asc' == $this->subscribe2_options['cron_order'] ) {
2107
+ echo " checked=\"checked\"";
2108
+ }
2109
+ echo " /> " . __('Ascending', 'subscribe2') . "</label><br /><br />\r\n";
2110
+ }
2111
+
2112
+ // email templates
2113
+ echo "<h2>" . __('Email Templates', 'subscribe2') . "</h2>\r\n";
2114
+ echo"<br />";
2115
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"1\" class=\"editform\">\r\n";
2116
+ echo "<tr><td>";
2117
+ echo __('New Post email (must not be empty)', 'subscribe2') . ":<br />\r\n";
2118
+ echo __('Subject Line', 'subscribe2') . ": ";
2119
+ echo "<input type=\"text\" name=\"notification_subject\" value=\"" . stripslashes($this->subscribe2_options['notification_subject']) . "\" size=\"30\" />";
2120
+ echo "<br />\r\n";
2121
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea><br /><br />\r\n";
2122
+ echo "</td><td valign=\"top\" rowspan=\"3\">";
2123
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Send Email Preview', 'subscribe2') . "\" /></p>\r\n";
2124
+ echo "<h3>" . __('Message substitions', 'subscribe2') . "</h3>\r\n";
2125
+ echo "<dl>";
2126
+ echo "<dt><b>BLOGNAME</b></dt><dd>" . get_option('blogname') . "</dd>\r\n";
2127
+ echo "<dt><b>BLOGLINK</b></dt><dd>" . get_option('home') . "</dd>\r\n";
2128
+ echo "<dt><b>TITLE</b></dt><dd>" . __("the post's title<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2129
+ 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";
2130
+ echo "<dt><b>POSTTIME</b></dt><dd>" . __("the excerpt of the post and the time it was posted<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2131
+ echo "<dt><b>TABLE</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2132
+ echo "<dt><b>TABLELINKS</b></dt><dd>" . __("a list of post titles followed by links to the atricles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2133
+ echo "<dt><b>PERMALINK</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2134
+ echo "<dt><b>TINYLINK</b></dt><dd>" . __("the post's permalink after conversion by TinyURL<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
2135
+ echo "<dt><b>DATE</b></dt><dd>" . __("the date the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
2136
+ echo "<dt><b>TIME</b></dt><dd>" . __("the time the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
2137
+ echo "<dt><b>MYNAME</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
2138
+ echo "<dt><b>EMAIL</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
2139
+ echo "<dt><b>AUTHORNAME</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
2140
+ 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";
2141
+ 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";
2142
+ echo "<dt><b>CATS</b></dt><dd>" . __("the post's assigned categories", 'subscribe2') . "</dd>\r\n";
2143
+ echo "<dt><b>TAGS</b></dt><dd>" . __("the post's assigned Tags", 'subscribe2') . "</dd>\r\n";
2144
+ echo "<dt><b>COUNT</b></dt><dd>" . __("the number of posts included in the digest email<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
2145
+ echo "</dl></td></tr><tr><td>";
2146
+ echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
2147
+ echo __('Subject Line', 'subscribe2') . ": ";
2148
+ echo "<input type=\"text\" name=\"confirm_subject\" value=\"" . stripslashes($this->subscribe2_options['confirm_subject']) . "\" size=\"30\" /><br />\r\n";
2149
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea><br /><br />\r\n";
2150
+ echo "</td></tr><tr valign=\"top\"><td>";
2151
+ echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
2152
+ echo __('Subject Line', 'subscribe2') . ": ";
2153
+ echo "<input type=\"text\" name=\"remind_subject\" value=\"" . stripslashes($this->subscribe2_options['remind_subject']) . "\" size=\"30\" /><br />\r\n";
2154
+ echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
2155
+ echo "</td></tr></table><br />\r\n";
2156
+
2157
+ // excluded categories
2158
+ echo "<h2>" . __('Excluded Categories', 'subscribe2') . "</h2>\r\n";
2159
+ echo"<p>";
2160
+ 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";
2161
+ echo"</p>";
2162
+ $this->display_category_form(explode(',', $this->subscribe2_options['exclude']));
2163
+ echo "<center><label><input type=\"checkbox\" name=\"reg_override\" value=\"1\"";
2164
+ if ( '1' == $this->subscribe2_options['reg_override'] ) {
2165
+ echo " checked=\"checked\"";
2166
+ }
2167
+ echo " /> " . __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</label></center><br />\r\n";
2168
+
2169
+ // Appearance options
2170
+ echo "<h2>" . __('Appearance', 'subscribe2') . "</h2>\r\n";
2171
+ echo"<p>";
2172
+
2173
+ // WordPress page ID where subscribe2 token is used
2174
+ echo __('Set default Subscribe2 page as ID', 'subscribe2') . ': ';
2175
+ echo "<select name=\"page\">\r\n";
2176
+ $this->pages_dropdown($this->subscribe2_options['s2page']);
2177
+ echo "</select>\r\n";
2178
+
2179
+ // Number of subscribers per page
2180
+ echo "<br /><br />" . __('Set the number of Subscribers displayed per page', 'subscribe2') . ': ';
2181
+ echo "<span id=\"s2entries_1\"><span id=\"s2entries\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['entries'] . "</span> ";
2182
+ echo "<a href=\"#\" onclick=\"s2_show('entries'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
2183
+ echo "<span id=\"s2entries_2\">\r\n";
2184
+ echo "<input type=\"text\" name=\"entries\" value=\"" . $this->subscribe2_options['entries'] . "\" size=\"3\" />\r\n";
2185
+ echo "<a href=\"#\" onclick=\"s2_update('entries'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
2186
+ echo "<a href=\"#\" onclick=\"s2_revert('entries'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
2187
+
2188
+ // show link to WordPress page in meta
2189
+ echo "<br /><br /><label><input type=\"checkbox\" name=\"show_meta\" value=\"1\"";
2190
+ if ( '1' == $this->subscribe2_options['show_meta'] ) {
2191
+ echo " checked=\"checked\"";
2192
+ }
2193
+ echo " /> " . __('Show a link to your subscription page in "meta"?', 'subscribe2') . "</label><br /><br />\r\n";
2194
+
2195
+ // show QuickTag button
2196
+ echo "<label><input type=\"checkbox\" name=\"show_button\" value=\"1\"";
2197
+ if ( '1' == $this->subscribe2_options['show_button'] ) {
2198
+ echo " checked=\"checked\"";
2199
+ }
2200
+ echo " /> " . __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "</label><br /><br />\r\n";
2201
+
2202
+ // show Widget
2203
+ echo "<label><input type=\"checkbox\" name=\"widget\" value=\"1\"";
2204
+ if ( '1' == $this->subscribe2_options['widget'] ) {
2205
+ echo " checked=\"checked\"";
2206
+ }
2207
+ echo " /> " . __('Enable Subscribe2 Widget?', 'subscribe2') . "</label><br /><br />\r\n";
2208
+
2209
+ // show Counter Widget
2210
+ echo "<label><input type=\"checkbox\" name=\"counterwidget\" value=\"1\"";
2211
+ if ( '1' == $this->subscribe2_options['counterwidget'] ) {
2212
+ echo " checked=\"checked\"";
2213
+ }
2214
+ echo " /> " . __('Enable Subscribe2 Counter Widget?', 'subscribe2') . "</label><br /><br />\r\n";
2215
+
2216
+ // s2_meta checked by default
2217
+ echo "<label><input type =\"checkbox\" name=\"s2meta_default\" value=\"1\"";
2218
+ if ( "1" == $this->subscribe2_options['s2meta_default'] ) {
2219
+ echo " checked=\"checked\"";
2220
+ }
2221
+ echo " /> " . __('Disable email notifications is checked by default on authoring pages?', 'subscribe2') . "</label>\r\n";
2222
+ echo "</p>";
2223
+
2224
+ //Auto Subscription for new registrations
2225
+ echo "<h2>" . __('Auto Subscribe', 'subscribe2') . "</h2>\r\n";
2226
+ echo"<p>";
2227
+ echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
2228
+ echo "<label><input type=\"radio\" name=\"autosub\" value=\"yes\"";
2229
+ if ( 'yes' == $this->subscribe2_options['autosub'] ) {
2230
+ echo " checked=\"checked\"";
2231
+ }
2232
+ echo " /> " . __('Automatically', 'subscribe2') . "</label>&nbsp;&nbsp;";
2233
+ echo "<label><input type=\"radio\" name=\"autosub\" value=\"wpreg\"";
2234
+ if ( 'wpreg' == $this->subscribe2_options['autosub'] ) {
2235
+ echo " checked=\"checked\"";
2236
+ }
2237
+ echo " /> " . __('Display option on Registration Form', 'subscribe2') . "</label>&nbsp;&nbsp;";
2238
+ echo "<label><input type=\"radio\" name=\"autosub\" value=\"no\"";
2239
+ if ( 'no' == $this->subscribe2_options['autosub'] ) {
2240
+ echo " checked=\"checked\"";
2241
+ }
2242
+ echo " /> " . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2243
+ echo __('Auto-subscribe includes any excluded categories', 'subscribe2') . ":<br />\r\n";
2244
+ echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"yes\"";
2245
+ if ( 'yes' == $this->subscribe2_options['newreg_override'] ) {
2246
+ echo " checked=\"checked\"";
2247
+ }
2248
+ echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2249
+ echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"no\"";
2250
+ if ( 'no' == $this->subscribe2_options['newreg_override'] ) {
2251
+ echo " checked=\"checked\"";
2252
+ }
2253
+ echo " />" . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2254
+ echo __('Registration Form option is checked by default', 'subscribe2') . ":<br />\r\n";
2255
+ echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"yes\"";
2256
+ if ( 'yes' == $this->subscribe2_options['wpregdef'] ) {
2257
+ echo " checked=\"checked\"";
2258
+ }
2259
+ echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2260
+ echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"no\"";
2261
+ if ( 'no' == $this->subscribe2_options['wpregdef'] ) {
2262
+ echo " checked=\"checked\"";
2263
+ }
2264
+ echo " />" . __('No', 'subscribe2') . "</label><br /><br />\r\n";
2265
+ echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
2266
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html\"";
2267
+ if ( 'html' == $this->subscribe2_options['autoformat'] ) {
2268
+ echo "checked=\"checked\" ";
2269
+ }
2270
+ echo "/> " . __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
2271
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html_excerpt\"";
2272
+ if ( 'html_excerpt' == $this->subscribe2_options['autoformat'] ) {
2273
+ echo "checked=\"checked\" ";
2274
+ }
2275
+ echo "/> " . __('HTML - Excerpt', 'subscribe2') ."</label>&nbsp;&nbsp;";
2276
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"post\" ";
2277
+ if ( 'post' == $this->subscribe2_options['autoformat'] ) {
2278
+ echo "checked=\"checked\" ";
2279
+ }
2280
+ echo "/> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
2281
+ echo "<label><input type=\"radio\" name=\"autoformat\" value=\"excerpt\" ";
2282
+ if ( 'excerpt' == $this->subscribe2_options['autoformat'] ) {
2283
+ echo "checked=\"checked\" ";
2284
+ }
2285
+ echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />";
2286
+ echo __('Registered Users have the option to auto-subscribe to new categories', 'subscribe2') . ": <br />\r\n";
2287
+ echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"yes\"";
2288
+ if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
2289
+ echo " checked=\"checked\"";
2290
+ }
2291
+ echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2292
+ echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"no\"";
2293
+ if ( 'no' == $this->subscribe2_options['show_autosub'] ) {
2294
+ echo " checked=\"checked\"";
2295
+ }
2296
+ echo " />" . __('No', 'subscribe2') . "</label>&nbsp;&nbsp;";
2297
+ echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"exclude\"";
2298
+ if ( 'exclude' == $this->subscribe2_options['show_autosub'] ) {
2299
+ echo " checked=\"checked\"";
2300
+ }
2301
+ echo " />" .__('New categories are immediately excluded', 'subscribe2') . "</label><br /><br />";
2302
+ echo __('Option for Registered Users to auto-subscribe to new categories is checked by default', 'subscribe2') . ": <br />\r\n";
2303
+ echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"yes\"";
2304
+ if ( 'yes' == $this->subscribe2_options['autosub_def'] ) {
2305
+ echo " checked=\"checked\"";
2306
+ }
2307
+ echo " />" . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2308
+ echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"no\"";
2309
+ if ( 'no' == $this->subscribe2_options['autosub_def'] ) {
2310
+ echo " checked=\"checked\"";
2311
+ }
2312
+ echo " />" . __('No', 'subscribe2');
2313
+ echo"</label></p>";
2314
+
2315
+ //barred domains
2316
+ echo "<h2>" . __('Barred Domains', 'subscribe2') . "</h2>\r\n";
2317
+ echo"<p>";
2318
+ 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');
2319
+ echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . $this->subscribe2_options['barred'] . "</textarea>";
2320
+ echo"</p>";
2321
+
2322
+ // submit
2323
+ echo "<p class=\"submit\" align=\"center\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p>";
2324
+
2325
+ // reset
2326
+ echo "<h2>" . __('Reset Default', 'subscribe2') . "</h2>\r\n";
2327
+ 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";
2328
+ echo "<p class=\"submit\" align=\"center\">";
2329
+ echo "<input type=\"submit\" id=\"deletepost\" name=\"reset\" value=\"" . __('RESET', 'subscribe2') .
2330
+ "\" />";
2331
+ echo "</p></form></div>\r\n";
2332
+
2333
+ include(ABSPATH . 'wp-admin/admin-footer.php');
2334
+ // just to be sure
2335
+ die;
2336
+ } // end options_menu()
2337
+
2338
+ /**
2339
+ Our profile menu
2340
+ */
2341
+ function user_menu() {
2342
+ global $user_ID, $s2nonce;
2343
+
2344
+ if ( isset($_GET['email']) ) {
2345
+ global $wpdb;
2346
+ $user_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . urldecode($_GET['email']) . "'");
2347
+ } else {
2348
+ get_currentuserinfo();
2349
+ }
2350
+
2351
+ // was anything POSTed?
2352
+ if ( isset($_POST['s2_admin']) && 'user' == $_POST['s2_admin'] ) {
2353
+ check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
2354
+
2355
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
2356
+ update_usermeta($user_ID, 's2_format', $_POST['s2_format']);
2357
+ update_usermeta($user_ID, 's2_autosub', $_POST['new_category']);
2358
+
2359
+ $cats = $_POST['category'];
2360
+
2361
+ if ( empty($cats) || $cats == '-1' ) {
2362
+ $oldcats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
2363
+ if ( $oldcats ) {
2364
+ foreach ( $oldcats as $cat ) {
2365
+ delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat);
2366
+ }
2367
+ }
2368
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
2369
+ } elseif ( $cats == 'digest' ) {
2370
+ $all_cats = get_categories(array('hide_empty' => false));
2371
+ foreach ( $all_cats as $cat ) {
2372
+ ('' == $catids) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
2373
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
2374
+ }
2375
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $catids);
2376
+ } else {
2377
+ if ( !is_array($cats) ) {
2378
+ $cats = array($_POST['category']);
2379
+ }
2380
+ $old_cats = explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')));
2381
+ $remove = array_diff($old_cats, $cats);
2382
+ $new = array_diff($cats, $old_cats);
2383
+ if ( !empty($remove) ) {
2384
+ // remove subscription to these cat IDs
2385
+ foreach ( $remove as $id ) {
2386
+ delete_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
2387
+ }
2388
+ }
2389
+ if ( !empty($new) ) {
2390
+ // add subscription to these cat IDs
2391
+ foreach ( $new as $id ) {
2392
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
2393
+ }
2394
+ }
2395
+ update_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $cats));
2396
+ }
2397
+ }
2398
+
2399
+ // show our form
2400
+ echo "<div class=\"wrap\">";
2401
+ screen_icon();
2402
+ echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
2403
+ if ( isset($_GET['email']) ) {
2404
+ $user = get_userdata($user_ID);
2405
+ echo "<span style=\"color: red;line-height: 300%;\">" . __('Editing Subscribe2 preferences for user', 'subscribe2') . ": " . $user->display_name . "</span>";
2406
+ }
2407
+ echo "<form method=\"post\" action=\"\">";
2408
+ echo "<p>";
2409
+ if ( function_exists('wp_nonce_field') ) {
2410
+ wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
2411
+ }
2412
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
2413
+ if ( $this->subscribe2_options['email_freq'] == 'never' ) {
2414
+ echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
2415
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html\"";
2416
+ if ( 'html' == get_usermeta($user_ID, 's2_format') ) {
2417
+ echo "checked=\"checked\" ";
2418
+ }
2419
+ echo "/> " . __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
2420
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html_excerpt\" ";
2421
+ if ( 'html_excerpt' == get_usermeta($user_ID, 's2_format') ) {
2422
+ echo "checked=\"checked\" ";
2423
+ }
2424
+ echo "/> " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;";
2425
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"post\" ";
2426
+ if ( 'post' == get_usermeta($user_ID, 's2_format') ) {
2427
+ echo "checked=\"checked\" ";
2428
+ }
2429
+ echo "/> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
2430
+ echo "<label><input type=\"radio\" name=\"s2_format\" value=\"excerpt\" ";
2431
+ if ( 'excerpt' == get_usermeta($user_ID, 's2_format') ) {
2432
+ echo "checked=\"checked\" ";
2433
+ }
2434
+ echo "/> " . __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />\r\n";
2435
+
2436
+ if ( $this->subscribe2_options['show_autosub'] == 'yes' ) {
2437
+ echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
2438
+ echo "<label><input type=\"radio\" name=\"new_category\" value=\"yes\" ";
2439
+ if ( 'yes' == get_usermeta($user_ID, 's2_autosub') ) {
2440
+ echo "checked=\"checked\" ";
2441
+ }
2442
+ echo "/> " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
2443
+ echo "<label><input type=\"radio\" name=\"new_category\" value=\"no\" ";
2444
+ if ( 'no' == get_usermeta($user_ID, 's2_autosub') ) {
2445
+ echo "checked=\"checked\" ";
2446
+ }
2447
+ echo "/> " . __('No', 'subscribe2') . "</label>";
2448
+ echo "</p>";
2449
+ }
2450
+
2451
+ // subscribed categories
2452
+ if ( $this->s2_mu ) {
2453
+ global $blog_id;
2454
+ $subscribed = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
2455
+ // if we are subscribed to the current blog display an "unsubscribe" link
2456
+ if ( !empty($subscribed) ) {
2457
+ $unsubscribe_link = get_option('home') . "/wp-admin/?s2mu_unsubscribe=". $blog_id;
2458
+ echo "<p><a href=\"". $unsubscribe_link ."\" class=\"button\">" . __('Unsubscribe me from this blog', 'subscribe2') . "</a></p>";
2459
+ } else {
2460
+ // else we show a "subscribe" link
2461
+ $subscribe_link = get_option('home') . "/wp-admin/?s2mu_subscribe=". $blog_id;
2462
+ echo "<p><a href=\"". $subscribe_link ."\" class=\"button\">" . __('Subscribe to all categories', 'subscribe2') . "</a></p>";
2463
+ }
2464
+ echo "<h2>" . __('Subscribed Categories on', 'subscribe2') . " " . get_option('blogname') . " </h2>\r\n";
2465
+ } else {
2466
+ echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
2467
+ }
2468
+ $this->display_category_form(explode(',', get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'))), $this->subscribe2_options['reg_override']);
2469
+ } else {
2470
+ // we're doing daily digests, so just show
2471
+ // subscribe / unnsubscribe
2472
+ echo __('Receive periodic summaries of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
2473
+ echo "<label>";
2474
+ echo "<input type=\"radio\" name=\"category\" value=\"digest\" ";
2475
+ if ( get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')) ) {
2476
+ echo "checked=\"checked\" ";
2477
+ }
2478
+ echo "/> " . __('Yes', 'subscribe2') . "</label> <label><input type=\"radio\" name=\"category\" value=\"-1\" ";
2479
+ if ( !get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed')) ) {
2480
+ echo "checked=\"checked\" ";
2481
+ }
2482
+ echo "/> " . __('No', 'subscribe2');
2483
+ echo "</label></p>";
2484
+ }
2485
+
2486
+ // submit
2487
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __("Update Preferences", 'subscribe2') . " &raquo;\" /></p>";
2488
+ echo "</form>\r\n";
2489
+
2490
+ // list of subscribed blogs on wordpress mu
2491
+ if ( $this->s2_mu && !isset($_GET['email']) ) {
2492
+ global $blog_id;
2493
+ $s2blog_id = $blog_id;
2494
+ $blogs = $this->get_mu_blog_list();
2495
+
2496
+ $blogs_subscribed = array();
2497
+ $blogs_notsubscribed = array();
2498
+
2499
+ foreach ( $blogs as $key => $blog ) {
2500
+ // switch to blog
2501
+ switch_to_blog($blog['blog_id']);
2502
+
2503
+ // check that the plugin is active on the current blog
2504
+ $current_plugins = get_option('active_plugins');
2505
+ if ( !is_array($current_plugins) ) {
2506
+ $current_plugins = (array)$current_plugins;
2507
+ }
2508
+ if ( !in_array(S2DIR . '/subscribe2.php', $current_plugins) ) {
2509
+ continue;
2510
+ }
2511
+
2512
+ // check if we're subscribed to the blog
2513
+ $subscribed = get_usermeta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
2514
+
2515
+ $blogname = get_option('blogname');
2516
+ if ( strlen($blogname) > 30 ) {
2517
+ $blog['blogname'] = wp_html_excerpt($blogname, 30) . "..";
2518
+ } else {
2519
+ $blog['blogname'] = $blogname;
2520
+ }
2521
+ $blog['description'] = get_option('blogdescription');
2522
+ $blog['blogurl'] = get_option('home');
2523
+ $blog['subscribe_page'] = get_option('home') . "/wp-admin/users.php?page=s2_users";
2524
+
2525
+ $key = strtolower($blog['blogname'] . "-" . $blog['blog_id']);
2526
+ if ( !empty($subscribed) ) {
2527
+ $blogs_subscribed[$key] = $blog;
2528
+ } else {
2529
+ $blogs_notsubscribed[$key] = $blog;
2530
+ }
2531
+ restore_current_blog();
2532
+ }
2533
+
2534
+ if ( !empty($blogs_subscribed) ) {
2535
+ ksort($blogs_subscribed);
2536
+ echo "<h2>" . __('Subscribed Blogs', 'subscribe2') . "</h2>\r\n";
2537
+ echo "<ul class=\"s2_blogs\">\r\n";
2538
+ foreach ( $blogs_subscribed as $blog ) {
2539
+ echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
2540
+ if ( $s2blog_id == $blog['blog_id'] ) {
2541
+ echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
2542
+ } else {
2543
+ echo "<span class=\"buttons\">";
2544
+ if ( is_blog_user($blog['blog_id']) ) {
2545
+ echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
2546
+ }
2547
+ echo "<a href=\"" . $blog['blogurl'] . "/wp-admin/?s2mu_unsubscribe=" . $blog['blog_id'] . "\">" . __('Unsubscribe', 'subscribe2') . "</a></span>\r\n";
2548
+ }
2549
+ echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
2550
+ echo "</li>";
2551
+ }
2552
+ echo "</ul>\r\n";
2553
+ }
2554
+
2555
+ if ( !empty($blogs_notsubscribed) ) {
2556
+ ksort($blogs_notsubscribed);
2557
+ echo "<h2>" . __('Subscribe to new blogs', 'subscribe2') . "</h2>\r\n";
2558
+ echo "<ul class=\"s2_blogs\">";
2559
+ foreach ( $blogs_notsubscribed as $blog ) {
2560
+ echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
2561
+ if ( $s2blog_id == $blog['blog_id'] ) {
2562
+ echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
2563
+ } else {
2564
+ echo "<span class=\"buttons\">";
2565
+ if ( is_blog_user($blog['blog_id']) ) {
2566
+ echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
2567
+ }
2568
+ echo "<a href=\"" . $blog['blogurl'] . "/wp-admin/?s2mu_subscribe=" . $blog['blog_id'] . "\">" . __('Subscribe', 'subscribe2') . "</a></span>\r\n";
2569
+ }
2570
+ echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
2571
+ echo "</li>";
2572
+ }
2573
+ echo "</ul>\r\n";
2574
+ }
2575
+ }
2576
+
2577
+ echo "</div>\r\n";
2578
+
2579
+ include(ABSPATH . 'wp-admin/admin-footer.php');
2580
+ // just to be sure
2581
+ die;
2582
+ } // end user_menu()
2583
+
2584
+ /**
2585
+ Display the Write sub-menu
2586
+ */
2587
+ function write_menu() {
2588
+ global $wpdb, $s2nonce, $current_user;
2589
+
2590
+ // was anything POSTed?
2591
+ if ( isset($_POST['s2_admin']) && 'mail' == $_POST['s2_admin'] ) {
2592
+ check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
2593
+ $subject = $this->substitute(stripslashes(strip_tags($_POST['subject'])));
2594
+ $body = $this->substitute(stripslashes($_POST['content']));
2595
+ if ( '' != $current_user->display_name || '' != $current_user->user_email ) {
2596
+ $this->myname = html_entity_decode($current_user->display_name, ENT_QUOTES);
2597
+ $this->myemail = $current_user->user_email;
2598
+ }
2599
+ if ( isset($_POST['send']) ) {
2600
+ if ( 'confirmed' == $_POST['what'] ) {
2601
+ $recipients = $this->get_public();
2602
+ } elseif ( 'unconfirmed' == $_POST['what'] ) {
2603
+ $recipients = $this->get_public(0);
2604
+ } elseif ( 'public' == $_POST['what'] ) {
2605
+ $confirmed = $this->get_public();
2606
+ $unconfirmed = $this->get_public(0);
2607
+ $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
2608
+ } elseif ( is_numeric($_POST['what']) ) {
2609
+ $cat = intval($_POST['what']);
2610
+ $recipients = $this->get_registered("cats=$cat");
2611
+ } elseif ( 'all_users' == $_POST['what'] ) {
2612
+ $recipients = $this->get_all_registered();
2613
+ } else {
2614
+ $recipients = $this->get_registered();
2615
+ }
2616
+ } elseif ( isset($_POST['preview']) ) {
2617
+ global $user_email;
2618
+ $recipients[] = $user_email;
2619
+ }
2620
+ $status = $this->mail($recipients, $subject, $body, 'text');
2621
+ if ( $status ) {
2622
+ $message = $this->mail_sent;
2623
+ } else {
2624
+ global $phpmailer;
2625
+ $message = $this->mail_failed . $phpmailer->ErrorInfo;
2626
+ }
2627
+ }
2628
+
2629
+ if ( '' != $message ) {
2630
+ echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
2631
+ }
2632
+ // show our form
2633
+ echo "<div class=\"wrap\">";
2634
+ screen_icon();
2635
+ echo "<h2>" . __('Send an email to subscribers', 'subscribe2') . "</h2>\r\n";
2636
+ echo "<form method=\"post\" action=\"\">\r\n";
2637
+ if ( function_exists('wp_nonce_field') ) {
2638
+ wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
2639
+ }
2640
+ if ( isset($_POST['subject']) ) {
2641
+ $subject = $_POST['subject'];
2642
+ } else {
2643
+ $subject = __('A message from', 'subscribe2') . " " . get_option('blogname');
2644
+ }
2645
+ echo "<p>" . __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . $subject . "\" /> <br /><br />";
2646
+ echo "<textarea rows=\"12\" cols=\"75\" name=\"content\">" . $body . "</textarea>";
2647
+ echo "<br /><br />\r\n";
2648
+ echo __('Recipients:', 'subscribe2') . " ";
2649
+ $this->display_subscriber_dropdown('registered', false, array('all'));
2650
+ echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
2651
+ echo "</p>";
2652
+ echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Preview', 'subscribe2') . "\" \><input type=\"submit\" class=\"button-primary\" name=\"send\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
2653
+ echo "</form></div>\r\n";
2654
+ echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
2655
+
2656
+ include(ABSPATH . 'wp-admin/admin-footer.php');
2657
+ // just to be sure
2658
+ die;
2659
+ } // end write_menu()
2660
+
2661
+ /* ===== helper functions: forms and stuff ===== */
2662
+ /**
2663
+ Display a table of categories with checkboxes
2664
+ Optionally pre-select those categories specified
2665
+ */
2666
+ function display_category_form($selected = array(), $override = 1) {
2667
+ global $wpdb;
2668
+
2669
+ $all_cats = get_categories(array('hide_empty' => false, 'orderby' => 'slug'));
2670
+ $exclude = explode(',', $this->subscribe2_options['exclude']);
2671
+
2672
+ if ( 0 == $override ) {
2673
+ // registered users are not allowed to subscribe to
2674
+ // excluded categories
2675
+ foreach ( $all_cats as $cat => $term_id ) {
2676
+ if ( in_array($all_cats[$cat]->term_id, $exclude) ) {
2677
+ $cat = (int)$cat;
2678
+ unset($all_cats[$cat]);
2679
+ }
2680
+ }
2681
+ }
2682
+
2683
+ $half = (count($all_cats) / 2);
2684
+ $i = 0;
2685
+ $j = 0;
2686
+ echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" class=\"editform\">\r\n";
2687
+ echo "<tr><td align=\"left\" colspan=\"2\">\r\n";
2688
+ echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"cat_checkall\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
2689
+ echo "</td></tr>\r\n";
2690
+ echo "<tr valign=\"top\"><td width=\"50%\" align=\"left\">\r\n";
2691
+ foreach ( $all_cats as $cat ) {
2692
+ if ( $i >= $half && 0 == $j ){
2693
+ echo "</td><td width=\"50%\" align=\"left\">\r\n";
2694
+ $j++;
2695
+ }
2696
+ if ( 0 == $j ) {
2697
+ echo "<label><input class=\"cat_checkall\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
2698
+ if ( in_array($cat->term_id, $selected) ) {
2699
+ echo " checked=\"checked\"";
2700
+ }
2701
+ echo " /> <abbr title=\"" . $cat->slug . "\">" . rtrim(get_category_parents($cat->term_id, false, ' &#187; '), ' &#187; ') . "</abbr></label><br />\r\n";
2702
+ } else {
2703
+ echo "<label><input class=\"cat_checkall\" type=\"checkbox\" name=\"category[]\" value=\"" . $cat->term_id . "\"";
2704
+ if ( in_array($cat->term_id, $selected) ) {
2705
+ echo " checked=\"checked\"";
2706
+ }
2707
+ echo " /> <abbr title=\"" . $cat->slug . "\">" . rtrim(get_category_parents($cat->term_id, false, ' &#187; '), ' &#187; ') . "</abbr></label><br />\r\n";
2708
+ }
2709
+ $i++;
2710
+ }
2711
+ echo "</td></tr>\r\n";
2712
+ echo "</table>\r\n";
2713
+ } // end display_category_form()
2714
+
2715
+ /**
2716
+ Display a drop-down form to select subscribers
2717
+ $selected is the option to select
2718
+ $submit is the text to use on the Submit button
2719
+ */
2720
+ function display_subscriber_dropdown($selected = 'registered', $submit = '', $exclude = array()) {
2721
+ global $wpdb;
2722
+
2723
+ $who = array('all' => __('All Users and Subscribers', 'subscribe2'),
2724
+ 'public' => __('Public Subscribers', 'subscribe2'),
2725
+ 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
2726
+ 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
2727
+ 'all_users' => __('All Registered Users', 'subscribe2'),
2728
+ 'registered' => __('Registered Subscribers', 'subscribe2'));
2729
+
2730
+ $all_cats = get_categories(array('hide_empty' => false));
2731
+
2732
+ // count the number of subscribers
2733
+ $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
2734
+ $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
2735
+ if ( in_array('unconfirmed', $exclude) ) {
2736
+ $count['public'] = $count['confirmed'];
2737
+ } elseif ( in_array('confirmed', $exclude) ) {
2738
+ $count['public'] = $count['unconfirmed'];
2739
+ } else {
2740
+ $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
2741
+ }
2742
+ if ( $this->s2_mu ) {
2743
+ $count['all_users'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
2744
+ } else {
2745
+ $count['all_users'] = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
2746
+ }
2747
+ if ( $this->s2_mu ) {
2748
+ $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities' AND meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
2749
+ } else {
2750
+ $count['registered'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_subscribed') . "'");
2751
+ }
2752
+ $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
2753
+ if ( $this->s2_mu ) {
2754
+ foreach ( $all_cats as $cat ) {
2755
+ $count[$cat->name] = $wpdb->get_var("SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
2756
+ }
2757
+ } else {
2758
+ foreach ( $all_cats as $cat ) {
2759
+ $count[$cat->name] = $wpdb->get_var("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key='" . $this->get_usermeta_keyname('s2_cat') . $cat->term_id . "'");
2760
+ }
2761
+ }
2762
+
2763
+ // do have actually have some subscribers?
2764
+ if ( 0 == $count['confirmed'] && 0 == $count['unconfirmed'] && 0 == $count['all_users'] ) {
2765
+ // no? bail out
2766
+ return;
2767
+ }
2768
+
2769
+ echo "<select name=\"what\">\r\n";
2770
+ foreach ( $who as $whom => $display ) {
2771
+ if ( in_array($whom, $exclude) ) { continue; }
2772
+ if ( 0 == $count[$whom] ) { continue; }
2773
+
2774
+ echo "<option value=\"" . $whom . "\"";
2775
+ if ( $whom == $selected ) { echo " selected=\"selected\" "; }
2776
+ echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
2777
+ }
2778
+
2779
+ if ( $count['registered'] > 0 ) {
2780
+ foreach ( $all_cats as $cat ) {
2781
+ if ( in_array($cat->term_id, $exclude) ) { continue; }
2782
+ echo "<option value=\"" . $cat->term_id . "\"";
2783
+ if ( $cat->term_id == $selected ) { echo " selected=\"selected\" "; }
2784
+ echo "> &nbsp;&nbsp;" . $cat->name . "&nbsp;(" . $count[$cat->name] . ") </option>\r\n";
2785
+ }
2786
+ }
2787
+ echo "</select>";
2788
+ if ( false !== $submit ) {
2789
+ echo "&nbsp;<input type=\"submit\" class=\"button-secondary\" value=\"$submit\" />\r\n";
2790
+ }
2791
+ } // end display_subscriber_dropdown()
2792
+
2793
+ /**
2794
+ Display a drop down lisy of administrator level users and
2795
+ optionally include a choice for Post Author
2796
+ */
2797
+ function admin_dropdown($inc_author = false) {
2798
+ global $wpdb;
2799
+
2800
+ $sql = "SELECT ID, display_name FROM $wpdb->users INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key='" . $wpdb->prefix . "user_level' AND $wpdb->usermeta.meta_value IN (8, 9, 10)";
2801
+ $admins = $wpdb->get_results($sql);
2802
+
2803
+ // handle issues from WordPress core where user_level is not set or set low
2804
+ if ( empty($admins) ) {
2805
+ $role = 'administrator';
2806
+ if ( !class_exists(WP_User_Search) ) {
2807
+ require(ABSPATH . 'wp-admin/includes/user.php');
2808
+ }
2809
+ $wp_user_search = new WP_User_Search( '', '', $role);
2810
+ $admins_string = implode(', ', $wp_user_search->get_results());
2811
+ $sql = "SELECT ID, display_name FROM $wpdb->users WHERE ID IN (" . $admins_string . ")";
2812
+ $admins = $wpdb->get_results($sql);
2813
+ }
2814
+
2815
+ if ( $inc_author ) {
2816
+ $author[] = (object)array('ID' => 'author', 'display_name' => 'Post Author');
2817
+ $admins = array_merge($author, $admins);
2818
+ }
2819
+
2820
+ echo "<select name=\"sender\">\r\n";
2821
+ foreach ( $admins as $admin ) {
2822
+ echo "<option value=\"" . $admin->ID . "\"";
2823
+ if ( $admin->ID == $this->subscribe2_options['sender'] ) {
2824
+ echo " selected=\"selected\"";
2825
+ }
2826
+ echo ">" . $admin->display_name . "</option>\r\n";
2827
+ }
2828
+ echo "</select>\r\n";
2829
+ } // end admin_dropdown()
2830
+
2831
+ /**
2832
+ Display a dropdown of choices for digest email frequency
2833
+ and give user details of timings when event is scheduled
2834
+ */
2835
+ function display_digest_choices() {
2836
+ global $wpdb;
2837
+ $scheduled_time = wp_next_scheduled('s2_digest_cron');
2838
+ $schedule = (array)wp_get_schedules();
2839
+ $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('For each Post', 'subscribe2'))), $schedule);
2840
+ $sort = array();
2841
+ foreach ( (array)$schedule as $key => $value ) {
2842
+ $sort[$key] = $value['interval'];
2843
+ }
2844
+ asort($sort);
2845
+ $schedule_sorted = array();
2846
+ foreach ( $sort as $key => $value ) {
2847
+ $schedule_sorted[$key] = $schedule[$key];
2848
+ }
2849
+ foreach ( $schedule_sorted as $key => $value ) {
2850
+ echo "<label><input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"";
2851
+ if ( $key == $this->subscribe2_options['email_freq'] ) {
2852
+ echo " checked=\"checked\" ";
2853
+ }
2854
+ echo " /> " . $value['display'] . "</label><br />\r\n";
2855
+ }
2856
+ echo "<br />" . __('Send Digest Notification at', 'subscribe2') . ": \r\n";
2857
+ $hours = array('12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am', '10am', '11am', '12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm');
2858
+ echo "<select name=\"hour\">\r\n";
2859
+ while ( $hour = current($hours) ) {
2860
+ echo "<option value=\"" . key($hours) . "\"";
2861
+ if ( key($hours) == date('H', $scheduled_time) && !empty($scheduled_time) ){
2862
+ echo " selected=\"selected\"";
2863
+ }
2864
+ echo ">" . $hour . "</option>\r\n";
2865
+ next($hours);
2866
+ }
2867
+ echo "</select>\r\n";
2868
+ echo "<strong><em style=\"color: red\">" . __('This option will be ignored if the time selected is not in the future in relation to the current time', 'subscribe2') . "</em></strong>\r\n";
2869
+ if ( $scheduled_time ) {
2870
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
2871
+ echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
2872
+ echo "<strong>" . date_i18n($datetime, false, 'gmt') . "</strong></p>\r\n";
2873
+ echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
2874
+ echo "<strong>" . date_i18n($datetime) . "</strong></p>\r\n";
2875
+ echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
2876
+ echo "<strong>" . date_i18n($datetime, $scheduled_time) . "</strong></p>\r\n";
2877
+ if ( !empty($this->subscribe2_options['previous_s2cron']) ) {
2878
+ echo "<p>" . __('Attempt to resend the last Digest Notification email', 'subscribe2') . ": ";
2879
+ echo "<input type=\"submit\" class=\"button-secondary\" name=\"resend\" value=\"" . __('Resend Digest', 'subscribe2') . "\" /></p>\r\n";
2880
+ }
2881
+ } else {
2882
+ echo "<br />";
2883
+ }
2884
+ } // end display_digest_choices()
2885
+
2886
+ /**
2887
+ Create and display a dropdown list of pages
2888
+ */
2889
+ function pages_dropdown($s2page) {
2890
+ global $wpdb;
2891
+ $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
2892
+ $pages = $wpdb->get_results($sql);
2893
+
2894
+ if ( empty($pages) ) { return; }
2895
+
2896
+ $option = '';
2897
+ foreach ( $pages as $page ) {
2898
+ $option .= "<option value=\"" . $page->ID . "\"";
2899
+ if ( $page->ID == $s2page ) {
2900
+ $option .= " selected=\"selected\"";
2901
+ }
2902
+ $option .= ">" . $page->post_title . "</option>\r\n";
2903
+ }
2904
+
2905
+ echo $option;
2906
+ } // end pages_dropdown()
2907
+
2908
+ /**
2909
+ Export subscriber emails and other details to CSV
2910
+ */
2911
+ function prepare_export( $what ) {
2912
+ $confirmed = $this->get_public();
2913
+ $unconfirmed = $this->get_public(0);
2914
+ if ( 'all' == $what ) {
2915
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed, (array)$this->get_all_registered());
2916
+ } elseif ( 'public' == $what ) {
2917
+ $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
2918
+ } elseif ( 'confirmed' == $what ) {
2919
+ $subscribers = $confirmed;
2920
+ } elseif ( 'unconfirmed' == $what ) {
2921
+ $subscribers = $unconfirmed;
2922
+ } elseif ( is_numeric($what) ) {
2923
+ $subscribers = $this->get_registered("cats=$what");
2924
+ } elseif ( 'registered' == $what ) {
2925
+ $subscribers = $this->get_registered();
2926
+ } elseif ( 'all_users' == $what ) {
2927
+ $subscribers = $this->get_all_registered();
2928
+ }
2929
+
2930
+ natcasesort($subscribers);
2931
+
2932
+ $exportcsv = "User Email,User Name";
2933
+ $all_cats = get_categories(array('hide_empty' => false, 'orderby' => 'ID'));
2934
+ foreach ($all_cats as $cat) {
2935
+ $exportcsv .= "," . $cat->cat_name;
2936
+ $cat_ids[] = $cat->term_id;
2937
+ }
2938
+ $exportcsv .= "\r\n";
2939
+
2940
+ foreach ( $subscribers as $subscriber ) {
2941
+ if ( $this->is_registered($subscriber) ) {
2942
+ $user_id = $this->get_user_id( $subscriber );
2943
+ $user_info = get_userdata($user_id);
2944
+
2945
+ $cats = explode(',', get_usermeta($user_info->ID, $this->get_usermeta_keyname('s2_subscribed')));
2946
+ $subscribed_cats = '';
2947
+ foreach ( $cat_ids as $cat ) {
2948
+ (in_array($cat, $cats)) ? $subscribed_cats .= ",Yes" : $subscribed_cats .= ", No";
2949
+ }
2950
+
2951
+ $exportcsv .= $user_info->user_email . ',';
2952
+ $exportcsv .= $user_info->display_name;
2953
+ $exportcsv .= $subscribed_cats . "\r\n";
2954
+ } else {
2955
+ if ( in_array($subscriber, $confirmed) ) {
2956
+ $exportcsv .= $subscriber . ',' . __('Confirmed Public Subscriber', 'subscribe2') . "\r\n";
2957
+ } elseif ( in_array($subscriber, $unconfirmed) ) {
2958
+ $exportcsv .= $subscriber . ',' . __('Unconfirmed Public Subscriber', 'subscribe2') . "\r\n";
2959
+ }
2960
+ }
2961
+ }
2962
+
2963
+ return $exportcsv;
2964
+ } // end prepare_export()
2965
+
2966
+ /**
2967
+ Filter for usermeta table key names to adjust them if needed for WPMU blogs
2968
+ */
2969
+ function get_usermeta_keyname($metaname) {
2970
+ global $wpdb;
2971
+
2972
+ // Is this WordPressMU or not?
2973
+ if ( $this->s2_mu === true ) {
2974
+ switch( $metaname ) {
2975
+ case 's2_subscribed':
2976
+ case 's2_cat':
2977
+ return $wpdb->prefix . $metaname;
2978
+ break;
2979
+ }
2980
+ }
2981
+ // Not MU or not a prefixed option name
2982
+ return $metaname;
2983
+ }
2984
+
2985
+ /**
2986
+ Obtain a list of current WordPress multiuser blogs
2987
+ Note this may affect performance but there is no alternative
2988
+ */
2989
+ function get_mu_blog_list() {
2990
+ global $wpdb;
2991
+ $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
2992
+
2993
+ foreach ( (array) $blogs as $details ) {
2994
+ $blog_list[$details['blog_id']] = $details;
2995
+ }
2996
+
2997
+ if ( false == is_array( $blog_list ) ) {
2998
+ return array();
2999
+ }
3000
+
3001
+ return $blog_list;
3002
+ } // end get_mu_blog_list()
3003
+
3004
+ /**
3005
+ Adds a links directly to the settings page from the plugin page
3006
+ */
3007
+ function plugin_links($links, $file) {
3008
+ if ( $file == S2DIR.'/subscribe2.php' ) {
3009
+ $links[] = "<a href='options-general.php?page=s2_settings'>" . __('Settings', 'subscribe2') . "</a>";
3010
+ $links[] = "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904'><b>" . __('Donate', 'subscribe2') . "</b></a>";
3011
+ }
3012
+ return $links;
3013
+ } // end plugin_links()
3014
+
3015
+ /**
3016
+ Adds information to the WordPress registration screen for new users
3017
+ */
3018
+ function register_form() {
3019
+ if ( 'wpreg' == $this->subscribe2_options['autosub'] ) {
3020
+ echo "<p>\r\n<label>";
3021
+ echo __('Check here to Subscribe to email notifications for new posts', 'subscribe2') . ":<br />\r\n";
3022
+ echo "<input type=\"checkbox\" name=\"subscribe\"";
3023
+ if ( 'yes' == $this->subscribe2_options['wpregdef'] ) {
3024
+ echo " checked=\"checked\"";
3025
+ }
3026
+ echo " /></label>\r\n";
3027
+ echo "</p>\r\n";
3028
+ } elseif ( 'yes' == $this->subscribe2_options['autosub'] ) {
3029
+ echo "<p>\r\n<center>\r\n";
3030
+ echo __('By registering with this blog you are also agreeing to receive email notifications for new posts but you can unsubscribe at anytime', 'subscribe2') . ".<br />\r\n";
3031
+ echo "</center></p>\r\n";
3032
+ }
3033
+ }
3034
+
3035
+ /**
3036
+ Process function to add action if user selects to subscribe to posts during registration
3037
+ */
3038
+ function register_post() {
3039
+ if ( 'on' == $_POST['subscribe'] ) {
3040
+ $user = get_userdatabylogin($_POST['user_login']);
3041
+ if ( 0 == $user->ID ) { return; }
3042
+ $this->register($user->ID);
3043
+ }
3044
+ }
3045
+
3046
+ /**
3047
+ Create meta box on write pages
3048
+ */
3049
+ function s2_meta_init() {
3050
+ add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'post', 'advanced');
3051
+ add_meta_box('subscribe2', __('Subscribe2 Notification Override', 'subscribe2' ), array(&$this, 's2_meta_box'), 'page', 'advanced');
3052
+ } // end s2_meta_init()
3053
+
3054
+ /**
3055
+ Meta box code for WordPress 2.5+
3056
+ */
3057
+ function s2_meta_box() {
3058
+ global $post_ID;
3059
+ $s2mail = get_post_meta($post_ID, 's2mail', true);
3060
+ echo "<input type=\"hidden\" name=\"s2meta_nonce\" id=\"s2meta_nonce\" value=\"" . wp_create_nonce(md5(plugin_basename(__FILE__))) . "\" />";
3061
+ echo __("Check here to disable sending of an email notification for this post/page", 'subscribe2');
3062
+ echo "&nbsp;&nbsp;<input type=\"checkbox\" name=\"s2_meta_field\" value=\"no\"";
3063
+ if ( $s2mail == 'no' || ($this->subscribe2_options['s2meta_default'] == "1" && $s2mail == "") ) {
3064
+ echo " checked=\"checked\"";
3065
+ }
3066
+ echo " />";
3067
+ } // end s2_meta_box()
3068
+
3069
+ /**
3070
+ Meta box form handler
3071
+ */
3072
+ function s2_meta_handler($post_id) {
3073
+ if ( !isset($_POST['s2meta_nonce']) || !wp_verify_nonce($_POST['s2meta_nonce'], md5(plugin_basename(__FILE__))) ) { return $post_id; }
3074
+
3075
+ if ( 'page' == $_POST['post_type'] ) {
3076
+ if ( !current_user_can('edit_page', $post_id) ) { return $post_id; }
3077
+ } else {
3078
+ if ( !current_user_can('edit_post', $post_id) ) { return $post_id; }
3079
+ }
3080
+
3081
+ if ( isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no' ) {
3082
+ update_post_meta($post_id, 's2mail', $_POST['s2_meta_field']);
3083
+ } else {
3084
+ update_post_meta($post_id, 's2mail', 'yes');
3085
+ }
3086
+ } // end s2_meta_box_handler()
3087
+
3088
+ /* ===== template and filter functions ===== */
3089
+ /**
3090
+ Display our form; also handles (un)subscribe requests
3091
+ */
3092
+ function shortcode($atts) {
3093
+ extract(shortcode_atts(array(
3094
+ 'hide' => '',
3095
+ 'id' => '',
3096
+ 'url' => ''
3097
+ ), $atts));
3098
+
3099
+ // if a button is hidden, show only other
3100
+ if ( $hide == 'subscribe' ) {
3101
+ $this->input_form_action = "<input type=\"submit\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" />";
3102
+ } elseif ( $hide == 'unsubscribe' ) {
3103
+ $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
3104
+ } else {
3105
+ // both form input actions
3106
+ $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />&nbsp;<input type=\"submit\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" />";
3107
+ }
3108
+ // if ID is provided, get permalink
3109
+ if ( $id ) {
3110
+ $url = get_permalink( $id );
3111
+ }
3112
+ // build default form
3113
+ $this->form = "<form method=\"post\" action=\"" . $url . "\"><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p>" . __('Your email:', 'subscribe2') . "<br /><input type=\"text\" name=\"email\" value=\"" . __('Enter email address...', 'subscribe2') . "\" size=\"20\" onfocus=\"if (this.value == '" . __('Enter email address...', 'subscribe2') . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . __('Enter email address...', 'subscribe2') . "';}\" /></p><p>" . $this->input_form_action . "</p></form>\r\n";
3114
+ $this->s2form = $this->form;
3115
+
3116
+ global $user_ID;
3117
+ get_currentuserinfo();
3118
+ if ( $user_ID ) {
3119
+ if ( current_user_can('manage_options') ) {
3120
+ $this->s2form = $this->use_profile_admin;
3121
+ } else {
3122
+ $this->s2form = $this->use_profile_users;
3123
+ }
3124
+ }
3125
+ if ( isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) {
3126
+ global $wpdb, $user_email;
3127
+ if ( !is_email($_POST['email']) ) {
3128
+ $this->s2form = $this->form . $this->not_an_email;
3129
+ } elseif ( $this->is_barred($_POST['email']) ) {
3130
+ $this->s2form = $this->form . $this->barred_domain;
3131
+ } else {
3132
+ $this->email = $this->sanitize_email($_POST['email']);
3133
+ $this->ip = $_POST['ip'];
3134
+ // does the supplied email belong to a registered user?
3135
+ $check = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE user_email = '$this->email'");
3136
+ if ( '' != $check ) {
3137
+ // this is a registered email
3138
+ $this->s2form = $this->please_log_in;
3139
+ } else {
3140
+ // this is not a registered email
3141
+ // what should we do?
3142
+ if ( isset($_POST['subscribe']) ) {
3143
+ // someone is trying to subscribe
3144
+ // lets see if they've tried to subscribe previously
3145
+ if ( '1' !== $this->is_public($this->email) ) {
3146
+ // the user is unknown or inactive
3147
+ $this->add();
3148
+ $status = $this->send_confirm('add');
3149
+ // set a variable to denote that we've already run, and shouldn't run again
3150
+ $this->filtered = 1;
3151
+ if ( $status ) {
3152
+ $this->s2form = $this->confirmation_sent;
3153
+ } else {
3154
+ $this->s2form = $this->error;
3155
+ }
3156
+ } else {
3157
+ // they're already subscribed
3158
+ $this->s2form = $this->already_subscribed;
3159
+ }
3160
+ $this->action = 'subscribe';
3161
+ } elseif ( isset($_POST['unsubscribe']) ) {
3162
+ // is this email a subscriber?
3163
+ if ( false == $this->is_public($this->email) ) {
3164
+ $this->s2form = $this->form . $this->not_subscribed;
3165
+ } else {
3166
+ $status = $this->send_confirm('del');
3167
+ // set a variable to denote that we've already run, and shouldn't run again
3168
+ $this->filtered = 1;
3169
+ if ( $status ) {
3170
+ $this->s2form = $this->confirmation_sent;
3171
+ } else {
3172
+ $this->s2form = $this->error;
3173
+ }
3174
+ }
3175
+ $this->action='unsubscribe';
3176
+ }
3177
+ }
3178
+ }
3179
+ }
3180
+ return $this->s2form;
3181
+ } // end shortcode()
3182
+
3183
+ /**
3184
+ Display form when deprecated <!--subscribe2--> is used
3185
+ */
3186
+ function filter($content = '') {
3187
+ if ( '' == $content || !strstr($content, '<!--subscribe2-->') ) { return $content; }
3188
+
3189
+ return preg_replace('|(<p>)?(\n)*<!--subscribe2-->(\n)*(</p>)?|', do_shortcode( '[subscribe2]' ), $content);
3190
+ } // end filter()
3191
+
3192
+ /**
3193
+ Overrides the default query when handling a (un)subscription confirmation
3194
+ This is basically a trick: if the s2 variable is in the query string, just grab the first
3195
+ static page and override it's contents later with title_filter()
3196
+ */
3197
+ function query_filter() {
3198
+ // don't interfere if we've already done our thing
3199
+ if ( 1 == $this->filtered ) { return; }
3200
+
3201
+ global $wpdb;
3202
+
3203
+ if ( 0 != $this->subscribe2_options['s2page'] ) {
3204
+ return "page_id=" . $this->subscribe2_options['s2page'];
3205
+ } else {
3206
+ $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
3207
+ if ( $id ) {
3208
+ return "page_id=$id";
3209
+ } else {
3210
+ return "showposts=1";
3211
+ }
3212
+ }
3213
+ } // end query_filter()
3214
+
3215
+ /**
3216
+ Overrides the page title
3217
+ */
3218
+ function title_filter($title) {
3219
+ // don't interfere if we've already done our thing
3220
+ if ( in_the_loop() ) {
3221
+ return __('Subscription Confirmation', 'subscribe2');
3222
+ } else {
3223
+ return $title;
3224
+ }
3225
+ } // end title_filter()
3226
+
3227
+ /* ===== widget functions ===== */
3228
+ /**
3229
+ Register the form widget
3230
+ */
3231
+ function subscribe2_widget() {
3232
+ require_once( WP_CONTENT_DIR . '/plugins/' . S2DIR . '/include/widget.php');
3233
+ register_widget('S2_Form_widget');
3234
+ } // end subscribe2_widget()
3235
+
3236
+ /**
3237
+ Register the counter widget
3238
+ */
3239
+ function counter_widget() {
3240
+ require_once( WP_CONTENT_DIR . '/plugins/' . S2DIR . '/include/counterwidget.php');
3241
+ register_widget('S2_Counter_widget');
3242
+ } // end counter_widget()
3243
+
3244
+ /**
3245
+ Function to add js files to admin header
3246
+ */
3247
+ function widget_s2counter_js() {
3248
+ echo '<script type="text/javascript" src="' . WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/colorpicker/js/colorpicker.js"></script>' . "\r\n";
3249
+ echo "<script type=\"text/javascript\">
3250
+ jQuery(document).ready(function() {
3251
+ jQuery('.colorpickerField').focusin(function() {
3252
+ jQuery(this).ColorPickerShow();
3253
+ });
3254
+ jQuery('.colorpickerField').focusout(function() {
3255
+ jQuery(this).ColorPickerHide();
3256
+ });
3257
+ jQuery('.colorpickerField').ColorPicker({
3258
+ onSubmit: function(hsb, hex, rgb, el) {
3259
+ jQuery(el).val(hex);
3260
+ jQuery(el).ColorPickerHide();
3261
+ },
3262
+ onBeforeShow: function () {
3263
+ jQuery(this).ColorPickerSetColor(this.value);
3264
+ }
3265
+ })
3266
+ .bind('keyup', function(){
3267
+ jQuery(this).ColorPickerSetColor(this.value);
3268
+ });
3269
+ });
3270
+ </script>";
3271
+ } // end widget_s2_counter_js()
3272
+
3273
+ /**
3274
+ Function to add css files to admin header
3275
+ */
3276
+ function widget_s2counter_css() {
3277
+ echo '<link rel="stylesheet" href="' . WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/colorpicker/css/colorpicker.css" type="text/css" />' . "\r\n";
3278
+ } // end widget_s2counter_css
3279
+
3280
+ function namechange_subscribe2_widget() {
3281
+ // rename WPMU widgets without requiring user to re-enable
3282
+ global $wpdb;
3283
+ $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
3284
+
3285
+ foreach ( $blogs as $blog ) {
3286
+ switch_to_blog($blog);
3287
+
3288
+ $sidebars = get_option('sidebars_widgets');
3289
+ if ( empty($sidebars) || !is_array($sidebars) ) { return; }
3290
+ $changed = false;
3291
+ foreach ( $sidebars as $s =>$sidebar ) {
3292
+ if ( empty($sidebar) || !is_array($sidebar) ) { break; }
3293
+ foreach ( $sidebar as $w => $widget ) {
3294
+ if ( $widget == 'subscribe2widget' ) {
3295
+ $sidebars[$s][$w] = 'subscribe2';
3296
+ $changed = true;
3297
+ }
3298
+ }
3299
+ }
3300
+ if ( $changed ) {
3301
+ update_option('sidebar_widgets', $sidebars);
3302
+ }
3303
+ }
3304
+ restore_current_blog();
3305
+ } // end namechange_subscribe2_widget()
3306
+
3307
+ /**
3308
+ Add hook for Minimeta Widget plugin
3309
+ */
3310
+ function add_minimeta() {
3311
+ if ( $this->subscribe2_options['s2page'] != 0 ) {
3312
+ echo "<li><a href=\"" . get_option('siteurl') . "/?page_id=" . $this->subscribe2_options['s2page'] . "\">" . __('[Un]Subscribe to Posts', 'subscribe2') . "</a></li>\r\n";
3313
+ }
3314
+ } // end add_minimeta()
3315
+
3316
+ /* ===== Write Toolbar Button Functions ===== */
3317
+
3318
+ /**
3319
+ Register our button in the QuickTags bar
3320
+ */
3321
+ function button_init() {
3322
+ if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) { return; }
3323
+ if ( 'true' == get_user_option('rich_editing') ) {
3324
+ // Use WordPress 2.5+ hooks
3325
+ add_filter('mce_external_plugins', array(&$this, 'mce3_plugin'));
3326
+ add_filter('mce_buttons', array(&$this, 'mce3_button'));
3327
+ } else {
3328
+ buttonsnap_separator();
3329
+ buttonsnap_jsbutton(WP_CONTENT_URL . '/plugins/' . S2DIR . '/include/s2_button.png', __('Subscribe2', 'subscribe2'), 's2_insert_token();');
3330
+ }
3331
+ } // end button_init()
3332
+
3333
+ /**
3334
+ Add buttons for WordPress 2.5+ using built in hooks
3335
+ */
3336
+ function mce3_plugin($arr) {
3337
+ $path = WP_CONTENT_URL . '/plugins/' . S2DIR . '/tinymce3/editor_plugin.js';
3338
+ $arr['subscribe2'] = $path;
3339
+ return $arr;
3340
+ }
3341
+
3342
+ function mce3_button($arr) {
3343
+ $arr[] = 'subscribe2';
3344
+ return $arr;
3345
+ }
3346
+
3347
+ function s2_edit_form() {
3348
+ echo "<!-- Start Subscribe2 Quicktags Javascript -->\r\n";
3349
+ echo "<script type=\"text/javascript\">\r\n";
3350
+ echo "//<![CDATA[\r\n";
3351
+ echo "function s2_insert_token() {
3352
+ buttonsnap_settext('<!--subscribe2-->');
3353
+ }\r\n";
3354
+ echo "//]]>\r\n";
3355
+ echo "</script>\r\n";
3356
+ echo "<!-- End Subscribe2 Quicktags Javascript -->\r\n";
3357
+ }
3358
+
3359
+ /* ===== wp-cron functions ===== */
3360
+ /**
3361
+ Add a weekly event to cron
3362
+ */
3363
+ function add_weekly_sched($sched) {
3364
+ $sched['weekly'] = array('interval' => 604800, 'display' => __('Weekly', 'subscribe2'));
3365
+ return $sched;
3366
+ } // end add_weekly_sched()
3367
+
3368
+ /**
3369
+ Send a daily digest of today's new posts
3370
+ */
3371
+ function subscribe2_cron($preview = '', $resend = '') {
3372
+ if ( defined('DOING_S2_CRON') && DOING_S2_CRON ) { return; }
3373
+ define( 'DOING_S2_CRON', true );
3374
+ global $wpdb;
3375
+
3376
+ if ( '' == $preview ) {
3377
+ // update last_s2cron execution time before completing or bailing
3378
+ $now = current_time('mysql');
3379
+ $prev = $this->subscribe2_options['last_s2cron'];
3380
+ $last = $this->subscribe2_options['previous_s2cron'];
3381
+ $this->subscribe2_options['last_s2cron'] = $now;
3382
+ $this->subscribe2_options['previous_s2cron'] = $prev;
3383
+ if ( '' == $resend ) {
3384
+ // update sending times provided this is not a resend
3385
+ update_option('subscribe2_options', $this->subscribe2_options);
3386
+ }
3387
+
3388
+ // set up SQL query based on options
3389
+ if ( $this->subscribe2_options['private'] == 'yes' ) {
3390
+ $status = "'publish', 'private'";
3391
+ } else {
3392
+ $status = "'publish'";
3393
+ }
3394
+
3395
+ // send notifications for allowed post type (defaults for posts and pages)
3396
+ // uses s2_post_types filter to allow for custom post types in WP 3.0
3397
+ if ( $this->subscribe2_options['pages'] == 'yes' ) {
3398
+ $s2_post_types = array('page', 'post');
3399
+ } else {
3400
+ $s2_post_types = array('post');
3401
+ }
3402
+ $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
3403
+ foreach( $s2_post_types as $post_type ) {
3404
+ ('' == $type) ? $type = "'$post_type'" : $type .= ", '$post_type'";
3405
+ }
3406
+
3407
+ // collect posts
3408
+ if ( $resend == 'resend' ) {
3409
+ if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
3410
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
3411
+ } else {
3412
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$last' AND post_date < '$prev' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
3413
+ }
3414
+ } else {
3415
+ if ( $this->subscribe2_options['cron_order'] == 'desc' ) {
3416
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date DESC");
3417
+ } else {
3418
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts WHERE post_date >= '$prev' AND post_date < '$now' AND post_status IN ($status) AND post_type IN ($type) ORDER BY post_date ASC");
3419
+ }
3420
+ }
3421
+ } else {
3422
+ // we are sending a preview
3423
+ $posts = get_posts('numberposts=1');
3424
+ }
3425
+
3426
+ // do we have any posts?
3427
+ if ( empty($posts) ) { return false; }
3428
+ $this->post_count = count($posts);
3429
+
3430
+ // if we have posts, let's prepare the digest
3431
+ $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
3432
+ $all_post_cats = array();
3433
+ $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
3434
+ $table = '';
3435
+ $tablelinks = '';
3436
+ $message_post= '';
3437
+ $message_posttime = '';
3438
+ foreach ( $posts as $post ) {
3439
+ $post_cats = wp_get_post_categories($post->ID);
3440
+ $post_cats_string = implode(',', $post_cats);
3441
+ $all_post_cats = array_unique(array_merge($all_post_cats, $post_cats));
3442
+ $check = false;
3443
+ // Pages are put into category 1 so make sure we don't exclude
3444
+ // pages if category 1 is excluded
3445
+ if ( $post->post_type != 'page' ) {
3446
+ // is the current post assigned to any categories
3447
+ // which should not generate a notification email?
3448
+ foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
3449
+ if ( in_array($cat, $post_cats) ) {
3450
+ $check = true;
3451
+ }
3452
+ }
3453
+ }
3454
+ // is the current post set by the user to
3455
+ // not generate a notification email?
3456
+ $s2mail = get_post_meta($post->ID, 's2mail', true);
3457
+ if ( strtolower(trim($s2mail)) == 'no' ) {
3458
+ $check = true;
3459
+ }
3460
+ // is the current post private
3461
+ // and should this not generate a notification email?
3462
+ if ( $this->subscribe2_options['password'] == 'no' && $post->post_password != '' ) {
3463
+ $check = true;
3464
+ }
3465
+ // if this post is excluded
3466
+ // don't include it in the digest
3467
+ if ( $check ) {
3468
+ continue;
3469
+ }
3470
+ $post_title = html_entity_decode($post->post_title, ENT_QUOTES);
3471
+ ('' == $table) ? $table .= "* " . $post_title : $table .= "\r\n* " . $post_title;
3472
+ ('' == $tablelinks) ? $tablelinks .= "* " . $post_title : $tablelinks .= "\r\n* " . $post_title;
3473
+ $message_post .= $post_title;
3474
+ $message_posttime .= $post_title;
3475
+ if ( strstr($mailtext, "AUTHORNAME") ) {
3476
+ $author = get_userdata($post->post_author);
3477
+ if ( $author->display_name != '' ) {
3478
+ $message_post .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
3479
+ $message_posttime .= " (" . __('Author', 'subscribe2') . ": " . $author->display_name . ")";
3480
+ }
3481
+ }
3482
+ $message_post .= "\r\n";
3483
+ $message_posttime .= "\r\n";
3484
+
3485
+ $tablelinks .= "\r\n" . get_permalink($post->ID) . "\r\n";
3486
+ $message_post .= get_permalink($post->ID) . "\r\n";
3487
+ $message_posttime .= __('Posted on', 'subscribe2') . ": " . mysql2date($datetime, $post->post_date) . "\r\n";
3488
+ $message_posttime .= get_permalink($post->ID) . "\r\n";
3489
+ if ( strstr($mailtext, "CATS") ) {
3490
+ $post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
3491
+ $message_post .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
3492
+ $message_posttime .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
3493
+ }
3494
+ if ( strstr($mailtext, "TAGS") ) {
3495
+ $post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
3496
+ if ( $post_tag_names != '' ) {
3497
+ $message_post .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
3498
+ $message_posttime .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
3499
+ }
3500
+ }
3501
+ $message_post .= "\r\n";
3502
+ $message_posttime .= "\r\n";
3503
+
3504
+ $excerpt = $post->post_excerpt;
3505
+ if ( '' == $excerpt ) {
3506
+ // no excerpt, is there a <!--more--> ?
3507
+ if ( false !== strpos($post->post_content, '<!--more-->') ) {
3508
+ list($excerpt, $more) = explode('<!--more-->', $post->post_content, 2);
3509
+ $excerpt = strip_tags($excerpt);
3510
+ if ( function_exists('strip_shortcodes') ) {
3511
+ $excerpt = strip_shortcodes($excerpt);
3512
+ }
3513
+ } else {
3514
+ $excerpt = strip_tags($post->post_content);
3515
+ if ( function_exists('strip_shortcodes') ) {
3516
+ $excerpt = strip_shortcodes($excerpt);
3517
+ }
3518
+ $words = explode(' ', $excerpt, $this->excerpt_length + 1);
3519
+ if ( count($words) > $this->excerpt_length ) {
3520
+ array_pop($words);
3521
+ array_push($words, '[...]');
3522
+ $excerpt = implode(' ', $words);
3523
+ }
3524
+ }
3525
+ // strip leading and trailing whitespace
3526
+ $excerpt = trim($excerpt);
3527
+ }
3528
+ $message_post .= $excerpt . "\r\n\r\n";
3529
+ $message_posttime .= $excerpt . "\r\n\r\n";
3530
+ }
3531
+
3532
+ // we add a blank line after each post excerpt now trim white space that occurs for the last post
3533
+ $message_post = trim($message_post);
3534
+ $message_posttime = trim($message_posttime);
3535
+
3536
+ //sanity check - don't send a mail if the content is empty
3537
+ if ( !$message_post && !$message_posttime && !$table && !$tablelinks ) {
3538
+ return;
3539
+ }
3540
+
3541
+ // get admin details
3542
+ $user = $this->get_userdata($this->subscribe2_options['sender']);
3543
+ $this->myemail = $user->user_email;
3544
+ $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
3545
+
3546
+ $scheds = (array)wp_get_schedules();
3547
+ $email_freq = $this->subscribe2_options['email_freq'];
3548
+ $display = $scheds[$email_freq]['display'];
3549
+ ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(get_option('blogname')) . "] ";
3550
+ $subject .= $display . " " . __('Digest Email', 'subscribe2');
3551
+ $mailtext = str_replace("TABLELINKS", $tablelinks, $mailtext);
3552
+ $mailtext = str_replace("TABLE", $table, $mailtext);
3553
+ $mailtext = str_replace("POSTTIME", $message_posttime, $mailtext);
3554
+ $mailtext = str_replace("POST", $message_post, $mailtext);
3555
+ $mailtext = stripslashes($this->substitute($mailtext));
3556
+
3557
+ // prepare recipients
3558
+ if ( $preview != '' ) {
3559
+ $this->myemail = $preview;
3560
+ $this->myname = "Preview";
3561
+ $this->mail(array($preview), $subject, $mailtext);
3562
+ } else {
3563
+ $public = $this->get_public();
3564
+ $all_post_cats_string = implode(',', $all_post_cats);
3565
+ $registered = $this->get_registered("cats=$all_post_cats_string");
3566
+ $recipients = array_merge((array)$public, (array)$registered);
3567
+ $this->mail($recipients, $subject, $mailtext);
3568
+ }
3569
+ } // end subscribe2_cron
3570
+
3571
+ /* ===== Our constructor ===== */
3572
+ /**
3573
+ Subscribe2 constructor
3574
+ */
3575
+ function s2init() {
3576
+ // load the options
3577
+ $this->subscribe2_options = get_option('subscribe2_options');
3578
+
3579
+ add_action('init', array(&$this, 'subscribe2'));
3580
+ if ( '1' == $this->subscribe2_options['show_button'] ) {
3581
+ add_action('init', array(&$this, 'button_init'));
3582
+ }
3583
+
3584
+ // add action to display widget if option is enabled
3585
+ if ( '1' == $this->subscribe2_options['widget'] ) {
3586
+ add_action('widgets_init', array(&$this, 'subscribe2_widget'));
3587
+ }
3588
+
3589
+ // add action to display counter widget if option is enabled
3590
+ if ( '1' == $this->subscribe2_options['counterwidget'] ) {
3591
+ add_action('admin_print_styles', array(&$this, 'widget_s2counter_css'), 20);
3592
+ add_action('admin_print_scripts', array(&$this, 'widget_s2counter_js'), 20);
3593
+ add_action('widgets_init', array(&$this, 'counter_widget'));
3594
+ }
3595
+
3596
+ // add action to handle WPMU subscriptions and unsubscriptions
3597
+ if ( isset($_GET['s2mu_subscribe']) || isset($_GET['s2mu_unsubscribe']) ) {
3598
+ add_action('init', array(&$this, 'wpmu_subscribe'));
3599
+ }
3600
+ } // end s2init()
3601
+
3602
+ function subscribe2() {
3603
+ global $wpdb, $table_prefix, $wp_version, $wpmu_version;
3604
+
3605
+ load_plugin_textdomain('subscribe2', 'wp-content/plugins/' . S2DIR, '/' . S2DIR);
3606
+
3607
+ // Is this WordPressMU or not?
3608
+ $this->s2_mu = false;
3609
+ if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
3610
+ $this->s2_mu = true;
3611
+ }
3612
+ if ( function_exists('is_multisite') && is_multisite() ) {
3613
+ $this->s2_mu = true;
3614
+ }
3615
+
3616
+ // do we need to install anything?
3617
+ $this->public = $table_prefix . "subscribe2";
3618
+ if ( $wpdb->get_var("SHOW TABLES LIKE '{$this->public}'") != $this->public ) { $this->install(); }
3619
+ //do we need to upgrade anything?
3620
+ if ( is_array($this->subscribe2_options) && $this->subscribe2_options['version'] !== S2VERSION ) {
3621
+ add_action('shutdown', array(&$this, 'upgrade'));
3622
+ }
3623
+
3624
+ if ( isset($_GET['s2']) ) {
3625
+ // someone is confirming a request
3626
+ if ( defined('DOING_S2_CONFIRM') && DOING_S2_CONFIRM ) { return; }
3627
+ define( 'DOING_S2_CONFIRM', true );
3628
+ add_filter('query_string', array(&$this, 'query_filter'));
3629
+ add_filter('the_title', array(&$this, 'title_filter'));
3630
+ add_filter('the_content', array(&$this, 'confirm'));
3631
+ }
3632
+
3633
+ if ( isset($_POST['s2_admin']) && $_POST['csv'] ) {
3634
+ $date = date('Y-m-d');
3635
+ header("Content-Description: File Transfer");
3636
+ header("Content-type: application/octet-stream");
3637
+ header("Content-Disposition: attachment; filename=subscribe2_users_$date.csv");
3638
+ header("Pragma: no-cache");
3639
+ header("Expires: 0");
3640
+ echo $this->prepare_export($_POST['exportcsv']);
3641
+
3642
+ exit(0);
3643
+ }
3644
+
3645
+ //add regular actions and filters
3646
+ add_action('admin_menu', array(&$this, 'admin_menu'));
3647
+ add_action('admin_menu', array(&$this, 's2_meta_init'));
3648
+ add_action('save_post', array(&$this, 's2_meta_handler'));
3649
+ add_action('create_category', array(&$this, 'new_category'));
3650
+ add_action('delete_category', array(&$this, 'delete_category'));
3651
+ add_shortcode('subscribe2', array(&$this, 'shortcode'));
3652
+ add_filter('the_content', array(&$this, 'filter'), 10);
3653
+ add_filter('cron_schedules', array(&$this, 'add_weekly_sched'));
3654
+
3655
+ // add actions for other plugins
3656
+ if ( '1' == $this->subscribe2_options['show_meta'] ) {
3657
+ add_action('wp_meta', array(&$this, 'add_minimeta'), 0);
3658
+ }
3659
+ // Add filters for Ozh Admin Menu
3660
+ add_filter('ozh_adminmenu_icon_s2_posts', array(&$this, 'ozh_s2_icon'));
3661
+ add_filter('ozh_adminmenu_icon_s2_users', array(&$this, 'ozh_s2_icon'));
3662
+ add_filter('ozh_adminmenu_icon_s2_tools', array(&$this, 'ozh_s2_icon'));
3663
+ add_filter('ozh_adminmenu_icon_s2_settings', array(&$this, 'ozh_s2_icon'));
3664
+
3665
+ // add action to display editor buttons if option is enabled
3666
+ if ( '1' == $this->subscribe2_options['show_button'] ) {
3667
+ add_action('edit_page_form', array(&$this, 's2_edit_form'));
3668
+ add_action('edit_form_advanced', array(&$this, 's2_edit_form'));
3669
+ }
3670
+
3671
+ // add actions for automatic subscription based on option settings
3672
+ add_action('register_form', array(&$this, 'register_form'));
3673
+ add_action('user_register', array(&$this, 'register'));
3674
+ add_action('add_user_to_blog', array(&$this, 'register'), 10, 1);
3675
+
3676
+ // add actions for processing posts based on per-post or cron email settings
3677
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) {
3678
+ add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
3679
+ } else {
3680
+ add_action('new_to_publish', array(&$this, 'publish'));
3681
+ add_action('draft_to_publish', array(&$this, 'publish'));
3682
+ add_action('pending_to_publish', array(&$this, 'publish'));
3683
+ add_action('private_to_publish', array(&$this, 'publish'));
3684
+ add_action('future_to_publish', array(&$this, 'publish'));
3685
+ if ( $this->subscribe2_options['private'] == 'yes' ) {
3686
+ add_action('new_to_private', array(&$this, 'publish'));
3687
+ add_action('draft_to_private', array(&$this, 'publish'));
3688
+ add_action('pending_to_private', array(&$this, 'publish'));
3689
+ }
3690
+ }
3691
+
3692
+ // load our strings
3693
+ $this->load_strings();
3694
+ } // end subscribe2()
3695
+
3696
+ /* ===== our variables ===== */
3697
+ // cache variables
3698
+ var $subscribe2_options = array();
3699
+ var $all_public = '';
3700
+ var $all_unconfirmed = '';
3701
+ var $excluded_cats = '';
3702
+ var $post_title = '';
3703
+ var $permalink = '';
3704
+ var $myname = '';
3705
+ var $myemail = '';
3706
+ var $signup_dates = array();
3707
+ var $filtered = 0;
3708
+ var $preview_email = false;
3709
+
3710
+ // state variables used to affect processing
3711
+ var $action = '';
3712
+ var $email = '';
3713
+ var $message = '';
3714
+ var $excerpt_length = 55;
3715
+
3716
+ // some messages
3717
+ var $please_log_in = '';
3718
+ var $use_profile_admin = '';
3719
+ var $use_profile_users = '';
3720
+ var $confirmation_sent = '';
3721
+ var $already_subscribed = '';
3722
+ var $not_subscribed ='';
3723
+ var $not_an_email = '';
3724
+ var $barred_domain = '';
3725
+ var $error = '';
3726
+ var $mail_sent = '';
3727
+ var $mail_failed = '';
3728
+ var $form = '';
3729
+ var $no_such_email = '';
3730
+ var $added = '';
3731
+ var $deleted = '';
3732
+ var $subscribe = '';
3733
+ var $unsubscribe = '';
3734
+ var $confirm_subject = '';
3735
+ var $options_saved = '';
3736
+ var $options_reset = '';
3737
+ } // end class subscribe2
3738
  ?>
subscribe2.pot CHANGED
@@ -8,7 +8,7 @@ msgid ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2010-09-07 20:12+0100\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -33,8 +33,9 @@ msgstr ""
33
  msgid "profile"
34
  msgstr ""
35
 
36
- #: subscribe2.php:70 subscribe2.php:79 subscribe2.php:101 subscribe2.php:1704
37
- #: subscribe2.php:1801 subscribe2.php:2563
 
38
  msgid "Subscribe"
39
  msgstr ""
40
 
@@ -82,785 +83,785 @@ msgid ""
82
  "Message failed! Check your settings and check with your hosting provider"
83
  msgstr ""
84
 
85
- #: subscribe2.php:101
86
- msgid "Your email:"
87
- msgstr ""
88
-
89
- #: subscribe2.php:101
90
- msgid "Enter email address..."
91
- msgstr ""
92
-
93
- #: subscribe2.php:101 subscribe2.php:1705 subscribe2.php:1802
94
- #: subscribe2.php:2542
95
- msgid "Unsubscribe"
96
- msgstr ""
97
-
98
- #: subscribe2.php:104
99
  msgid "No such email address is registered."
100
  msgstr ""
101
 
102
- #: subscribe2.php:106
103
  msgid "You have successfully subscribed!"
104
  msgstr ""
105
 
106
- #: subscribe2.php:108
107
  msgid "You have successfully unsubscribed."
108
  msgstr ""
109
 
110
- #: subscribe2.php:110
111
  msgid "subscribe"
112
  msgstr ""
113
 
114
- #: subscribe2.php:112
115
  msgid "unsubscribe"
116
  msgstr ""
117
 
118
- #: subscribe2.php:115
119
  msgid "Options saved!"
120
  msgstr ""
121
 
122
- #: subscribe2.php:116
123
  msgid "Options reset!"
124
  msgstr ""
125
 
126
- #: subscribe2.php:124
127
  msgid "Subscribers"
128
  msgstr ""
129
 
130
- #: subscribe2.php:127
131
  msgid "Subscribe2 Options"
132
  msgstr ""
133
 
134
- #: subscribe2.php:127 subscribe2.php:3294 include/widget.php:17
135
  msgid "Subscribe2"
136
  msgstr ""
137
 
138
- #: subscribe2.php:132
139
  msgid "Your Subscriptions"
140
  msgstr ""
141
 
142
- #: subscribe2.php:136
143
  msgid "Mail Subscribers"
144
  msgstr ""
145
 
146
- #: subscribe2.php:892
147
- msgid "New subscription"
148
  msgstr ""
149
 
150
- #: subscribe2.php:894
151
  msgid "subscribed to email notifications!"
152
  msgstr ""
153
 
154
- #: subscribe2.php:920
155
  msgid "New Unsubscription"
156
  msgstr ""
157
 
158
- #: subscribe2.php:922
159
  msgid "unsubscribed from email notifications!"
160
  msgstr ""
161
 
162
- #: subscribe2.php:1515
163
  msgid "Address(es) subscribed!"
164
  msgstr ""
165
 
166
- #: subscribe2.php:1522
167
  msgid "Address(es) unsubscribed!"
168
  msgstr ""
169
 
170
- #: subscribe2.php:1526
171
  msgid "Some emails were not processed, the following were already subscribed"
172
  msgstr ""
173
 
174
- #: subscribe2.php:1529
175
  msgid "Some emails were not processed, the following were not in the database"
176
  msgstr ""
177
 
178
- #: subscribe2.php:1538
179
  msgid "Address(es) deleted!"
180
  msgstr ""
181
 
182
- #: subscribe2.php:1544 subscribe2.php:1550
183
  msgid "Status changed!"
184
  msgstr ""
185
 
186
- #: subscribe2.php:1564
187
  msgid "Reminder Email(s) Sent!"
188
  msgstr ""
189
 
190
- #: subscribe2.php:1567
191
  msgid "Registered Users Subscribed!"
192
  msgstr ""
193
 
194
- #: subscribe2.php:1570
195
  msgid "Registered Users Unsubscribed!"
196
  msgstr ""
197
 
198
- #: subscribe2.php:1573
199
  msgid "Format updated for Selected Registered Users!"
200
  msgstr ""
201
 
202
- #: subscribe2.php:1668
203
  msgid "Previous Page"
204
  msgstr ""
205
 
206
- #: subscribe2.php:1688
207
  msgid "Next Page"
208
  msgstr ""
209
 
210
- #: subscribe2.php:1695
211
  msgid "Manage Subscribers"
212
  msgstr ""
213
 
214
- #: subscribe2.php:1700
215
  msgid "Add/Remove Subscribers"
216
  msgstr ""
217
 
218
- #: subscribe2.php:1701
219
  msgid "Enter addresses, one per line or comma-separated"
220
  msgstr ""
221
 
222
- #: subscribe2.php:1708
 
 
 
 
 
223
  msgid "Current Subscribers"
224
  msgstr ""
225
 
226
- #: subscribe2.php:1710
227
  msgid "Filter"
228
  msgstr ""
229
 
230
- #: subscribe2.php:1715
231
  msgid "Search Subscribers"
232
  msgstr ""
233
 
234
- #: subscribe2.php:1718
235
  msgid "Send Reminder Email"
236
  msgstr ""
237
 
238
- #: subscribe2.php:1725
239
  msgid "Save Emails to CSV File"
240
  msgstr ""
241
 
242
- #: subscribe2.php:1731 subscribe2.php:1789
243
  msgid "Process"
244
  msgstr ""
245
 
246
- #: subscribe2.php:1744 subscribe2.php:1766
247
  msgid "Confirm this email address"
248
  msgstr ""
249
 
250
- #: subscribe2.php:1746 subscribe2.php:1759
251
  msgid "Unconfirm this email address"
252
  msgstr ""
253
 
254
- #: subscribe2.php:1748 subscribe2.php:1761 subscribe2.php:1769
255
  msgid "Delete this email address"
256
  msgstr ""
257
 
258
- #: subscribe2.php:1752 subscribe2.php:2683
259
  msgid "Select / Unselect All"
260
  msgstr ""
261
 
262
- #: subscribe2.php:1776
263
  msgid "edit"
264
  msgstr ""
265
 
266
- #: subscribe2.php:1783
267
  msgid "No matching subscribers found"
268
  msgstr ""
269
 
270
- #: subscribe2.php:1785
271
  msgid "NONE"
272
  msgstr ""
273
 
274
- #: subscribe2.php:1797
275
  msgid "Categories"
276
  msgstr ""
277
 
278
- #: subscribe2.php:1798
279
  msgid ""
280
  "Preferences for Registered Users selected in the filter above can be changed "
281
  "using this section."
282
  msgstr ""
283
 
284
- #: subscribe2.php:1799
285
  msgid "Consider User Privacy as changes cannot be undone"
286
  msgstr ""
287
 
288
- #: subscribe2.php:1800
289
  msgid "Action to perform"
290
  msgstr ""
291
 
292
- #: subscribe2.php:1805
293
  msgid "Bulk Update Categories"
294
  msgstr ""
295
 
296
- #: subscribe2.php:1807
297
  msgid "Send email as"
298
  msgstr ""
299
 
300
- #: subscribe2.php:1808 subscribe2.php:2265 subscribe2.php:2414
301
  msgid "HTML - Full"
302
  msgstr ""
303
 
304
- #: subscribe2.php:1809 subscribe2.php:2270 subscribe2.php:2419
305
  msgid "HTML - Excerpt"
306
  msgstr ""
307
 
308
- #: subscribe2.php:1810 subscribe2.php:2275 subscribe2.php:2424
309
  msgid "Plain Text - Full"
310
  msgstr ""
311
 
312
- #: subscribe2.php:1811 subscribe2.php:2280 subscribe2.php:2429
313
  msgid "Plain Text - Excerpt"
314
  msgstr ""
315
 
316
- #: subscribe2.php:1812
317
  msgid "Bulk Update Format"
318
  msgstr ""
319
 
320
- #: subscribe2.php:1849
321
  msgid "Preview message(s) sent to logged in user"
322
  msgstr ""
323
 
324
- #: subscribe2.php:1853
325
  msgid ""
326
  "The Digest Notification email contained no post information. No email was "
327
  "sent"
328
  msgstr ""
329
 
330
- #: subscribe2.php:1855
331
  msgid "Attempt made to resend the Digest Notification email"
332
  msgstr ""
333
 
334
- #: subscribe2.php:2000
335
  msgid "Subscribe2 Settings"
336
  msgstr ""
337
 
338
- #: subscribe2.php:2001
339
  msgid "Plugin Blog"
340
  msgstr ""
341
 
342
- #: subscribe2.php:2002
343
  msgid "Make a donation via PayPal"
344
  msgstr ""
345
 
346
- #: subscribe2.php:2013 subscribe2.php:2397
347
  msgid "Notification Settings"
348
  msgstr ""
349
 
350
- #: subscribe2.php:2014
351
  msgid "Restrict the number of recipients per email to (0 for unlimited)"
352
  msgstr ""
353
 
354
- #: subscribe2.php:2016 subscribe2.php:2177
355
  msgid "Edit"
356
  msgstr ""
357
 
358
- #: subscribe2.php:2019 subscribe2.php:2180
359
  msgid "Update"
360
  msgstr ""
361
 
362
- #: subscribe2.php:2020 subscribe2.php:2181
363
  msgid "Revert"
364
  msgstr ""
365
 
366
- #: subscribe2.php:2022
367
  msgid "Send Admins notifications for new"
368
  msgstr ""
369
 
370
- #: subscribe2.php:2027
371
  msgid "Subscriptions"
372
  msgstr ""
373
 
374
- #: subscribe2.php:2032
375
  msgid "Unsubscriptions"
376
  msgstr ""
377
 
378
- #: subscribe2.php:2037
379
  msgid "Both"
380
  msgstr ""
381
 
382
- #: subscribe2.php:2042
383
  msgid "Neither"
384
  msgstr ""
385
 
386
- #: subscribe2.php:2044
387
  msgid "Include theme CSS stylesheet in HTML notifications"
388
  msgstr ""
389
 
390
- #: subscribe2.php:2049 subscribe2.php:2061 subscribe2.php:2072
391
- #: subscribe2.php:2083 subscribe2.php:2243 subscribe2.php:2254
392
- #: subscribe2.php:2286 subscribe2.php:2302 subscribe2.php:2437
393
- #: subscribe2.php:2473
394
  msgid "Yes"
395
  msgstr ""
396
 
397
- #: subscribe2.php:2054 subscribe2.php:2066 subscribe2.php:2077
398
- #: subscribe2.php:2088 subscribe2.php:2237 subscribe2.php:2248
399
- #: subscribe2.php:2259 subscribe2.php:2291 subscribe2.php:2307
400
- #: subscribe2.php:2442 subscribe2.php:2477
401
  msgid "No"
402
  msgstr ""
403
 
404
- #: subscribe2.php:2056
405
  msgid "Send Emails for Pages"
406
  msgstr ""
407
 
408
- #: subscribe2.php:2067
409
  msgid "Send Emails for Password Protected Posts"
410
  msgstr ""
411
 
412
- #: subscribe2.php:2078
413
  msgid "Send Emails for Private Posts"
414
  msgstr ""
415
 
416
- #: subscribe2.php:2089
417
  msgid "Send Email From"
418
  msgstr ""
419
 
420
- #: subscribe2.php:2094
421
  msgid "Send Emails"
422
  msgstr ""
423
 
424
- #: subscribe2.php:2096
425
  msgid "For digest notifications, date order for posts is"
426
  msgstr ""
427
 
428
- #: subscribe2.php:2101
429
  msgid "Descending"
430
  msgstr ""
431
 
432
- #: subscribe2.php:2106
433
  msgid "Ascending"
434
  msgstr ""
435
 
436
- #: subscribe2.php:2110
437
  msgid "Email Templates"
438
  msgstr ""
439
 
440
- #: subscribe2.php:2114
441
  msgid "New Post email (must not be empty)"
442
  msgstr ""
443
 
444
- #: subscribe2.php:2115 subscribe2.php:2144 subscribe2.php:2149
445
  msgid "Subject Line"
446
  msgstr ""
447
 
448
- #: subscribe2.php:2120
449
  msgid "Send Email Preview"
450
  msgstr ""
451
 
452
- #: subscribe2.php:2121
453
  msgid "Message substitions"
454
  msgstr ""
455
 
456
- #: subscribe2.php:2125
457
  msgid "the post's title<br />(<i>for per-post emails only</i>)"
458
  msgstr ""
459
 
460
- #: subscribe2.php:2126
461
  msgid ""
462
  "the excerpt or the entire post<br />(<i>based on the subscriber's "
463
  "preferences</i>)"
464
  msgstr ""
465
 
466
- #: subscribe2.php:2127
467
  msgid ""
468
  "the excerpt of the post and the time it was posted<br />(<i>for digest "
469
  "emails only</i>)"
470
  msgstr ""
471
 
472
- #: subscribe2.php:2128
473
  msgid "a list of post titles<br />(<i>for digest emails only</i>)"
474
  msgstr ""
475
 
476
- #: subscribe2.php:2129
477
  msgid ""
478
  "a list of post titles followed by links to the atricles<br />(<i>for digest "
479
  "emails only</i>)"
480
  msgstr ""
481
 
482
- #: subscribe2.php:2130
483
  msgid "the post's permalink<br />(<i>for per-post emails only</i>)"
484
  msgstr ""
485
 
486
- #: subscribe2.php:2131
487
  msgid ""
488
  "the post's permalink after conversion by TinyURL<br />(<i>for per-post "
489
  "emails only</i>)"
490
  msgstr ""
491
 
492
- #: subscribe2.php:2132
493
  msgid "the date the post was made<br />(<i>for per-post emails only</i>)"
494
  msgstr ""
495
 
496
- #: subscribe2.php:2133
497
  msgid "the time the post was made<br />(<i>for per-post emails only</i>)"
498
  msgstr ""
499
 
500
- #: subscribe2.php:2134
501
  msgid "the admin or post author's name"
502
  msgstr ""
503
 
504
- #: subscribe2.php:2135
505
  msgid "the admin or post author's email"
506
  msgstr ""
507
 
508
- #: subscribe2.php:2136
509
  msgid "the post author's name"
510
  msgstr ""
511
 
512
- #: subscribe2.php:2137
513
  msgid ""
514
  "the generated link to confirm a request<br />(<i>only used in the "
515
  "confirmation email template</i>)"
516
  msgstr ""
517
 
518
- #: subscribe2.php:2138
519
  msgid ""
520
  "Action performed by LINK in confirmation email<br />(<i>only used in the "
521
  "confirmation email template</i>)"
522
  msgstr ""
523
 
524
- #: subscribe2.php:2139
525
  msgid "the post's assigned categories"
526
  msgstr ""
527
 
528
- #: subscribe2.php:2140
529
  msgid "the post's assigned Tags"
530
  msgstr ""
531
 
532
- #: subscribe2.php:2141
533
  msgid ""
534
  "the number of posts included in the digest email<br />(<i>for digest emails "
535
  "only</i>)"
536
  msgstr ""
537
 
538
- #: subscribe2.php:2143
539
  msgid "Subscribe / Unsubscribe confirmation email"
540
  msgstr ""
541
 
542
- #: subscribe2.php:2148
543
  msgid "Reminder email to Unconfirmed Subscribers"
544
  msgstr ""
545
 
546
- #: subscribe2.php:2155
547
  msgid "Excluded Categories"
548
  msgstr ""
549
 
550
- #: subscribe2.php:2157
551
  msgid ""
552
  "Posts assigned to any Excluded Category do not generate notifications and "
553
  "are not included in digest notifications"
554
  msgstr ""
555
 
556
- #: subscribe2.php:2164
557
  msgid "Allow registered users to subscribe to excluded categories?"
558
  msgstr ""
559
 
560
- #: subscribe2.php:2167
561
  msgid "Appearance"
562
  msgstr ""
563
 
564
- #: subscribe2.php:2171
565
  msgid "Set default Subscribe2 page as ID"
566
  msgstr ""
567
 
568
- #: subscribe2.php:2175
569
  msgid "Set the number of Subscribers displayed per page"
570
  msgstr ""
571
 
572
- #: subscribe2.php:2188
573
  msgid "Show a link to your subscription page in \"meta\"?"
574
  msgstr ""
575
 
576
- #: subscribe2.php:2195
577
  msgid "Show the Subscribe2 button on the Write toolbar?"
578
  msgstr ""
579
 
580
- #: subscribe2.php:2202
581
  msgid "Enable Subscribe2 Widget?"
582
  msgstr ""
583
 
584
- #: subscribe2.php:2209
585
  msgid "Enable Subscribe2 Counter Widget?"
586
  msgstr ""
587
 
588
- #: subscribe2.php:2216
589
  msgid "Disable email notifications is checked by default on authoring pages?"
590
  msgstr ""
591
 
592
- #: subscribe2.php:2220
593
  msgid "Auto Subscribe"
594
  msgstr ""
595
 
596
- #: subscribe2.php:2222
597
  msgid "Subscribe new users registering with your blog"
598
  msgstr ""
599
 
600
- #: subscribe2.php:2227
601
  msgid "Automatically"
602
  msgstr ""
603
 
604
- #: subscribe2.php:2232
605
  msgid "Display option on Registration Form"
606
  msgstr ""
607
 
608
- #: subscribe2.php:2238
609
  msgid "Auto-subscribe includes any excluded categories"
610
  msgstr ""
611
 
612
- #: subscribe2.php:2249
613
  msgid "Registration Form option is checked by default"
614
  msgstr ""
615
 
616
- #: subscribe2.php:2260
617
  msgid "Auto-subscribe users to receive email as"
618
  msgstr ""
619
 
620
- #: subscribe2.php:2281
621
  msgid "Registered Users have the option to auto-subscribe to new categories"
622
  msgstr ""
623
 
624
- #: subscribe2.php:2296
625
  msgid "New categories are immediately excluded"
626
  msgstr ""
627
 
628
- #: subscribe2.php:2297
629
  msgid ""
630
  "Option for Registered Users to auto-subscribe to new categories is checked "
631
  "by default"
632
  msgstr ""
633
 
634
- #: subscribe2.php:2311
635
  msgid "Barred Domains"
636
  msgstr ""
637
 
638
- #: subscribe2.php:2313
639
  msgid ""
640
  "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
641
  "each entry and omit the \"@\" symbol, for example email.com)"
642
  msgstr ""
643
 
644
- #: subscribe2.php:2318
645
  msgid "Submit"
646
  msgstr ""
647
 
648
- #: subscribe2.php:2321
649
  msgid "Reset Default"
650
  msgstr ""
651
 
652
- #: subscribe2.php:2322
653
  msgid ""
654
  "Use this to reset all options to their defaults. This <strong><em>will not</"
655
  "em></strong> modify your list of subscribers."
656
  msgstr ""
657
 
658
- #: subscribe2.php:2324
659
  msgid "RESET"
660
  msgstr ""
661
 
662
- #: subscribe2.php:2350
663
  msgid "Subscription preferences updated."
664
  msgstr ""
665
 
666
- #: subscribe2.php:2400
667
  msgid "Editing Subscribe2 preferences for user"
668
  msgstr ""
669
 
670
- #: subscribe2.php:2409
671
  msgid "Receive email as"
672
  msgstr ""
673
 
674
- #: subscribe2.php:2432
675
  msgid "Automatically subscribe me to newly created categories"
676
  msgstr ""
677
 
678
- #: subscribe2.php:2453
679
  msgid "Unsubscribe me from this blog"
680
  msgstr ""
681
 
682
- #: subscribe2.php:2457
683
  msgid "Subscribe to all categories"
684
  msgstr ""
685
 
686
- #: subscribe2.php:2459
687
  msgid "Subscribed Categories on"
688
  msgstr ""
689
 
690
- #: subscribe2.php:2461
691
  msgid "Subscribed Categories"
692
  msgstr ""
693
 
694
- #: subscribe2.php:2467
695
  msgid "Receive periodic summaries of new posts?"
696
  msgstr ""
697
 
698
- #: subscribe2.php:2482
699
  msgid "Update Preferences"
700
  msgstr ""
701
 
702
- #: subscribe2.php:2531
703
  msgid "Subscribed Blogs"
704
  msgstr ""
705
 
706
- #: subscribe2.php:2536 subscribe2.php:2557
707
  msgid "Viewing Settings Now"
708
  msgstr ""
709
 
710
- #: subscribe2.php:2540 subscribe2.php:2561
711
  msgid "View Settings"
712
  msgstr ""
713
 
714
- #: subscribe2.php:2552
715
  msgid "Subscribe to new blogs"
716
  msgstr ""
717
 
718
- #: subscribe2.php:2630
719
  msgid "Send an email to subscribers"
720
  msgstr ""
721
 
722
- #: subscribe2.php:2638
723
  msgid "A message from"
724
  msgstr ""
725
 
726
- #: subscribe2.php:2640
727
  msgid "Subject"
728
  msgstr ""
729
 
730
- #: subscribe2.php:2643
731
  msgid "Recipients:"
732
  msgstr ""
733
 
734
- #: subscribe2.php:2647
735
  msgid "Preview"
736
  msgstr ""
737
 
738
- #: subscribe2.php:2647
739
  msgid "Send"
740
  msgstr ""
741
 
742
- #: subscribe2.php:2718
743
  msgid "All Users and Subscribers"
744
  msgstr ""
745
 
746
- #: subscribe2.php:2719
747
  msgid "Public Subscribers"
748
  msgstr ""
749
 
750
- #: subscribe2.php:2720
751
  msgid "Confirmed"
752
  msgstr ""
753
 
754
- #: subscribe2.php:2721
755
  msgid "Unconfirmed"
756
  msgstr ""
757
 
758
- #: subscribe2.php:2722
759
  msgid "All Registered Users"
760
  msgstr ""
761
 
762
- #: subscribe2.php:2723
763
  msgid "Registered Subscribers"
764
  msgstr ""
765
 
766
- #: subscribe2.php:2834
767
  msgid "For each Post"
768
  msgstr ""
769
 
770
- #: subscribe2.php:2851
771
  msgid "Send Digest Notification at"
772
  msgstr ""
773
 
774
- #: subscribe2.php:2863
775
  msgid ""
776
  "This option will be ignored if the time selected is not in the future in "
777
  "relation to the current time"
778
  msgstr ""
779
 
780
- #: subscribe2.php:2866
781
  msgid "Current UTC time is"
782
  msgstr ""
783
 
784
- #: subscribe2.php:2868
785
  msgid "Current blog time is"
786
  msgstr ""
787
 
788
- #: subscribe2.php:2870
789
  msgid "Next email notification will be sent when your blog time is after"
790
  msgstr ""
791
 
792
- #: subscribe2.php:2873
793
  msgid "Attempt to resend the last Digest Notification email"
794
  msgstr ""
795
 
796
- #: subscribe2.php:2874
797
  msgid "Resend Digest"
798
  msgstr ""
799
 
800
- #: subscribe2.php:2950
801
  msgid "Confirmed Public Subscriber"
802
  msgstr ""
803
 
804
- #: subscribe2.php:2952
805
  msgid "Unconfirmed Public Subscriber"
806
  msgstr ""
807
 
808
- #: subscribe2.php:3003
809
  msgid "Settings"
810
  msgstr ""
811
 
812
- #: subscribe2.php:3004
813
  msgid "Donate"
814
  msgstr ""
815
 
816
- #: subscribe2.php:3015
817
  msgid "Check here to Subscribe to email notifications for new posts"
818
  msgstr ""
819
 
820
- #: subscribe2.php:3024
821
  msgid ""
822
  "By registering with this blog you are also agreeing to receive email "
823
  "notifications for new posts but you can unsubscribe at anytime"
824
  msgstr ""
825
 
826
- #: subscribe2.php:3044 subscribe2.php:3045
827
  msgid "Subscribe2 Notification Override"
828
  msgstr ""
829
 
830
- #: subscribe2.php:3055
831
  msgid ""
832
  "Check here to disable sending of an email notification for this post/page"
833
  msgstr ""
834
 
835
- #: subscribe2.php:3186
 
 
 
 
 
 
 
 
836
  msgid "Subscription Confirmation"
837
  msgstr ""
838
 
839
- #: subscribe2.php:3277
840
  msgid "[Un]Subscribe to Posts"
841
  msgstr ""
842
 
843
- #: subscribe2.php:3329
844
  msgid "Weekly"
845
  msgstr ""
846
 
847
- #: subscribe2.php:3443 subscribe2.php:3444
848
  msgid "Author"
849
  msgstr ""
850
 
851
- #: subscribe2.php:3452
852
  msgid "Posted on"
853
  msgstr ""
854
 
855
- #: subscribe2.php:3456 subscribe2.php:3457
856
  msgid "Posted in"
857
  msgstr ""
858
 
859
- #: subscribe2.php:3462 subscribe2.php:3463
860
  msgid "Tagged as"
861
  msgstr ""
862
 
863
- #: subscribe2.php:3515
864
  msgid "Digest Email"
865
  msgstr ""
866
 
@@ -925,22 +926,38 @@ msgstr ""
925
  msgid "Subscribe2 Widget"
926
  msgstr ""
927
 
928
- #: include/widget.php:71
929
  msgid "Title"
930
  msgstr ""
931
 
932
- #: include/widget.php:73
933
  msgid "Div class name"
934
  msgstr ""
935
 
936
- #: include/widget.php:75
937
  msgid "Pre-Content"
938
  msgstr ""
939
 
940
- #: include/widget.php:77
941
  msgid "Post-Content"
942
  msgstr ""
943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
944
  #: include/counterwidget.php:7
945
  msgid "Subscriber Counter widget for the Subscribe2 plugin"
946
  msgstr ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2010-10-31 21:03+0000\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
33
  msgid "profile"
34
  msgstr ""
35
 
36
+ #: subscribe2.php:70 subscribe2.php:79 subscribe2.php:1707 subscribe2.php:1804
37
+ #: subscribe2.php:2568 subscribe2.php:3103 subscribe2.php:3106
38
+ #: include/widget.php:96
39
  msgid "Subscribe"
40
  msgstr ""
41
 
83
  "Message failed! Check your settings and check with your hosting provider"
84
  msgstr ""
85
 
86
+ #: subscribe2.php:102
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  msgid "No such email address is registered."
88
  msgstr ""
89
 
90
+ #: subscribe2.php:104
91
  msgid "You have successfully subscribed!"
92
  msgstr ""
93
 
94
+ #: subscribe2.php:106
95
  msgid "You have successfully unsubscribed."
96
  msgstr ""
97
 
98
+ #: subscribe2.php:108
99
  msgid "subscribe"
100
  msgstr ""
101
 
102
+ #: subscribe2.php:110
103
  msgid "unsubscribe"
104
  msgstr ""
105
 
106
+ #: subscribe2.php:113
107
  msgid "Options saved!"
108
  msgstr ""
109
 
110
+ #: subscribe2.php:114
111
  msgid "Options reset!"
112
  msgstr ""
113
 
114
+ #: subscribe2.php:122
115
  msgid "Subscribers"
116
  msgstr ""
117
 
118
+ #: subscribe2.php:125
119
  msgid "Subscribe2 Options"
120
  msgstr ""
121
 
122
+ #: subscribe2.php:125 subscribe2.php:3329 include/widget.php:17
123
  msgid "Subscribe2"
124
  msgstr ""
125
 
126
+ #: subscribe2.php:130
127
  msgid "Your Subscriptions"
128
  msgstr ""
129
 
130
+ #: subscribe2.php:134
131
  msgid "Mail Subscribers"
132
  msgstr ""
133
 
134
+ #: subscribe2.php:895
135
+ msgid "New Subscription"
136
  msgstr ""
137
 
138
+ #: subscribe2.php:897
139
  msgid "subscribed to email notifications!"
140
  msgstr ""
141
 
142
+ #: subscribe2.php:923
143
  msgid "New Unsubscription"
144
  msgstr ""
145
 
146
+ #: subscribe2.php:925
147
  msgid "unsubscribed from email notifications!"
148
  msgstr ""
149
 
150
+ #: subscribe2.php:1518
151
  msgid "Address(es) subscribed!"
152
  msgstr ""
153
 
154
+ #: subscribe2.php:1525
155
  msgid "Address(es) unsubscribed!"
156
  msgstr ""
157
 
158
+ #: subscribe2.php:1529
159
  msgid "Some emails were not processed, the following were already subscribed"
160
  msgstr ""
161
 
162
+ #: subscribe2.php:1532
163
  msgid "Some emails were not processed, the following were not in the database"
164
  msgstr ""
165
 
166
+ #: subscribe2.php:1541
167
  msgid "Address(es) deleted!"
168
  msgstr ""
169
 
170
+ #: subscribe2.php:1547 subscribe2.php:1553
171
  msgid "Status changed!"
172
  msgstr ""
173
 
174
+ #: subscribe2.php:1567
175
  msgid "Reminder Email(s) Sent!"
176
  msgstr ""
177
 
178
+ #: subscribe2.php:1570
179
  msgid "Registered Users Subscribed!"
180
  msgstr ""
181
 
182
+ #: subscribe2.php:1573
183
  msgid "Registered Users Unsubscribed!"
184
  msgstr ""
185
 
186
+ #: subscribe2.php:1576
187
  msgid "Format updated for Selected Registered Users!"
188
  msgstr ""
189
 
190
+ #: subscribe2.php:1671
191
  msgid "Previous Page"
192
  msgstr ""
193
 
194
+ #: subscribe2.php:1691
195
  msgid "Next Page"
196
  msgstr ""
197
 
198
+ #: subscribe2.php:1698
199
  msgid "Manage Subscribers"
200
  msgstr ""
201
 
202
+ #: subscribe2.php:1703
203
  msgid "Add/Remove Subscribers"
204
  msgstr ""
205
 
206
+ #: subscribe2.php:1704
207
  msgid "Enter addresses, one per line or comma-separated"
208
  msgstr ""
209
 
210
+ #: subscribe2.php:1708 subscribe2.php:1805 subscribe2.php:2547
211
+ #: subscribe2.php:3101 subscribe2.php:3106 include/widget.php:96
212
+ msgid "Unsubscribe"
213
+ msgstr ""
214
+
215
+ #: subscribe2.php:1711
216
  msgid "Current Subscribers"
217
  msgstr ""
218
 
219
+ #: subscribe2.php:1713
220
  msgid "Filter"
221
  msgstr ""
222
 
223
+ #: subscribe2.php:1718
224
  msgid "Search Subscribers"
225
  msgstr ""
226
 
227
+ #: subscribe2.php:1721
228
  msgid "Send Reminder Email"
229
  msgstr ""
230
 
231
+ #: subscribe2.php:1728
232
  msgid "Save Emails to CSV File"
233
  msgstr ""
234
 
235
+ #: subscribe2.php:1734 subscribe2.php:1792
236
  msgid "Process"
237
  msgstr ""
238
 
239
+ #: subscribe2.php:1747 subscribe2.php:1769
240
  msgid "Confirm this email address"
241
  msgstr ""
242
 
243
+ #: subscribe2.php:1749 subscribe2.php:1762
244
  msgid "Unconfirm this email address"
245
  msgstr ""
246
 
247
+ #: subscribe2.php:1751 subscribe2.php:1764 subscribe2.php:1772
248
  msgid "Delete this email address"
249
  msgstr ""
250
 
251
+ #: subscribe2.php:1755 subscribe2.php:2688
252
  msgid "Select / Unselect All"
253
  msgstr ""
254
 
255
+ #: subscribe2.php:1779
256
  msgid "edit"
257
  msgstr ""
258
 
259
+ #: subscribe2.php:1786
260
  msgid "No matching subscribers found"
261
  msgstr ""
262
 
263
+ #: subscribe2.php:1788
264
  msgid "NONE"
265
  msgstr ""
266
 
267
+ #: subscribe2.php:1800
268
  msgid "Categories"
269
  msgstr ""
270
 
271
+ #: subscribe2.php:1801
272
  msgid ""
273
  "Preferences for Registered Users selected in the filter above can be changed "
274
  "using this section."
275
  msgstr ""
276
 
277
+ #: subscribe2.php:1802
278
  msgid "Consider User Privacy as changes cannot be undone"
279
  msgstr ""
280
 
281
+ #: subscribe2.php:1803
282
  msgid "Action to perform"
283
  msgstr ""
284
 
285
+ #: subscribe2.php:1808
286
  msgid "Bulk Update Categories"
287
  msgstr ""
288
 
289
+ #: subscribe2.php:1810
290
  msgid "Send email as"
291
  msgstr ""
292
 
293
+ #: subscribe2.php:1811 subscribe2.php:2270 subscribe2.php:2419
294
  msgid "HTML - Full"
295
  msgstr ""
296
 
297
+ #: subscribe2.php:1812 subscribe2.php:2275 subscribe2.php:2424
298
  msgid "HTML - Excerpt"
299
  msgstr ""
300
 
301
+ #: subscribe2.php:1813 subscribe2.php:2280 subscribe2.php:2429
302
  msgid "Plain Text - Full"
303
  msgstr ""
304
 
305
+ #: subscribe2.php:1814 subscribe2.php:2285 subscribe2.php:2434
306
  msgid "Plain Text - Excerpt"
307
  msgstr ""
308
 
309
+ #: subscribe2.php:1815
310
  msgid "Bulk Update Format"
311
  msgstr ""
312
 
313
+ #: subscribe2.php:1852
314
  msgid "Preview message(s) sent to logged in user"
315
  msgstr ""
316
 
317
+ #: subscribe2.php:1856
318
  msgid ""
319
  "The Digest Notification email contained no post information. No email was "
320
  "sent"
321
  msgstr ""
322
 
323
+ #: subscribe2.php:1858
324
  msgid "Attempt made to resend the Digest Notification email"
325
  msgstr ""
326
 
327
+ #: subscribe2.php:2003
328
  msgid "Subscribe2 Settings"
329
  msgstr ""
330
 
331
+ #: subscribe2.php:2004
332
  msgid "Plugin Blog"
333
  msgstr ""
334
 
335
+ #: subscribe2.php:2005
336
  msgid "Make a donation via PayPal"
337
  msgstr ""
338
 
339
+ #: subscribe2.php:2016 subscribe2.php:2402
340
  msgid "Notification Settings"
341
  msgstr ""
342
 
343
+ #: subscribe2.php:2017
344
  msgid "Restrict the number of recipients per email to (0 for unlimited)"
345
  msgstr ""
346
 
347
+ #: subscribe2.php:2019 subscribe2.php:2182
348
  msgid "Edit"
349
  msgstr ""
350
 
351
+ #: subscribe2.php:2022 subscribe2.php:2185
352
  msgid "Update"
353
  msgstr ""
354
 
355
+ #: subscribe2.php:2023 subscribe2.php:2186
356
  msgid "Revert"
357
  msgstr ""
358
 
359
+ #: subscribe2.php:2025
360
  msgid "Send Admins notifications for new"
361
  msgstr ""
362
 
363
+ #: subscribe2.php:2030
364
  msgid "Subscriptions"
365
  msgstr ""
366
 
367
+ #: subscribe2.php:2035
368
  msgid "Unsubscriptions"
369
  msgstr ""
370
 
371
+ #: subscribe2.php:2040
372
  msgid "Both"
373
  msgstr ""
374
 
375
+ #: subscribe2.php:2045
376
  msgid "Neither"
377
  msgstr ""
378
 
379
+ #: subscribe2.php:2047
380
  msgid "Include theme CSS stylesheet in HTML notifications"
381
  msgstr ""
382
 
383
+ #: subscribe2.php:2052 subscribe2.php:2064 subscribe2.php:2075
384
+ #: subscribe2.php:2086 subscribe2.php:2248 subscribe2.php:2259
385
+ #: subscribe2.php:2291 subscribe2.php:2307 subscribe2.php:2442
386
+ #: subscribe2.php:2478
387
  msgid "Yes"
388
  msgstr ""
389
 
390
+ #: subscribe2.php:2057 subscribe2.php:2069 subscribe2.php:2080
391
+ #: subscribe2.php:2091 subscribe2.php:2242 subscribe2.php:2253
392
+ #: subscribe2.php:2264 subscribe2.php:2296 subscribe2.php:2312
393
+ #: subscribe2.php:2447 subscribe2.php:2482
394
  msgid "No"
395
  msgstr ""
396
 
397
+ #: subscribe2.php:2059
398
  msgid "Send Emails for Pages"
399
  msgstr ""
400
 
401
+ #: subscribe2.php:2070
402
  msgid "Send Emails for Password Protected Posts"
403
  msgstr ""
404
 
405
+ #: subscribe2.php:2081
406
  msgid "Send Emails for Private Posts"
407
  msgstr ""
408
 
409
+ #: subscribe2.php:2092
410
  msgid "Send Email From"
411
  msgstr ""
412
 
413
+ #: subscribe2.php:2097
414
  msgid "Send Emails"
415
  msgstr ""
416
 
417
+ #: subscribe2.php:2099
418
  msgid "For digest notifications, date order for posts is"
419
  msgstr ""
420
 
421
+ #: subscribe2.php:2104
422
  msgid "Descending"
423
  msgstr ""
424
 
425
+ #: subscribe2.php:2109
426
  msgid "Ascending"
427
  msgstr ""
428
 
429
+ #: subscribe2.php:2113
430
  msgid "Email Templates"
431
  msgstr ""
432
 
433
+ #: subscribe2.php:2117
434
  msgid "New Post email (must not be empty)"
435
  msgstr ""
436
 
437
+ #: subscribe2.php:2118 subscribe2.php:2147 subscribe2.php:2152
438
  msgid "Subject Line"
439
  msgstr ""
440
 
441
+ #: subscribe2.php:2123
442
  msgid "Send Email Preview"
443
  msgstr ""
444
 
445
+ #: subscribe2.php:2124
446
  msgid "Message substitions"
447
  msgstr ""
448
 
449
+ #: subscribe2.php:2128
450
  msgid "the post's title<br />(<i>for per-post emails only</i>)"
451
  msgstr ""
452
 
453
+ #: subscribe2.php:2129
454
  msgid ""
455
  "the excerpt or the entire post<br />(<i>based on the subscriber's "
456
  "preferences</i>)"
457
  msgstr ""
458
 
459
+ #: subscribe2.php:2130
460
  msgid ""
461
  "the excerpt of the post and the time it was posted<br />(<i>for digest "
462
  "emails only</i>)"
463
  msgstr ""
464
 
465
+ #: subscribe2.php:2131
466
  msgid "a list of post titles<br />(<i>for digest emails only</i>)"
467
  msgstr ""
468
 
469
+ #: subscribe2.php:2132
470
  msgid ""
471
  "a list of post titles followed by links to the atricles<br />(<i>for digest "
472
  "emails only</i>)"
473
  msgstr ""
474
 
475
+ #: subscribe2.php:2133
476
  msgid "the post's permalink<br />(<i>for per-post emails only</i>)"
477
  msgstr ""
478
 
479
+ #: subscribe2.php:2134
480
  msgid ""
481
  "the post's permalink after conversion by TinyURL<br />(<i>for per-post "
482
  "emails only</i>)"
483
  msgstr ""
484
 
485
+ #: subscribe2.php:2135
486
  msgid "the date the post was made<br />(<i>for per-post emails only</i>)"
487
  msgstr ""
488
 
489
+ #: subscribe2.php:2136
490
  msgid "the time the post was made<br />(<i>for per-post emails only</i>)"
491
  msgstr ""
492
 
493
+ #: subscribe2.php:2137
494
  msgid "the admin or post author's name"
495
  msgstr ""
496
 
497
+ #: subscribe2.php:2138
498
  msgid "the admin or post author's email"
499
  msgstr ""
500
 
501
+ #: subscribe2.php:2139
502
  msgid "the post author's name"
503
  msgstr ""
504
 
505
+ #: subscribe2.php:2140
506
  msgid ""
507
  "the generated link to confirm a request<br />(<i>only used in the "
508
  "confirmation email template</i>)"
509
  msgstr ""
510
 
511
+ #: subscribe2.php:2141
512
  msgid ""
513
  "Action performed by LINK in confirmation email<br />(<i>only used in the "
514
  "confirmation email template</i>)"
515
  msgstr ""
516
 
517
+ #: subscribe2.php:2142
518
  msgid "the post's assigned categories"
519
  msgstr ""
520
 
521
+ #: subscribe2.php:2143
522
  msgid "the post's assigned Tags"
523
  msgstr ""
524
 
525
+ #: subscribe2.php:2144
526
  msgid ""
527
  "the number of posts included in the digest email<br />(<i>for digest emails "
528
  "only</i>)"
529
  msgstr ""
530
 
531
+ #: subscribe2.php:2146
532
  msgid "Subscribe / Unsubscribe confirmation email"
533
  msgstr ""
534
 
535
+ #: subscribe2.php:2151
536
  msgid "Reminder email to Unconfirmed Subscribers"
537
  msgstr ""
538
 
539
+ #: subscribe2.php:2158
540
  msgid "Excluded Categories"
541
  msgstr ""
542
 
543
+ #: subscribe2.php:2160
544
  msgid ""
545
  "Posts assigned to any Excluded Category do not generate notifications and "
546
  "are not included in digest notifications"
547
  msgstr ""
548
 
549
+ #: subscribe2.php:2167
550
  msgid "Allow registered users to subscribe to excluded categories?"
551
  msgstr ""
552
 
553
+ #: subscribe2.php:2170
554
  msgid "Appearance"
555
  msgstr ""
556
 
557
+ #: subscribe2.php:2174
558
  msgid "Set default Subscribe2 page as ID"
559
  msgstr ""
560
 
561
+ #: subscribe2.php:2180
562
  msgid "Set the number of Subscribers displayed per page"
563
  msgstr ""
564
 
565
+ #: subscribe2.php:2193
566
  msgid "Show a link to your subscription page in \"meta\"?"
567
  msgstr ""
568
 
569
+ #: subscribe2.php:2200
570
  msgid "Show the Subscribe2 button on the Write toolbar?"
571
  msgstr ""
572
 
573
+ #: subscribe2.php:2207
574
  msgid "Enable Subscribe2 Widget?"
575
  msgstr ""
576
 
577
+ #: subscribe2.php:2214
578
  msgid "Enable Subscribe2 Counter Widget?"
579
  msgstr ""
580
 
581
+ #: subscribe2.php:2221
582
  msgid "Disable email notifications is checked by default on authoring pages?"
583
  msgstr ""
584
 
585
+ #: subscribe2.php:2225
586
  msgid "Auto Subscribe"
587
  msgstr ""
588
 
589
+ #: subscribe2.php:2227
590
  msgid "Subscribe new users registering with your blog"
591
  msgstr ""
592
 
593
+ #: subscribe2.php:2232
594
  msgid "Automatically"
595
  msgstr ""
596
 
597
+ #: subscribe2.php:2237
598
  msgid "Display option on Registration Form"
599
  msgstr ""
600
 
601
+ #: subscribe2.php:2243
602
  msgid "Auto-subscribe includes any excluded categories"
603
  msgstr ""
604
 
605
+ #: subscribe2.php:2254
606
  msgid "Registration Form option is checked by default"
607
  msgstr ""
608
 
609
+ #: subscribe2.php:2265
610
  msgid "Auto-subscribe users to receive email as"
611
  msgstr ""
612
 
613
+ #: subscribe2.php:2286
614
  msgid "Registered Users have the option to auto-subscribe to new categories"
615
  msgstr ""
616
 
617
+ #: subscribe2.php:2301
618
  msgid "New categories are immediately excluded"
619
  msgstr ""
620
 
621
+ #: subscribe2.php:2302
622
  msgid ""
623
  "Option for Registered Users to auto-subscribe to new categories is checked "
624
  "by default"
625
  msgstr ""
626
 
627
+ #: subscribe2.php:2316
628
  msgid "Barred Domains"
629
  msgstr ""
630
 
631
+ #: subscribe2.php:2318
632
  msgid ""
633
  "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
634
  "each entry and omit the \"@\" symbol, for example email.com)"
635
  msgstr ""
636
 
637
+ #: subscribe2.php:2323
638
  msgid "Submit"
639
  msgstr ""
640
 
641
+ #: subscribe2.php:2326
642
  msgid "Reset Default"
643
  msgstr ""
644
 
645
+ #: subscribe2.php:2327
646
  msgid ""
647
  "Use this to reset all options to their defaults. This <strong><em>will not</"
648
  "em></strong> modify your list of subscribers."
649
  msgstr ""
650
 
651
+ #: subscribe2.php:2329
652
  msgid "RESET"
653
  msgstr ""
654
 
655
+ #: subscribe2.php:2355
656
  msgid "Subscription preferences updated."
657
  msgstr ""
658
 
659
+ #: subscribe2.php:2405
660
  msgid "Editing Subscribe2 preferences for user"
661
  msgstr ""
662
 
663
+ #: subscribe2.php:2414
664
  msgid "Receive email as"
665
  msgstr ""
666
 
667
+ #: subscribe2.php:2437
668
  msgid "Automatically subscribe me to newly created categories"
669
  msgstr ""
670
 
671
+ #: subscribe2.php:2458
672
  msgid "Unsubscribe me from this blog"
673
  msgstr ""
674
 
675
+ #: subscribe2.php:2462
676
  msgid "Subscribe to all categories"
677
  msgstr ""
678
 
679
+ #: subscribe2.php:2464
680
  msgid "Subscribed Categories on"
681
  msgstr ""
682
 
683
+ #: subscribe2.php:2466
684
  msgid "Subscribed Categories"
685
  msgstr ""
686
 
687
+ #: subscribe2.php:2472
688
  msgid "Receive periodic summaries of new posts?"
689
  msgstr ""
690
 
691
+ #: subscribe2.php:2487
692
  msgid "Update Preferences"
693
  msgstr ""
694
 
695
+ #: subscribe2.php:2536
696
  msgid "Subscribed Blogs"
697
  msgstr ""
698
 
699
+ #: subscribe2.php:2541 subscribe2.php:2562
700
  msgid "Viewing Settings Now"
701
  msgstr ""
702
 
703
+ #: subscribe2.php:2545 subscribe2.php:2566
704
  msgid "View Settings"
705
  msgstr ""
706
 
707
+ #: subscribe2.php:2557
708
  msgid "Subscribe to new blogs"
709
  msgstr ""
710
 
711
+ #: subscribe2.php:2635
712
  msgid "Send an email to subscribers"
713
  msgstr ""
714
 
715
+ #: subscribe2.php:2643
716
  msgid "A message from"
717
  msgstr ""
718
 
719
+ #: subscribe2.php:2645
720
  msgid "Subject"
721
  msgstr ""
722
 
723
+ #: subscribe2.php:2648
724
  msgid "Recipients:"
725
  msgstr ""
726
 
727
+ #: subscribe2.php:2652
728
  msgid "Preview"
729
  msgstr ""
730
 
731
+ #: subscribe2.php:2652
732
  msgid "Send"
733
  msgstr ""
734
 
735
+ #: subscribe2.php:2723
736
  msgid "All Users and Subscribers"
737
  msgstr ""
738
 
739
+ #: subscribe2.php:2724
740
  msgid "Public Subscribers"
741
  msgstr ""
742
 
743
+ #: subscribe2.php:2725
744
  msgid "Confirmed"
745
  msgstr ""
746
 
747
+ #: subscribe2.php:2726
748
  msgid "Unconfirmed"
749
  msgstr ""
750
 
751
+ #: subscribe2.php:2727
752
  msgid "All Registered Users"
753
  msgstr ""
754
 
755
+ #: subscribe2.php:2728
756
  msgid "Registered Subscribers"
757
  msgstr ""
758
 
759
+ #: subscribe2.php:2839
760
  msgid "For each Post"
761
  msgstr ""
762
 
763
+ #: subscribe2.php:2856
764
  msgid "Send Digest Notification at"
765
  msgstr ""
766
 
767
+ #: subscribe2.php:2868
768
  msgid ""
769
  "This option will be ignored if the time selected is not in the future in "
770
  "relation to the current time"
771
  msgstr ""
772
 
773
+ #: subscribe2.php:2871
774
  msgid "Current UTC time is"
775
  msgstr ""
776
 
777
+ #: subscribe2.php:2873
778
  msgid "Current blog time is"
779
  msgstr ""
780
 
781
+ #: subscribe2.php:2875
782
  msgid "Next email notification will be sent when your blog time is after"
783
  msgstr ""
784
 
785
+ #: subscribe2.php:2878
786
  msgid "Attempt to resend the last Digest Notification email"
787
  msgstr ""
788
 
789
+ #: subscribe2.php:2879
790
  msgid "Resend Digest"
791
  msgstr ""
792
 
793
+ #: subscribe2.php:2956
794
  msgid "Confirmed Public Subscriber"
795
  msgstr ""
796
 
797
+ #: subscribe2.php:2958
798
  msgid "Unconfirmed Public Subscriber"
799
  msgstr ""
800
 
801
+ #: subscribe2.php:3009
802
  msgid "Settings"
803
  msgstr ""
804
 
805
+ #: subscribe2.php:3010
806
  msgid "Donate"
807
  msgstr ""
808
 
809
+ #: subscribe2.php:3021
810
  msgid "Check here to Subscribe to email notifications for new posts"
811
  msgstr ""
812
 
813
+ #: subscribe2.php:3030
814
  msgid ""
815
  "By registering with this blog you are also agreeing to receive email "
816
  "notifications for new posts but you can unsubscribe at anytime"
817
  msgstr ""
818
 
819
+ #: subscribe2.php:3050 subscribe2.php:3051
820
  msgid "Subscribe2 Notification Override"
821
  msgstr ""
822
 
823
+ #: subscribe2.php:3061
824
  msgid ""
825
  "Check here to disable sending of an email notification for this post/page"
826
  msgstr ""
827
 
828
+ #: subscribe2.php:3113
829
+ msgid "Your email:"
830
+ msgstr ""
831
+
832
+ #: subscribe2.php:3113
833
+ msgid "Enter email address..."
834
+ msgstr ""
835
+
836
+ #: subscribe2.php:3221
837
  msgid "Subscription Confirmation"
838
  msgstr ""
839
 
840
+ #: subscribe2.php:3312
841
  msgid "[Un]Subscribe to Posts"
842
  msgstr ""
843
 
844
+ #: subscribe2.php:3364
845
  msgid "Weekly"
846
  msgstr ""
847
 
848
+ #: subscribe2.php:3478 subscribe2.php:3479
849
  msgid "Author"
850
  msgstr ""
851
 
852
+ #: subscribe2.php:3487
853
  msgid "Posted on"
854
  msgstr ""
855
 
856
+ #: subscribe2.php:3491 subscribe2.php:3492
857
  msgid "Posted in"
858
  msgstr ""
859
 
860
+ #: subscribe2.php:3497 subscribe2.php:3498
861
  msgid "Tagged as"
862
  msgstr ""
863
 
864
+ #: subscribe2.php:3550
865
  msgid "Digest Email"
866
  msgstr ""
867
 
926
  msgid "Subscribe2 Widget"
927
  msgstr ""
928
 
929
+ #: include/widget.php:87
930
  msgid "Title"
931
  msgstr ""
932
 
933
+ #: include/widget.php:89
934
  msgid "Div class name"
935
  msgstr ""
936
 
937
+ #: include/widget.php:91
938
  msgid "Pre-Content"
939
  msgstr ""
940
 
941
+ #: include/widget.php:93
942
  msgid "Post-Content"
943
  msgstr ""
944
 
945
+ #: include/widget.php:95
946
+ msgid "Hide button"
947
+ msgstr ""
948
+
949
+ #: include/widget.php:96
950
+ msgid "None"
951
+ msgstr ""
952
+
953
+ #: include/widget.php:98
954
+ msgid "Post form content to page"
955
+ msgstr ""
956
+
957
+ #: include/widget.php:100
958
+ msgid "Use Subscribe2 Default"
959
+ msgstr ""
960
+
961
  #: include/counterwidget.php:7
962
  msgid "Subscriber Counter widget for the Subscribe2 plugin"
963
  msgstr ""