Subscribe2 - Version 10.22

Version Description

Download this release

Release Info

Developer tanaylakhani
Plugin Icon 128x128 Subscribe2
Version 10.22
Comparing to
See all releases

Code changes from version 10.21 to 10.22

Files changed (63) hide show
  1. 2422.diff +0 -421
  2. ChangeLog.txt +4 -0
  3. ReadMe.txt +11 -31
  4. admin/send-email.php +140 -0
  5. admin/send_email.php +0 -139
  6. admin/settings.php +365 -351
  7. admin/subscribers.php +168 -203
  8. admin/your-subscriptions.php +48 -0
  9. admin/your_subscriptions.php +0 -279
  10. classes/class-s2-admin.php +470 -534
  11. classes/class-s2-ajax.php +11 -13
  12. classes/class-s2-core.php +842 -809
  13. include/counterwidget.php → classes/class-s2-counter-widget.php +27 -6
  14. include/widget.php → classes/class-s2-form-widget.php +43 -14
  15. classes/class-s2-forms.php +410 -0
  16. classes/class-s2-frontend.php +256 -195
  17. classes/class-s2-list-table-legacy.php +358 -0
  18. classes/class-s2-list-table.php +230 -110
  19. classes/class-s2-multisite.php +62 -62
  20. classes/class-s2-upgrade.php +267 -147
  21. include/Sign-Alert-icon.png +0 -0
  22. include/{email_edit.png → email-edit.png} +0 -0
  23. include/options.php +92 -78
  24. include/{s2_ajax.js → s2-ajax.js} +21 -18
  25. include/s2-ajax.min.js +1 -0
  26. include/{s2_button.js → s2-button.js} +0 -0
  27. include/s2-button.min.js +1 -0
  28. include/{s2_button.png → s2-button.png} +0 -0
  29. include/{s2_checkbox.js → s2-checkbox.js} +0 -0
  30. include/s2-checkbox.min.js +1 -0
  31. include/{s2_colorpicker.js → s2-colorpicker.js} +0 -0
  32. include/s2-colorpicker.min.js +1 -0
  33. include/s2-date-time.js +6 -0
  34. include/s2-date-time.min.js +1 -0
  35. include/s2-dismiss.js +12 -0
  36. include/s2-dismiss.min.js +1 -0
  37. include/{s2_edit.js → s2-edit.js} +2 -2
  38. include/s2-edit.min.js +1 -0
  39. include/s2-ip-updater.js +12 -0
  40. include/s2-ip-updater.min.js +1 -0
  41. include/{s2_marker.png → s2-marker.png} +0 -0
  42. include/s2-subscribers.js +53 -0
  43. include/s2-subscribers.min.js +1 -0
  44. include/{s2_user_admin.css → s2-user-admin.css} +0 -0
  45. include/s2_ajax.min.js +0 -1
  46. include/s2_button.min.js +0 -1
  47. include/s2_checkbox.min.js +0 -1
  48. include/s2_colorpicker.min.js +0 -1
  49. include/s2_date_time.js +0 -6
  50. include/s2_date_time.min.js +0 -1
  51. include/s2_edit.min.js +0 -1
  52. Licence.txt → license.txt +0 -0
  53. subscribe2.php +25 -34
  54. subscribe2.pot +0 -1638
  55. tinymce/css/content.css +9 -1
  56. tinymce/css/content.min.css +1 -0
  57. tinymce/{editor_plugin3.js → editor-plugin3.js} +4 -6
  58. tinymce/editor-plugin3.min.js +1 -0
  59. tinymce/{editor_plugin4.js → editor-plugin4.js} +4 -4
  60. tinymce/editor-plugin4.min.js +1 -0
  61. tinymce/editor_plugin3.min.js +0 -1
  62. tinymce/editor_plugin4.min.js +0 -1
  63. uninstall.php +19 -20
2422.diff DELETED
@@ -1,421 +0,0 @@
1
- Index: include/counterwidget.php
2
- ===================================================================
3
- --- include/counterwidget.php (revision 1228025)
4
- +++ include/counterwidget.php (working copy)
5
- @@ -3,34 +3,34 @@
6
- /**
7
- Declares the S2_Counter_widget class.
8
- */
9
- - function S2_Counter_widget() {
10
- - $widget_options = array('classname' => 's2_counter', 'description' => __('Subscriber Counter widget for Subscribe2', 'subscribe2') );
11
- - $control_options = array('width' => 250, 'height' => 500);
12
- - $this->WP_Widget('s2_counter', __('Subscribe2 Counter', 'subscribe2'), $widget_options, $control_options);
13
- + function __construct() {
14
- + $widget_options = array( 'classname' => 's2_counter', 'description' => esc_html__( 'Subscriber Counter widget for Subscribe2', 'subscribe2' ) );
15
- + $control_options = array( 'width' => 250, 'height' => 500 );
16
- + parent::__construct( 's2_counter', esc_html__( 'Subscribe2 Counter', 'subscribe2' ), $widget_options, $control_options );
17
- }
18
-
19
- /**
20
- Displays the Widget
21
- */
22
- - function widget($args, $instance) {
23
- - $title = empty($instance['title']) ? 'Subscriber Count' : $instance['title'];
24
- - $s2w_bg = empty($instance['s2w_bg']) ? '#e3dacf' : $instance['s2w_bg'];
25
- - $s2w_fg = empty($instance['s2w_fg']) ? '#345797' : $instance['s2w_fg'];
26
- - $s2w_width = empty($instance['s2w_width']) ? '82' : $instance['s2w_width'];
27
- - $s2w_height = empty($instance['s2w_height']) ? '16' : $instance['s2w_height'];
28
- - $s2w_font = empty($instance['s2w_font']) ? '11' : $instance['s2w_font'];
29
- + function widget( $args, $instance ) {
30
- + $title = empty( $instance['title'] ) ? 'Subscriber Count' : $instance['title'];
31
- + $s2w_bg = empty( $instance['s2w_bg'] ) ? '#e3dacf' : $instance['s2w_bg'];
32
- + $s2w_fg = empty( $instance['s2w_fg'] ) ? '#345797' : $instance['s2w_fg'];
33
- + $s2w_width = empty( $instance['s2w_width'] ) ? '82' : $instance['s2w_width'];
34
- + $s2w_height = empty( $instance['s2w_height'] ) ? '16' : $instance['s2w_height'];
35
- + $s2w_font = empty( $instance['s2w_font'] ) ? '11' : $instance['s2w_font'];
36
-
37
- echo $args['before_widget'];
38
- - if ( !empty($title) ) {
39
- + if ( ! empty( $title ) ) {
40
- echo $args['before_title'] . $title . $args['after_title'];
41
- }
42
- global $mysubscribe2;
43
- $registered = $mysubscribe2->get_registered();
44
- $confirmed = $mysubscribe2->get_public();
45
- - $count = (count($registered) + count($confirmed));
46
- - echo "<ul><div style=\"text-align:center; background-color:" . $s2w_bg . "; color:" . $s2w_fg . "; width:" . $s2w_width . "px; height:" . $s2w_height . "px; font:" . $s2w_font . "pt Verdana, Arial, Helvetica, sans-serif; vertical-align:middle; padding:3px; border:1px solid #444;\">";
47
- + $count = (count( $registered ) + count( $confirmed ));
48
- + echo '<ul><div style="text-align:center; background-color:' . $s2w_bg . '; color:' . $s2w_fg . '; width:' . $s2w_width . 'px; height:' . $s2w_height . 'px; font:' . $s2w_font . 'pt Verdana, Arial, Helvetica, sans-serif; vertical-align:middle; padding:3px; border:1px solid #444;">';
49
- echo $count;
50
- - echo "</div></ul>";
51
- + echo '</div></ul>';
52
- echo $args['after_widget'];
53
- }
54
-
55
- @@ -37,14 +37,14 @@
56
- /**
57
- Saves the widgets settings.
58
- */
59
- - function update($new_instance, $old_instance) {
60
- + function update( $new_instance, $old_instance ) {
61
- $instance = $old_instance;
62
- - $instance['title'] = strip_tags(stripslashes($new_instance['title']));
63
- - $instance['s2w_bg'] = strip_tags(stripslashes($new_instance['s2w_bg']));
64
- - $instance['s2w_fg'] = strip_tags(stripslashes($new_instance['s2w_fg']));
65
- - $instance['s2w_width'] = strip_tags(stripslashes($new_instance['s2w_width']));
66
- - $instance['s2w_height'] = strip_tags(stripslashes($new_instance['s2w_height']));
67
- - $instance['s2w_font'] = strip_tags(stripslashes($new_instance['s2w_font']));
68
- + $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
69
- + $instance['s2w_bg'] = strip_tags( stripslashes( $new_instance['s2w_bg'] ) );
70
- + $instance['s2w_fg'] = strip_tags( stripslashes( $new_instance['s2w_fg'] ) );
71
- + $instance['s2w_width'] = strip_tags( stripslashes( $new_instance['s2w_width'] ) );
72
- + $instance['s2w_height'] = strip_tags( stripslashes( $new_instance['s2w_height'] ) );
73
- + $instance['s2w_font'] = strip_tags( stripslashes( $new_instance['s2w_font'] ) );
74
-
75
- return $instance;
76
- }
77
- @@ -52,47 +52,47 @@
78
- /**
79
- Creates the edit form for the widget.
80
- */
81
- - function form($instance) {
82
- + function form( $instance ) {
83
- // set some defaults
84
- - $options = get_option('widget_s2counter');
85
- - if ( $options === false ) {
86
- - $defaults = array('title'=>'Subscriber Count', 's2w_bg'=>'#e3dacf', 's2w_fg'=>'#345797', 's2w_width'=>'82', 's2w_height'=>'16', 's2w_font'=>'11');
87
- + $options = get_option( 'widget_s2counter' );
88
- + if ( false === $options ) {
89
- + $defaults = array( 'title' => 'Subscriber Count', 's2w_bg' => '#e3dacf', 's2w_fg' => '#345797', 's2w_width' => '82', 's2w_height' => '16', 's2w_font' => '11' );
90
- } else {
91
- - $defaults = array('title'=>$options['title'], 's2w_bg'=>$options['s2w_bg'], 's2w_fg'=>$options['s2w_fg'], 's2w_width'=>$options['s2w_width'], 's2w_height'=>$options['s2w_height'], 's2w_font'=>$options['s2w_font']);
92
- - delete_option('widget_s2counter');
93
- + $defaults = array( 'title' => $options['title'], 's2w_bg' => $options['s2w_bg'], 's2w_fg' => $options['s2w_fg'], 's2w_width' => $options['s2w_width'], 's2w_height' => $options['s2w_height'], 's2w_font' => $options['s2w_font'] );
94
- + delete_option( 'widget_s2counter' );
95
- }
96
- - $instance = wp_parse_args( (array) $instance, $defaults);
97
- + $instance = wp_parse_args( (array) $instance, $defaults );
98
- // Be sure you format your options to be valid HTML attributes.
99
- - $s2w_title = htmlspecialchars($instance['title'], ENT_QUOTES);
100
- - $s2w_bg = htmlspecialchars($instance['s2w_bg'], ENT_QUOTES);
101
- - $s2w_fg = htmlspecialchars($instance['s2w_fg'], ENT_QUOTES);
102
- - $s2w_width = htmlspecialchars($instance['s2w_width'], ENT_QUOTES);
103
- - $s2w_height = htmlspecialchars($instance['s2w_height'], ENT_QUOTES);
104
- - $s2w_font = htmlspecialchars($instance['s2w_font'], ENT_QUOTES);
105
- - echo "<div>\r\n";
106
- - echo "<fieldset><legend><label for=\"" . $this->get_field_id('title') . "\">" . __('Widget Title', 'subscribe2') . "</label></legend>\r\n";
107
- - echo "<input type=\"text\" name=\"" . $this->get_field_name('title') . "\" id=\"" . $this->get_field_id('title') . "\" value=\"" . $s2w_title . "\" />\r\n";
108
- - echo "</fieldset>\r\n";
109
- + $s2w_title = htmlspecialchars( $instance['title'], ENT_QUOTES );
110
- + $s2w_bg = htmlspecialchars( $instance['s2w_bg'], ENT_QUOTES );
111
- + $s2w_fg = htmlspecialchars( $instance['s2w_fg'], ENT_QUOTES );
112
- + $s2w_width = htmlspecialchars( $instance['s2w_width'], ENT_QUOTES );
113
- + $s2w_height = htmlspecialchars( $instance['s2w_height'], ENT_QUOTES );
114
- + $s2w_font = htmlspecialchars( $instance['s2w_font'], ENT_QUOTES );
115
- + echo '<div>' . "\r\n";
116
- + echo '<fieldset><legend><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Widget Title', 'subscribe2' ) . '</label></legend>' . "\r\n";
117
- + echo '<input type="text" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" value="' . esc_html__( $s2w_title ) . '" />' . "\r\n";
118
- + echo '</fieldset>' . "\r\n";
119
-
120
- - echo "<fieldset>\r\n";
121
- - echo "<legend>" . __('Color Scheme', 'subscribe2') . "</legend>\r\n";
122
- - echo "<label>\r\n";
123
- - echo "<input type=\"text\" name=\"" . $this->get_field_name('s2w_bg') . "\" id=\"" . $this->get_field_id('s2w_bg') . "\" maxlength=\"6\" value=\"" . $s2w_bg . "\" class=\"colorpickerField\" style=\"width:60px;\" /> " . __('Body', 'subscribe2') . "</label><br />\r\n";
124
- - echo "<label>\r\n";
125
- - echo "<input type=\"text\" name=\"" . $this->get_field_name('s2w_fg') . "\" id=\"" . $this->get_field_id('s2w_fg') . "\" maxlength=\"6\" value=\"" . $s2w_fg . "\" class=\"colorpickerField\" style=\"width:60px;\" /> " . __('Text', 'subscribe2') . "</label><br />\r\n";
126
- - echo "<div class=\"s2_colorpicker\" id =\"" . $this->get_field_id('s2_colorpicker') . "\"></div>";
127
- - echo "</fieldset>";
128
- + echo '<fieldset>' . "\r\n";
129
- + echo '<legend>' . esc_html__( 'Color Scheme', 'subscribe2' ) . '</legend>' . "\r\n";
130
- + echo '<label>' . "\r\n";
131
- + echo '<input type="text" name="' . esc_attr( $this->get_field_name( 's2w_bg' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_bg' ) ) . '" maxlength="6" value="' . esc_attr( $s2w_bg ) . '" class="colorpickerField" style="width:60px;" /> ' . esc_html__( 'Body', 'subscribe2' ) . '</label><br />' . "\r\n";
132
- + echo '<label>' . "\r\n";
133
- + echo '<input type="text" name="' . esc_attr( $this->get_field_name( 's2w_fg' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_fg' ) ) . '" maxlength="6" value="' . esc_attr( $s2w_fg ) . '" class="colorpickerField" style="width:60px;" /> ' . esc_html__( 'Text', 'subscribe2' ) . '</label><br />' . "\r\n";
134
- + echo '<div class="s2_colorpicker" id ="' . esc_attr( $this->get_field_id( 's2_colorpicker' ) ) . '"></div>';
135
- + echo '</fieldset>';
136
-
137
- - echo "<fieldset>\r\n";
138
- - echo "<legend>" . __('Width, Height and Font Size', 'subscribe2') . "</legend>\r\n";
139
- - echo "<table style=\"border:0; padding:0; margin:0 0 12px 0; border-collapse:collapse;\" align=\"center\">\r\n";
140
- - echo "<tr><td><label for=\"" . $this->get_field_id('s2w_width') . "\">" . __('Width', 'subscribe2') . "</label></td>\r\n";
141
- - echo "<td><input type=\"text\" name=\"" . $this->get_field_name('s2w_width') . "\" id=\"" . $this->get_field_id('s2w_width') . "\" value=\"" . $s2w_width . "\" /></td></tr>\r\n";
142
- - echo "<tr><td><label for=\"" . $this->get_field_id('s2w_height') . "\">" . __('Height', 'subscribe2') . "</label></td>\r\n";
143
- - echo "<td><input type=\"text\" name=\"" . $this->get_field_name('s2w_height') . "\" id=\"" . $this->get_field_id('s2w_height') . "\" value=\"" . $s2w_height . "\" /></td></tr>\r\n";
144
- - echo "<tr><td><label for=\"" . $this->get_field_id('s2w_font') . "\">" . __('Font', 'subscribe2') . "</label></td>\r\n";
145
- - echo "<td><input type=\"text\" name=\"" . $this->get_field_name('s2w_font') . "\" id=\"" . $this->get_field_id('s2w_font') . "\" value=\"" . $s2w_font . "\" /></td></tr>\r\n";
146
- - echo "</table></fieldset></div>\r\n";
147
- + echo '<fieldset>' . "\r\n";
148
- + echo '<legend>' . esc_html__( 'Width, Height and Font Size', 'subscribe2' ) . '</legend>' . "\r\n";
149
- + echo '<table style="border:0; padding:0; margin:0 0 12px 0; border-collapse:collapse;" align="center">' . "\r\n";
150
- + echo '<tr><td><label for="' . esc_attr( $this->get_field_id( 's2w_width' ) ) . '">' . esc_html__( 'Width', 'subscribe2' ) . '</label></td>' . "\r\n";
151
- + echo '<td><input type="text" name="' . esc_attr( $this->get_field_name( 's2w_width' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_width' ) ) . '" value="' . esc_attr( $s2w_width ) . '" /></td></tr>' . "\r\n";
152
- + echo '<tr><td><label for="' . esc_attr( $this->get_field_id( 's2w_height' ) ) . '">' . esc_html__( 'Height', 'subscribe2' ) . '</label></td>' . "\r\n";
153
- + echo '<td><input type="text" name="' . esc_attr( $this->get_field_name( 's2w_height' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_height' ) ) . '" value="' . esc_attr( $s2w_height ) . '" /></td></tr>' . "\r\n";
154
- + echo '<tr><td><label for="' . esc_attr( $this->get_field_id( 's2w_font' ) ) . '">' . esc_html__( 'Font', 'subscribe2' ) . '</label></td>' . "\r\n";
155
- + echo '<td><input type="text" name="' . esc_attr( $this->get_field_name( 's2w_font' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_font' ) ) . '" value="' . esc_attr( $s2w_font ) . '" /></td></tr>' . "\r\n";
156
- + echo '</table></fieldset></div>' . "\r\n";
157
- }
158
- }// end S2_Counter_widget class
159
- ?>
160
-
161
- Index: include/widget.php
162
- ===================================================================
163
- --- include/widget.php (revision 1228025)
164
- +++ include/widget.php (working copy)
165
- @@ -3,62 +3,62 @@
166
- /**
167
- Declares the Subscribe2 widget class.
168
- */
169
- - function S2_Form_widget() {
170
- - $widget_ops = array('classname' => 's2_form_widget', 'description' => __('Sidebar Widget for Subscribe2', 'subscribe2') );
171
- - $control_ops = array('width' => 250, 'height' => 300);
172
- - $this->WP_Widget('s2_form_widget', __('Subscribe2 Widget', 'subscribe2'), $widget_ops, $control_ops);
173
- + function __construct() {
174
- + $widget_ops = array( 'classname' => 's2_form_widget', 'description' => esc_html__( 'Sidebar Widget for Subscribe2', 'subscribe2' ) );
175
- + $control_ops = array( 'width' => 250, 'height' => 300 );
176
- + parent::__construct( 's2_form_widget', esc_html__( 'Subscribe2 Widget', 'subscribe2' ), $widget_ops, $control_ops );
177
- }
178
-
179
- /**
180
- Displays the Widget
181
- */
182
- - function widget($args, $instance) {
183
- - $title = empty($instance['title']) ? __('Subscribe2', 'subscribe2') : $instance['title'];
184
- - $div = empty($instance['div']) ? 'search' : $instance['div'];
185
- - $widgetprecontent = empty($instance['widgetprecontent']) ? '' : $instance['widgetprecontent'];
186
- - $widgetpostcontent = empty($instance['widgetpostcontent']) ? '' : $instance['widgetpostcontent'];
187
- - $textbox_size = empty($instance['size']) ? 20 : $instance['size'];
188
- - $hidebutton = empty($instance['hidebutton']) ? 'none' : $instance['hidebutton'];
189
- - $postto = empty($instance['postto']) ? '' : $instance['postto'];
190
- - $js = empty($instance['js']) ? '' : $instance['js'];
191
- - $noantispam = empty($instance['noantispam']) ? '' : $instance['noantispam'];
192
- - $nowrap = empty($instance['nowrap']) ? '' : $instance['nowrap'];
193
- + function widget( $args, $instance ) {
194
- + $title = empty( $instance['title'] ) ? __( 'Subscribe2', 'subscribe2' ) : $instance['title'];
195
- + $div = empty( $instance['div'] ) ? 'search' : $instance['div'];
196
- + $widgetprecontent = empty( $instance['widgetprecontent'] ) ? '' : $instance['widgetprecontent'];
197
- + $widgetpostcontent = empty( $instance['widgetpostcontent'] ) ? '' : $instance['widgetpostcontent'];
198
- + $textbox_size = empty( $instance['size'] ) ? 20 : $instance['size'];
199
- + $hidebutton = empty( $instance['hidebutton'] ) ? 'none' : $instance['hidebutton'];
200
- + $postto = empty( $instance['postto'] ) ? '' : $instance['postto'];
201
- + $js = empty( $instance['js'] ) ? '' : $instance['js'];
202
- + $noantispam = empty( $instance['noantispam'] ) ? '' : $instance['noantispam'];
203
- + $nowrap = empty( $instance['nowrap'] ) ? '' : $instance['nowrap'];
204
- $hide = '';
205
- - if ( $hidebutton == 'subscribe' || $hidebutton == 'unsubscribe' ) {
206
- - $hide = " hide=\"" . $hidebutton . "\"";
207
- - } elseif ( $hidebutton == 'link' ) {
208
- - $hide = " link=\"" . __('(Un)Subscribe to Posts', 'subscribe2') . "\"";
209
- + if ( 'subscribe' === $hidebutton || 'unsubscribe' === $hidebutton ) {
210
- + $hide = ' hide="' . $hidebutton . '"';
211
- + } elseif ( 'link' === $hidebutton ) {
212
- + $hide = ' link="' . __( '(Un)Subscribe to Posts', 'subscribe2' ) . '"';
213
- }
214
- $postid = '';
215
- - if ( !empty($postto) ) {
216
- - $postid = " id=\"" . $postto . "\"";
217
- + if ( ! empty( $postto ) ) {
218
- + $postid = ' id="' . $postto . '"';
219
- }
220
- - $size = " size=\"" . $textbox_size . "\"";
221
- + $size = ' size="' . $textbox_size . '"';
222
- $nojs = '';
223
- if ( $js ) {
224
- - $nojs = " nojs=\"true\"";
225
- + $nojs = ' nojs="true"';
226
- }
227
- if ( $noantispam ) {
228
- - $noantispam = " noantispam=\"true\"";
229
- + $noantispam = ' noantispam="true"';
230
- }
231
- if ( $nowrap ) {
232
- - $nowrap = " wrap=\"false\"";
233
- + $nowrap = ' wrap="false"';
234
- }
235
- - $shortcode = "[subscribe2" . $hide . $postid . $size . $nojs . $noantispam . $nowrap . "]";
236
- + $shortcode = '[subscribe2' . $hide . $postid . $size . $nojs . $noantispam . $nowrap . ']';
237
- echo $args['before_widget'];
238
- - if ( !empty($title) ) {
239
- - echo $args['before_title'] . $title . $args['after_title'];
240
- + if ( ! empty( $title ) ) {
241
- + echo $args['before_title'] . esc_attr( $title ) . $args['after_title'];
242
- }
243
- - echo "<div class=\"" . $div . "\">";
244
- + echo '<div class="' . esc_attr( $div ) . '">';
245
- $content = do_shortcode( $shortcode );
246
- - if ( !empty($widgetprecontent) ) {
247
- - echo $widgetprecontent;
248
- + if ( ! empty( $widgetprecontent ) ) {
249
- + echo wp_kses( $widgetprecontent, 'post' );
250
- }
251
- echo $content;
252
- - if ( !empty($widgetpostcontent) ) {
253
- - echo $widgetpostcontent;
254
- + if ( ! empty( $widgetpostcontent ) ) {
255
- + echo wp_kses( $widgetpostcontent, 'post' );
256
- }
257
- - echo "</div>";
258
- + echo '</div>';
259
- echo $args['after_widget'];
260
- }
261
-
262
- @@ -65,18 +65,18 @@
263
- /**
264
- Saves the widgets settings.
265
- */
266
- - function update($new_instance, $old_instance) {
267
- + function update( $new_instance, $old_instance ) {
268
- $instance = $old_instance;
269
- - $instance['title'] = strip_tags(stripslashes($new_instance['title']));
270
- - $instance['div'] = strip_tags(stripslashes($new_instance['div']));
271
- - $instance['widgetprecontent'] = stripslashes($new_instance['widgetprecontent']);
272
- - $instance['widgetpostcontent'] = stripslashes($new_instance['widgetpostcontent']);
273
- - $instance['size'] = intval(stripslashes($new_instance['size']));
274
- - $instance['hidebutton'] = strip_tags(stripslashes($new_instance['hidebutton']));
275
- - $instance['postto'] = stripslashes($new_instance['postto']);
276
- - $instance['js'] = stripslashes($new_instance['js']);
277
- - $instance['noantispam'] = stripslashes($new_instance['noantispam']);
278
- - $instance['nowrap'] = stripslashes($new_instance['nowrap']);
279
- + $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
280
- + $instance['div'] = strip_tags( stripslashes( $new_instance['div'] ) );
281
- + $instance['widgetprecontent'] = stripslashes( $new_instance['widgetprecontent'] );
282
- + $instance['widgetpostcontent'] = stripslashes( $new_instance['widgetpostcontent'] );
283
- + $instance['size'] = intval( stripslashes( $new_instance['size'] ) );
284
- + $instance['hidebutton'] = strip_tags( stripslashes( $new_instance['hidebutton'] ) );
285
- + $instance['postto'] = stripslashes( $new_instance['postto'] );
286
- + $instance['js'] = stripslashes( $new_instance['js'] );
287
- + $instance['noantispam'] = stripslashes( $new_instance['noantispam'] );
288
- + $instance['nowrap'] = stripslashes( $new_instance['nowrap'] );
289
-
290
- return $instance;
291
- }
292
- @@ -84,72 +84,72 @@
293
- /**
294
- Creates the edit form for the widget.
295
- */
296
- - function form($instance) {
297
- + function form( $instance ) {
298
- // set some defaults, getting any old options first
299
- - $options = get_option('widget_subscribe2widget');
300
- - if ( $options === false ) {
301
- - $defaults = array('title' => 'Subscribe2', 'div' => 'search', 'widgetprecontent' => '', 'widgetpostcontent' => '', 'size' => 20, 'hidebutton' => 'none', 'postto' => '', 'js' => '', 'noantispam' => '', 'nowrap' => '');
302
- + $options = get_option( 'widget_subscribe2widget' );
303
- + if ( false === $options ) {
304
- + $defaults = array( 'title' => 'Subscribe2', 'div' => 'search', 'widgetprecontent' => '', 'widgetpostcontent' => '', 'size' => 20, 'hidebutton' => 'none', 'postto' => '', 'js' => '', 'noantispam' => '', 'nowrap' => '' );
305
- } else {
306
- - $defaults = array('title' => $options['title'], 'div' => $options['div'], 'widgetprecontent' => $options['widgetprecontent'], 'widgetpostcontent' => $options['widgetpostcontent'], 'size' => $options['size'], 'hidebutton' => $options['hidebutton'], 'postto' => $options['postto'], 'js' => $options['js'], 'noantispam' => $options['noantispam'], 'nowrap' => $options['nowrap']);
307
- - delete_option('widget_subscribe2widget');
308
- + $defaults = array( 'title' => $options['title'], 'div' => $options['div'], 'widgetprecontent' => $options['widgetprecontent'], 'widgetpostcontent' => $options['widgetpostcontent'], 'size' => $options['size'], 'hidebutton' => $options['hidebutton'], 'postto' => $options['postto'], 'js' => $options['js'], 'noantispam' => $options['noantispam'], 'nowrap' => $options['nowrap'] );
309
- + delete_option( 'widget_subscribe2widget' );
310
- }
311
- // code to obtain old settings too
312
- - $instance = wp_parse_args( (array) $instance, $defaults);
313
- + $instance = wp_parse_args( (array) $instance, $defaults );
314
-
315
- - $title = htmlspecialchars($instance['title'], ENT_QUOTES);
316
- - $div = htmlspecialchars($instance['div'], ENT_QUOTES);
317
- - $widgetprecontent = htmlspecialchars($instance['widgetprecontent'], ENT_QUOTES);
318
- - $widgetpostcontent = htmlspecialchars($instance['widgetpostcontent'], ENT_QUOTES);
319
- - $size = htmlspecialchars($instance['size'], ENT_QUOTES);
320
- - $hidebutton = htmlspecialchars($instance['hidebutton'], ENT_QUOTES);
321
- - $postto = htmlspecialchars($instance['postto'], ENT_QUOTES);
322
- - $js = htmlspecialchars($instance['js'], ENT_QUOTES);
323
- - $noantispam = htmlspecialchars($instance['noantispam'], ENT_QUOTES);
324
- - $nowrap = htmlspecialchars($instance['nowrap'], ENT_QUOTES);
325
- + $title = htmlspecialchars( $instance['title'], ENT_QUOTES );
326
- + $div = htmlspecialchars( $instance['div'], ENT_QUOTES );
327
- + $widgetprecontent = htmlspecialchars( $instance['widgetprecontent'], ENT_QUOTES );
328
- + $widgetpostcontent = htmlspecialchars( $instance['widgetpostcontent'], ENT_QUOTES );
329
- + $size = htmlspecialchars( $instance['size'], ENT_QUOTES );
330
- + $hidebutton = htmlspecialchars( $instance['hidebutton'], ENT_QUOTES );
331
- + $postto = htmlspecialchars( $instance['postto'], ENT_QUOTES );
332
- + $js = htmlspecialchars( $instance['js'], ENT_QUOTES );
333
- + $noantispam = htmlspecialchars( $instance['noantispam'], ENT_QUOTES );
334
- + $nowrap = htmlspecialchars( $instance['nowrap'], ENT_QUOTES );
335
-
336
- global $wpdb, $mysubscribe2;
337
- $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
338
-
339
- - echo "<div>\r\n";
340
- - echo "<p><label for=\"" . $this->get_field_id('title') . "\">" . __('Title', 'subscribe2') . ":\r\n";
341
- - echo "<input class=\"widefat\" id=\"" . $this->get_field_id('title') . "\" name=\"" . $this->get_field_name('title') . "\" type=\"text\" value=\"" . $title . "\" /></label></p>\r\n";
342
- - echo "<p><label for=\"" . $this->get_field_id('div') . "\">" . __('Div class name', 'subscribe2') . ":\r\n";
343
- - echo "<input class=\"widefat\" id=\"" . $this->get_field_id('div') . "\" name=\"" . $this->get_field_name('div') . "\" type=\"text\" value=\"" . $div . "\" /></label></p>\r\n";
344
- - echo "<p><label for=\"" . $this->get_field_id('widgetprecontent') . "\">" . __('Pre-Content', 'subscribe2') . ":\r\n";
345
- - echo "<textarea class=\"widefat\" id=\"" . $this->get_field_id('widgetprecontent') . "\" name=\"" . $this->get_field_name('widgetprecontent') . "\" rows=\"2\" cols=\"25\">" . $widgetprecontent . "</textarea></label></p>\r\n";
346
- - echo "<p><label for=\"" . $this->get_field_id('widgetpostcontent') . "\">" . __('Post-Content', 'subscribe2') . ":\r\n";
347
- - 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";
348
- - echo "<p><label for=\"" . $this->get_field_id('size') . "\">" . __('Text Box Size', 'subscribe2') . ":\r\n";
349
- - echo "<input class=\"widefat\" id=\"" . $this->get_field_id('size') . "\" name=\"" . $this->get_field_name('size') . "\" type=\"text\" value=\"" . $size . "\" /></label></p>\r\n";
350
- - echo "<p>" . __('Display options', 'subscribe2') . ":<br />\r\n";
351
- - echo "<label for=\"" . $this->get_field_id('hidebutton') . "complete\"><input id=\"" . $this->get_field_id('hidebutton') . "complete\" name=\"" . $this->get_field_name('hidebutton') . "\" type=\"radio\" value=\"none\"". checked('none', $hidebutton, false) . "/> " . __('Show complete form', 'subscribe2') . "</label>\r\n";
352
- - echo "<br /><label for=\"" . $this->get_field_id('hidebutton') . "subscribe\"><input id=\"" . $this->get_field_id('hidebutton') . "subscribe\" name=\"" . $this->get_field_name('hidebutton') . "\" type=\"radio\" value=\"subscribe\"". checked('subscribe', $hidebutton, false) . "/> " . __('Hide Subscribe button', 'subscribe2') . "</label>\r\n";
353
- - echo "<br /><label for=\"" . $this->get_field_id('hidebutton') . "unsubscribe\"><input id=\"" . $this->get_field_id('hidebutton') . "unsubscribe\" name=\"" . $this->get_field_name('hidebutton') . "\" type=\"radio\" value=\"unsubscribe\"". checked('unsubscribe', $hidebutton, false) . "/> " . __('Hide Unsubscribe button', 'subscribe2') . "</label>\r\n";
354
- - if ( '1' == $mysubscribe2->subscribe2_options['ajax'] ) {
355
- - echo "<br /><label for=\"" . $this->get_field_id('hidebutton') . "ajax\"><input id=\"" . $this->get_field_id('hidebutton') . "ajax\" name=\"" . $this->get_field_name('hidebutton') . "\" type=\"radio\" value=\"link\"". checked('link', $hidebutton, false) . "/> " . __('Show as link', 'subscribe2') . "</label>\r\n";
356
- + echo '<div>' . "\r\n";
357
- + echo '<p><label for="'. esc_attr( $this->get_field_id( 'title' ) ) . '">' . __( 'Title', 'subscribe2' ) . ':' . "\r\n";
358
- + echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_html__( $title ) . '" /></label></p>' . "\r\n";
359
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'div' ) ) . '">' . __( 'Div class name', 'subscribe2' ) . ':' . "\r\n";
360
- + echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'div' ) ) . '" name="' . esc_attr( $this->get_field_name( 'div' ) ) . '" type="text" value="' . esc_html__( $div ) . '" /></label></p>' . "\r\n";
361
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '">' . esc_html__( 'Pre-Content', 'subscribe2' ) . ':' . "\r\n";
362
- + echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetprecontent' ) ) . '" rows="2" cols="25">' . esc_html__( $widgetprecontent ) . '</textarea></label></p>' . "\r\n";
363
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '">' . __( 'Post-Content', 'subscribe2' ) . ':' . "\r\n";
364
- + echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetpostcontent' ) ) . '" rows="2" cols="25">' . esc_html__( $widgetpostcontent ) . '</textarea></label></p>' . "\r\n";
365
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'size' ) ) . '">' . esc_html__( 'Text Box Size', 'subscribe2' ) . ':' . "\r\n";
366
- + echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'size' ) ) . '" name="' . esc_attr( $this->get_field_name( 'size' ) ) . '" type="text" value="' . esc_html__( $size ) . '" /></label></p>' . "\r\n";
367
- + echo '<p>' . __( 'Display options', 'subscribe2' ) . ':<br />' . "\r\n";
368
- + echo '<label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="none"'. checked( 'none', $hidebutton, false ) . '/> ' . esc_html__( 'Show complete form', 'subscribe2' ) . '</label>' . "\r\n";
369
- + echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="subscribe"' . checked( 'subscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Subscribe button', 'subscribe2' ) . '</label>' . "\r\n";
370
- + echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="unsubscribe"'. checked( 'unsubscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Unsubscribe button', 'subscribe2' ) . '</label>' . "\r\n";
371
- + if ( '1' === $mysubscribe2->subscribe2_options['ajax'] ) {
372
- + echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="link"'. checked( 'link', $hidebutton, false ) . '/> ' . esc_html__( 'Show as link', 'subscribe2' ) . '</label>' . "\r\n";
373
- }
374
- - echo "</p>\r\n";
375
- - echo "<p><label for=\"" . $this->get_field_id('postto') . "\">" . __('Post form content to page', 'subscribe2') . ":\r\n";
376
- - echo "<select class=\"widefat\" id=\"" . $this->get_field_id('postto') . "\" name=\"" . $this->get_field_name('postto') . "\">\r\n";
377
- - echo "<option value=\"" . $mysubscribe2->subscribe2_options['s2page'] . "\">" . __('Use Subscribe2 Default', 'subscribe2') . "</option>\r\n";
378
- - echo "<option value=\"home\"";
379
- - if ( $postto === 'home' ) { echo " selected=\"selected\""; }
380
- - echo ">" . __('Use Home Page', 'subscribe2') . "</option>\r\n";
381
- - echo "<option value=\"self\"";
382
- - if ( $postto === 'self' ) { echo " selected=\"selected\""; }
383
- - echo ">" . __('Use Referring Page', 'subscribe2') . "</option>\r\n";
384
- - $mysubscribe2->pages_dropdown($postto);
385
- - echo "</select></label></p>\r\n";
386
- - echo "<p><label for=\"" . $this->get_field_id('js') . "\">" . __('Disable JavaScript', 'subscribe2') . ":\r\n";
387
- - echo "<input id=\"" . $this->get_field_id('js') . "\" name =\"" . $this->get_field_name('js') . "\" value=\"true\" type=\"checkbox\"" . checked('true', $js, false) . "/>";
388
- - echo "</label></p>\r\n";
389
- - echo "<p><label for=\"" . $this->get_field_id('noantispam') . "\">" . __('Disable Anti-spam measures', 'subscribe2') . ":\r\n";
390
- - echo "<input id=\"" . $this->get_field_id('noantispam') . "\" name =\"" . $this->get_field_name('noantispam') . "\" value=\"true\" type=\"checkbox\"" . checked('true', $noantispam, false) . "/>";
391
- - echo "</label></p>\r\n";
392
- - echo "<p><label for=\"" . $this->get_field_id('nowrap') . "\">" . __('Disable wrapping of form buttons', 'subscribe2') . ":\r\n";
393
- - echo "<input id=\"" . $this->get_field_id('nowrap') . "\" name =\"" . $this->get_field_name('nowrap') . "\" value=\"true\" type=\"checkbox\"" . checked('true', $nowrap, false) . "/>";
394
- - echo "</label></p>\r\n";
395
- - echo "</div>\r\n";
396
- + echo '</p>' . "\r\n";
397
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'postto' ) ) . '">' . esc_html__( 'Post form content to page', 'subscribe2' ) . ':' . "\r\n";
398
- + echo '<select class="widefat" id="' . esc_attr( $this->get_field_id( 'postto' ) ) . '" name="' . esc_attr( $this->get_field_name( 'postto' ) ) . '">' . "\r\n";
399
- + echo '<option value="' . esc_attr( $mysubscribe2->subscribe2_options['s2page'] ) . '">' . esc_html__( 'Use Subscribe2 Default', 'subscribe2' ) . '</option>' . "\r\n";
400
- + echo '<option value="home"';
401
- + if ( 'home' === $postto ) { echo ' selected="selected"'; }
402
- + echo '>' . esc_html__( 'Use Home Page', 'subscribe2' ) . '</option>' . "\r\n";
403
- + echo '<option value="self"';
404
- + if ( 'self' === $postto ) { echo ' selected="selected"'; }
405
- + echo '>' . esc_html__( 'Use Referring Page', 'subscribe2' ) . '</option>' . "\r\n";
406
- + $mysubscribe2->pages_dropdown( $postto );
407
- + echo '</select></label></p>' . "\r\n";
408
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'js' ) ) . '">' . esc_html__( 'Disable JavaScript', 'subscribe2' ) . ':' . "\r\n";
409
- + echo '<input id="' . esc_attr( $this->get_field_id( 'js' ) ) . '" name ="' . esc_attr( $this->get_field_name( 'js' ) ) . '" value="true" type="checkbox"' . checked( 'true', $js, false ) . '/>';
410
- + echo '</label></p>' . "\r\n";
411
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'noantispam' ) ) . '">' . esc_html__( 'Disable Anti-spam measures', 'subscribe2' ) . ':' . "\r\n";
412
- + echo '<input id="' . esc_attr( $this->get_field_id( 'noantispam' ) ) . '" name ="' . esc_attr( $this->get_field_name( 'noantispam' ) ) . '" value="true" type="checkbox"' . checked( 'true', $noantispam, false ) . '/>';
413
- + echo '</label></p>' . "\r\n";
414
- + echo '<p><label for="' . esc_attr( $this->get_field_id( 'nowrap' ) ) . '">' . esc_html__( 'Disable wrapping of form buttons', 'subscribe2' ) . ':' . "\r\n";
415
- + echo '<input id="' . esc_attr( $this->get_field_id( 'nowrap' ) ) . '" name ="' . esc_attr( $this->get_field_name( 'nowrap' ) ) . '" value="true" type="checkbox"' . checked( 'true', $nowrap, false ) . '/>';
416
- + echo '</label></p>' . "\r\n";
417
- + echo '</div>' . "\r\n";
418
- }
419
- } // End S2_Form_widget class
420
- ?>
421
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ChangeLog.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  = 10.21 =
2
 
3
  * Remove ReadyGraph from subscribe2
1
+ = 10.22 =
2
+
3
+ * New release with lots of code improvements, bug fixes and enhancements - Thanks to Bryan Hadaway (bhadaway)!
4
+
5
  = 10.21 =
6
 
7
  * Remove ReadyGraph from subscribe2
ReadMe.txt CHANGED
@@ -1,36 +1,28 @@
1
  === Subscribe2 ===
 
2
  Contributors: Dabelon, wenzhixue, tanaylakhani
3
- Donate link: http://plugins.readygraph.com/donate/
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 3.3
6
- Tested up to: 4.3
7
- Stable tag: 10.21
8
- License: GPL3
9
 
10
- Sends a list of subscribers emails when you publish new posts.
11
 
12
  == Description ==
13
 
14
- Check official website for live demo http://plugins.readygraph.com/subscribe2/
15
-
16
- * [Live demo](http://plugins.readygraph.com/subscribe2/)
17
-
18
- * [More Description](http://plugins.readygraph.com/subscribe2/)
19
-
20
- * [Suggestion/comments](http://plugins.readygraph.com/subscribe2/)
21
-
22
-
23
  = Summary =
24
- Subscribe2 provides a comprehensive subscription management and email notification system for WordPress blogs that sends email notifications to a list of subscribers when you publish new content to your blog.
25
 
26
- **ReadyGraph is removed from the plugin**
27
 
28
  A full description of features is below.
29
 
30
  = Email =
 
31
  Email notifications can be sent on a per-post basis or periodically in a Digest email. Additionally, certain categories can be excluded from inclusion in the notification and posts can be excluded on an individual basis by setting a custom field.
32
 
33
  = Subscriptions =
 
34
  Subscription requests allows users to publicly subscribe (**Public Subscribers**) by submitting their email address in an easy to use form or to register with your blog (**Registered Users**) which enables greater flexibility over the email content for per-post notifications for the subscriber. Admins are given control over the presentation of the email notifications, can bulk manage subscriptions for users and manually send email notices to subscribers.
35
 
36
  The format of the email can also be customised for per-post notifications, Subscribe2 can generate emails for each of the following formats:
@@ -42,14 +34,11 @@ The format of the email can also be customised for per-post notifications, Subsc
42
 
43
  If you want to send full content HTML emails to Public Subscribers too then upgrade to [Subscribe2 HTML](http://semperplugins.com/plugins/subscribe2-html/).
44
 
45
-
46
  == Installation ==
47
 
48
- Installation Instruction and Configuration can also be found at [Installation Instruction and Configuration](http://plugins.readygraph.com/subscribe2/installation/)
49
-
50
  = AUTOMATIC INSTALLATION =
51
 
52
- 1. Log in to your WordPress blog and visit Plugins->Add New.
53
  2. Search for Subscribe2, click "Install Now" and then Activate the Plugin
54
  3. Visit the "Subscribe2 -> Settings" menu.
55
  4. Configure the options to taste, including the email template and any categories which should be excluded from notification
@@ -73,17 +62,8 @@ This token will automatically be replaced by dynamic subscription information an
73
 
74
  == Frequently Asked Questions ==
75
 
76
- For detailed FAQ and other support visit [http://plugins.readygraph.com/subscribe2/faq/](http://plugins.readygraph.com/subscribe2/faq/)
77
-
78
- == Screenshots ==
79
- 1. The Subscribe2->Mail Subscribers admin page generated by the plugin. http://plugins.readygraph.com/subscribe2/screenshots/
80
- 2. The Subscribe2->Subscribers admin page generated by the plugin. http://plugins.readygraph.com/subscribe2/screenshots/
81
- 3. The Subscribe2->Subscriptions admin page generated by the plugin. http://plugins.readygraph.com/subscribe2/screenshots/
82
- 4. The Subscribe2->Subscribe2 admin page generated by the plugin. http://plugins.readygraph.com/subscribe2/screenshots/
83
 
84
  == Changelog ==
85
 
86
- See complete changelog [here.](http://plugins.svn.wordpress.org/subscribe2/trunk/ChangeLog.txt)
87
-
88
- == Upgrade Notice ==
89
- See Update Version History
1
  === Subscribe2 ===
2
+
3
  Contributors: Dabelon, wenzhixue, tanaylakhani
 
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 3.3
6
+ Tested up to: 4.8.1
7
+ Stable tag: 10.22
8
+ License: GPLv3
9
 
10
+ Sends a list of subscribers an email notification when you publish new posts.
11
 
12
  == Description ==
13
 
 
 
 
 
 
 
 
 
 
14
  = Summary =
 
15
 
16
+ Subscribe2 provides a comprehensive subscription management and email notification system for WordPress blogs that sends email notifications to a list of subscribers when you publish new content to your blog.
17
 
18
  A full description of features is below.
19
 
20
  = Email =
21
+
22
  Email notifications can be sent on a per-post basis or periodically in a Digest email. Additionally, certain categories can be excluded from inclusion in the notification and posts can be excluded on an individual basis by setting a custom field.
23
 
24
  = Subscriptions =
25
+
26
  Subscription requests allows users to publicly subscribe (**Public Subscribers**) by submitting their email address in an easy to use form or to register with your blog (**Registered Users**) which enables greater flexibility over the email content for per-post notifications for the subscriber. Admins are given control over the presentation of the email notifications, can bulk manage subscriptions for users and manually send email notices to subscribers.
27
 
28
  The format of the email can also be customised for per-post notifications, Subscribe2 can generate emails for each of the following formats:
34
 
35
  If you want to send full content HTML emails to Public Subscribers too then upgrade to [Subscribe2 HTML](http://semperplugins.com/plugins/subscribe2-html/).
36
 
 
37
  == Installation ==
38
 
 
 
39
  = AUTOMATIC INSTALLATION =
40
 
41
+ 1. Log in to your WordPress blog and visit Plugins -> Add New.
42
  2. Search for Subscribe2, click "Install Now" and then Activate the Plugin
43
  3. Visit the "Subscribe2 -> Settings" menu.
44
  4. Configure the options to taste, including the email template and any categories which should be excluded from notification
62
 
63
  == Frequently Asked Questions ==
64
 
65
+ [Visit FAQ site](https://subscribe2.wordpress.com/support/faqs/)
 
 
 
 
 
 
66
 
67
  == Changelog ==
68
 
69
+ See complete changelog installed in the same folder as this readme.
 
 
 
admin/send-email.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! function_exists( 'add_action' ) ) {
3
+ exit();
4
+ }
5
+
6
+ global $wpdb, $current_user;
7
+
8
+ // was anything POSTed?
9
+ if ( ( isset( $_POST['s2_admin'] ) && 'mail' === $_POST['s2_admin'] ) || isset( $_GET['delete-draft'] ) ) {
10
+ if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'subscribe2-write_subscribers' . S2VERSION ) ) {
11
+ die( '<p>' . __( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
12
+ }
13
+
14
+ $subject = html_entity_decode( stripslashes( wp_kses( $this->substitute( $_POST['subject'] ), '' ) ), ENT_QUOTES );
15
+ $body = wpautop( $this->substitute( stripslashes( $_POST['content'] ) ), true );
16
+ if ( '' !== $current_user->display_name || '' !== $current_user->user_email ) {
17
+ $this->myname = html_entity_decode( $current_user->display_name, ENT_QUOTES );
18
+ $this->myemail = $current_user->user_email;
19
+ }
20
+ if ( isset( $_POST['send'] ) ) {
21
+ if ( 'confirmed' === $_POST['what'] ) {
22
+ $recipients = $this->get_public();
23
+ } elseif ( 'unconfirmed' === $_POST['what'] ) {
24
+ $recipients = $this->get_public( 0 );
25
+ } elseif ( 'public' === $_POST['what'] ) {
26
+ $confirmed = $this->get_public();
27
+ $unconfirmed = $this->get_public( 0 );
28
+ $recipients = array_merge( (array) $confirmed, (array) $unconfirmed );
29
+ } elseif ( is_numeric( $_POST['what'] ) ) {
30
+ $cat = intval( $_POST['what'] );
31
+ $recipients = $this->get_registered( "cats=$cat" );
32
+ } elseif ( 'all_users' === $_POST['what'] ) {
33
+ $recipients = $this->get_all_registered();
34
+ } elseif ( 'all' === $_POST['what'] ) {
35
+ $confirmed = $this->get_public();
36
+ $unconfirmed = $this->get_public( 0 );
37
+ $registered = $this->get_all_registered();
38
+ $recipients = array_merge( (array) $confirmed, (array) $unconfirmed, (array) $registered );
39
+ } else {
40
+ $recipients = $this->get_registered();
41
+ }
42
+ } elseif ( isset( $_POST['preview'] ) ) {
43
+ global $user_email;
44
+ $recipients[] = $user_email;
45
+ }
46
+
47
+ $uploads = array();
48
+ if ( ! empty( $_FILES ) ) {
49
+ foreach ( $_FILES['file']['name'] as $key => $value ) {
50
+ if ( 0 === $_FILES['file']['error'][ $key ] ) {
51
+ $file = array(
52
+ 'name' => $_FILES['file']['name'][ $key ],
53
+ 'type' => $_FILES['file']['type'][ $key ],
54
+ 'tmp_name' => $_FILES['file']['tmp_name'][ $key ],
55
+ 'error' => $_FILES['file']['error'][ $key ],
56
+ 'size' => $_FILES['file']['size'][ $key ],
57
+ );
58
+ $uploads[] = wp_handle_upload( $file, array(
59
+ 'test_form' => false,
60
+ ) );
61
+ }
62
+ }
63
+ }
64
+ $attachments = array();
65
+ if ( ! empty( $uploads ) ) {
66
+ foreach ( $uploads as $upload ) {
67
+ if ( ! isset( $upload['error'] ) ) {
68
+ $attachments[] = $upload['file'];
69
+ } else {
70
+ $upload_error = $upload['error'];
71
+ }
72
+ }
73
+ }
74
+
75
+ if ( empty( $body ) ) {
76
+ $error_message = __( 'Your email was empty', 'subscribe2' );
77
+ $status = false;
78
+ } elseif ( isset( $upload_error ) ) {
79
+ $error_message = $upload_error;
80
+ $status = false;
81
+ } else {
82
+ $status = $this->mail( $recipients, $subject, $body, 'text', $attachments );
83
+ $error_message = __( 'Check your settings and check with your hosting provider', 'subscribe2' );
84
+ }
85
+
86
+ if ( $status ) {
87
+ if ( isset( $_POST['preview'] ) ) {
88
+ $message = '<p class="s2_message">' . __( 'Preview message sent!', 'subscribe2' ) . '</p>';
89
+ } elseif ( isset( $_POST['send'] ) ) {
90
+ $message = '<p class="s2_message">' . __( 'Message sent!', 'subscribe2' ) . '</p>';
91
+ }
92
+ } else {
93
+ global $phpmailer;
94
+ $message = '<p class="s2_error">' . __( 'Message failed!', 'subscribe2' ) . '</p>' . $error_message . $phpmailer->ErrorInfo;
95
+ }
96
+ echo '<div id="message" class="updated"><strong><p>' . $message . '</p></strong></div>' . "\r\n";
97
+ }
98
+
99
+ // show our form
100
+ echo '<div class="wrap">';
101
+ echo '<h1>' . __( 'Send an email to subscribers', 'subscribe2' ) . '</h1>' . "\r\n";
102
+ echo '<form method="post" enctype="multipart/form-data">' . "\r\n";
103
+
104
+ wp_nonce_field( 'subscribe2-write_subscribers' . S2VERSION );
105
+
106
+ if ( isset( $_POST['subject'] ) ) {
107
+ $subject = stripslashes( esc_html( $_POST['subject'] ) );
108
+ } else {
109
+ $subject = __( 'A message from', 'subscribe2' ) . ' ' . html_entity_decode( get_option( 'blogname' ), ENT_QUOTES );
110
+ }
111
+ if ( ! isset( $_POST['content'] ) ) {
112
+ $body = '';
113
+ }
114
+ echo '<p>' . __( 'Subject', 'subscribe2' ) . ': <input type="text" size="69" name="subject" value="' . $subject . '" /> <br /><br />';
115
+ echo '<textarea rows="12" cols="75" name="content">' . $body . '</textarea>';
116
+ echo "<br /><div id=\"upload_files\"><input type=\"file\" name=\"file[]\"></div>\r\n";
117
+ echo '<input type="button" class="button-secondary" name="addmore" value="' . __( 'Add More Files', 'subscribe2' ) . "\" onClick=\"add_file_upload();\" />\r\n";
118
+ echo "<br /><br />\r\n";
119
+ echo __( 'Recipients:', 'subscribe2' ) . ' ';
120
+ $this->display_subscriber_dropdown( apply_filters( 's2_subscriber_dropdown_default', 'registered' ), false );
121
+ echo '<input type="hidden" name="s2_admin" value="mail" />';
122
+ echo '<p class="submit"><input type="submit" class="button-secondary" name="preview" value="' . __( 'Preview', 'subscribe2' ) . '" />&nbsp;<input type="submit" class="button-primary" name="send" value="' . __( 'Send', 'subscribe2' ) . '" /></p>';
123
+ echo '</form></div>' . "\r\n";
124
+ echo '<div style="clear: both;"><p>&nbsp;</p></div>';
125
+ ?>
126
+ <script type="text/javascript">
127
+ //<![CDATA[
128
+ function add_file_upload() {
129
+ var div = document.getElementById('upload_files');
130
+ var field = div.getElementsByTagName('input')[0];
131
+ div.appendChild(document.createElement("br"));
132
+ div.appendChild(field.cloneNode(false));
133
+ }
134
+ //]]>
135
+ </script>
136
+ <?php
137
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
138
+ // just to be sure
139
+ die;
140
+ ?>
admin/send_email.php DELETED
@@ -1,139 +0,0 @@
1
- <?php
2
- if ( !function_exists('add_action') ) {
3
- exit();
4
- }
5
-
6
- global $wpdb, $s2nonce, $current_user;
7
-
8
- // was anything POSTed?
9
- if ( isset($_POST['s2_admin']) && 'mail' == $_POST['s2_admin'] ) {
10
- check_admin_referer('subscribe2-write_subscribers' . $s2nonce);
11
- $subject = html_entity_decode(stripslashes(wp_kses($this->substitute($_POST['subject']), '')), ENT_QUOTES);
12
- $body = $this->substitute(stripslashes($_POST['content']));
13
- if ( '' != $current_user->display_name || '' != $current_user->user_email ) {
14
- $this->myname = html_entity_decode($current_user->display_name, ENT_QUOTES);
15
- $this->myemail = $current_user->user_email;
16
- }
17
- if ( isset($_POST['send']) ) {
18
- if ( 'confirmed' == $_POST['what'] ) {
19
- $recipients = $this->get_public();
20
- } elseif ( 'unconfirmed' == $_POST['what'] ) {
21
- $recipients = $this->get_public(0);
22
- } elseif ( 'public' == $_POST['what'] ) {
23
- $confirmed = $this->get_public();
24
- $unconfirmed = $this->get_public(0);
25
- $recipients = array_merge((array)$confirmed, (array)$unconfirmed);
26
- } elseif ( is_numeric($_POST['what']) ) {
27
- $cat = intval($_POST['what']);
28
- $recipients = $this->get_registered("cats=$cat");
29
- } elseif ( 'all_users' == $_POST['what'] ) {
30
- $recipients = $this->get_all_registered();
31
- } elseif ( 'all' == $_POST['what'] ) {
32
- $confirmed = $this->get_public();
33
- $unconfirmed = $this->get_public(0);
34
- $registered = $this->get_all_registered();
35
- $recipients = array_merge((array)$confirmed, (array)$unconfirmed, (array)$registered);
36
- } else {
37
- $recipients = $this->get_registered();
38
- }
39
- } elseif ( isset($_POST['preview']) ) {
40
- global $user_email;
41
- $recipients[] = $user_email;
42
- }
43
-
44
- $uploads = array();
45
- if ( !empty($_FILES) ) {
46
- foreach ($_FILES['file']['name'] as $key => $value) {
47
- if ( $_FILES['file']['error'][$key] === 0 ) {
48
- $file = array(
49
- 'name' => $_FILES['file']['name'][$key],
50
- 'type' => $_FILES['file']['type'][$key],
51
- 'tmp_name' => $_FILES['file']['tmp_name'][$key],
52
- 'error' => $_FILES['file']['error'][$key],
53
- 'size' => $_FILES['file']['size'][$key]
54
- );
55
- $uploads[] = wp_handle_upload($file, array('test_form' => false));
56
- }
57
- }
58
- }
59
- $attachments = array();
60
- if ( !empty($uploads) ) {
61
- foreach ( $uploads as $upload ) {
62
- if ( !isset($upload['error']) ) {
63
- $attachments[] = $upload['file'];
64
- } else {
65
- $upload_error = $upload['error'];
66
- }
67
- }
68
- }
69
-
70
- if ( empty($body) ) {
71
- $error_message = __('Your email was empty', 'subscribe2');
72
- $status = false;
73
- } elseif ( isset($upload_error) ) {
74
- $error_message = $upload_error;
75
- $status = false;
76
- } else {
77
- $status = $this->mail($recipients, $subject, $body, 'text', $attachments);
78
- $error_message = __('Check your settings and check with your hosting provider', 'subscribe2');
79
- }
80
-
81
- if ( $status ) {
82
- if ( isset($_POST['preview']) ) {
83
- $message = "<p class=\"s2_message\">" . __('Preview message sent!', 'subscribe2') . "</p>";
84
- } else {
85
- $message = "<p class=\"s2_message\">" . __('Message sent!', 'subscribe2') . "</p>";
86
- }
87
- } else {
88
- global $phpmailer;
89
- $message = "<p class=\"s2_error\">" . __('Message failed!', 'subscribe2') . "</p>" . $error_message . $phpmailer->ErrorInfo;
90
- }
91
- echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
92
- }
93
-
94
- // show our form
95
- echo "<div class=\"wrap\">";
96
- if ( version_compare($GLOBALS['wp_version'], '3.8', '<=') ) {
97
- echo "<div id=\"icon-edit\" class=\"icon32\"></div>";
98
- }
99
-
100
- echo "<h2>" . __('Send an email to subscribers', 'subscribe2') . "</h2>\r\n";
101
- echo "<form method=\"post\" enctype=\"multipart/form-data\">\r\n";
102
- if ( function_exists('wp_nonce_field') ) {
103
- wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
104
- }
105
- if ( isset($_POST['subject']) ) {
106
- $subject = stripslashes(esc_html($_POST['subject']));
107
- } else {
108
- $subject = __('A message from', 'subscribe2') . " " . html_entity_decode(get_option('blogname'), ENT_QUOTES);
109
- }
110
- if ( !isset($_POST['content']) ) {
111
- $body = '';
112
- }
113
- echo "<p>" . __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . $subject . "\" /> <br /><br />";
114
- echo "<textarea rows=\"12\" cols=\"75\" name=\"content\">" . $body . "</textarea>";
115
- echo "<br /><div id=\"upload_files\"><input type=\"file\" name=\"file[]\"></div>\r\n";
116
- echo "<input type=\"button\" class=\"button-secondary\" name=\"addmore\" value=\"" . __('Add More Files', 'subscribe2') . "\" onClick=\"add_file_upload();\" />\r\n";
117
- echo "<br /><br />\r\n";
118
- echo __('Recipients:', 'subscribe2') . " ";
119
- $this->display_subscriber_dropdown('registered', false);
120
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
121
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Preview', 'subscribe2') . "\" />&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"send\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
122
- echo "</form></div>\r\n";
123
- echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
124
- ?>
125
- <script type="text/javascript">
126
- //<![CDATA[
127
- function add_file_upload() {
128
- var div = document.getElementById('upload_files');
129
- var field = div.getElementsByTagName('input')[0];
130
- div.appendChild(document.createElement("br"));
131
- div.appendChild(field.cloneNode(false));
132
- }
133
- //]]>
134
- </script>
135
- <?php
136
- include(ABSPATH . 'wp-admin/admin-footer.php');
137
- // just to be sure
138
- die;
139
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/settings.php CHANGED
@@ -1,492 +1,506 @@
1
  <?php
2
- if ( !function_exists('add_action') ) {
3
  exit();
4
  }
5
 
6
- global $s2nonce, $wpdb, $wp_version, $current_tab;
7
 
8
  // was anything POSTed?
9
- if ( isset( $_POST['s2_admin']) ) {
10
- check_admin_referer('subscribe2-options_subscribers' . $s2nonce);
11
- if ( isset($_POST['reset']) ) {
 
 
 
12
  $this->reset();
13
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Options reset!', 'subscribe2') . "</strong></p></div>";
14
- } elseif ( isset($_POST['preview']) ) {
15
  global $user_email, $post;
16
  $this->preview_email = true;
17
- if ( 'never' == $this->subscribe2_options['email_freq'] ) {
18
- $posts = get_posts('numberposts=1');
19
  $post = $posts[0];
20
- $this->publish($post, $user_email);
21
  } else {
22
- $this->subscribe2_cron($user_email);
23
  }
24
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Preview message(s) sent to logged in user', 'subscribe2') . "</strong></p></div>";
25
- } elseif ( isset($_POST['resend']) ) {
26
- $status = $this->subscribe2_cron('', 'resend');
27
- if ( $status === false ) {
28
- 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>";
 
29
  } else {
30
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Attempt made to resend the Digest Notification email', 'subscribe2') . "</strong></p></div>";
31
  }
32
- } elseif ( isset($_POST['submit']) ) {
33
- foreach ($_POST as $key => $value) {
34
- if ( in_array($key, array('bcclimit', 's2page', 'entries')) ) {
35
  // numerical inputs fixed for old option names
36
- if ( is_numeric($_POST[$key]) && $_POST[$key] >= 0 ) {
37
- $this->subscribe2_options[$key] = (int)$_POST[$key];
 
 
38
  }
39
- } elseif ( in_array($key, array('show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'reg_override')) ) {
40
  // check box entries
41
- ( isset($_POST[$key]) && $_POST[$key] == '1' ) ? $newvalue = '1' : $newvalue = '0';
42
- $this->subscribe2_options[$key] = $newvalue;
43
- } elseif ( $key === 'appearance_users_tab' ) {
44
- $options = array('show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default');
45
  foreach ( $options as $option ) {
46
- if ( !isset($_POST[$option]) ) {
47
- $this->subscribe2_options[$option] = '';
48
  }
49
  }
50
- } elseif ( in_array($key, array('notification_subject', 'mailtext', 'confirm_subject', 'confirm_email', 'remind_subject', 'remind_email')) && !empty($_POST[$key]) ) {
51
  // email subject and body templates
52
- $this->subscribe2_options[$key] = $_POST[$key];
53
- } elseif ( in_array($key, array('compulsory', 'exclude', 'format')) ) {
54
- sort($_POST[$key]);
55
- $newvalue = implode(',', $_POST[$key]);
56
 
57
- if ($key === 'format') {
58
  $this->subscribe2_options['exclude_formats'] = $newvalue;
59
  } else {
60
- $this->subscribe2_options[$key] = $newvalue;
61
  }
62
- } elseif ( $key === 'registered_users_tab' ) {
63
- $options = array('compulsory', 'exclude', 'format', 'reg_override');
64
  foreach ( $options as $option ) {
65
- if ( !isset($_POST[$option]) ) {
66
- if ($option === 'format') {
67
  $this->subscribe2_options['exclude_formats'] = '';
68
  } else {
69
- $this->subscribe2_options[$option] = '';
70
  }
71
  }
72
  }
73
- } elseif ( $key === 'email_freq' ) {
74
  // send per-post or digest emails
75
  $email_freq = $_POST['email_freq'];
76
- $scheduled_time = wp_next_scheduled('s2_digest_cron');
77
- $timestamp_offset = get_option('gmt_offset') * 60 * 60;
78
- $crondate = (isset($_POST['crondate'])) ? $_POST['crondate'] : 0;
79
- $crontime = (isset($_POST['crondate'])) ? $_POST['crontime'] : 0;
80
- if ( $email_freq != $this->subscribe2_options['email_freq'] || $crondate != date_i18n(get_option('date_format'), $scheduled_time + $timestamp_offset) || $crontime != date('G', $scheduled_time + $timestamp_offset) ) {
81
  $this->subscribe2_options['email_freq'] = $email_freq;
82
- wp_clear_scheduled_hook('s2_digest_cron');
83
- $scheds = (array)wp_get_schedules();
84
- $interval = ( isset($scheds[$email_freq]['interval']) ) ? (int)$scheds[$email_freq]['interval'] : 0;
85
- if ( $interval == 0 ) {
86
  // if we are on per-post emails remove last_cron entry
87
- unset($this->subscribe2_options['last_s2cron']);
88
  } else {
89
  // if we are using digest schedule the event and prime last_cron as now
90
  $time = time() + $interval;
91
- $srttimestamp = strtotime($crondate) + ($crontime * 60 * 60);
92
- if ( $srttimestamp === false || $srttimestamp === 0 ) {
93
- $srttimestamp == time();
94
  }
95
  $timestamp = $srttimestamp - $timestamp_offset;
96
- while ($timestamp < time()) {
97
  // if we are trying to set the time in the past increment it forward
98
  // by the interval period until it is in the future
99
  $timestamp += $interval;
100
  }
101
- wp_schedule_event($timestamp, $email_freq, 's2_digest_cron');
102
  }
103
  }
104
  } else {
105
- if ( isset($this->subscribe2_options[$key]) ) {
106
- $this->subscribe2_options[$key] = $_POST[$key];
 
 
 
107
  }
108
  }
109
  }
110
 
111
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Options saved!', 'subscribe2') . "</strong></p></div>";
112
- update_option('subscribe2_options', $this->subscribe2_options);
113
  }
114
  }
115
 
116
  // send error message if no WordPress page exists
117
  $sql = "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1";
118
- $id = $wpdb->get_var($sql);
119
- if ( empty($id) ) {
120
- echo "<div id=\"page_message\" class=\"error\"><p class=\"s2_error\"><strong>" . __('You must create a WordPress page for this plugin to work correctly.', 'subscribe2') . "</strong></p></div>";
121
  }
122
 
123
- if ( $this->subscribe2_options['email_freq'] != 'never' ) {
124
- $disallowed_keywords = array('{TITLE}', '{PERMALINK}', '{DATE}', '{TIME}', '{LINK}', '{ACTION}', '{REFERENCELINKS}');
125
  } else {
126
- $disallowed_keywords = array('{POSTTIME}', '{TABLE}', '{TABLELINKS}', '{COUNT}', '{LINK}', '{ACTION}');
127
  }
128
  $disallowed = false;
129
  foreach ( $disallowed_keywords as $disallowed_keyword ) {
130
- if ( strstr($this->subscribe2_options['mailtext'], $disallowed_keyword) !== false ) {
131
  $disallowed[] = $disallowed_keyword;
132
  }
133
  }
134
- if ( $disallowed !== false ) {
135
- $disallowed_keywords = __('Your chosen email type (per-post or digest) does not support the following keywords:', 'subscribe2');
136
- $template_link = "<a href = \"" . admin_url('admin.php?page=s2_settings&tab=templates') . "\">" . __('Modify your template', 'subscribe2') . "</a>";
137
- echo "<div id=\"keyword_message\" class=\"error\"><p class=\"s2_error\"><strong>$disallowed_keywords</strong><br />" . implode($disallowed, ', ') . "<br />" . $template_link . "</p></div>";
 
138
  }
139
 
140
  // send error message if sender email address is off-domain
141
- if ( $this->subscribe2_options['sender'] == 'blogname' ) {
142
- $sender = get_bloginfo('admin_email');
143
  } else {
144
- $userdata = $this->get_userdata($this->subscribe2_options['sender']);
145
  $sender = $userdata->user_email;
146
  }
147
- list($user, $domain) = explode('@', $sender, 2);
148
- if ( !stristr($_SERVER['SERVER_NAME'], $domain) && $this->subscribe2_options['sender'] != 'author' ) {
149
- echo "<div id=\"sender_message\" class=\"error\"><p class=\"s2_error\"><strong>" . sprintf(__('You appear to be sending notifications from %1$s, which has a different domain name than your blog server %2$s. This may result in failed emails.', 'subscribe2'), $sender, $_SERVER['SERVER_NAME']) . "</strong></p></div>";
150
  }
151
 
152
  // detect or define which tab we are in
153
  $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'email';
154
 
155
  // show our form
156
- echo "<div class=\"wrap\">";
157
- if ( version_compare($GLOBALS['wp_version'], '3.8', '<=') ) {
158
- echo "<div id=\"icon-options-general\" class=\"icon32\"></div>";
159
- }
160
-
161
- $tabs = array('email' => __('Email Settings', 'subscribe2'),
162
- 'templates' => __('Templates', 'subscribe2'),
163
- 'registered' => __('Registered Users', 'subscribe2'),
164
- 'appearance' => __('Appearance', 'subscribe2'),
165
- 'misc' => __('Miscellaneous', 'subscribe2'));
166
- echo "<h2 class=\"nav-tab-wrapper\">";
167
  foreach ( $tabs as $tab_key => $tab_caption ) {
168
- $active = ($current_tab == $tab_key) ? "nav-tab-active" : "";
169
- echo "<a class=\"nav-tab " . $active . "\" href=\"?page=s2_settings&amp;tab=" . $tab_key . "\">" . $tab_caption . "</a>";
170
  }
171
- echo "</h2>";
172
 
173
- echo "<form method=\"post\">\r\n";
174
- if ( function_exists('wp_nonce_field') ) {
175
- wp_nonce_field('subscribe2-options_subscribers' . $s2nonce);
176
- }
177
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"options\" />\r\n";
178
- echo "<input type=\"hidden\" id=\"jsbcclimit\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" />";
179
- echo "<input type=\"hidden\" id=\"jsentries\" value=\"" . $this->subscribe2_options['entries'] . "\" />";
180
 
181
- switch ($current_tab) {
 
 
 
 
182
  case 'email':
183
  // settings for outgoing emails
184
- echo "<div class=\"s2_admin\" id=\"s2_notification_settings\">\r\n";
185
- echo "<p>\r\n";
186
- echo __('Restrict the number of <strong>recipients per email</strong> to (0 for unlimited)', 'subscribe2') . ': ';
187
- echo "<span id=\"s2bcclimit_1\"><span id=\"s2bcclimit\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['bcclimit'] . "</span> ";
188
- echo "<a href=\"#\" onclick=\"s2_show('bcclimit'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
189
- echo "<span id=\"s2bcclimit_2\">\r\n";
190
- echo "<input type=\"text\" name=\"bcclimit\" value=\"" . $this->subscribe2_options['bcclimit'] . "\" size=\"3\" />\r\n";
191
- echo "<a href=\"#\" onclick=\"s2_update('bcclimit'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
192
- echo "<a href=\"#\" onclick=\"s2_revert('bcclimit'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
193
-
194
- echo "<br /><br />" . __('Send Admins notifications for new', 'subscribe2') . ': ';
195
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"subs\"" . checked($this->subscribe2_options['admin_email'], 'subs', false) . " />\r\n";
196
- echo __('Subscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
197
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"unsubs\"" . checked($this->subscribe2_options['admin_email'], 'unsubs', false) . " />\r\n";
198
- echo __('Unsubscriptions', 'subscribe2') . "</label>&nbsp;&nbsp;";
199
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"both\"" . checked($this->subscribe2_options['admin_email'], 'both', false) . " />\r\n";
200
- echo __('Both', 'subscribe2') . "</label>&nbsp;&nbsp;";
201
- echo "<label><input type=\"radio\" name=\"admin_email\" value=\"none\"" . checked($this->subscribe2_options['admin_email'], 'none', false) . " />\r\n";
202
- echo __('Neither', 'subscribe2') . "</label><br /><br />\r\n";
203
-
204
- echo __('Include theme CSS stylesheet in HTML notifications', 'subscribe2') . ': ';
205
- echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"yes\"" . checked($this->subscribe2_options['stylesheet'], 'yes', false) . " /> ";
206
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
207
- echo "<label><input type=\"radio\" name=\"stylesheet\" value=\"no\"" . checked($this->subscribe2_options['stylesheet'], 'no', false) . " /> ";
208
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
209
-
210
- echo __('Send Emails for Pages', 'subscribe2') . ': ';
211
- echo "<label><input type=\"radio\" name=\"pages\" value=\"yes\"" . checked($this->subscribe2_options['pages'], 'yes', false) . " /> ";
212
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
213
- echo "<label><input type=\"radio\" name=\"pages\" value=\"no\"" . checked($this->subscribe2_options['pages'], 'no', false) . " /> ";
214
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
215
- $s2_post_types = apply_filters('s2_post_types', NULL);
216
- if ( !empty($s2_post_types) ) {
217
  $types = '';
218
- echo __('Subscribe2 will send email notifications for the following custom post types', 'subscribe2') . ': <strong>';
219
- foreach ($s2_post_types as $type) {
220
- ('' == $types) ? $types = ucwords($type) : $types .= ", " . ucwords($type);
221
  }
222
- echo $types . "</strong><br /><br />\r\n";
223
  }
224
- echo __('Send Emails for Password Protected Posts', 'subscribe2') . ': ';
225
- echo "<label><input type=\"radio\" name=\"password\" value=\"yes\"" . checked($this->subscribe2_options['password'], 'yes', false) . " /> ";
226
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
227
- echo "<label><input type=\"radio\" name=\"password\" value=\"no\"" . checked($this->subscribe2_options['password'], 'no', false) . " /> ";
228
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
229
- echo __('Send Emails for Private Posts', 'subscribe2') . ': ';
230
- echo "<label><input type=\"radio\" name=\"private\" value=\"yes\"" . checked($this->subscribe2_options['private'], 'yes', false) . " /> ";
231
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
232
- echo "<label><input type=\"radio\" name=\"private\" value=\"no\"" . checked($this->subscribe2_options['private'], 'no', false) . " /> ";
233
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
234
- echo __('Include Sticky Posts at the top of all Digest Notifications', 'subscribe2') . ': ';
235
- echo "<label><input type=\"radio\" name=\"stickies\" value=\"yes\"" . checked($this->subscribe2_options['stickies'], 'yes', false) . " /> ";
236
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
237
- echo "<label><input type=\"radio\" name=\"stickies\" value=\"no\"" . checked($this->subscribe2_options['stickies'], 'no', false) . " /> ";
238
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
239
- echo __('Send Email From', 'subscribe2') . ': ';
240
- echo "<label>\r\n";
241
- $this->admin_dropdown(true);
242
- echo "</label><br /><br />\r\n";
243
- if ( function_exists('wp_schedule_event') ) {
244
- echo __('Send Emails', 'subscribe2') . ": <br /><br />\r\n";
245
  $this->display_digest_choices();
246
- echo "<p>" . __('For digest notifications, date order for posts is', 'subscribe2') . ": \r\n";
247
- echo "<label><input type=\"radio\" name=\"cron_order\" value=\"desc\"" . checked($this->subscribe2_options['cron_order'], 'desc', false) . " /> ";
248
- echo __('Descending', 'subscribe2') . "</label>&nbsp;&nbsp;";
249
- echo "<label><input type=\"radio\" name=\"cron_order\" value=\"asc\"" . checked($this->subscribe2_options['cron_order'], 'asc', false) . " /> ";
250
- echo __('Ascending', 'subscribe2') . "</label></p>\r\n";
251
  }
252
- echo __('Add Tracking Parameters to the Permalink', 'subscribe2') . ": ";
253
- echo "<input type=\"text\" name=\"tracking\" value=\"" . stripslashes($this->subscribe2_options['tracking']) . "\" size=\"50\" /> ";
254
- echo "<br />" . __('eg. utm_source=subscribe2&amp;utm_medium=email&amp;utm_campaign=postnotify&amp;utm_id={ID}&amp;utm_title={TITLE}', 'subscribe2') . "\r\n";
255
- echo "</p>\r\n";
256
- echo "</div>\r\n";
257
  break;
258
 
259
  case 'templates':
260
  // email templates
261
- echo "<div class=\"s2_admin\" id=\"s2_templates\">\r\n";
262
- echo "<p>\r\n";
263
- echo "<table style=\"width: 100%; border-collapse: separate; border-spacing: 5px; *border-collapse: expression('separate', cellSpacing = '5px');\" class=\"editform\">\r\n";
264
- echo "<tr><td style=\"vertical-align: top; height: 350px; min-height: 350px;\">";
265
- echo __('Notification email (must not be empty)', 'subscribe2') . ":<br />\r\n";
266
- echo __('Subject Line', 'subscribe2') . ": ";
267
- echo "<input type=\"text\" name=\"notification_subject\" value=\"" . stripslashes($this->subscribe2_options['notification_subject']) . "\" size=\"45\" />";
268
- echo "<br />\r\n";
269
- echo "<textarea rows=\"9\" cols=\"60\" name=\"mailtext\">" . stripslashes($this->subscribe2_options['mailtext']) . "</textarea>\r\n";
270
- echo "</td><td style=\"vertical-align: top;\" rowspan=\"3\">";
271
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Send Email Preview', 'subscribe2') . "\" /></p>\r\n";
272
- echo "<h3>" . __('Message substitutions', 'subscribe2') . "</h3>\r\n";
273
- echo "<dl>";
274
- echo "<dt><b><em style=\"color: red\">" . __('IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED' ,'subscribe2') . "</em></b></dt><dd></dd>\r\n";
275
- echo "<dt><b>{BLOGNAME}</b></dt><dd>" . get_option('blogname') . "</dd>\r\n";
276
- echo "<dt><b>{BLOGLINK}</b></dt><dd>" . get_option('home') . "</dd>\r\n";
277
- echo "<dt><b>{TITLE}</b></dt><dd>" . __("the post's title<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
278
- 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";
279
- 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";
280
- echo "<dt><b>{TABLE}</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
281
- echo "<dt><b>{TABLELINKS}</b></dt><dd>" . __("a list of post titles followed by links to the articles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
282
- echo "<dt><b>{REFERENCELINKS}</b></dt><dd>" . __("a reference style list of links at the end of the email with corresponding numbers in the content<br />(<i>for the full content plain text per-post email only</i>)", 'subscribe2') . "</dd>\r\n";
283
- echo "<dt><b>{PERMALINK}</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
284
- echo "<dt><b>{TINYLINK}</b></dt><dd>" . __("the post's permalink after conversion by TinyURL", 'subscribe2') . "</dd>\r\n";
285
- 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";
286
- 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";
287
- echo "<dt><b>{MYNAME}</b></dt><dd>" . __("the admin or post author's name", 'subscribe2') . "</dd>\r\n";
288
- echo "<dt><b>{EMAIL}</b></dt><dd>" . __("the admin or post author's email", 'subscribe2') . "</dd>\r\n";
289
- echo "<dt><b>{AUTHORNAME}</b></dt><dd>" . __("the post author's name", 'subscribe2') . "</dd>\r\n";
290
- 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";
291
- 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";
292
- echo "<dt><b>{CATS}</b></dt><dd>" . __("the post's assigned categories", 'subscribe2') . "</dd>\r\n";
293
- echo "<dt><b>{TAGS}</b></dt><dd>" . __("the post's assigned Tags", 'subscribe2') . "</dd>\r\n";
294
- 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";
295
- echo "</dl></td></tr><tr><td style=\"vertical-align: top; height: 350px; min-height: 350px;\">";
296
- echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
297
- echo __('Subject Line', 'subscribe2') . ": ";
298
- echo "<input type=\"text\" name=\"confirm_subject\" value=\"" . stripslashes($this->subscribe2_options['confirm_subject']) . "\" size=\"45\" /><br />\r\n";
299
- echo "<textarea rows=\"9\" cols=\"60\" name=\"confirm_email\">" . stripslashes($this->subscribe2_options['confirm_email']) . "</textarea>\r\n";
300
- echo "</td></tr><tr><td style=\"vertical-align: top; height: 350px; min-height: 350px;\">";
301
- echo __('Reminder email to Unconfirmed Subscribers', 'subscribe2') . ":<br />\r\n";
302
- echo __('Subject Line', 'subscribe2') . ": ";
303
- echo "<input type=\"text\" name=\"remind_subject\" value=\"" . stripslashes($this->subscribe2_options['remind_subject']) . "\" size=\"45\" /><br />\r\n";
304
- echo "<textarea rows=\"9\" cols=\"60\" name=\"remind_email\">" . stripslashes($this->subscribe2_options['remind_email']) . "</textarea><br /><br />\r\n";
305
- echo "</td></tr></table>\r\n";
306
- echo "</div>\r\n";
 
 
307
  break;
308
 
309
  case 'registered':
 
 
 
 
310
  // compulsory categories
311
- echo "<div class=\"s2_admin\" id=\"s2_compulsory_categories\">\r\n";
312
- echo "<input type=\"hidden\" name=\"registered_users_tab\" value=\"options\" />\r\n";
313
- echo "<h3>" . __('Compulsory Categories', 'subscribe2') . "</h3>\r\n";
314
- echo "<p>\r\n";
315
- echo "<strong><em style=\"color: red\">" . __('Compulsory categories will be checked by default for Registered Subscribers', 'subscribe2') . "</em></strong><br />\r\n";
316
- echo "</p>";
317
- $this->display_category_form(explode(',', $this->subscribe2_options['compulsory']), 1, array(), 'compulsory');
318
  echo "</div>\r\n";
319
 
320
  // excluded categories
321
- echo "<div class=\"s2_admin\" id=\"s2_excluded_categories\">\r\n";
322
- echo "<h3>" . __('Excluded Categories', 'subscribe2') . "</h3>\r\n";
323
- echo "<p>";
324
- 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";
325
- echo "</p>";
326
- $this->display_category_form(explode(',', $this->subscribe2_options['exclude']), 1, array(), 'exclude');
327
- echo "<p style=\"text-align: center;\"><label><input type=\"checkbox\" name=\"reg_override\" value=\"1\"" . checked($this->subscribe2_options['reg_override'], '1', false) . " /> ";
328
- echo __('Allow registered users to subscribe to excluded categories?', 'subscribe2') . "</label></p>\r\n";
329
- echo "</div>\r\n";
330
 
331
  // excluded post formats
332
- $formats = get_theme_support('post-formats');
333
- if ( $formats !== false ) {
334
  // excluded formats
335
- echo "<div class=\"s2_admin\" id=\"s2_excluded_formats\">\r\n";
336
- echo "<h3>" . __('Excluded Formats', 'subscribe2') . "</h3>\r\n";
337
- echo "<p>";
338
- echo "<strong><em style=\"color: red\">" . __('Posts assigned to any Excluded Format do not generate notifications and are not included in digest notifications', 'subscribe2') . "</em></strong><br />\r\n";
339
- echo "</p>";
340
- $this->display_format_form($formats, explode(',', $this->subscribe2_options['exclude_formats']));
341
- echo "</div>\r\n";
342
  }
343
 
344
  //Auto Subscription for new registrations
345
- echo "<div class=\"s2_admin\" id=\"s2_autosubscribe_settings\">\r\n";
346
- echo "<h3>" . __('Auto-Subscribe', 'subscribe2') . "</h3>\r\n";
347
- echo "<p>\r\n";
348
- echo __('Subscribe new users registering with your blog', 'subscribe2') . ":<br />\r\n";
349
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"yes\"" . checked($this->subscribe2_options['autosub'], 'yes', false) . " /> ";
350
- echo __('Automatically', 'subscribe2') . "</label>&nbsp;&nbsp;";
351
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"wpreg\"" . checked($this->subscribe2_options['autosub'], 'wpreg', false) . " /> ";
352
- echo __('Display option on Registration Form', 'subscribe2') . "</label>&nbsp;&nbsp;";
353
- echo "<label><input type=\"radio\" name=\"autosub\" value=\"no\"" . checked($this->subscribe2_options['autosub'], 'no', false) . " /> ";
354
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
355
- echo __('Auto-subscribe includes any excluded categories', 'subscribe2') . ":<br />\r\n";
356
- echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"yes\"" . checked($this->subscribe2_options['newreg_override'], 'yes', false) . " /> ";
357
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
358
- echo "<label><input type=\"radio\" name=\"newreg_override\" value=\"no\"" . checked($this->subscribe2_options['newreg_override'], 'no', false) . " /> ";
359
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
360
- echo __('Registration Form option is checked by default', 'subscribe2') . ":<br />\r\n";
361
- echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"yes\"" . checked($this->subscribe2_options['wpregdef'], 'yes', false) . " /> ";
362
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
363
- echo "<label><input type=\"radio\" name=\"wpregdef\" value=\"no\"" . checked($this->subscribe2_options['wpregdef'], 'no', false) . " /> ";
364
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
365
- echo __('Auto-subscribe users to receive email as', 'subscribe2') . ": <br />\r\n";
366
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html\"" . checked($this->subscribe2_options['autoformat'], 'html', false) . " /> ";
367
- echo __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
368
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"html_excerpt\"" . checked($this->subscribe2_options['autoformat'], 'html_excerpt', false) . " /> ";
369
- echo __('HTML - Excerpt', 'subscribe2') ."</label>&nbsp;&nbsp;";
370
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"post\"" . checked($this->subscribe2_options['autoformat'], 'post', false) . " /> ";
371
- echo __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
372
- echo "<label><input type=\"radio\" name=\"autoformat\" value=\"excerpt\"" . checked($this->subscribe2_options['autoformat'], 'excerpt', false) . " /> ";
373
- echo __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />";
374
- echo __('Registered Users have the option to auto-subscribe to new categories', 'subscribe2') . ": <br />\r\n";
375
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"yes\"" . checked($this->subscribe2_options['show_autosub'], 'yes', false) . " /> ";
376
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
377
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"no\"" . checked($this->subscribe2_options['show_autosub'], 'no', false) . " /> ";
378
- echo __('No', 'subscribe2') . "</label>&nbsp;&nbsp;";
379
- echo "<label><input type=\"radio\" name=\"show_autosub\" value=\"exclude\"" . checked($this->subscribe2_options['show_autosub'], 'exclude', false) . " /> ";
380
- echo __('New categories are immediately excluded', 'subscribe2') . "</label><br /><br />";
381
- echo __('Option for Registered Users to auto-subscribe to new categories is checked by default', 'subscribe2') . ": <br />\r\n";
382
- echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"yes\"" . checked($this->subscribe2_options['autosub_def'], 'yes', false) . " /> ";
383
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
384
- echo "<label><input type=\"radio\" name=\"autosub_def\" value=\"no\"" . checked($this->subscribe2_options['autosub_def'], 'no', false) . " /> ";
385
- echo __('No', 'subscribe2') . "</label><br /><br />";
386
  // Hide these options if using Jetpack Comments
387
- if ( !class_exists('Jetpack_Comments') ) {
388
- echo __('Display checkbox to allow subscriptions from the comment form', 'subscribe2') . ": <br />\r\n";
389
- echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"before\"" . checked($this->subscribe2_options['comment_subs'], 'before', false) . " /> ";
390
- echo __('Before the Comment Submit button', 'subscribe2') . "</label>&nbsp;&nbsp;";
391
- echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"after\"" . checked($this->subscribe2_options['comment_subs'], 'after', false) . " /> ";
392
- echo __('After the Comment Submit button', 'subscribe2') . "</label>&nbsp;&nbsp;";
393
- echo "<label><input type=\"radio\" name=\"comment_subs\" value=\"no\"" . checked($this->subscribe2_options['comment_subs'], 'no', false) . " /> ";
394
- echo __('No', 'subscribe2') . "</label><br /><br />";
395
- echo __('Comment form checkbox is checked by default', 'subscribe2') . ": <br />\r\n";
396
- echo "<label><input type=\"radio\" name=\"comment_def\" value=\"yes\"" . checked($this->subscribe2_options['comment_def'], 'yes', false) . " /> ";
397
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
398
- echo "<label><input type=\"radio\" name=\"comment_def\" value=\"no\"" . checked($this->subscribe2_options['comment_def'], 'no', false) . " /> ";
399
- echo __('No', 'subscribe2') . "</label><br /><br />\r\n";
400
  }
401
- echo __('Show one-click subscription on profile page', 'subscribe2') . ":<br />\r\n";
402
- echo "<label><input type=\"radio\" name=\"one_click_profile\" value=\"yes\"" . checked($this->subscribe2_options['one_click_profile'], 'yes', false) . " /> ";
403
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
404
- echo "<label><input type=\"radio\" name=\"one_click_profile\" value=\"no\"" . checked($this->subscribe2_options['one_click_profile'], 'no', false) . " /> ";
405
- echo __('No', 'subscribe2') . "</label>\r\n";
406
- echo "</p></div>\r\n";
407
  break;
408
 
409
  case 'appearance':
410
  // Appearance options
411
- echo "<div class=\"s2_admin\" id=\"s2_appearance_settings\">\r\n";
412
- echo "<input type=\"hidden\" name=\"appearance_users_tab\" value=\"options\" />\r\n";
413
- echo "<p>\r\n";
414
 
415
  // WordPress page ID where subscribe2 token is used
416
- echo __('Set default Subscribe2 page as', 'subscribe2') . ': ';
417
- echo "<select name=\"s2page\">\r\n";
418
- echo "<option value=\"0\">" . __('Select a page', 'subscribe2') . "</option>\r\n";
419
- $this->pages_dropdown($this->subscribe2_options['s2page']);
420
- echo "</select>\r\n";
421
 
422
  // Number of subscribers per page
423
- echo "<br /><br />" . __('Set the number of Subscribers displayed per page', 'subscribe2') . ': ';
424
- echo "<span id=\"s2entries_1\"><span id=\"s2entries\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['entries'] . "</span> ";
425
- echo "<a href=\"#\" onclick=\"s2_show('entries'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
426
- echo "<span id=\"s2entries_2\">\r\n";
427
- echo "<input type=\"text\" name=\"entries\" value=\"" . $this->subscribe2_options['entries'] . "\" size=\"3\" />\r\n";
428
- echo "<a href=\"#\" onclick=\"s2_update('entries'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
429
- echo "<a href=\"#\" onclick=\"s2_revert('entries'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
430
 
431
  // show link to WordPress page in meta
432
- echo "<br /><br /><label><input type=\"checkbox\" name=\"show_meta\" value=\"1\"" . checked($this->subscribe2_options['show_meta'], '1', false) . " /> ";
433
- echo __('Show a link to your subscription page in "meta"?', 'subscribe2') . "</label><br /><br />\r\n";
434
 
435
  // show QuickTag button
436
- echo "<label><input type=\"checkbox\" name=\"show_button\" value=\"1\"" . checked($this->subscribe2_options['show_button'], '1', false) . " /> ";
437
- echo __('Show the Subscribe2 button on the Write toolbar?', 'subscribe2') . "</label><br /><br />\r\n";
438
 
439
- // enable AJAX style form
440
- echo "<label><input type=\"checkbox\" name=\"ajax\" value=\"1\"" . checked($this->subscribe2_options['ajax'], '1', false) . " /> ";
441
- echo __('Enable AJAX style subscription form?', 'subscribe2') . "</label><br /><br />\r\n";
442
 
443
  // show Widget
444
- echo "<label><input type=\"checkbox\" name=\"widget\" value=\"1\"" . checked($this->subscribe2_options['widget'], '1', false) . " /> ";
445
- echo __('Enable Subscribe2 Widget?', 'subscribe2') . "</label><br /><br />\r\n";
446
 
447
  // show Counter Widget
448
- echo "<label><input type=\"checkbox\" name=\"counterwidget\" value=\"1\"" . checked($this->subscribe2_options['counterwidget'], '1', false) . " /> ";
449
- echo __('Enable Subscribe2 Counter Widget?', 'subscribe2') . "</label><br /><br />\r\n";
450
 
451
  // s2_meta checked by default
452
- echo "<label><input type =\"checkbox\" name=\"s2meta_default\" value=\"1\"" . checked($this->subscribe2_options['s2meta_default'], '1', false) . " /> ";
453
- echo __('Disable email notifications is checked by default on authoring pages?', 'subscribe2') . "</label>\r\n";
454
- echo "</p>";
455
- echo "</div>\r\n";
456
  break;
457
 
458
  case 'misc':
459
  //barred domains
460
- echo "<div class=\"s2_admin\" id=\"s2_barred_domains\">\r\n";
461
- echo "<h3>" . __('Barred Domains', 'subscribe2') . "</h3>\r\n";
462
- echo "<p>\r\n";
463
- 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');
464
- echo "<br />\r\n<textarea style=\"width: 98%;\" rows=\"4\" cols=\"60\" name=\"barred\">" . esc_textarea($this->subscribe2_options['barred']) . "</textarea>";
465
- echo "</p>";
466
- echo "<h3>" . __('Links', 'subscribe2') . "</h3>\r\n";
467
- echo "<a href=\"http://wordpress.org/extend/plugins/subscribe2/\">" . __('Plugin Site', 'subscribe2') . "</a><br />";
468
- echo "<a href='http://plugins.trac.wordpress.org/browser/subscribe2/i18n/'>" . __('Translation Files', 'subscribe2') . "</a><br />";
469
- echo "<a href=\"http://wordpress.org/support/plugin/subscribe2\">" . __('Plugin Forum', 'subscribe2') . "</a><br />";
470
- echo "<a href=\"http://subscribe2.wordpress.com/\">" . __('Plugin Blog', 'subscribe2') . "</a><br />";
471
- 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>";
472
- echo "</div>\r\n";
473
  break;
474
 
475
  }
476
  // submit
477
- echo "<p class=\"submit\" style=\"text-align: center\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __('Submit', 'subscribe2') . "\" /></p>";
478
 
479
- if ($current_tab === 'misc') {
480
  // reset
481
- echo "<h3>" . __('Reset to Default Settings', 'subscribe2') . "</h3>\r\n";
482
- 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";
483
- echo "<p class=\"submit\" style=\"text-align: center\">";
484
- echo "<input type=\"submit\" id=\"deletepost\" name=\"reset\" value=\"" . __('RESET', 'subscribe2') .
485
- "\" /></p>";
486
  }
487
- echo "</form></div>\r\n";
488
 
489
- include(ABSPATH . 'wp-admin/admin-footer.php');
490
  // just to be sure
491
  die;
492
  ?>
1
  <?php
2
+ if ( ! function_exists( 'add_action' ) ) {
3
  exit();
4
  }
5
 
6
+ global $wpdb, $wp_version, $current_tab;
7
 
8
  // was anything POSTed?
9
+ if ( isset( $_POST['s2_admin'] ) ) {
10
+ if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'subscribe2-options_subscribers' . S2VERSION ) ) {
11
+ die( '<p>' . __( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
12
+ }
13
+
14
+ if ( isset( $_POST['reset'] ) ) {
15
  $this->reset();
16
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Options reset!', 'subscribe2' ) . '</strong></p></div>';
17
+ } elseif ( isset( $_POST['preview'] ) ) {
18
  global $user_email, $post;
19
  $this->preview_email = true;
20
+ if ( 'never' === $this->subscribe2_options['email_freq'] ) {
21
+ $posts = get_posts( 'numberposts=1' );
22
  $post = $posts[0];
23
+ $this->publish( $post, $user_email );
24
  } else {
25
+ do_action( 's2_digest_preview', $user_email );
26
  }
27
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Preview message(s) sent to logged in user', 'subscribe2' ) . '</strong></p></div>';
28
+ } elseif ( isset( $_POST['resend'] ) ) {
29
+ $stickies = get_option( 'sticky_posts' );
30
+ if ( ! empty( $this->subscribe2_options['last_s2cron'] ) || ( 'yes' === $this->subscribe2_options['stickies'] && ! empty( $stickies ) ) ) {
31
+ do_action( 's2_digest_resend', 'resend' );
32
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Attempt made to resend the Digest Notification email', 'subscribe2' ) . '</strong></p></div>';
33
  } else {
34
+ 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>';
35
  }
36
+ } elseif ( isset( $_POST['submit'] ) ) {
37
+ foreach ( $_POST as $key => $value ) {
38
+ if ( in_array( $key, array( 'bcclimit', 's2page', 'entries' ) ) ) {
39
  // numerical inputs fixed for old option names
40
+ if ( 'entries' === $key && is_numeric( $_POST[ $key ] ) && $_POST[ $key ] > 0 ) {
41
+ $this->subscribe2_options[ $key ] = (int) $_POST[ $key ];
42
+ } elseif ( 'entries' !== $key && is_numeric( $_POST[ $key ] ) && $_POST[ $key ] >= 0 ) {
43
+ $this->subscribe2_options[ $key ] = (int) $_POST[ $key ];
44
  }
45
+ } elseif ( in_array( $key, array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'reg_override' ) ) ) {
46
  // check box entries
47
+ ( isset( $_POST[ $key ] ) && '1' === $_POST[ $key ] ) ? $newvalue = '1' : $newvalue = '0';
48
+ $this->subscribe2_options[ $key ] = $newvalue;
49
+ } elseif ( 'appearance_users_tab' === $key ) {
50
+ $options = array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default' );
51
  foreach ( $options as $option ) {
52
+ if ( ! isset( $_POST[ $option ] ) ) {
53
+ $this->subscribe2_options[ $option ] = '';
54
  }
55
  }
56
+ } elseif ( in_array( $key, array( 'notification_subject', 'mailtext', 'confirm_subject', 'confirm_email', 'remind_subject', 'remind_email', 's2_license_key' ) ) && ! empty( $_POST[ $key ] ) ) {
57
  // email subject and body templates
58
+ $this->subscribe2_options[ $key ] = trim( $_POST[ $key ] );
59
+ } elseif ( in_array( $key, array( 'compulsory', 'exclude', 'format' ) ) ) {
60
+ sort( $_POST[ $key ] );
61
+ $newvalue = implode( ',', $_POST[ $key ] );
62
 
63
+ if ( 'format' === $key ) {
64
  $this->subscribe2_options['exclude_formats'] = $newvalue;
65
  } else {
66
+ $this->subscribe2_options[ $key ] = $newvalue;
67
  }
68
+ } elseif ( 'registered_users_tab' === $key ) {
69
+ $options = array( 'compulsory', 'exclude', 'format', 'reg_override' );
70
  foreach ( $options as $option ) {
71
+ if ( ! isset( $_POST[ $option ] ) ) {
72
+ if ( 'format' === $option ) {
73
  $this->subscribe2_options['exclude_formats'] = '';
74
  } else {
75
+ $this->subscribe2_options[ $option ] = '';
76
  }
77
  }
78
  }
79
+ } elseif ( 'email_freq' === $key ) {
80
  // send per-post or digest emails
81
  $email_freq = $_POST['email_freq'];
82
+ $scheduled_time = wp_next_scheduled( 's2_digest_cron' );
83
+ $timestamp_offset = get_option( 'gmt_offset' ) * 60 * 60;
84
+ $crondate = ( isset( $_POST['crondate'] ) ) ? $_POST['crondate'] : 0;
85
+ $crontime = ( isset( $_POST['crondate'] ) ) ? $_POST['crontime'] : 0;
86
+ if ( $email_freq !== $this->subscribe2_options['email_freq'] || date_i18n( get_option( 'date_format' ), $scheduled_time + $timestamp_offset ) !== $crondate || date( 'G', $scheduled_time + $timestamp_offset ) !== $crontime ) {
87
  $this->subscribe2_options['email_freq'] = $email_freq;
88
+ wp_clear_scheduled_hook( 's2_digest_cron' );
89
+ $scheds = (array) wp_get_schedules();
90
+ $interval = ( isset( $scheds[ $email_freq ]['interval'] ) ) ? (int) $scheds[ $email_freq ]['interval'] : 0;
91
+ if ( 0 === $interval ) {
92
  // if we are on per-post emails remove last_cron entry
93
+ unset( $this->subscribe2_options['last_s2cron'] );
94
  } else {
95
  // if we are using digest schedule the event and prime last_cron as now
96
  $time = time() + $interval;
97
+ $srttimestamp = strtotime( $crondate ) + ($crontime * 60 * 60);
98
+ if ( false === $srttimestamp || 0 === $srttimestamp ) {
99
+ $srttimestamp = time();
100
  }
101
  $timestamp = $srttimestamp - $timestamp_offset;
102
+ while ( $timestamp < time() ) {
103
  // if we are trying to set the time in the past increment it forward
104
  // by the interval period until it is in the future
105
  $timestamp += $interval;
106
  }
107
+ wp_schedule_event( $timestamp, $email_freq, 's2_digest_cron' );
108
  }
109
  }
110
  } else {
111
+ if ( isset( $this->subscribe2_options[ $key ] ) ) {
112
+ if ( 'sender' === $key && $this->subscribe2_options[ $key ] !== $_POST[ $key ] ) {
113
+ $this->subscribe2_options['dismiss_sender_warning'] = '0';
114
+ }
115
+ $this->subscribe2_options[ $key ] = $_POST[ $key ];
116
  }
117
  }
118
  }
119
 
120
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Options saved!', 'subscribe2' ) . '</strong></p></div>';
121
+ update_option( 'subscribe2_options', $this->subscribe2_options );
122
  }
123
  }
124
 
125
  // send error message if no WordPress page exists
126
  $sql = "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1";
127
+ $id = $wpdb->get_var( $sql );
128
+ if ( empty( $id ) ) {
129
+ echo '<div id="page_message" class="error"><p class="s2_error"><strong>' . __( 'You must create a WordPress page for this plugin to work correctly.', 'subscribe2' ) . '</strong></p></div>';
130
  }
131
 
132
+ if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
133
+ $disallowed_keywords = array( '{TITLE}', '{TITLETEXT}', '{PERMALINK}', '{PERMAURL}', '{DATE}', '{TIME}', '{LINK}', '{ACTION}', '{REFERENCELINKS}' );
134
  } else {
135
+ $disallowed_keywords = array( '{POSTTIME}', '{TABLE}', '{TABLELINKS}', '{COUNT}', '{LINK}', '{ACTION}' );
136
  }
137
  $disallowed = false;
138
  foreach ( $disallowed_keywords as $disallowed_keyword ) {
139
+ if ( false !== strstr( $this->subscribe2_options['mailtext'], $disallowed_keyword ) ) {
140
  $disallowed[] = $disallowed_keyword;
141
  }
142
  }
143
+
144
+ $template_link = '<a href="' . admin_url( 'admin.php?page=s2_settings&tab=templates' ) . '">' . __( 'Modify your template', 'subscribe2' ) . '</a>';
145
+ if ( false !== $disallowed ) {
146
+ $disallowed_keywords = __( 'Your chosen email type (per-post or digest) does not support the following keywords:', 'subscribe2' );
147
+ echo '<div id="keyword_message" class="error"><p class="s2_error"><strong>' . $disallowed_keywords . '</strong><br />' . implode( $disallowed, ', ' ) . '<br />' . $template_link . '</p></div>';
148
  }
149
 
150
  // send error message if sender email address is off-domain
151
+ if ( 'blogname' === $this->subscribe2_options['sender'] ) {
152
+ $sender = get_bloginfo( 'admin_email' );
153
  } else {
154
+ $userdata = $this->get_userdata( $this->subscribe2_options['sender'] );
155
  $sender = $userdata->user_email;
156
  }
157
+ list( $user, $domain ) = explode( '@', $sender, 2 );
158
+ if ( ! stristr( esc_html( $_SERVER['SERVER_NAME'] ), $domain ) && 'author' !== $this->subscribe2_options['sender'] && '0' === $this->subscribe2_options['dismiss_sender_warning'] ) {
159
+ echo '<div id="sender_message" class="error notice is-dismissible"><p class="s2_error"><strong>' . sprintf( __( 'You appear to be sending notifications from %1$s, which has a different domain name than your blog server %2$s. This may result in failed emails.', 'subscribe2' ), $sender, $_SERVER['SERVER_NAME'] ) . '</strong></p></div>';
160
  }
161
 
162
  // detect or define which tab we are in
163
  $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'email';
164
 
165
  // show our form
166
+ echo '<div class="wrap">';
167
+ echo '<h1>' . __( 'Settings', 'subscribe2' ) . '</h1>' . "\r\n";
168
+ $tabs = array(
169
+ 'email' => __( 'Email Settings', 'subscribe2' ),
170
+ 'templates' => __( 'Templates', 'subscribe2' ),
171
+ 'registered' => __( 'Registered Users', 'subscribe2' ),
172
+ 'appearance' => __( 'Appearance', 'subscribe2' ),
173
+ 'misc' => __( 'Miscellaneous', 'subscribe2' ),
174
+ );
175
+ echo '<h2 class="nav-tab-wrapper">';
 
176
  foreach ( $tabs as $tab_key => $tab_caption ) {
177
+ $active = ($current_tab === $tab_key) ? 'nav-tab-active' : '';
178
+ echo '<a class="nav-tab ' . $active . '" href="?page=s2_settings&amp;tab=' . $tab_key . '">' . $tab_caption . '</a>';
179
  }
180
+ echo '</h2>';
181
 
182
+ echo '<form method="post">' . "\r\n";
183
+
184
+ wp_nonce_field( 'subscribe2-options_subscribers' . S2VERSION );
 
 
 
 
185
 
186
+ echo '<input type="hidden" name="s2_admin" value="options" />' . "\r\n";
187
+ echo '<input type="hidden" id="jsbcclimit" value="' . $this->subscribe2_options['bcclimit'] . '" />';
188
+ echo '<input type="hidden" id="jsentries" value="' . $this->subscribe2_options['entries'] . '" />';
189
+
190
+ switch ( $current_tab ) {
191
  case 'email':
192
  // settings for outgoing emails
193
+ echo '<div class="s2_admin" id="s2_notification_settings">' . "\r\n";
194
+ echo '<p>' . "\r\n";
195
+ echo __( 'Restrict the number of <strong>recipients per email</strong> to (0 for unlimited)', 'subscribe2' ) . ': ';
196
+ echo '<span id="s2bcclimit_1"><span id="s2bcclimit" style="background-color: #FFFBCC">' . $this->subscribe2_options['bcclimit'] . '</span> ';
197
+ echo '<a href="#" onclick="s2_show(\'bcclimit\'); return false;">' . __( 'Edit', 'subscribe2' ) . '</a></span>' . "\r\n";
198
+ echo '<span id="s2bcclimit_2">' . "\r\n";
199
+ echo '<input type="text" name="bcclimit" value="' . $this->subscribe2_options['bcclimit'] . '" size="3" />' . "\r\n";
200
+ echo '<a href="#" onclick="s2_update(\'bcclimit\'); return false;">' . __( 'Update', 'subscribe2' ) . '</a>' . "\r\n";
201
+ echo '<a href="#" onclick="s2_revert(\'bcclimit\'); return false;">' . __( 'Revert', 'subscribe2' ) . '</a></span>' . "\n";
202
+
203
+ echo '<br /><br />' . __( 'Send Admins notifications for new', 'subscribe2' ) . ': ';
204
+ echo '<label><input type="radio" name="admin_email" value="subs"' . checked( $this->subscribe2_options['admin_email'], 'subs', false ) . ' />' . "\r\n";
205
+ echo __( 'Subscriptions', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
206
+ echo '<label><input type="radio" name="admin_email" value="unsubs"' . checked( $this->subscribe2_options['admin_email'], 'unsubs', false ) . ' />' . "\r\n";
207
+ echo __( 'Unsubscriptions', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
208
+ echo '<label><input type="radio" name="admin_email" value="both"' . checked( $this->subscribe2_options['admin_email'], 'both', false ) . ' />' . "\r\n";
209
+ echo __( 'Both', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
210
+ echo '<label><input type="radio" name="admin_email" value="none"' . checked( $this->subscribe2_options['admin_email'], 'none', false ) . ' />' . "\r\n";
211
+ echo __( 'Neither', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
212
+
213
+ echo __( 'Include theme CSS stylesheet in HTML notifications', 'subscribe2' ) . ': ';
214
+ echo '<label><input type="radio" name="stylesheet" value="yes"' . checked( $this->subscribe2_options['stylesheet'], 'yes', false ) . ' /> ';
215
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
216
+ echo '<label><input type="radio" name="stylesheet" value="no"' . checked( $this->subscribe2_options['stylesheet'], 'no', false ) . ' /> ';
217
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
218
+
219
+ echo __( 'Send Emails for Pages', 'subscribe2' ) . ': ';
220
+ echo '<label><input type="radio" name="pages" value="yes"' . checked( $this->subscribe2_options['pages'], 'yes', false ) . ' /> ';
221
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
222
+ echo '<label><input type="radio" name="pages" value="no"' . checked( $this->subscribe2_options['pages'], 'no', false ) . ' /> ';
223
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
224
+ $s2_post_types = apply_filters( 's2_post_types', null );
225
+ if ( ! empty( $s2_post_types ) ) {
226
  $types = '';
227
+ echo __( 'Subscribe2 will send email notifications for the following custom post types', 'subscribe2' ) . ': <strong>';
228
+ foreach ( $s2_post_types as $type ) {
229
+ ('' === $types) ? $types = ucwords( $type ) : $types .= ', ' . ucwords( $type );
230
  }
231
+ echo $types . '</strong><br /><br />' . "\r\n";
232
  }
233
+ echo __( 'Send Emails for Password Protected Posts', 'subscribe2' ) . ': ';
234
+ echo '<label><input type="radio" name="password" value="yes"' . checked( $this->subscribe2_options['password'], 'yes', false ) . ' /> ';
235
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
236
+ echo '<label><input type="radio" name="password" value="no"' . checked( $this->subscribe2_options['password'], 'no', false ) . ' /> ';
237
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
238
+ echo __( 'Send Emails for Private Posts', 'subscribe2' ) . ': ';
239
+ echo '<label><input type="radio" name="private" value="yes"' . checked( $this->subscribe2_options['private'], 'yes', false ) . ' /> ';
240
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
241
+ echo '<label><input type="radio" name="private" value="no"' . checked( $this->subscribe2_options['private'], 'no', false ) . ' /> ';
242
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
243
+ echo __( 'Include Sticky Posts at the top of all Digest Notifications', 'subscribe2' ) . ': ';
244
+ echo '<label><input type="radio" name="stickies" value="yes"' . checked( $this->subscribe2_options['stickies'], 'yes', false ) . ' /> ';
245
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
246
+ echo '<label><input type="radio" name="stickies" value="no"' . checked( $this->subscribe2_options['stickies'], 'no', false ) . ' /> ';
247
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
248
+ echo __( 'Send Email From', 'subscribe2' ) . ': ';
249
+ echo '<label>' . "\r\n";
250
+ $this->admin_dropdown( true );
251
+ echo '</label><br /><br />' . "\r\n";
252
+ if ( function_exists( 'wp_schedule_event' ) ) {
253
+ echo __( 'Send Emails', 'subscribe2' ) . ': <br /><br />' . "\r\n";
254
  $this->display_digest_choices();
255
+ echo '<p>' . __( 'For digest notifications, date order for posts is', 'subscribe2' ) . ': ' . "\r\n";
256
+ echo '<label><input type="radio" name="cron_order" value="desc"' . checked( $this->subscribe2_options['cron_order'], 'desc', false ) . ' /> ';
257
+ echo __( 'Descending', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
258
+ echo '<label><input type="radio" name="cron_order" value="asc"' . checked( $this->subscribe2_options['cron_order'], 'asc', false ) . ' /> ';
259
+ echo __( 'Ascending', 'subscribe2' ) . '</label></p>' . "\r\n";
260
  }
261
+ echo __( 'Add Tracking Parameters to the Permalink', 'subscribe2' ) . ': ';
262
+ echo '<input type="text" name="tracking" value="' . stripslashes( $this->subscribe2_options['tracking'] ) . '" size="50" /> ';
263
+ echo '<br />' . __( 'eg. utm_source=subscribe2&amp;utm_medium=email&amp;utm_campaign=postnotify&amp;utm_id={ID}&amp;utm_title={TITLE}', 'subscribe2' ) . "\r\n";
264
+ echo '</p>' . "\r\n";
265
+ echo '</div>' . "\r\n";
266
  break;
267
 
268
  case 'templates':
269
  // email templates
270
+ echo '<div class="s2_admin" id="s2_templates">' . "\r\n";
271
+ echo '<p>' . "\r\n";
272
+ echo '<table style="width: 100%; border-collapse: separate; border-spacing: 5px; *border-collapse: expression(\'separate\', cellSpacing = \'5px\');" class="editform">' . "\r\n";
273
+ echo '<tr><td style="vertical-align: top; height: 350px; min-height: 350px;">';
274
+ echo __( 'Notification email (must not be empty)', 'subscribe2' ) . ':<br />' . "\r\n";
275
+ echo __( 'Subject Line', 'subscribe2' ) . ': ';
276
+ echo '<input type="text" name="notification_subject" value="' . stripslashes( $this->subscribe2_options['notification_subject'] ) . '" size="45" />';
277
+ echo '<br />' . "\r\n";
278
+ echo '<textarea rows="9" cols="60" name="mailtext">' . stripslashes( $this->subscribe2_options['mailtext'] ) . '</textarea>' . "\r\n";
279
+ echo '</td><td style="vertical-align: top;" rowspan="3">';
280
+ echo '<p class="submit"><input type="submit" class="button-secondary" name="preview" value="' . __( 'Send Email Preview', 'subscribe2' ) . '" /></p>' . "\r\n";
281
+ echo '<h3>' . __( 'Message substitutions', 'subscribe2' ) . '</h3>' . "\r\n";
282
+ echo '<dl>';
283
+ echo '<dt><b><em style="color: red">' . __( 'IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED' ,'subscribe2' ) . '</em></b></dt><dd></dd>' . "\r\n";
284
+ echo '<dt><b>{BLOGNAME}</b></dt><dd>' . get_option( 'blogname' ) . '</dd>' . "\r\n";
285
+ echo '<dt><b>{BLOGLINK}</b></dt><dd>' . get_option( 'home' ) . '</dd>' . "\r\n";
286
+ echo '<dt><b>{TITLE}</b></dt><dd>' . __( "the post's title<br />(<i>for per-post emails only</i>)", 'subscribe2' ) . '</dd>' . "\r\n";
287
+ echo '<dt><b>{TITLETEXT}</b></dt><dd>' . __( "the post's unformatted title <br />(<i>for per-post emails only</i>)", 'subscribe2' ) . '</dd>' . "\r\n";
288
+ 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";
289
+ 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";
290
+ echo '<dt><b>{TABLE}</b></dt><dd>' . __( 'a list of post titles<br />(<i>for digest emails only</i>)', 'subscribe2' ) . '</dd>' . "\r\n";
291
+ echo '<dt><b>{TABLELINKS}</b></dt><dd>' . __( 'a list of post titles followed by links to the articles<br />(<i>for digest emails only</i>)', 'subscribe2' ) . '</dd>' . "\r\n";
292
+ echo '<dt><b>{REFERENCELINKS}</b></dt><dd>' . __( 'a reference style list of links at the end of the email with corresponding numbers in the content<br />(<i>for the full content plain text per-post email only</i>)', 'subscribe2' ) . '</dd>' . "\r\n";
293
+ echo '<dt><b>{PERMALINK}</b></dt><dd>' . __( "the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2' ) . '</dd>' . "\r\n";
294
+ echo '<dt><b>{TINYLINK}</b></dt><dd>' . __( "the post's permalink after conversion by TinyURL", 'subscribe2' ) . '</dd>' . "\r\n";
295
+ echo '<dt><b>{PERMAURL}</b></dt><dd>' . __( "the post's unformatted permalink<br />(<i>for per-post emails only</i>)", 'subscribe2' ) . '</dd>' . "\r\n";
296
+ 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";
297
+ 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";
298
+ echo '<dt><b>{MYNAME}</b></dt><dd>' . __( "the admin or post author's name", 'subscribe2' ) . '</dd>' . "\r\n";
299
+ echo '<dt><b>{EMAIL}</b></dt><dd>' . __( "the admin or post author's email", 'subscribe2' ) . ' </dd>' . "\r\n";
300
+ echo '<dt><b>{AUTHORNAME}</b></dt><dd>' . __( "the post author's name", 'subscribe2' ) . '</dd>' . "\r\n";
301
+ 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";
302
+ 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";
303
+ echo '<dt><b>{CATS}</b></dt><dd>' . __( "the post's assigned categories", 'subscribe2' ) . "</dd>\r\n";
304
+ echo '<dt><b>{TAGS}</b></dt><dd>' . __( "the post's assigned Tags", 'subscribe2' ) . "</dd>\r\n";
305
+ 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";
306
+ echo '</dl></td></tr><tr><td style="vertical-align: top; height: 350px; min-height: 350px;">';
307
+ echo __( 'Subscribe / Unsubscribe confirmation email', 'subscribe2' ) . ':<br />' . "\r\n";
308
+ echo __( 'Subject Line', 'subscribe2' ) . ': ';
309
+ echo '<input type="text" name="confirm_subject" value="' . stripslashes( $this->subscribe2_options['confirm_subject'] ) . '" size="45" /><br />' . "\r\n";
310
+ echo '<textarea rows="9" cols="60" name="confirm_email">' . stripslashes( $this->subscribe2_options['confirm_email'] ) . '</textarea>' . "\r\n";
311
+ echo '</td></tr><tr><td style="vertical-align: top; height: 350px; min-height: 350px;">';
312
+ echo __( 'Reminder email to Unconfirmed Subscribers', 'subscribe2' ) . ':<br />' . "\r\n";
313
+ echo __( 'Subject Line', 'subscribe2' ) . ': ';
314
+ echo '<input type="text" name="remind_subject" value="' . stripslashes( $this->subscribe2_options['remind_subject'] ) . '" size="45" /><br />' . "\r\n";
315
+ echo '<textarea rows="9" cols="60" name="remind_email">' . stripslashes( $this->subscribe2_options['remind_email'] ) . '</textarea><br /><br />' . "\r\n";
316
+ echo '</td></tr></table>' . "\r\n";
317
+ echo '</div>' . "\r\n";
318
  break;
319
 
320
  case 'registered':
321
+ // Access function to allow display for form elements
322
+ require_once( S2PATH . 'classes/class-s2-forms.php' );
323
+ $s2_forms = new s2_forms;
324
+
325
  // compulsory categories
326
+ echo '<div class="s2_admin" id="s2_compulsory_categories">' . "\r\n";
327
+ echo '<input type="hidden" name="registered_users_tab" value="options" />' . "\r\n";
328
+ echo '<h3>' . __( 'Compulsory Categories', 'subscribe2' ) . '</h3>' . "\r\n";
329
+ echo '<p>' . "\r\n";
330
+ echo '<strong><em style="color: red">' . __( 'Compulsory categories will be checked by default for Registered Subscribers', 'subscribe2' ) . '</em></strong><br />' . "\r\n";
331
+ echo '</p>';
332
+ $s2_forms->display_category_form( explode( ',', $this->subscribe2_options['compulsory'] ), 1, array(), 'compulsory' );
333
  echo "</div>\r\n";
334
 
335
  // excluded categories
336
+ echo '<div class="s2_admin" id="s2_excluded_categories">' . "\r\n";
337
+ echo '<h3>' . __( 'Excluded Categories', 'subscribe2' ) . '</h3>' . "\r\n";
338
+ echo '<p>';
339
+ 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";
340
+ echo '</p>';
341
+ $s2_forms->display_category_form( explode( ',', $this->subscribe2_options['exclude'] ), 1, array(), 'exclude' );
342
+ echo '<p style="text-align: center;"><label><input type="checkbox" name="reg_override" value="1"' . checked( $this->subscribe2_options['reg_override'], '1', false ) . ' /> ';
343
+ echo __( 'Allow registered users to subscribe to excluded categories?', 'subscribe2' ) . '</label></p>' . "\r\n";
344
+ echo '</div>' . "\r\n";
345
 
346
  // excluded post formats
347
+ $formats = get_theme_support( 'post-formats' );
348
+ if ( false !== $formats ) {
349
  // excluded formats
350
+ echo '<div class="s2_admin" id="s2_excluded_formats">' . "\r\n";
351
+ echo '<h3>' . __( 'Excluded Formats', 'subscribe2' ) . '</h3>' . "\r\n";
352
+ echo '<p>';
353
+ echo '<strong><em style="color: red">' . __( 'Posts assigned to any Excluded Format do not generate notifications and are not included in digest notifications', 'subscribe2' ) . '</em></strong><br />' . "\r\n";
354
+ echo '</p>';
355
+ $this->display_format_form( $formats, explode( ',', $this->subscribe2_options['exclude_formats'] ) );
356
+ echo '</div>' . "\r\n";
357
  }
358
 
359
  //Auto Subscription for new registrations
360
+ echo '<div class="s2_admin" id="s2_autosubscribe_settings">' . "\r\n";
361
+ echo '<h3>' . __( 'Auto-Subscribe', 'subscribe2' ) . '</h3>' . "\r\n";
362
+ echo '<p>' . "\r\n";
363
+ echo __( 'Subscribe new users registering with your blog', 'subscribe2' ) . ':<br />' . "\r\n";
364
+ echo '<label><input type="radio" name="autosub" value="yes"' . checked( $this->subscribe2_options['autosub'], 'yes', false ) . ' /> ';
365
+ echo __( 'Automatically', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
366
+ echo '<label><input type="radio" name="autosub" value="wpreg"' . checked( $this->subscribe2_options['autosub'], 'wpreg', false ) . ' /> ';
367
+ echo __( 'Display option on Registration Form', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
368
+ echo '<label><input type="radio" name="autosub" value="no"' . checked( $this->subscribe2_options['autosub'], 'no', false ) . ' /> ';
369
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
370
+ echo __( 'Auto-subscribe includes any excluded categories', 'subscribe2' ) . ':<br />' . "\r\n";
371
+ echo '<label><input type="radio" name="newreg_override" value="yes"' . checked( $this->subscribe2_options['newreg_override'], 'yes', false ) . ' /> ';
372
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
373
+ echo '<label><input type="radio" name="newreg_override" value="no"' . checked( $this->subscribe2_options['newreg_override'], 'no', false ) . ' /> ';
374
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
375
+ echo __( 'Registration Form option is checked by default', 'subscribe2' ) . ':<br />' . "\r\n";
376
+ echo '<label><input type="radio" name="wpregdef" value="yes"' . checked( $this->subscribe2_options['wpregdef'], 'yes', false ) . ' /> ';
377
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
378
+ echo '<label><input type="radio" name="wpregdef" value="no"' . checked( $this->subscribe2_options['wpregdef'], 'no', false ) . ' /> ';
379
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
380
+ echo __( 'Auto-subscribe users to receive email as', 'subscribe2' ) . ': <br />' . "\r\n";
381
+ echo '<label><input type="radio" name="autoformat" value="html"' . checked( $this->subscribe2_options['autoformat'], 'html', false ) . ' /> ';
382
+ echo __( 'HTML - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
383
+ echo '<label><input type="radio" name="autoformat" value="html_excerpt"' . checked( $this->subscribe2_options['autoformat'], 'html_excerpt', false ) . ' /> ';
384
+ echo __( 'HTML - Excerpt', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
385
+ echo '<label><input type="radio" name="autoformat" value="post"' . checked( $this->subscribe2_options['autoformat'], 'post', false ) . ' /> ';
386
+ echo __( 'Plain Text - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
387
+ echo '<label><input type="radio" name="autoformat" value="excerpt"' . checked( $this->subscribe2_options['autoformat'], 'excerpt', false ) . ' /> ';
388
+ echo __( 'Plain Text - Excerpt', 'subscribe2' ) . '</label><br /><br />';
389
+ echo __( 'Registered Users have the option to auto-subscribe to new categories', 'subscribe2' ) . ': <br />' . "\r\n";
390
+ echo '<label><input type="radio" name="show_autosub" value="yes"' . checked( $this->subscribe2_options['show_autosub'], 'yes', false ) . ' /> ';
391
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
392
+ echo '<label><input type="radio" name="show_autosub" value="no"' . checked( $this->subscribe2_options['show_autosub'], 'no', false ) . ' /> ';
393
+ echo __( 'No', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
394
+ echo '<label><input type="radio" name="show_autosub" value="exclude"' . checked( $this->subscribe2_options['show_autosub'], 'exclude', false ) . ' /> ';
395
+ echo __( 'New categories are immediately excluded', 'subscribe2' ) . '</label><br /><br />';
396
+ echo __( 'Option for Registered Users to auto-subscribe to new categories is checked by default', 'subscribe2' ) . ': <br />' . "\r\n";
397
+ echo '<label><input type="radio" name="autosub_def" value="yes"' . checked( $this->subscribe2_options['autosub_def'], 'yes', false ) . ' /> ';
398
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
399
+ echo '<label><input type="radio" name="autosub_def" value="no"' . checked( $this->subscribe2_options['autosub_def'], 'no', false ) . ' /> ';
400
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />';
401
  // Hide these options if using Jetpack Comments
402
+ if ( ! class_exists( 'Jetpack_Comments' ) ) {
403
+ echo __( 'Display checkbox to allow subscriptions from the comment form', 'subscribe2' ) . ': <br />' . "\r\n";
404
+ echo '<label><input type="radio" name="comment_subs" value="before"' . checked( $this->subscribe2_options['comment_subs'], 'before', false ) . ' /> ';
405
+ echo __( 'Before the Comment Submit button', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
406
+ echo '<label><input type="radio" name="comment_subs" value="after"' . checked( $this->subscribe2_options['comment_subs'], 'after', false ) . ' /> ';
407
+ echo __( 'After the Comment Submit button', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
408
+ echo '<label><input type="radio" name="comment_subs" value="no"' . checked( $this->subscribe2_options['comment_subs'], 'no', false ) . ' /> ';
409
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />';
410
+ echo __( 'Comment form checkbox is checked by default', 'subscribe2' ) . ': <br />' . "\r\n";
411
+ echo '<label><input type="radio" name="comment_def" value="yes"' . checked( $this->subscribe2_options['comment_def'], 'yes', false ) . ' /> ';
412
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
413
+ echo '<label><input type="radio" name="comment_def" value="no"' . checked( $this->subscribe2_options['comment_def'], 'no', false ) . ' /> ';
414
+ echo __( 'No', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
415
  }
416
+ echo __( 'Show one-click subscription on profile page', 'subscribe2' ) . ':<br />' . "\r\n";
417
+ echo '<label><input type="radio" name="one_click_profile" value="yes"' . checked( $this->subscribe2_options['one_click_profile'], 'yes', false ) . ' /> ';
418
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
419
+ echo '<label><input type="radio" name="one_click_profile" value="no"' . checked( $this->subscribe2_options['one_click_profile'], 'no', false ) . ' /> ';
420
+ echo __( 'No', 'subscribe2' ) . '</label>' . "\r\n";
421
+ echo '</p></div>' . "\r\n";
422
  break;
423
 
424
  case 'appearance':
425
  // Appearance options
426
+ echo '<div class="s2_admin" id="s2_appearance_settings">' . "\r\n";
427
+ echo '<input type="hidden" name="appearance_users_tab" value="options" />' . "\r\n";
428
+ echo '<p>' . "\r\n";
429
 
430
  // WordPress page ID where subscribe2 token is used
431
+ echo __( 'Set default Subscribe2 page as', 'subscribe2' ) . ': ';
432
+ echo '<select name="s2page">' . "\r\n";
433
+ echo '<option value="0">' . __( 'Select a page', 'subscribe2' ) . '</option>' . "\r\n";
434
+ $this->pages_dropdown( $this->subscribe2_options['s2page'] );
435
+ echo '</select>' . "\r\n";
436
 
437
  // Number of subscribers per page
438
+ echo '<br /><br />' . __( 'Set the number of Subscribers displayed per page', 'subscribe2' ) . ': ';
439
+ echo '<span id="s2entries_1"><span id="s2entries" style="background-color: #FFFBCC">' . $this->subscribe2_options['entries'] . '</span> ';
440
+ echo '<a href="#" onclick="s2_show(\'entries\'); return false;">' . __( 'Edit', 'subscribe2' ) . '</a></span>' . "\r\n";
441
+ echo '<span id="s2entries_2">' . "\r\n";
442
+ echo '<input type="text" name="entries" value="' . $this->subscribe2_options['entries'] . '" size="3" />' . "\r\n";
443
+ echo '<a href="#" onclick="s2_update(\'entries\'); return false;">' . __( 'Update', 'subscribe2' ) . '</a>' . "\r\n";
444
+ echo '<a href="#" onclick="s2_revert(\'entries\'); return false;">' . __( 'Revert', 'subscribe2' ) . '</a></span>' . "\r\n";
445
 
446
  // show link to WordPress page in meta
447
+ echo '<br /><br /><label><input type="checkbox" name="show_meta" value="1"' . checked( $this->subscribe2_options['show_meta'], '1', false ) . ' /> ';
448
+ echo __( 'Show a link to your subscription page in "meta"?', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
449
 
450
  // show QuickTag button
451
+ echo '<label><input type="checkbox" name="show_button" value="1"' . checked( $this->subscribe2_options['show_button'], '1', false ) . ' /> ';
452
+ echo __( 'Show the Subscribe2 button on the Write toolbar?', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
453
 
454
+ // enable popup style form
455
+ echo '<label><input type="checkbox" name="ajax" value="1"' . checked( $this->subscribe2_options['ajax'], '1', false ) . ' /> ';
456
+ echo __( 'Enable popup style subscription form?', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
457
 
458
  // show Widget
459
+ echo '<label><input type="checkbox" name="widget" value="1"' . checked( $this->subscribe2_options['widget'], '1', false ) . ' /> ';
460
+ echo __( 'Enable Subscribe2 Widget?', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
461
 
462
  // show Counter Widget
463
+ echo '<label><input type="checkbox" name="counterwidget" value="1"' . checked( $this->subscribe2_options['counterwidget'], '1', false ) . ' /> ';
464
+ echo __( 'Enable Subscribe2 Counter Widget?', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
465
 
466
  // s2_meta checked by default
467
+ echo '<label><input type="checkbox" name="s2meta_default" value="1"' . checked( $this->subscribe2_options['s2meta_default'], '1', false ) . ' /> ';
468
+ echo __( 'Disable email notifications is checked by default on authoring pages?', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
469
+ echo '</p>';
470
+ echo '</div>' . "\r\n";
471
  break;
472
 
473
  case 'misc':
474
  //barred domains
475
+ echo '<div class="s2_admin" id="s2_barred_domains">' . "\r\n";
476
+ echo '<h3>' . __( 'Barred Domains', 'subscribe2' ) . '</h3>' . "\r\n";
477
+ echo '<p>' . "\r\n";
478
+ echo __( 'Enter domains to bar from public subscriptions (wildcards allowed): <br /> (Use a new line for each entry and omit the "@" symbol, for example *.email.com or yahoo.*)', 'subscribe2' );
479
+ echo "\r\n" . '<br /><textarea style="width: 98%;" rows="4" cols="60" name="barred">' . esc_textarea( $this->subscribe2_options['barred'] ) . '</textarea>';
480
+ echo '</p>';
481
+ echo '<h3>' . __( 'Links', 'subscribe2' ) . '</h3>' . "\r\n";
482
+ echo '<a href="http://wordpress.org/extend/plugins/subscribe2/">' . __( 'Plugin Site', 'subscribe2' ) . '</a><br />';
483
+ echo '<a href="http://wordpress.org/support/plugin/subscribe2">' . __( 'Plugin Forum', 'subscribe2' ) . '</a><br />';
484
+ echo '<a href="http://subscribe2.wordpress.com/">' . __( 'Plugin Blog', 'subscribe2' ) . '</a><br />';
485
+ 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>';
486
+ echo '</div>' . "\r\n";
 
487
  break;
488
 
489
  }
490
  // submit
491
+ echo '<p class="submit" style="text-align: center"><input type="submit" class="button-primary" name="submit" value="' . __( 'Submit', 'subscribe2' ) . '" /></p>';
492
 
493
+ if ( 'misc' === $current_tab ) {
494
  // reset
495
+ echo '<h3>' . __( 'Reset to Default Settings', 'subscribe2' ) . '</h3>' . "\r\n";
496
+ 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";
497
+ echo '<p class="submit" style="text-align: center">';
498
+ echo '<input type="submit" id="deletepost" name="reset" value="' . __( 'RESET', 'subscribe2' ) .
499
+ '" /></p>';
500
  }
501
+ echo '</form></div>' . "\r\n";
502
 
503
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
504
  // just to be sure
505
  die;
506
  ?>
admin/subscribers.php CHANGED
@@ -1,325 +1,290 @@
1
  <?php
2
- if ( !function_exists('add_action') ) {
3
  exit();
4
  }
5
 
6
  global $wpdb, $subscribers, $what, $current_tab;
7
 
8
  // detect or define which tab we are in
9
- $current_tab = isset( $_GET['tab'] ) ? esc_attr($_GET['tab']) : 'public';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  // was anything POSTed ?
12
- if ( isset($_POST['s2_admin']) ) {
13
- check_admin_referer('bulk-subscribers');
14
- if ( !empty($_POST['addresses']) ) {
 
 
 
15
  $reg_sub_error = '';
16
  $pub_sub_error = '';
17
  $unsub_error = '';
18
  $message = '';
19
- foreach ( preg_split("|[\s,]+|", $_POST['addresses']) as $email ) {
20
- $email = $this->sanitize_email($email);
21
- if ( is_email($email) && isset($_POST['subscribe']) ) {
22
- if ( $this->is_public($email) !== false ) {
23
- ('' == $pub_sub_error) ? $pub_sub_error = "$email" : $pub_sub_error .= ", $email";
24
  continue;
25
  }
26
- if ( $this->is_registered($email) ) {
27
- ('' == $reg_sub_error) ? $reg_sub_error = "$email" : $reg_sub_error .= ", $email";
28
  continue;
29
  }
30
- $this->add($email, true);
31
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) subscribed!', 'subscribe2') . "</strong></p></div>";
32
- } elseif ( is_email($email) && isset($_POST['unsubscribe']) ) {
33
- if ( $this->is_public($email) === false || $this->is_registered($email) ) {
34
- ('' == $unsub_error) ? $unsub_error = "$email" : $unsub_error .= ", $email";
35
  continue;
36
  }
37
- $this->delete($email);
38
- $message = "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) unsubscribed!', 'subscribe2') . "</strong></p></div>";
39
  }
40
  }
41
- if ( $reg_sub_error != '' ) {
42
- echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following are already Registered Subscribers' , 'subscribe2') . ":<br />$reg_sub_error</strong></p></div>";
43
  }
44
- if ( $pub_sub_error != '' ) {
45
- echo "<div id=\"message\" class=\"error\"><p><strong>" . __('Some emails were not processed, the following are already Public Subscribers' , 'subscribe2') . ":<br />$pub_sub_error</strong></p></div>";
46
  }
47
- if ( $unsub_error != '' ) {
48
- 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>";
49
  }
50
- if ( $message != '' ) {
51
  echo $message;
52
  }
53
  $_POST['what'] = 'confirmed';
54
- } elseif ( (isset($_POST['action']) && $_POST['action'] === 'delete') || (isset($_POST['action2']) && $_POST['action2'] === 'delete') ) {
55
- if ( $current_tab === 'public' ) {
56
- foreach ( $_POST['subscriber'] as $address ) {
57
- $this->delete($address);
58
- }
59
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) deleted!', 'subscribe2') . "</strong></p></div>";
60
- } elseif ( $current_tab === 'registered' ) {
61
- global $current_user;
62
- $users_deleted_error = '';
63
- $users_deleted = '';
64
- foreach ( $_POST['subscriber'] as $address ) {
65
- $user = get_user_by('email', $address);
66
- if ( !current_user_can('delete_user', $user->ID) || $user->ID == $current_user->ID ) {
67
- $users_deleted_error = __('Delete failed! You cannot delete some or all of these users', 'subscribe2') . "<br />";
68
- continue;
69
- } else {
70
- $users_deleted = __('User(s) deleted! Any posts made by these users were assigned to you', 'subscribe2');
71
- wp_delete_user($user->ID, $current_user->ID);
72
- }
73
- }
74
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . $users_deleted_error . $users_deleted . "</strong></p></div>";
75
- }
76
- } elseif ( (isset($_POST['action']) && $_POST['action'] === 'toggle') || (isset($_POST['action2']) && $_POST['action2'] === 'toggle') ) {
77
- global $current_user;
78
- $this->ip = $current_user->user_login;
79
- foreach ( $_POST['subscriber'] as $address ) {
80
- $this->toggle($address);
81
- }
82
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Status changed!', 'subscribe2') . "</strong></p></div>";
83
- } elseif ( isset($_POST['remind']) ) {
84
- $this->remind($_POST['reminderemails']);
85
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Reminder Email(s) Sent!', 'subscribe2') . "</strong></p></div>";
86
- } elseif ( isset($_POST['sub_categories']) && 'subscribe' == $_POST['manage'] ) {
87
- $this->subscribe_registered_users($_POST['exportcsv'], $_POST['category']);
88
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Subscribed!', 'subscribe2') . "</strong></p></div>";
89
- } elseif ( isset($_POST['sub_categories']) && 'unsubscribe' == $_POST['manage'] ) {
90
- $this->unsubscribe_registered_users($_POST['exportcsv'], $_POST['category']);
91
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Registered Users Unsubscribed!', 'subscribe2') . "</strong></p></div>";
92
- } elseif ( isset($_POST['sub_format']) ) {
93
- $this->format_change( $_POST['exportcsv'], $_POST['format'] );
94
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Format updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
95
- } elseif ( isset($_POST['sub_digest']) ) {
96
- $this->digest_change( $_POST['exportcsv'], $_POST['sub_category'] );
97
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Digest Subscription updated for Selected Registered Users!', 'subscribe2') . "</strong></p></div>";
98
  }
99
  }
100
 
101
- if ( $current_tab == 'registered' ) {
102
  // Get Registered Subscribers
103
- $registered = $this->get_registered();
104
- $all_users = $this->get_all_registered();
105
  // safety check for our arrays
106
- if ( '' == $registered ) { $registered = array(); }
107
- if ( '' == $all_users ) { $all_users = array(); }
108
  } else {
109
  //Get Public Subscribers
110
  $confirmed = $this->get_public();
111
- $unconfirmed = $this->get_public(0);
112
  // safety check for our arrays
113
- if ( '' == $confirmed ) { $confirmed = array(); }
114
- if ( '' == $unconfirmed ) { $unconfirmed = array(); }
115
  }
116
 
117
  $reminderform = false;
118
- if ( isset($_REQUEST['what']) ) {
119
- if ( 'public' == $_REQUEST['what'] ) {
120
  $what = 'public';
121
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
122
- } elseif ( 'confirmed' == $_REQUEST['what'] ) {
123
  $what = 'confirmed';
124
  $subscribers = $confirmed;
125
- } elseif ( 'unconfirmed' == $_REQUEST['what'] ) {
126
  $what = 'unconfirmed';
127
  $subscribers = $unconfirmed;
128
- if ( !empty($subscribers) ) {
129
- $reminderemails = implode(",", $subscribers);
130
  $reminderform = true;
131
  }
132
- } elseif ( is_numeric($_REQUEST['what']) ) {
133
- $what = intval($_REQUEST['what']);
134
- $subscribers = $this->get_registered("cats=$what");
135
- } elseif ( 'registered' == $_REQUEST['what'] ) {
136
  $what = 'registered';
137
  $subscribers = $registered;
138
- } elseif ( 'all_users' == $_REQUEST['what'] ) {
139
  $what = 'all_users';
140
  $subscribers = $all_users;
141
  }
142
  } else {
143
- if ( $current_tab === 'public' ) {
144
  $what = 'public';
145
- $subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
146
  } else {
147
  $what = 'all_users';
148
  $subscribers = $all_users;
149
  }
150
  }
151
 
152
- if ( !empty($_REQUEST['s']) ) {
153
- if ( !empty($_POST['s']) ) {
154
  foreach ( $subscribers as $subscriber ) {
155
- if ( is_numeric(stripos($subscriber, $_POST['s'])) ) {
156
  $result[] = $subscriber;
157
  }
158
  }
159
- $subscribers = $result;
160
  } else {
161
  foreach ( $subscribers as $subscriber ) {
162
- if ( is_numeric(stripos($subscriber, $_REQUEST['s'])) ) {
163
  $result[] = $subscriber;
164
  }
165
  }
166
- $subscribers = $result;
167
  }
 
168
  }
169
 
170
- if ( !class_exists('WP_List_Table') ) {
171
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
172
- }
173
- if ( !class_exists('Subscribe2_List_Table') ) {
174
- require_once( S2PATH . 'classes/class-s2-list-table.php' );
175
- }
176
-
177
- // Instantiate and prepare our table data - this also runs the bulk actions
178
- $S2ListTable = new Subscribe2_List_Table();
179
  $S2ListTable->prepare_items();
180
 
181
  // show our form
182
- echo "<div class=\"wrap\">";
183
- if ( version_compare($GLOBALS['wp_version'], '3.8', '<=') ) {
184
- echo "<div id=\"icon-tools\" class=\"icon32\"></div>";
185
- }
186
-
187
- $tabs = array('public' => __('Public Subscribers', 'subscribe2'), 'registered' => __('Registered Subscribers', 'subscribe2'));
188
- echo "<h2 class=\"nav-tab-wrapper\">";
189
  foreach ( $tabs as $tab_key => $tab_caption ) {
190
- $active = ($current_tab == $tab_key) ? "nav-tab-active" : "";
191
- echo "<a class=\"nav-tab " . $active . "\" href=\"?page=s2_tools&amp;tab=" . $tab_key . "\">" . $tab_caption . "</a>";
192
  }
193
- echo "</h2>";
194
- echo "<form method=\"post\">\r\n";
195
- echo "<input type=\"hidden\" name=\"s2_admin\" />\r\n";
196
- switch ($current_tab) {
 
197
  case 'public':
198
- echo "<div class=\"s2_admin\" id=\"s2_add_subscribers\">\r\n";
199
- echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
200
- echo "<p>" . __('Enter addresses, one per line or comma-separated', 'subscribe2') . "<br />\r\n";
201
- echo "<textarea rows=\"2\" cols=\"80\" name=\"addresses\"></textarea></p>\r\n";
202
- echo "<input type=\"hidden\" name=\"s2_admin\" />\r\n";
203
- echo "<p class=\"submit\" style=\"border-top: none;\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __('Subscribe', 'subscribe2') . "\" />";
204
- echo "&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __('Unsubscribe', 'subscribe2') . "\" /></p>\r\n";
205
- echo "</div>\r\n";
 
206
 
207
  // subscriber lists
208
- echo "<div class=\"s2_admin\" id=\"s2_current_subscribers\">\r\n";
209
- echo "<h2>" . __('Current Subscribers', 'subscribe2') . "</h2>\r\n";
210
- echo "<br />";
211
  $cats = $this->all_cats();
212
  $cat_ids = array();
213
- foreach ( $cats as $cat) {
214
  $cat_ids[] = $cat->term_id;
215
  }
216
- $exclude = array_merge(array('all', 'all_users', 'registered'), $cat_ids);
217
  break;
218
 
219
  case 'registered':
220
- echo "<div class=\"s2_admin\" id=\"s2_add_subscribers\">\r\n";
221
- echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
222
- echo "<p class=\"submit\" style=\"border-top: none;\"><a class=\"button-primary\" href=\"" . admin_url('user-new.php') . "\">" . __('Add Registered User', 'subscribe2') . "</a></p>\r\n";
 
223
 
224
  echo "</div>\r\n";
225
 
226
  // subscriber lists
227
- echo "<div class=\"s2_admin\" id=\"s2_current_subscribers\">\r\n";
228
- echo "<h2>" . __('Current Subscribers', 'subscribe2') . "</h2>\r\n";
229
- echo "<br />";
230
- $exclude = array('all', 'public', 'confirmed', 'unconfirmed');
231
  break;
232
  }
233
 
234
  // show the selected subscribers
235
- echo "<table style=\"width: 100%; border-collapse: separate; border-spacing: 0px; *border-collapse: expression('separate', cellSpacing = '0px');\"><tr>";
236
- echo "<td style=\"width: 50%; text-align: left;\">";
237
- $this->display_subscriber_dropdown($what, __('Filter', 'subscribe2'), $exclude);
238
- echo "</td>\r\n";
239
  if ( $reminderform ) {
240
- echo "<td style=\"width: 25%; text-align: right;\"><input type=\"hidden\" name=\"reminderemails\" value=\"" . $reminderemails . "\" />\r\n";
241
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"remind\" value=\"" . __('Send Reminder Email', 'subscribe2') . "\" /></td>\r\n";
242
  } else {
243
- echo "<td style=\"width: 25%;\"></td>";
244
  }
245
- if ( !empty($subscribers) ) {
246
- $exportcsv = implode(",\r\n", $subscribers);
247
- echo "<td style=\"width: 25%; text-align: right;\"><input type=\"hidden\" name=\"exportcsv\" value=\"" . $exportcsv . "\" />\r\n";
248
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"csv\" value=\"" . __('Save Emails to CSV File', 'subscribe2') . "\" /></td>\r\n";
 
 
 
 
 
 
 
249
  } else {
250
- echo "<td style=\"width: 25%;\"></td>";
251
  }
252
- echo "</tr></table>";
253
 
254
  // output our subscriber table
255
- $S2ListTable->search_box(__('Search', 'subscribe2'), 'search_id');
256
  $S2ListTable->display();
257
- echo "</div>\r\n";
258
 
259
- // show bulk managment form if filtered in some Registered Users
260
- if ( $current_tab === 'registered' ) {
261
- echo "<div class=\"s2_admin\" id=\"s2_bulk_manage\">\r\n";
262
- echo "<h2>" . __('Bulk Management', 'subscribe2') . "</h2>\r\n";
263
- if ( $this->subscribe2_options['email_freq'] == 'never' ) {
264
  $categories = array();
265
- if ( isset($_POST['category']) ) {
266
  $categories = $_POST['category'];
267
  }
268
  $format = '';
269
- if ( isset($_POST['format']) ) {
270
  $format = $_POST['format'];
271
  }
272
- echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
273
- echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
274
- echo "<br />" . __('Action to perform', 'subscribe2') . ":\r\n";
275
- echo "<label><input type=\"radio\" name=\"manage\" value=\"subscribe\" checked=\"checked\" /> " . __('Subscribe', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
276
- echo "<label><input type=\"radio\" name=\"manage\" value=\"unsubscribe\" /> " . __('Unsubscribe', 'subscribe2') . "</label><br /><br />\r\n";
277
  if ( '1' === $this->subscribe2_options['reg_override'] ) {
278
- $this->display_category_form($categories, 1);
279
  } else {
280
- $this->display_category_form($categories, 0);
281
  }
282
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_categories\" value=\"" . __('Bulk Update Categories', 'subscribe2') . "\" /></p>";
283
- echo "<br />" . __('Send email as', 'subscribe2') . ":\r\n";
284
- echo "<label><input type=\"radio\" name=\"format\" value=\"html\"" . checked($format, 'html', false) . " /> " . __('HTML - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
285
- echo "<label><input type=\"radio\" name=\"format\" value=\"html_excerpt\"" . checked($format, 'html_excerpt', false) . " /> " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
286
- echo "<label><input type=\"radio\" name=\"format\" value=\"post\"" . checked($format, 'post', false) . " /> " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
287
- echo "<label><input type=\"radio\" name=\"format\" value=\"excerpt\"" . checked($format, 'excerpt', false) . "/> " . __('Plain Text - Excerpt', 'subscribe2') . "</label>\r\n";
288
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_format\" value=\"" . __('Bulk Update Format', 'subscribe2') . "\" /></p>";
289
  } else {
290
  $sub_cats = '';
291
- if ( isset($_POST['sub_category']) ) {
292
  $sub_cats = $_POST['sub_category'];
293
  }
294
- echo __('Preferences for Registered Users selected in the filter above can be changed using this section.', 'subscribe2') . "<br />\r\n";
295
- echo "<strong><em style=\"color: red\">" . __('Consider User Privacy as changes cannot be undone', 'subscribe2') . "</em></strong><br />\r\n";
296
- echo "<br />" . __('Subscribe Selected Users to receive a periodic digest notification', 'subscribe2') . ":\r\n";
297
- echo "<label><input type=\"radio\" name=\"sub_category\" value=\"digest\"" . checked($sub_cats, 'digest', false) . " /> ";
298
- echo __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;\r\n";
299
- echo "<label><input type=\"radio\" name=\"sub_category\" value=\"-1\"" . checked($sub_cats, '-1', false) . " /> ";
300
- echo __('No', 'subscribe2') . "</label>";
301
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"sub_digest\" value=\"" . __('Bulk Update Digest Subscription', 'subscribe2') . "\" /></p>";
302
  }
303
- echo "</div>\r\n";
304
- }
305
- echo "</form></div>\r\n";
306
-
307
- if ( $current_tab === 'registered' ) {
308
- echo "<script type=\"text/javascript\">\r\n";
309
- echo "function s2_delete_check() {\r\n";
310
- echo " var action1 = document.getElementById('doaction');\r\n";
311
- echo " action1.onclick = submitHandler;\r\n";
312
- echo " var action2 = document.getElementById('doaction2');\r\n";
313
- echo " action2.onclick = submitHandler;\r\n";
314
- echo " function submitHandler() {\r\n";
315
- echo " var agree=confirm('" . __('You are about to delete user account(s). Are you sure?', 'subscribe2') . "'); if (agree) return true; else return false;\r\n";
316
- echo " }\r\n";
317
- echo "}\r\n";
318
- echo "window.onload=s2_delete_check;\r\n";
319
- echo "</script>\r\n";
320
  }
 
321
 
322
- include(ABSPATH . 'wp-admin/admin-footer.php');
323
  // just to be sure
324
  die;
325
  ?>
1
  <?php
2
+ if ( ! function_exists( 'add_action' ) ) {
3
  exit();
4
  }
5
 
6
  global $wpdb, $subscribers, $what, $current_tab;
7
 
8
  // detect or define which tab we are in
9
+ $current_tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'public';
10
+
11
+ // Access function to allow display for form elements
12
+ require_once( S2PATH . 'classes/class-s2-forms.php' );
13
+ $s2_forms = new s2_forms;
14
+
15
+ // Instantiate and prepare our table data - this also runs the bulk actions
16
+ if ( ! class_exists( 'WP_List_Table' ) ) {
17
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
18
+ }
19
+ if ( ! class_exists( 'Subscribe2_List_Table' ) ) {
20
+ if ( version_compare( $GLOBALS['wp_version'], '4.3', '<' ) ) {
21
+ require_once( S2PATH . 'classes/class-s2-list-table-legacy.php' );
22
+ $S2ListTable = new S2_List_Table_Legacy;
23
+ } else {
24
+ require_once( S2PATH . 'classes/class-s2-list-table.php' );
25
+ $S2ListTable = new S2_List_Table;
26
+ }
27
+ }
28
 
29
  // was anything POSTed ?
30
+ if ( isset( $_POST['s2_admin'] ) ) {
31
+ if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $S2ListTable->_args['plural'] ) ) {
32
+ die( '<p>' . __( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
33
+ }
34
+
35
+ if ( ! empty( $_POST['addresses'] ) ) {
36
  $reg_sub_error = '';
37
  $pub_sub_error = '';
38
  $unsub_error = '';
39
  $message = '';
40
+ foreach ( preg_split( '/[\s,]+/', $_POST['addresses'] ) as $email ) {
41
+ $email = $this->sanitize_email( $email );
42
+ if ( is_email( $email ) && isset( $_POST['subscribe'] ) ) {
43
+ if ( false !== $this->is_public( $email ) ) {
44
+ ('' === $pub_sub_error) ? $pub_sub_error = "$email" : $pub_sub_error .= ", $email";
45
  continue;
46
  }
47
+ if ( $this->is_registered( $email ) ) {
48
+ ('' === $reg_sub_error) ? $reg_sub_error = "$email" : $reg_sub_error .= ", $email";
49
  continue;
50
  }
51
+ $this->add( $email, true );
52
+ $message = '<div id="message" class="updated fade"><p><strong>' . __( 'Address(es) subscribed!', 'subscribe2' ) . '</strong></p></div>';
53
+ } elseif ( is_email( $email ) && isset( $_POST['unsubscribe'] ) ) {
54
+ if ( false === $this->is_public( $email ) || $this->is_registered( $email ) ) {
55
+ ('' === $unsub_error) ? $unsub_error = "$email" : $unsub_error .= ", $email";
56
  continue;
57
  }
58
+ $this->delete( $email );
59
+ $message = '<div id="message" class="updated fade"><p><strong>' . __( 'Address(es) unsubscribed!', 'subscribe2' ) . '</strong></p></div>';
60
  }
61
  }
62
+ if ( '' !== $reg_sub_error ) {
63
+ echo '<div id="message" class="error"><p><strong>' . __( 'Some emails were not processed, the following are already Registered Subscribers' , 'subscribe2' ) . ':<br />' . $reg_sub_error . '</strong></p></div>';
64
  }
65
+ if ( '' !== $pub_sub_error ) {
66
+ echo '<div id="message" class="error"><p><strong>' . __( 'Some emails were not processed, the following are already Public Subscribers' , 'subscribe2' ) . ':<br />' . $pub_sub_error . '</strong></p></div>';
67
  }
68
+ if ( '' !== $unsub_error ) {
69
+ 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>';
70
  }
71
+ if ( '' !== $message ) {
72
  echo $message;
73
  }
74
  $_POST['what'] = 'confirmed';
75
+ } elseif ( isset( $_POST['remind'] ) ) {
76
+ $this->remind( $_POST['reminderemails'] );
77
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Reminder Email(s) Sent!', 'subscribe2' ) . '</strong></p></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
  }
80
 
81
+ if ( 'registered' === $current_tab ) {
82
  // Get Registered Subscribers
83
+ $registered = $this->get_registered( 'return=emailid' );
84
+ $all_users = $this->get_all_registered( 'emailid' );
85
  // safety check for our arrays
86
+ if ( '' === $registered ) { $registered = array(); }
87
+ if ( '' === $all_users ) { $all_users = array(); }
88
  } else {
89
  //Get Public Subscribers
90
  $confirmed = $this->get_public();
91
+ $unconfirmed = $this->get_public( 0 );
92
  // safety check for our arrays
93
+ if ( '' === $confirmed ) { $confirmed = array(); }
94
+ if ( '' === $unconfirmed ) { $unconfirmed = array(); }
95
  }
96
 
97
  $reminderform = false;
98
+ if ( isset( $_REQUEST['what'] ) ) {
99
+ if ( 'public' === $_REQUEST['what'] ) {
100
  $what = 'public';
101
+ $subscribers = array_merge( (array) $confirmed, (array) $unconfirmed );
102
+ } elseif ( 'confirmed' === $_REQUEST['what'] ) {
103
  $what = 'confirmed';
104
  $subscribers = $confirmed;
105
+ } elseif ( 'unconfirmed' === $_REQUEST['what'] ) {
106
  $what = 'unconfirmed';
107
  $subscribers = $unconfirmed;
108
+ if ( ! empty( $subscribers ) ) {
109
+ $reminderemails = implode( ',', $subscribers );
110
  $reminderform = true;
111
  }
112
+ } elseif ( is_numeric( $_REQUEST['what'] ) ) {
113
+ $what = intval( $_REQUEST['what'] );
114
+ $subscribers = $this->get_registered( "cats=$what&return=emailid" );
115
+ } elseif ( 'registered' === $_REQUEST['what'] ) {
116
  $what = 'registered';
117
  $subscribers = $registered;
118
+ } elseif ( 'all_users' === $_REQUEST['what'] ) {
119
  $what = 'all_users';
120
  $subscribers = $all_users;
121
  }
122
  } else {
123
+ if ( 'public' === $current_tab ) {
124
  $what = 'public';
125
+ $subscribers = array_merge( (array) $confirmed, (array) $unconfirmed );
126
  } else {
127
  $what = 'all_users';
128
  $subscribers = $all_users;
129
  }
130
  }
131
 
132
+ if ( ! empty( $_POST['s'] ) ) {
133
+ if ( 'registered' === $current_tab ) {
134
  foreach ( $subscribers as $subscriber ) {
135
+ if ( is_numeric( stripos( $subscriber['user_email'], $_POST['s'] ) ) ) {
136
  $result[] = $subscriber;
137
  }
138
  }
 
139
  } else {
140
  foreach ( $subscribers as $subscriber ) {
141
+ if ( is_numeric( stripos( $subscriber, $_POST['s'] ) ) ) {
142
  $result[] = $subscriber;
143
  }
144
  }
 
145
  }
146
+ $subscribers = $result;
147
  }
148
 
 
 
 
 
 
 
 
 
 
149
  $S2ListTable->prepare_items();
150
 
151
  // show our form
152
+ echo '<div class="wrap">';
153
+ echo '<h1>' . __( 'Subscribers', 'subscribe2' ) . '</h1>' . "\r\n";
154
+ $tabs = array(
155
+ 'public' => __( 'Public Subscribers', 'subscribe2' ),
156
+ 'registered' => __( 'Registered Subscribers', 'subscribe2' ),
157
+ );
158
+ echo '<h2 class="nav-tab-wrapper">';
159
  foreach ( $tabs as $tab_key => $tab_caption ) {
160
+ $active = ($current_tab === $tab_key) ? 'nav-tab-active' : '';
161
+ echo '<a class="nav-tab ' . $active . '" href="?page=s2_tools&amp;tab=' . $tab_key . '">' . $tab_caption . '</a>';
162
  }
163
+ echo '</h2>';
164
+ echo '<form method="post">' . "\r\n";
165
+
166
+ echo '<input type="hidden" name="s2_admin" />' . "\r\n";
167
+ switch ( $current_tab ) {
168
  case 'public':
169
+ echo '<input type="hidden" id="s2_location" name="s2_location" value="public" />' . "\r\n";
170
+ echo '<div class="s2_admin" id="s2_add_subscribers">' . "\r\n";
171
+ echo '<h2>' . __( 'Add/Remove Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
172
+ echo '<p>' . __( 'Enter addresses, one per line or comma-separated', 'subscribe2' ) . '<br />' . "\r\n";
173
+ echo '<textarea rows="2" cols="80" name="addresses"></textarea></p>' . "\r\n";
174
+ echo '<input type="hidden" name="s2_admin" />' . "\r\n";
175
+ echo '<p class="submit" style="border-top: none;"><input type="submit" class="button-primary" name="subscribe" value="' . __( 'Subscribe', 'subscribe2' ) . '" />';
176
+ echo '&nbsp;<input type="submit" class="button-primary" name="unsubscribe" value="' . __( 'Unsubscribe', 'subscribe2' ) . '" /></p>' . "\r\n";
177
+ echo '</div>' . "\r\n";
178
 
179
  // subscriber lists
180
+ echo '<div class="s2_admin" id="s2_current_subscribers">' . "\r\n";
181
+ echo '<h2>' . __( 'Current Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
182
+ echo '<br />';
183
  $cats = $this->all_cats();
184
  $cat_ids = array();
185
+ foreach ( $cats as $cat ) {
186
  $cat_ids[] = $cat->term_id;
187
  }
188
+ $exclude = array_merge( array( 'all', 'all_users', 'registered' ), $cat_ids );
189
  break;
190
 
191
  case 'registered':
192
+ echo '<input type="hidden" id="s2_location" name="s2_location" value="registered" />' . "\r\n";
193
+ echo '<div class="s2_admin" id="s2_add_subscribers">' . "\r\n";
194
+ echo '<h2>' . __( 'Add/Remove Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
195
+ echo '<p class="submit" style="border-top: none;"><a class="button-primary" href="' . admin_url( 'user-new.php' ) . '">' . __( 'Add Registered User', 'subscribe2' ) . '</a></p>' . "\r\n";
196
 
197
  echo "</div>\r\n";
198
 
199
  // subscriber lists
200
+ echo '<div class="s2_admin" id="s2_current_subscribers">' . "\r\n";
201
+ echo '<h2>' . __( 'Current Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
202
+ echo '<br />';
203
+ $exclude = array( 'all', 'public', 'confirmed', 'unconfirmed' );
204
  break;
205
  }
206
 
207
  // show the selected subscribers
208
+ echo '<table style="width: 100%; border-collapse: separate; border-spacing: 0px; *border-collapse: expression("separate", cellSpacing = "0px");"><tr>';
209
+ echo '<td style="width: 50%; text-align: left;">';
210
+ $this->display_subscriber_dropdown( $what, __( 'Filter', 'subscribe2' ), $exclude );
211
+ echo '</td>' . "\r\n";
212
  if ( $reminderform ) {
213
+ echo '<td style="width: 25%; text-align: right;"><input type="hidden" name="reminderemails" value="' . $reminderemails . '" />' . "\r\n";
214
+ echo '<input type="submit" class="button-secondary" name="remind" value="' . __( 'Send Reminder Email', 'subscribe2' ) . '" /></td>' . "\r\n";
215
  } else {
216
+ echo '<td style="width: 25%;"></td>';
217
  }
218
+ if ( ! empty( $subscribers ) ) {
219
+ if ( 'public' === $current_tab ) {
220
+ $exportcsv = implode( ",\r\n", $subscribers );
221
+ } else {
222
+ $exportcsv = '';
223
+ foreach ( $subscribers as $subscriber ) {
224
+ ('' === $exportcsv) ? $exportcsv = $subscriber['user_email'] : $exportcsv .= ",\r\n" . $subscriber['user_email'];
225
+ }
226
+ }
227
+ echo '<td style="width: 25%; text-align: right;"><input type="hidden" name="exportcsv" value="' . $exportcsv . '" />' . "\r\n";
228
+ echo '<input type="submit" class="button-secondary" name="csv" value="' . __( 'Save Emails to CSV File', 'subscribe2' ) . '" /></td>' . "\r\n";
229
  } else {
230
+ echo '<td style="width: 25%;"></td>';
231
  }
232
+ echo '</tr></table>';
233
 
234
  // output our subscriber table
235
+ $S2ListTable->search_box( __( 'Search', 'subscribe2' ), 'search_id' );
236
  $S2ListTable->display();
237
+ echo '</div>' . "\r\n";
238
 
239
+ // show bulk management form if filtered in some Registered Users
240
+ if ( 'registered' === $current_tab ) {
241
+ echo '<div class="s2_admin" id="s2_bulk_manage">' . "\r\n";
242
+ echo '<h2>' . __( 'Bulk Management', 'subscribe2' ) . '</h2>' . "\r\n";
243
+ if ( 'never' === $this->subscribe2_options['email_freq'] ) {
244
  $categories = array();
245
+ if ( isset( $_POST['category'] ) ) {
246
  $categories = $_POST['category'];
247
  }
248
  $format = '';
249
+ if ( isset( $_POST['format'] ) ) {
250
  $format = $_POST['format'];
251
  }
252
+ echo __( 'Preferences for Registered Users selected above can be changed using this section.', 'subscribe2' ) . '<br />' . "\r\n";
253
+ echo '<strong><em style="color: red">' . __( 'Consider User Privacy as changes cannot be undone', 'subscribe2' ) . '</em></strong><br />' . "\r\n";
254
+ echo '<br />' . __( 'Action to perform', 'subscribe2' ) . ':' . "\r\n";
255
+ echo '<label><input type="radio" name="manage" value="subscribe" checked="checked" /> ' . __( 'Subscribe', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
256
+ echo '<label><input type="radio" name="manage" value="unsubscribe" /> ' . __( 'Unsubscribe', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
257
  if ( '1' === $this->subscribe2_options['reg_override'] ) {
258
+ $s2_forms->display_category_form( $categories, 1 );
259
  } else {
260
+ $s2_forms->display_category_form( $categories, 0 );
261
  }
262
+ echo '<p class="submit"><button class="button-primary" name="sub_categories" onclick="bu_cats();">' . __( 'Bulk Update Categories', 'subscribe2' ) . '</button></p>';
263
+ echo '<br />' . __( 'Send email as', 'subscribe2' ) . ':' . "\r\n";
264
+ echo '<label><input type="radio" name="format" value="html"' . checked( $format, 'html', false ) . ' /> ' . __( 'HTML - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
265
+ echo '<label><input type="radio" name="format" value="html_excerpt"' . checked( $format, 'html_excerpt', false ) . ' /> ' . __( 'HTML - Excerpt', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
266
+ echo '<label><input type="radio" name="format" value="post"' . checked( $format, 'post', false ) . ' /> ' . __( 'Plain Text - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
267
+ echo '<label><input type="radio" name="format" value="excerpt"' . checked( $format, 'excerpt', false ) . '/> ' . __( 'Plain Text - Excerpt', 'subscribe2' ) . '</label>' . "\r\n";
268
+ echo '<p class="submit"><button class="button-primary" name="sub_format" onclick="bu_format();">' . __( 'Bulk Update Format', 'subscribe2' ) . '</button></p>';
269
  } else {
270
  $sub_cats = '';
271
+ if ( isset( $_POST['sub_category'] ) ) {
272
  $sub_cats = $_POST['sub_category'];
273
  }
274
+ echo __( 'Preferences for Registered Users selected above can be changed using this section.', 'subscribe2' ) . "<br />\r\n";
275
+ echo '<strong><em style="color: red">' . __( 'Consider User Privacy as changes cannot be undone.', 'subscribe2' ) . '</em></strong><br />' . "\r\n";
276
+ echo '<br />' . __( 'Subscribe Selected Users to receive a periodic digest notification', 'subscribe2' ) . ':' . "\r\n";
277
+ echo '<label><input type="radio" name="sub_category" value="digest"' . checked( $sub_cats, 'digest', false ) . ' /> ';
278
+ echo __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
279
+ echo '<label><input type="radio" name="sub_category" value="-1"' . checked( $sub_cats, '-1', false ) . ' /> ';
280
+ echo __( 'No', 'subscribe2' ) . '</label>';
281
+ echo '<p class="submit"><button class="button-primary" name="sub_digest" onclick="bu_digest();">' . __( 'Bulk Update Digest Subscription', 'subscribe2' ) . '</button></p>';
282
  }
283
+ echo '</div>' . "\r\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  }
285
+ echo '</form></div>' . "\r\n";
286
 
287
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
288
  // just to be sure
289
  die;
290
  ?>
admin/your-subscriptions.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! function_exists( 'add_action' ) ) {
3
+ exit();
4
+ }
5
+
6
+ require_once( S2PATH . 'classes/class-s2-forms.php' );
7
+ $s2_forms = new S2_Forms;
8
+ $s2_forms->init();
9
+
10
+ // was anything POSTed?
11
+ if ( isset( $_POST['s2_admin'] ) && 'user' === $_POST['s2_admin'] ) {
12
+ if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'subscribe2-user_subscribers' . S2VERSION ) ) {
13
+ die( '<p>' . __( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
14
+ }
15
+ do_action( 's2_subscription_submit' );
16
+ }
17
+
18
+ // show our form
19
+ echo '<div class="wrap">';
20
+
21
+ global $user_ID;
22
+ $userid = $s2_forms->get_userid();
23
+ $user = get_userdata( $userid );
24
+
25
+ if ( $userid === $user_ID ) {
26
+ echo '<h1>' . __( 'Your Notification Settings', 'subscribe2' ) . "</h1>\r\n";
27
+ } else {
28
+ echo '<h1>' . __( 'Notification Settings for user:', 'subscribe2' ) . ' <span style="color: red;">' . $user->display_name . '</span></h1>' . "\r\n";
29
+ }
30
+
31
+
32
+ echo '<form method="post">';
33
+ wp_nonce_field( 'subscribe2-user_subscribers' . S2VERSION );
34
+
35
+ echo '<p>';
36
+
37
+ do_action( 's2_subscription_form', $userid );
38
+
39
+ // submit
40
+ echo '<p class="submit"><input type="submit" class="button-primary" name="submit" value="' . __( 'Update Preferences', 'subscribe2' ) . ' &raquo;" /></p>';
41
+ echo '</form>' . "\r\n";
42
+
43
+ echo '</div>' . "\r\n";
44
+
45
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
46
+ // just to be sure
47
+ die;
48
+ ?>
admin/your_subscriptions.php DELETED
@@ -1,279 +0,0 @@
1
- <?php
2
- if ( !function_exists('add_action') ) {
3
- exit();
4
- }
5
-
6
- global $user_ID, $s2nonce;
7
-
8
- if ( isset($_GET['email']) ) {
9
- global $wpdb;
10
- $user_ID = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_email = %s", $_GET['email']));
11
- } else {
12
- get_currentuserinfo();
13
- }
14
-
15
- // was anything POSTed?
16
- if ( isset($_POST['s2_admin']) && 'user' == $_POST['s2_admin'] ) {
17
- check_admin_referer('subscribe2-user_subscribers' . $s2nonce);
18
-
19
- if ( isset($_POST['submit']) ) {
20
- if ( isset($_POST['s2_format']) ) {
21
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $_POST['s2_format']);
22
- } else {
23
- // value has not been set so use default
24
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
25
- }
26
- if ( isset($_POST['new_category']) ) {
27
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $_POST['new_category']);
28
- } else {
29
- // value has not been passed so use Settings defaults
30
- if ( $this->subscribe2_options['show_autosub'] == 'yes' && $this->subscribe2_options['autosub_def'] == 'yes' ) {
31
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes');
32
- } else {
33
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'no');
34
- }
35
- }
36
-
37
- $cats = ( isset($_POST['category']) ) ? $_POST['category'] : '';
38
-
39
- if ( empty($cats) || $cats == '-1' ) {
40
- $oldcats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
41
- if ( $oldcats ) {
42
- foreach ( $oldcats as $cat ) {
43
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat);
44
- }
45
- }
46
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), '');
47
- } elseif ( $cats == 'digest' ) {
48
- $all_cats = $this->all_cats(false, 'ID');
49
- foreach ( $all_cats as $cat ) {
50
- ('' == $catids) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
51
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
52
- }
53
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $catids);
54
- } else {
55
- if ( !is_array($cats) ) {
56
- $cats = (array)$_POST['category'];
57
- }
58
- sort($cats);
59
- $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
60
- $remove = array_diff($old_cats, $cats);
61
- $new = array_diff($cats, $old_cats);
62
- if ( !empty($remove) ) {
63
- // remove subscription to these cat IDs
64
- foreach ( $remove as $id ) {
65
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
66
- }
67
- }
68
- if ( !empty($new) ) {
69
- // add subscription to these cat IDs
70
- foreach ( $new as $id ) {
71
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
72
- }
73
- }
74
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $cats));
75
- }
76
-
77
- $authors = ( isset($_POST['author']) ) ? $_POST['author'] : '';
78
- if ( is_array($authors) ) {
79
- $authors = implode(',', $authors);
80
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), $authors);
81
- } elseif ( empty($authors) ) {
82
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
83
- }
84
- } elseif ( isset($_POST['subscribe']) ) {
85
- $this->one_click_handler($user_ID, 'subscribe');
86
- } elseif ( isset($_POST['unsubscribe']) ) {
87
- $this->one_click_handler($user_ID, 'unsubscribe');
88
- }
89
-
90
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Subscription preferences updated.', 'subscribe2') . "</strong></p></div>\n";
91
- }
92
-
93
- // show our form
94
- echo "<div class=\"wrap\">";
95
- if ( version_compare($GLOBALS['wp_version'], '3.8', '<=') ) {
96
- echo "<div id=\"icon-users\" class=\"icon32\"></div>";
97
- }
98
-
99
- echo "<h2>" . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
100
- if ( isset($_GET['email']) ) {
101
- $user = get_userdata($user_ID);
102
- echo "<span style=\"color: red;line-height: 300%;\">" . __('Editing Subscribe2 preferences for user', 'subscribe2') . ": " . $user->display_name . "</span>";
103
- }
104
- echo "<form method=\"post\">";
105
- echo "<p>";
106
- if ( function_exists('wp_nonce_field') ) {
107
- wp_nonce_field('subscribe2-user_subscribers' . $s2nonce);
108
- }
109
- echo "<input type=\"hidden\" name=\"s2_admin\" value=\"user\" />";
110
- if ( $this->subscribe2_options['email_freq'] == 'never' ) {
111
- echo __('Receive email as', 'subscribe2') . ": &nbsp;&nbsp;";
112
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'html', false) . " />";
113
- echo " " . __('HTML - Full', 'subscribe2') ."</label>&nbsp;&nbsp;";
114
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"html_excerpt\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'html_excerpt', false) . " />";
115
- echo " " . __('HTML - Excerpt', 'subscribe2') . "</label>&nbsp;&nbsp;";
116
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"post\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'post', false) . " />";
117
- echo " " . __('Plain Text - Full', 'subscribe2') . "</label>&nbsp;&nbsp;";
118
- echo "<label><input type=\"radio\" name=\"s2_format\" value=\"excerpt\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true), 'excerpt', false) . " />";
119
- echo " " . __('Plain Text - Excerpt', 'subscribe2') . "</label><br /><br />\r\n";
120
-
121
- if ( $this->subscribe2_options['show_autosub'] == 'yes' ) {
122
- echo __('Automatically subscribe me to newly created categories', 'subscribe2') . ': &nbsp;&nbsp;';
123
- echo "<label><input type=\"radio\" name=\"new_category\" value=\"yes\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), true), 'yes', false) . " />";
124
- echo " " . __('Yes', 'subscribe2') . "</label>&nbsp;&nbsp;";
125
- echo "<label><input type=\"radio\" name=\"new_category\" value=\"no\"" . checked(get_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), true), 'no', false) . " />";
126
- echo " " . __('No', 'subscribe2') . "</label>";
127
- echo "</p>";
128
- }
129
-
130
- if ( $this->subscribe2_options['one_click_profile'] == 'yes' ) {
131
- // One-click subscribe and unsubscribe buttons
132
- echo "<h2>" . __('One Click Subscription / Unsubscription', 'subscribe2') . "</h2>\r\n";
133
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"subscribe\" value=\"" . __("Subscribe to All", 'subscribe2') . "\" />&nbsp;&nbsp;";
134
- echo "<input type=\"submit\" class=\"button-primary\" name=\"unsubscribe\" value=\"" . __("Unsubscribe from All", 'subscribe2') . "\" /></p>";
135
- }
136
-
137
- // subscribed categories
138
- if ( $this->s2_mu ) {
139
- global $blog_id;
140
- $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
141
- // if we are subscribed to the current blog display an "unsubscribe" link
142
- if ( !empty($subscribed) ) {
143
- $unsubscribe_link = esc_url( add_query_arg('s2mu_unsubscribe', $blog_id) );
144
- echo "<p><a href=\"". $unsubscribe_link ."\" class=\"button\">" . __('Unsubscribe me from this blog', 'subscribe2') . "</a></p>";
145
- } else {
146
- // else we show a "subscribe" link
147
- $subscribe_link = esc_url( add_query_arg('s2mu_subscribe', $blog_id) );
148
- echo "<p><a href=\"". $subscribe_link ."\" class=\"button\">" . __('Subscribe to all categories', 'subscribe2') . "</a></p>";
149
- }
150
- echo "<h2>" . __('Subscribed Categories on', 'subscribe2') . " " . get_option('blogname') . " </h2>\r\n";
151
- } else {
152
- echo "<h2>" . __('Subscribed Categories', 'subscribe2') . "</h2>\r\n";
153
- }
154
- ('' == $this->subscribe2_options['compulsory']) ? $compulsory = array() : $compulsory = explode(',', $this->subscribe2_options['compulsory']);
155
- $this->display_category_form(explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true)), $this->subscribe2_options['reg_override'], $compulsory);
156
- } else {
157
- // we're doing daily digests, so just show
158
- // subscribe / unnsubscribe
159
- echo __('Receive periodic summaries of new posts?', 'subscribe2') . ': &nbsp;&nbsp;';
160
- echo "<label>";
161
- echo "<input type=\"radio\" name=\"category\" value=\"digest\"";
162
- if ( get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
163
- echo " checked=\"checked\"";
164
- }
165
- echo " /> " . __('Yes', 'subscribe2') . "</label> <label><input type=\"radio\" name=\"category\" value=\"-1\" ";
166
- if ( !get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
167
- echo " checked=\"checked\"";
168
- }
169
- echo " /> " . __('No', 'subscribe2');
170
- echo "</label></p>";
171
- }
172
-
173
- if ( count($this->get_authors()) > 1 && $this->subscribe2_options['email_freq'] == 'never' ) {
174
- echo "<div class=\"s2_admin\" id=\"s2_authors\">\r\n";
175
- echo "<h2>" . __('Do not send notifications for post made by these authors', 'subscribe2') . "</h2>\r\n";
176
- $this->display_author_form(explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), true)));
177
- echo "</div>\r\n";
178
- }
179
-
180
- // submit
181
- echo "<p class=\"submit\"><input type=\"submit\" class=\"button-primary\" name=\"submit\" value=\"" . __("Update Preferences", 'subscribe2') . " &raquo;\" /></p>";
182
- echo "</form>\r\n";
183
-
184
- // list of subscribed blogs on wordpress mu
185
- if ( $this->s2_mu && !isset($_GET['email']) ) {
186
- global $blog_id, $current_user, $s2class_multisite;
187
- $s2blog_id = $blog_id;
188
- get_currentuserinfo();
189
- $blogs = $s2class_multisite->get_mu_blog_list();
190
-
191
- $blogs_subscribed = array();
192
- $blogs_notsubscribed = array();
193
-
194
- foreach ( $blogs as $blog ) {
195
- // switch to blog
196
- switch_to_blog($blog['blog_id']);
197
-
198
- // check that the Subscribe2 plugin is active on the current blog
199
- $current_plugins = get_option('active_plugins');
200
- if ( !is_array($current_plugins) ) {
201
- $current_plugins = (array)$current_plugins;
202
- }
203
- if ( !in_array(S2DIR . 'subscribe2.php', $current_plugins) ) {
204
- continue;
205
- }
206
-
207
- // check if we're subscribed to the blog
208
- $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
209
-
210
- $blogname = get_option('blogname');
211
- if ( strlen($blogname) > 30 ) {
212
- $blog['blogname'] = wp_html_excerpt($blogname, 30) . "..";
213
- } else {
214
- $blog['blogname'] = $blogname;
215
- }
216
- $blog['description'] = get_option('blogdescription');
217
- $blog['blogurl'] = get_option('home');
218
- $blog['subscribe_page'] = get_option('home') . "/wp-admin/admin.php?page=s2";
219
-
220
- $key = strtolower($blog['blogname'] . "-" . $blog['blog_id']);
221
- if ( !empty($subscribed) ) {
222
- $blogs_subscribed[$key] = $blog;
223
- } else {
224
- $blogs_notsubscribed[$key] = $blog;
225
- }
226
- restore_current_blog();
227
- }
228
-
229
- echo "<div class=\"s2_admin\" id=\"s2_mu_sites\">\r\n";
230
- if ( !empty($blogs_subscribed) ) {
231
- ksort($blogs_subscribed);
232
- echo "<h2>" . __('Subscribed Blogs', 'subscribe2') . "</h2>\r\n";
233
- echo "<ul class=\"s2_blogs\">\r\n";
234
- foreach ( $blogs_subscribed as $blog ) {
235
- echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
236
- if ( $s2blog_id == $blog['blog_id'] ) {
237
- echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
238
- } else {
239
- echo "<span class=\"buttons\">";
240
- if ( is_user_member_of_blog($current_user->id, $blog['blog_id']) ) {
241
- echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
242
- }
243
- echo "<a href=\"" . esc_url( add_query_arg('s2mu_unsubscribe', $blog['blog_id']) ) . "\">" . __('Unsubscribe', 'subscribe2') . "</a></span>\r\n";
244
- }
245
- echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
246
- echo "</li>";
247
- }
248
- echo "</ul>\r\n";
249
- }
250
-
251
- if ( !empty($blogs_notsubscribed) ) {
252
- ksort($blogs_notsubscribed);
253
- echo "<h2>" . __('Subscribe to new blogs', 'subscribe2') . "</h2>\r\n";
254
- echo "<ul class=\"s2_blogs\">";
255
- foreach ( $blogs_notsubscribed as $blog ) {
256
- echo "<li><span class=\"name\"><a href=\"" . $blog['blogurl'] . "\" title=\"" . $blog['description'] . "\">" . $blog['blogname'] . "</a></span>\r\n";
257
- if ( $s2blog_id == $blog['blog_id'] ) {
258
- echo "<span class=\"buttons\">" . __('Viewing Settings Now', 'subscribe2') . "</span>\r\n";
259
- } else {
260
- echo "<span class=\"buttons\">";
261
- if ( is_user_member_of_blog($current_user->id, $blog['blog_id']) ) {
262
- echo "<a href=\"". $blog['subscribe_page'] . "\">" . __('View Settings', 'subscribe2') . "</a>\r\n";
263
- }
264
- echo "<a href=\"" . esc_url( add_query_arg('s2mu_subscribe', $blog['blog_id']) ) . "\">" . __('Subscribe', 'subscribe2') . "</a></span>\r\n";
265
- }
266
- echo "<div class=\"additional_info\">" . $blog['description'] . "</div>\r\n";
267
- echo "</li>";
268
- }
269
- echo "</ul>\r\n";
270
- }
271
- echo "</div>\r\n";
272
- }
273
-
274
- echo "</div>\r\n";
275
-
276
- include(ABSPATH . 'wp-admin/admin-footer.php');
277
- // just to be sure
278
- die;
279
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-s2-admin.php CHANGED
@@ -1,30 +1,31 @@
1
  <?php
2
- class s2_admin extends s2class {
3
- /* ===== WordPress menu registration and scripts ===== */
4
  /**
5
  Hook the menu
6
  */
7
  function admin_menu() {
8
- add_menu_page(__('Subscribe2', 'subscribe2'), __('Subscribe2', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', NULL, S2URL . 'include/email_edit.png');
9
-
10
- $s2user = add_submenu_page('s2', __('Your Subscriptions', 'subscribe2'), __('Your Subscriptions', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', array(&$this, 'user_menu'), S2URL . 'include/email_edit.png');
11
- add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
12
- add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
13
- add_action('load-' . $s2user, array(&$this, 'user_help'));
14
-
15
- $s2subscribers = add_submenu_page('s2', __('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'manage'), 's2_tools', array(&$this, 'subscribers_menu'));
16
- add_action("admin_print_scripts-$s2subscribers", array(&$this, 'checkbox_form_js'));
17
- add_action('load-' . $s2subscribers, array(&$this, 'subscribers_help'));
18
-
19
- $s2settings = add_submenu_page('s2', __('Settings', 'subscribe2'), __('Settings', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'settings'), 's2_settings', array(&$this, 'settings_menu'));
20
- add_action("admin_print_scripts-$s2settings", array(&$this, 'checkbox_form_js'));
21
- add_action("admin_print_scripts-$s2settings", array(&$this, 'option_form_js'));
22
- add_filter('plugin_row_meta', array(&$this, 'plugin_links'), 10, 2);
23
- add_action('load-' . $s2settings, array(&$this, 'settings_help'));
24
-
25
- $s2mail = add_submenu_page('s2', __('Send Email', 'subscribe2'), __('Send Email', 'subscribe2'), apply_filters('s2_capability', "publish_posts", 'send'), 's2_posts', array(&$this, 'write_menu'));
26
- add_action('load-' . $s2mail, array(&$this, 'mail_help'));
27
- $s2nonce = wp_hash('subscribe2');
 
28
  } // end admin_menu()
29
 
30
  /**
@@ -32,134 +33,167 @@ class s2_admin extends s2class {
32
  */
33
  function user_help() {
34
  $screen = get_current_screen();
35
- if ( $this->subscribe2_options['email_freq'] != 'never' ) {
36
- $screen->add_help_tab(array(
37
  'id' => 's2-user-help1',
38
- 'title' => __('Overview', 'subscribe2'),
39
- 'content' => '<p>' . __('From this page you can opt in or out of receiving a periodical digest style email of blog posts.', 'subscribe2') . '</p>'
40
- ));
41
  } else {
42
- $screen->add_help_tab(array(
43
  'id' => 's2-user-help1',
44
- 'title' => __('Overview', 'subscribe2'),
45
- 'content' => '<p>' . __('From this page you can control your subscription preferences. Choose the email format you wish to receive, which categories you would like to receive notification for and depending on the site settings which authors you would like to read.', 'subscribe2') . '</p>'
46
- ));
47
  }
48
  } // end user_help()
49
 
50
  function subscribers_help() {
51
  $screen = get_current_screen();
52
- $screen->add_help_tab(array(
53
  'id' => 's2-subscribers-help1',
54
- 'title' => __('Overview', 'subscribe2'),
55
- 'content' => '<p>' . __('From this page you can manage your subscribers.', 'subscribe2') . '</p>'
56
- ));
57
- $screen->add_help_tab(array(
58
  'id' => 's2-subscribers-help2',
59
- 'title' => __('Public Subscribers', 'subscribe2'),
60
- 'content' => '<p>' . __('Public Subscribers are subscribers who have used the plugin form and only provided their email address.', 'subscribe2') . '</p><p>'. __('On this page public subscribers can be viewed, searched, deleted and also toggled between Confirmed and Unconfirmed status.', 'subscribe2') . '</p>'
61
- ));
62
- $screen->add_help_tab(array(
63
  'id' => 's2-subscribers-help3',
64
- 'title' => __('Registered Subscribers', 'subscribe2'),
65
- 'content' => '<p>' . __('Registered Subscribers are subscribers who have registered in WordPress and have a username and password.', 'subscribe2') .
66
- '</p><p>'. __('Registered Subscribers have greater personal control over their subscription. They can change the format of the email and also select which categories and authors they want to receive notifications about.', 'subscribe2') .
67
- '</p><p>'. __('On this page registered subscribers can be viewed and searched. User accounts can be deleted from here with any posts created by those users being assigned to the currently logged in user. Bulk changes can be applied to all user settings changing their subscription email format and categories.', 'subscribe2') . '</p>'
68
- ));
69
  } // end subscribers_help()
70
 
71
  function settings_help() {
72
  $screen = get_current_screen();
73
- $screen->add_help_tab(array(
74
  'id' => 's2-settings-help1',
75
- 'title' => __('Overview', 'subscribe2'),
76
- 'content' => '<p>' . __('From this page you can adjust the Settings for Subscribe2.', 'subscribe2') . '</p>'
77
- ));
78
- $screen->add_help_tab(array(
79
  'id' => 's2-settings-help2',
80
- 'title' => __('Email Settings', 'subscribe2'),
81
- 'content' => '<p>' . __('This section allows you to specify settings that apply to the emails generated by the site.', 'subscribe2') .
82
- '</p><p>'. __('Emails can be sent to individual subscribers by setting the number of recipients per email to 1. A setting greater than one will group recipients together and make use of the BCC emails header. A setting of 0 sends a single email with all subscribers in one large BCC group. A setting of 1 looks less like spam email to filters but takes longer to process.', 'subscribe2').
83
- '</p><p>'. __('This section is also where the sender of the email on this page is chosen. You can choose Post Author or your Blogname but it is recommended to create a user account with an email address that really exists and shares the same domain name as your site (the bit after the @ should be the same as your sites web address) and then use this account.', 'subscribe2') .
84
- '</p><p>'. __('This page also configures the frequency of emails. This can be at the time new posts are made (per post) or periodically with an excerpt of each post made (digest). Additionally the post types (pages, private, password protected) can also be configured here.', 'subscribe2') . '</p>'
85
- ));
86
- $screen->add_help_tab(array(
87
  'id' => 's2-settings-help3',
88
- 'title' => __('Templates', 'subscribe2'),
89
- 'content' => '<p>' . __('This section allows you to customise the content of your notification emails.', 'subscribe2') .
90
- '</p><p>'. __('There are special {KEYWORDS} that are used by Subscribe2 to place content into the final email. The template also accepts regular text and HTML as desired in the final emails.', 'subscribe2') .
91
- '</p><p>'. __('The {KEYWORDS} are listed on the right of the templates, note that some are for per post emails only and some are for digest emails only. Make sure the correct keywords are used based upon the Email Settings.', 'subscribe2') . '</p>'
92
- ));
93
- $screen->add_help_tab(array(
 
94
  'id' => 's2-settings-help4',
95
- 'title' => __('Registered Users', 'subscribe2'),
96
- 'content' => '<p>' . __('This section allows settings that apply to Registered Subscribers to be configured.', 'subscribe2') .
97
- '</p><p>'. __('Categories can be made compulsory so emails are always sent for posts in these categories. They can also be excludes so that emails are not generated. Excluded categories take precedence over Compulsory categories.', 'subscribe2') .
98
- '</p><p>'. __('A set of default settings for new users can also be specified using the Auto Subscribe section. Settings specified here will be applied to any newly created user accounts while Subscribe2 is activated.', 'subscribe2') . '</p>'
99
- ));
100
- $screen->add_help_tab(array(
101
  'id' => 's2-settings-help5',
102
- 'title' => __('Appearance', 'subscribe2'),
103
- 'content' => '<p>' . __('This section allows you to enable several aspect of the plugin such as Widgets and editor buttons.', 'subscribe2') .
104
- '</p><p>'. __('AJAX mode can be enabled that is intended to work with the shortcode link parameter so that a dialog opens in the centre of the browser rather then using the regular form.', 'subscribe2') .
105
- '</p><p>'. __('The email over ride check box can be set to be automatically checked for every new post and page from here to, this may be useful if you will only want to send very occasional notifications for specific posts. You can then uncheck this box just before you publish your content.', 'subscribe2') . '</p>'
106
- ));
107
- $screen->add_help_tab(array(
108
  'id' => 's2-settings-help6',
109
- 'title' => __('Miscellaneous', 'subscribe2'),
110
- 'content' => '<p>' . __('This section contains a place to bar specified domains from becoming Public Subscribers and links to help and support pages.', 'subscribe2') .
111
- '</p><p>'. __('In the paid Subscribe2 HTML version there is also a place here to enter a license code so that updates can be accessed automatically.', 'subscribe2') .
112
- '</p>'
113
- ));
114
  } // end settings_help()
115
 
116
  function mail_help() {
117
  $screen = get_current_screen();
118
- $screen->add_help_tab(array(
119
  'id' => 's2-send-mail-help1',
120
- 'title' => __('Overview', 'subscribe2'),
121
- 'content' => '<p>' . __('From this page you can send emails to the recipients in the group selected in the drop down.', 'subscribe2') .
122
- '</p><p>' . __('<strong>Preview</strong> will send a preview of the email to the currently logged in user. <strong>Send</strong> will send the email to the recipient list.', 'subscribe2') . '</p>'
123
- ));
124
  } // end send_email_help()
125
 
126
  /**
127
  Hook for Admin Drop Down Icons
128
  */
129
  function ozh_s2_icon() {
130
- return S2URL . 'include/email_edit.png';
131
  } // end ozh_s2_icon()
132
 
133
  /**
134
- Insert Javascript and CSS into admin_header
135
  */
136
  function checkbox_form_js() {
137
- wp_register_script('s2_checkbox', S2URL . 'include/s2_checkbox' . $this->script_debug . '.js', array('jquery'), '1.3');
138
- wp_enqueue_script('s2_checkbox');
139
  } //end checkbox_form_js()
140
 
141
  function user_admin_css() {
142
- wp_register_style('s2_user_admin', S2URL . 'include/s2_user_admin.css', array(), '1.0');
143
- wp_enqueue_style('s2_user_admin');
144
  } // end user_admin_css()
145
 
146
  function option_form_js() {
147
- wp_register_script('s2_edit', S2URL . 'include/s2_edit' . $this->script_debug . '.js', array('jquery'), '1.1');
148
- wp_enqueue_script('s2_edit');
149
- wp_enqueue_script('jquery-ui-datepicker');
150
- wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css');
151
- wp_register_script('s2_date_time', S2URL . 'include/s2_date_time' . $this->script_debug . '.js', array('jquery-ui-datepicker'), '1.0');
152
- wp_enqueue_script('s2_date_time');
 
 
153
  } // end option_form_js()
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  /**
156
  Adds a links directly to the settings page from the plugin page
157
  */
158
- function plugin_links($links, $file) {
159
- if ( $file == S2DIR.'subscribe2.php' ) {
160
- $links[] = "<a href='admin.php?page=s2_settings'>" . __('Settings', 'subscribe2') . "</a>";
161
- $links[] = "<a href='http://plugins.trac.wordpress.org/browser/subscribe2/i18n/'>" . __('Translation Files', 'subscribe2') . "</a>";
162
- $links[] = "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904'><b>" . __('Donate', 'subscribe2') . "</b></a>";
163
  }
164
  return $links;
165
  } // end plugin_links()
@@ -169,81 +203,80 @@ class s2_admin extends s2class {
169
  Our subscriber management page
170
  */
171
  function subscribers_menu() {
172
- require_once(S2PATH . 'admin/subscribers.php');
173
  } // end subscribers_menu()
174
 
175
- /**
176
  Our settings page
177
  */
178
  function settings_menu() {
179
- require_once(S2PATH . 'admin/settings.php');
180
  } // end settings_menu()
181
 
182
  /**
183
  Our profile menu
184
  */
185
  function user_menu() {
186
- require_once(S2PATH . 'admin/your_subscriptions.php');
187
  } // end user_menu()
188
 
189
  /**
190
  Display the Write sub-menu
191
  */
192
  function write_menu() {
193
- require_once(S2PATH . 'admin/send_email.php');
194
  } // end write_menu()
195
 
196
- /* ===== Write Toolbar Button Functions ===== */
197
  /**
198
  Register our button in the QuickTags bar
199
  */
200
  function button_init() {
201
  global $pagenow;
202
- if ( !in_array($pagenow, array('post-new.php', 'post.php', 'page-new.php', 'page.php')) ) { return; }
203
- if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) { return; }
204
- if ( 'true' == get_user_option('rich_editing') ) {
205
  // Hook into the rich text editor
206
- add_filter('mce_external_plugins', array(&$this, 'mce_plugin'));
207
- add_filter('mce_buttons', array(&$this, 'mce_button'));
208
  } else {
209
- wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button' . $this->script_debug . '.js', array('quicktags'), '2.0' );
210
  }
211
  } // end button_init()
212
 
213
  /**
214
  Add buttons for Rich Text Editor
215
  */
216
- function mce_plugin($arr) {
217
- if ( version_compare($this->wp_release, '3.9', '<') ) {
218
- $path = S2URL . 'tinymce/editor_plugin3' . $this->script_debug . '.js';
219
  } else {
220
- $path = S2URL . 'tinymce/editor_plugin4' . $this->script_debug . '.js';
221
  }
222
  $arr['subscribe2'] = $path;
223
  return $arr;
224
  } // end mce_plugin()
225
 
226
- function mce_button($arr) {
227
  $arr[] = 'subscribe2';
228
  return $arr;
229
  } // end mce_button()
230
 
231
- /* ===== widget functions ===== */
232
  /**
233
  Function to add css and js files to admin header
234
  */
235
  function widget_s2counter_css_and_js() {
236
  // ensure we only add colorpicker js to widgets page
237
- if ( stripos($_SERVER['REQUEST_URI'], 'widgets.php' ) !== false ) {
238
- wp_enqueue_style('farbtastic');
239
- wp_enqueue_script('farbtastic');
240
- wp_register_script('s2_colorpicker', S2URL . 'include/s2_colorpicker' . $this->script_debug . '.js', array('farbtastic'), '1.2');
241
- wp_enqueue_script('s2_colorpicker');
242
  }
243
  } // end widget_s2_counter_css_and_js()
244
 
245
-
246
- /* ===== meta box functions to allow per-post override ===== */
247
  /**
248
  Create meta box on write pages
249
  */
@@ -254,79 +287,79 @@ class s2_admin extends s2class {
254
  $s2_post_types = array( 'post' );
255
  }
256
  $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
257
- foreach( $s2_post_types as $s2_post_type ) {
258
- add_meta_box( 'subscribe2', __( 'Subscribe2 Notification Override', 'subscribe2' ), array( &$this, 's2_meta_box' ), $s2_post_type, 'advanced' );
259
  }
260
  } // end s2_meta_init()
261
 
262
  /**
263
- Meta box code
264
  */
265
- function s2_meta_box() {
266
  global $post_ID;
267
- $s2mail = get_post_meta($post_ID, '_s2mail', true);
268
- echo "<input type=\"hidden\" name=\"s2meta_nonce\" id=\"s2meta_nonce\" value=\"" . wp_create_nonce(wp_hash(plugin_basename(__FILE__))) . "\" />";
269
- echo __("Check here to disable sending of an email notification for this post/page", 'subscribe2');
270
- echo "&nbsp;&nbsp;<input type=\"checkbox\" name=\"s2_meta_field\" value=\"no\"";
271
- if ( $s2mail == 'no' || ($this->subscribe2_options['s2meta_default'] == "1" && $s2mail == "") ) {
272
- echo " checked=\"checked\"";
273
  }
274
- echo " />";
275
- } // end s2_meta_box()
276
 
277
  /**
278
- Meta box form handler
279
  */
280
- function s2_meta_handler($post_id) {
281
- if ( !isset($_POST['s2meta_nonce']) || !wp_verify_nonce($_POST['s2meta_nonce'], wp_hash(plugin_basename(__FILE__))) ) { return $post_id; }
282
 
283
- if ( 'page' == $_POST['post_type'] ) {
284
- if ( !current_user_can('edit_page', $post_id) ) { return $post_id; }
285
  } else {
286
- if ( !current_user_can('edit_post', $post_id) ) { return $post_id; }
287
  }
288
 
289
- if ( isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no' ) {
290
- update_post_meta($post_id, '_s2mail', $_POST['s2_meta_field']);
291
  } else {
292
- update_post_meta($post_id, '_s2mail', 'yes');
293
  }
294
  } // end s2_meta_box_handler()
295
 
296
- /* ===== WordPress menu helper functions ===== */
297
  /**
298
  Collects the signup date for all public subscribers
299
  */
300
- function signup_date($email = '') {
301
- if ( '' == $email ) { return false; }
302
 
303
  global $wpdb;
304
- if ( !empty($this->signup_dates) ) {
305
- return $this->signup_dates[$email];
306
  } else {
307
- $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
308
  foreach ( $results as $result ) {
309
- $this->signup_dates[$result[0]] = $result[1];
310
  }
311
- return $this->signup_dates[$email];
312
  }
313
  } // end signup_date()
314
 
315
  /**
316
  Collects the ip address for all public subscribers
317
  */
318
- function signup_ip($email = '') {
319
- if ( '' == $email ) {return false; }
320
 
321
  global $wpdb;
322
- if ( !empty($this->signup_ips) ) {
323
- return $this->signup_ips[$email];
324
  } else {
325
- $results = $wpdb->get_results("SELECT email, ip FROM $this->public", ARRAY_N);
326
  foreach ( $results as $result ) {
327
- $this->signup_ips[$result[0]] = $result[1];
328
  }
329
- return $this->signup_ips[$email];
330
  }
331
  } // end signup_ip()
332
 
@@ -334,43 +367,39 @@ class s2_admin extends s2class {
334
  Export subscriber emails and other details to CSV
335
  */
336
  function prepare_export( $subscribers ) {
337
- if ( empty($subscribers) ) { return; }
338
- $subscribers = explode(",\r\n", $subscribers);
339
- natcasesort($subscribers);
340
 
341
- $exportcsv = _x('User Email,User Type,User Name,Confirm Date,IP', 'Comma Separated Column Header names for CSV Export' , 'subscribe2');
342
- $all_cats = $this->all_cats(false, 'ID');
343
 
344
- foreach ($all_cats as $cat) {
345
- $exportcsv .= "," . html_entity_decode($cat->cat_name, ENT_QUOTES);
346
  $cat_ids[] = $cat->term_id;
347
  }
348
  $exportcsv .= "\r\n";
349
 
350
- if ( !function_exists('get_userdata') ) {
351
- require_once(ABSPATH . WPINC . '/pluggable.php');
352
- }
353
-
354
  foreach ( $subscribers as $subscriber ) {
355
- if ( $this->is_registered($subscriber) ) {
356
  $user_ID = $this->get_user_id( $subscriber );
357
  $user_info = get_userdata( $user_ID );
358
 
359
- $cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
360
  $subscribed_cats = '';
361
  foreach ( $cat_ids as $cat ) {
362
- (in_array($cat, $cats)) ? $subscribed_cats .= ",Yes" : $subscribed_cats .= ",No";
363
  }
364
 
365
  $exportcsv .= $subscriber . ',';
366
- $exportcsv .= __('Registered User', 'subscribe2');
367
  $exportcsv .= ',' . $user_info->display_name;
368
  $exportcsv .= ',,' . $subscribed_cats . "\r\n";
369
  } else {
370
- if ( $this->is_public($subscriber) === '1' ) {
371
- $exportcsv .= $subscriber . ',' . __('Confirmed Public Subscriber', 'subscribe2') . ',,' . $this->signup_date($subscriber) . ',' . $this->signup_ip($subscriber) . "\r\n";
372
- } elseif ( $this->is_public($subscriber) === '0' ) {
373
- $exportcsv .= $subscriber . ',' . __('Unconfirmed Public Subscriber', 'subscribe2') . ',,' . $this->signup_date($subscriber) . ',' . $this->signup_ip($subscriber) . "\r\n";
374
  }
375
  }
376
  }
@@ -378,252 +407,125 @@ class s2_admin extends s2class {
378
  return $exportcsv;
379
  } // end prepare_export()
380
 
381
- /**
382
- Display a table of categories with checkboxes
383
- Optionally pre-select those categories specified
384
- */
385
- function display_category_form($selected = array(), $override = 1, $compulsory = array(), $name = 'category') {
386
- global $wpdb;
387
-
388
- if ( $override == 0 ) {
389
- $all_cats = $this->all_cats(true);
390
- } else {
391
- $all_cats = $this->all_cats(false);
392
- }
393
-
394
- $half = (count($all_cats) / 2);
395
- $i = 0;
396
- $j = 0;
397
- echo "<table style=\"width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression('separate', cellSpacing = '2px');\" class=\"editform\">\r\n";
398
- echo "<tr><td style=\"text-align: left;\" colspan=\"2\">\r\n";
399
- echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_" . $name . "\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
400
- echo "</td></tr>\r\n";
401
- echo "<tr style=\"vertical-align: top;\"><td style=\"width: 50%; text-align: left;\">\r\n";
402
- foreach ( $all_cats as $cat ) {
403
- if ( $i >= $half && 0 == $j ) {
404
- echo "</td><td style=\"width: 50%; text-align: left;\">\r\n";
405
- $j++;
406
- }
407
- $catName = '';
408
- $parents = array_reverse( get_ancestors($cat->term_id, $cat->taxonomy) );
409
- if ( $parents ) {
410
- foreach ( $parents as $parent ) {
411
- $parent = get_term($parent, $cat->taxonomy);
412
- $catName .= $parent->name . ' &raquo; ';
413
- }
414
- }
415
- $catName .= $cat->name;
416
-
417
- if ( 0 == $j ) {
418
- echo "<label><input class=\"checkall_" . $name . "\" type=\"checkbox\" name=\"" . $name . "[]\" value=\"" . $cat->term_id . "\"";
419
- if ( in_array($cat->term_id, $selected) || in_array($cat->term_id, $compulsory) ) {
420
- echo " checked=\"checked\"";
421
- }
422
- if ( in_array($cat->term_id, $compulsory) && $name === 'category' ) {
423
- echo " DISABLED";
424
- }
425
- echo " /> <abbr title=\"" . $cat->slug . "\">" . $catName . "</abbr></label><br />\r\n";
426
- } else {
427
- echo "<label><input class=\"checkall_" . $name . "\" type=\"checkbox\" name=\"" . $name . "[]\" value=\"" . $cat->term_id . "\"";
428
- if ( in_array($cat->term_id, $selected) || in_array($cat->term_id, $compulsory) ) {
429
- echo " checked=\"checked\"";
430
- }
431
- if ( in_array($cat->term_id, $compulsory) && $name === 'category' ) {
432
- echo " DISABLED";
433
- }
434
- echo " /> <abbr title=\"" . $cat->slug . "\">" . $catName . "</abbr></label><br />\r\n";
435
- }
436
- $i++;
437
- }
438
- if ( !empty($compulsory) ) {
439
- foreach ($compulsory as $cat) {
440
- echo "<input type=\"hidden\" name=\"" . $name . "[]\" value=\"" . $cat . "\">\r\n";
441
- }
442
- }
443
- echo "</td></tr>\r\n";
444
- echo "</table>\r\n";
445
- } // end display_category_form()
446
-
447
  /**
448
  Display a table of post formats supported by the currently active theme
449
  */
450
- function display_format_form($formats, $selected = array()) {
451
- $half = (count($formats[0]) / 2);
452
  $i = 0;
453
  $j = 0;
454
- echo "<table style=\"width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression('separate', cellSpacing = '2px');\" class=\"editform\">\r\n";
455
- echo "<tr><td style=\"text-align: left;\" colspan=\"2\">\r\n";
456
- echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_format\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
457
- echo "</td></tr>\r\n";
458
- echo "<tr style=\"vertical-align: top;\"><td style=\"width: 50%; text-align: left\">\r\n";
459
  foreach ( $formats[0] as $format ) {
460
- if ( $i >= $half && 0 == $j ) {
461
- echo "</td><td style=\"width: 50%; text-align: left\">\r\n";
462
  $j++;
463
  }
464
 
465
- if ( 0 == $j ) {
466
- echo "<label><input class=\"checkall_format\" type=\"checkbox\" name=\"format[]\" value=\"" . $format . "\"";
467
- if ( in_array($format, $selected) ) {
468
- echo " checked=\"checked\"";
469
  }
470
- echo " /> " . ucwords($format) . "</label><br />\r\n";
471
  } else {
472
- echo "<label><input class=\"checkall_format\" type=\"checkbox\" name=\"format[]\" value=\"" . $format . "\"";
473
- if ( in_array($format, $selected) ) {
474
- echo " checked=\"checked\"";
475
  }
476
- echo " /> " . ucwords($format) . "</label><br />\r\n";
477
  }
478
  $i++;
479
  }
480
- echo "</td></tr>\r\n";
481
- echo "</table>\r\n";
482
  } // end display_format_form()
483
 
484
- /**
485
- Display a table of authors with checkboxes
486
- Optionally pre-select those authors specified
487
- */
488
- function display_author_form($selected = array()) {
489
- $all_authors = $this->get_authors();
490
-
491
- $half = (count($all_authors) / 2);
492
- $i = 0;
493
- $j = 0;
494
- echo "<table style=\"width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression('separate', cellSpacing = '2px');\" class=\"editform\">\r\n";
495
- echo "<tr><td style=\"text-align: left;\" colspan=\"2\">\r\n";
496
- echo "<label><input type=\"checkbox\" name=\"checkall\" value=\"checkall_author\" /> " . __('Select / Unselect All', 'subscribe2') . "</label>\r\n";
497
- echo "</td></tr>\r\n";
498
- echo "<tr style=\"vertical-align: top;\"><td style=\"width: 50%; test-align: left;\">\r\n";
499
- foreach ( $all_authors as $author ) {
500
- if ( $i >= $half && 0 == $j ) {
501
- echo "</td><td style=\"width: 50%; text-align: left;\">\r\n";
502
- $j++;
503
- }
504
- if ( 0 == $j ) {
505
- echo "<label><input class=\"checkall_author\" type=\"checkbox\" name=\"author[]\" value=\"" . $author->ID . "\"";
506
- if ( in_array($author->ID, $selected) ) {
507
- echo " checked=\"checked\"";
508
- }
509
- echo " /> " . $author->display_name . "</label><br />\r\n";
510
- } else {
511
- echo "<label><input class=\"checkall_author\" type=\"checkbox\" name=\"author[]\" value=\"" . $author->ID . "\"";
512
- if ( in_array($author->ID, $selected) ) {
513
- echo " checked=\"checked\"";
514
- }
515
- echo " /> " . $author->display_name . "</label><br />\r\n";
516
- $i++;
517
- }
518
- }
519
- echo "</td></tr>\r\n";
520
- echo "</table>\r\n";
521
- } // end display_author_form()
522
-
523
- /**
524
- Collect an array of all author level users and above
525
- */
526
- function get_authors() {
527
- if ( '' == $this->all_authors ) {
528
- $role = array('fields' => array('ID', 'display_name'), 'role' => 'administrator');
529
- $administrators = get_users( $role );
530
- $role = array('fields' => array('ID', 'display_name'), 'role' => 'editor');
531
- $editors = get_users( $role );
532
- $role = array('fields' => array('ID', 'display_name'), 'role' => 'author');
533
- $authors = get_users( $role );
534
-
535
- $this->all_authors = array_merge($administrators, $editors, $authors);
536
- }
537
- return apply_filters('s2_authors', $this->all_authors);
538
- } // end get_authors()
539
-
540
  /**
541
  Display a drop-down form to select subscribers
542
  $selected is the option to select
543
  $submit is the text to use on the Submit button
544
  */
545
- function display_subscriber_dropdown($selected = 'registered', $submit = '', $exclude = array()) {
546
  global $wpdb;
547
 
548
- $who = array('all' => __('All Users and Subscribers', 'subscribe2'),
549
- 'public' => __('Public Subscribers', 'subscribe2'),
550
- 'confirmed' => ' &nbsp;&nbsp;' . __('Confirmed', 'subscribe2'),
551
- 'unconfirmed' => ' &nbsp;&nbsp;' . __('Unconfirmed', 'subscribe2'),
552
- 'all_users' => __('All Registered Users', 'subscribe2'),
553
- 'registered' => __('Registered Subscribers', 'subscribe2'));
 
 
554
 
555
- $all_cats = $this->all_cats(false);
556
 
557
  // count the number of subscribers
558
- $count['confirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='1'");
559
- $count['unconfirmed'] = $wpdb->get_var("SELECT COUNT(id) FROM $this->public WHERE active='0'");
560
- if ( in_array('unconfirmed', $exclude) ) {
561
  $count['public'] = $count['confirmed'];
562
- } elseif ( in_array('confirmed', $exclude) ) {
563
  $count['public'] = $count['unconfirmed'];
564
  } else {
565
  $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
566
  }
567
  if ( $this->s2_mu ) {
568
- $count['all_users'] = $wpdb->get_var("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
569
  } else {
570
- $count['all_users'] = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
571
  }
572
  if ( $this->s2_mu ) {
573
- $count['registered'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(b.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=%s AND b.meta_value <> ''", $this->get_usermeta_keyname('s2_subscribed')));
574
  } else {
575
- $count['registered'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value <> ''", $this->get_usermeta_keyname('s2_subscribed')));
576
  }
577
  $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
578
  // get subscribers to individual categories but only if we are using per-post notifications
579
- if ( $this->subscribe2_options['email_freq'] == 'never' ) {
580
- $compulsory = explode(',', $this->subscribe2_options['compulsory']);
581
  if ( $this->s2_mu ) {
582
  foreach ( $all_cats as $cat ) {
583
- if ( in_array($cat->term_id, $compulsory) ) {
584
- $count[$cat->name] = $count['all_users'];
585
  } else {
586
- $count[$cat->name] = $wpdb->get_var($wpdb->prepare("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=%s", $this->get_usermeta_keyname('s2_cat') . $cat->term_id));
587
  }
588
  }
589
  } else {
590
  foreach ( $all_cats as $cat ) {
591
- if ( in_array($cat->term_id, $compulsory) ) {
592
- $count[$cat->name] = $count['all_users'];
593
  } else {
594
- $count[$cat->name] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $cat->term_id));
595
  }
596
  }
597
  }
598
  }
599
 
600
- // do have actually have some subscribers?
601
- if ( 0 == $count['confirmed'] && 0 == $count['unconfirmed'] && 0 == $count['all_users'] ) {
602
- // no? bail out
603
- return;
604
- }
605
-
606
- echo "<select name=\"what\">\r\n";
607
  foreach ( $who as $whom => $display ) {
608
- if ( in_array($whom, $exclude) ) { continue; }
609
- if ( 0 == $count[$whom] ) { continue; }
610
 
611
- echo "<option value=\"" . $whom . "\"";
612
- if ( $whom == $selected ) { echo " selected=\"selected\" "; }
613
- echo ">$display (" . ($count[$whom]) . ")</option>\r\n";
614
  }
615
 
616
- if ( $count['registered'] > 0 && $this->subscribe2_options['email_freq'] == 'never' ) {
617
  foreach ( $all_cats as $cat ) {
618
- if ( in_array($cat->term_id, $exclude) ) { continue; }
619
- echo "<option value=\"" . $cat->term_id . "\"";
620
- if ( $cat->term_id == $selected ) { echo " selected=\"selected\" "; }
621
- echo "> &nbsp;&nbsp;" . $cat->name . "&nbsp;(" . $count[$cat->name] . ") </option>\r\n";
622
  }
623
  }
624
- echo "</select>";
625
  if ( false !== $submit ) {
626
- echo "&nbsp;<input type=\"submit\" class=\"button-secondary\" value=\"$submit\" />\r\n";
627
  }
628
  } // end display_subscriber_dropdown()
629
 
@@ -631,13 +533,19 @@ class s2_admin extends s2class {
631
  Display a drop down list of administrator level users and
632
  optionally include a choice for Post Author
633
  */
634
- function admin_dropdown($inc_author = false) {
635
  global $wpdb;
636
 
637
- $args = array('fields' => array('ID', 'display_name'), 'role' => 'administrator');
 
 
 
 
 
 
638
  $wp_user_query = get_users( $args );
639
- if ( !empty($wp_user_query) ) {
640
- foreach ($wp_user_query as $user) {
641
  $admins[] = $user;
642
  }
643
  } else {
@@ -645,20 +553,26 @@ class s2_admin extends s2class {
645
  }
646
 
647
  if ( $inc_author ) {
648
- $author[] = (object)array('ID' => 'author', 'display_name' => __('Post Author', 'subscribe2'));
649
- $author[] = (object)array('ID' => 'blogname', 'display_name' => html_entity_decode(get_option('blogname'), ENT_QUOTES));
650
- $admins = array_merge($author, $admins);
651
- }
652
-
653
- echo "<select name=\"sender\">\r\n";
 
 
 
 
 
 
654
  foreach ( $admins as $admin ) {
655
- echo "<option value=\"" . $admin->ID . "\"";
656
- if ( $admin->ID == $this->subscribe2_options['sender'] ) {
657
- echo " selected=\"selected\"";
658
  }
659
- echo ">" . $admin->display_name . "</option>\r\n";
660
  }
661
- echo "</select>\r\n";
662
  } // end admin_dropdown()
663
 
664
  /**
@@ -668,84 +582,89 @@ class s2_admin extends s2class {
668
  function display_digest_choices() {
669
  global $wpdb;
670
  $cron_file = ABSPATH . 'wp-cron.php';
671
- if ( !is_readable($cron_file) ) {
672
- echo "<strong><em style=\"color: red\">" . __('The WordPress cron functions may be disabled on this server. Digest notifications may not work.', 'subscribe2') . "</em></strong><br />\r\n";
673
- }
674
- $scheduled_time = wp_next_scheduled('s2_digest_cron');
675
- $offset = get_option('gmt_offset') * 60 * 60;
676
- $schedule = (array)wp_get_schedules();
677
- $schedule = array_merge(array('never' => array('interval' => 0, 'display' => __('For each Post', 'subscribe2'))), $schedule);
 
 
 
 
 
678
  $sort = array();
679
- foreach ( (array)$schedule as $key => $value ) {
680
- $sort[$key] = $value['interval'];
681
  }
682
- asort($sort);
683
  $schedule_sorted = array();
684
  foreach ( $sort as $key => $value ) {
685
- $schedule_sorted[$key] = $schedule[$key];
686
  }
687
  foreach ( $schedule_sorted as $key => $value ) {
688
- echo "<label><input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"" . checked($this->subscribe2_options['email_freq'], $key, false) . " />";
689
- echo " " . $value['display'] . "</label><br />\r\n";
690
  }
691
  if ( $scheduled_time ) {
692
- $date_format = get_option('date_format');
693
- $time_format = get_option('time_format');
694
- echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
695
- echo "<strong>" . date_i18n($date_format . " @ " . $time_format, false, 'gmt') . "</strong></p>\r\n";
696
- echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
697
- echo "<strong>" . date_i18n($date_format . " @ " . $time_format) . "</strong></p>\r\n";
698
- echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
699
- echo "<input type=\"hidden\" id=\"jscrondate\" value=\"" . date_i18n($date_format, $scheduled_time + $offset) . "\" />";
700
- echo "<input type=\"hidden\" id=\"jscrontime\" value=\"" . date_i18n($time_format, $scheduled_time + $offset) . "\" />";
701
- echo "<span id=\"s2cron_1\"><span id=\"s2crondate\" style=\"background-color: #FFFBCC\">" . date_i18n($date_format, $scheduled_time + $offset) . "</span>";
702
- echo " @ <span id=\"s2crontime\" style=\"background-color: #FFFBCC\">" . date_i18n($time_format, $scheduled_time + $offset) . "</span> ";
703
- echo "<a href=\"#\" onclick=\"s2_show('cron'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
704
- echo "<span id=\"s2cron_2\">\r\n";
705
- echo "<input id=\"s2datepicker\" name=\"crondate\" value=\"" . date_i18n($date_format, $scheduled_time + $offset) . "\">\r\n";
706
- $hours = array('12:00 am', '1:00 am', '2:00 am', '3:00 am', '4:00 am', '5:00 am', '6:00 am', '7:00 am', '8:00 am', '9:00 am', '10:00 am', '11:00 am', '12:00 pm', '1:00 pm', '2:00 pm', '3:00 pm', '4:00 pm', '5:00 pm', '6:00 pm', '7:00 pm', '8:00 pm', '9:00 pm', '10:00 pm', '11:00 pm');
707
- $current_hour = intval(date_i18n('G', $scheduled_time + $offset));
708
- echo "<select name=\"crontime\">\r\n";
709
  foreach ( $hours as $key => $value ) {
710
- echo "<option value=\"" . $key . "\"";
711
- if ( !empty($scheduled_time) && $key === $current_hour ) {
712
- echo " selected=\"selected\"";
713
  }
714
- echo ">" . $value . "</option>\r\n";
715
  }
716
- echo "</select>\r\n";
717
- echo "<a href=\"#\" onclick=\"s2_cron_update('cron'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
718
- echo "<a href=\"#\" onclick=\"s2_cron_revert('cron'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
719
- if ( !empty($this->subscribe2_options['last_s2cron']) ) {
720
- echo "<p>" . __('Attempt to resend the last Digest Notification email', 'subscribe2') . ": ";
721
- echo "<input type=\"submit\" class=\"button-secondary\" name=\"resend\" value=\"" . __('Resend Digest', 'subscribe2') . "\" /></p>\r\n";
722
  }
723
  } else {
724
- echo "<br />";
725
  }
726
  } // end display_digest_choices()
727
 
728
  /**
729
  Create and display a dropdown list of pages
730
  */
731
- function pages_dropdown($s2page) {
732
  $pages = get_pages();
733
- if ( empty($pages) ) { return; }
734
 
735
  $option = '';
736
  foreach ( $pages as $page ) {
737
- $option .= "<option value=\"" . $page->ID . "\"";
738
- if ( $page->ID == $s2page ) {
739
- $option .= " selected=\"selected\"";
740
  }
741
- $option .= ">";
742
- $parents = array_reverse( get_ancestors($page->ID, 'page') );
743
  if ( $parents ) {
744
  foreach ( $parents as $parent ) {
745
- $option .= get_the_title($parent) . ' &raquo; ';
746
  }
747
  }
748
- $option .= $page->post_title . "</option>\r\n";
749
  }
750
 
751
  echo $option;
@@ -754,232 +673,249 @@ class s2_admin extends s2class {
754
  /**
755
  Subscribe all registered users to category selected on Admin Manage Page
756
  */
757
- function subscribe_registered_users($emails = '', $cats = array()) {
758
- if ( '' == $emails || '' == $cats ) { return false; }
759
  global $wpdb;
760
 
761
- $useremails = explode(",\r\n", $emails);
762
- $useremails = implode(", ", array_map(array($this, 'prepare_in_data'), $useremails));
763
 
764
  $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
765
- $user_IDs = $wpdb->get_col($sql);
766
 
767
  foreach ( $user_IDs as $user_ID ) {
768
- $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
769
- if ( !empty($old_cats) ) {
770
- $old_cats = explode(',', $old_cats);
771
- $newcats = array_unique(array_merge($cats, $old_cats));
772
  } else {
773
  $newcats = $cats;
774
  }
775
- if ( !empty($newcats) && $newcats !== $old_cats) {
776
  // add subscription to these cat IDs
777
  foreach ( $newcats as $id ) {
778
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id, $id);
779
  }
780
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
781
  }
782
- unset($newcats);
783
  }
784
  } // end subscribe_registered_users()
785
 
786
  /**
787
  Unsubscribe all registered users to category selected on Admin Manage Page
788
  */
789
- function unsubscribe_registered_users($emails = '', $cats = array()) {
790
- if ( '' == $emails || '' == $cats ) { return false; }
791
  global $wpdb;
792
 
793
- $useremails = explode(",\r\n", $emails);
794
- $useremails = implode(", ", array_map(array($this, 'prepare_in_data'), $useremails));
795
 
796
  $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
797
- $user_IDs = $wpdb->get_col($sql);
798
 
799
  foreach ( $user_IDs as $user_ID ) {
800
- $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
801
- $remain = array_diff($old_cats, $cats);
802
- if ( !empty($remain) && $remain !== $old_cats) {
803
  // remove subscription to these cat IDs and update s2_subscribed
804
  foreach ( $cats as $id ) {
805
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
806
  }
807
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
808
  } else {
809
  // remove subscription to these cat IDs and update s2_subscribed to ''
810
  foreach ( $cats as $id ) {
811
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
812
  }
813
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
814
  }
815
- unset($remain);
816
  }
817
  } // end unsubscribe_registered_users()
818
 
819
  /**
820
  Handles bulk changes to email format for Registered Subscribers
821
  */
822
- function format_change($emails, $format) {
823
- if ( empty($format) ) { return; }
824
 
825
  global $wpdb;
826
- $useremails = explode(",\r\n", $emails);
827
- $useremails = implode(", ", array_map(array($this,'prepare_in_data'), $useremails));
828
- $ids = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)");
829
- $ids = implode(',', array_map(array($this, 'prepare_in_data'), $ids));
830
- $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname('s2_format') . "' AND user_id IN ($ids)";
831
- $wpdb->query($sql);
832
  } // end format_change()
833
 
834
  /**
835
  Handles bulk update to digest preferences
836
  */
837
- function digest_change($emails, $digest) {
838
- if ( empty($digest) ) { return; }
839
 
840
  global $wpdb;
841
- $useremails = explode(",\r\n", $emails);
842
- $useremails = implode(", ", array_map(array($this, 'prepare_in_data'), $useremails));
843
 
844
  $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
845
- $user_IDs = $wpdb->get_col($sql);
846
 
847
- if ( $digest == 'digest' ) {
848
- $exclude = explode(',', $this->subscribe2_options['exclude']);
849
- if ( !empty($exclude) ) {
850
- $all_cats = $this->all_cats(true, 'ID');
851
  } else {
852
- $all_cats = $this->all_cats(false, 'ID');
853
  }
854
 
855
  $cats_string = '';
856
  foreach ( $all_cats as $cat ) {
857
- ('' == $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
858
  }
859
 
860
  foreach ( $user_IDs as $user_ID ) {
861
  foreach ( $all_cats as $cat ) {
862
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
863
  }
864
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats_string);
865
  }
866
- } elseif ( $digest == '-1' ) {
867
  foreach ( $user_IDs as $user_ID ) {
868
- $cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
869
  foreach ( $cats as $id ) {
870
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $id);
871
  }
872
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
873
  }
874
  }
875
  } // end digest_change()
876
 
877
- /* ===== functions to handle addition and removal of WordPress categories ===== */
878
  /**
879
  Autosubscribe registered users to newly created categories
880
  if registered user has selected this option
881
  */
882
- function new_category($new_category='') {
883
- if ( 'no' == $this->subscribe2_options['show_autosub'] ) { return; }
884
 
885
  global $wpdb;
886
- if ( $this->subscribe2_options['email_freq'] != 'never' ) {
887
  // if we are doing digests add new categories to users who are currently opted in
888
- $sql = $wpdb->prepare("SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value<>''", $this->get_usermeta_keyname('s2_subscribed'));
889
- $user_IDs = $wpdb->get_col($sql);
890
  foreach ( $user_IDs as $user_ID ) {
891
- $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
892
- $old_cats = explode(',', $old_cats);
893
- $newcats = array_merge($old_cats, (array)$new_category);
894
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $new_category, $new_category);
895
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
896
  }
897
  return;
898
  }
899
 
900
- if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
901
  if ( $this->s2_mu ) {
902
- $sql = $wpdb->prepare("SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key=%s AND a.meta_value='yes' AND b.meta_key=%s", $this->get_usermeta_keyname('s2_autosub'), $this->get_usermeta_keyname('s2_subscribed'));
903
  } else {
904
- $sql = $wpdb->prepare("SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key=%s AND $wpdb->usermeta.meta_value='yes'", $this->get_usermeta_keyname('s2_autosub'));
905
  }
906
- $user_IDs = $wpdb->get_col($sql);
907
- if ( '' == $user_IDs ) { return; }
908
 
909
  foreach ( $user_IDs as $user_ID ) {
910
- $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
911
- if ( empty($old_cats) ) {
912
- $newcats = (array)$new_category;
913
  } else {
914
- $old_cats = explode(',', $old_cats);
915
- $newcats = array_merge($old_cats, (array)$new_category);
916
  }
917
  // add subscription to these cat IDs
918
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $new_category, $new_category);
919
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
920
  }
921
- } elseif ( 'exclude' == $this->subscribe2_options['show_autosub'] ) {
922
- $excluded_cats = explode(',', $this->subscribe2_options['exclude']);
923
  $excluded_cats[] = $new_category;
924
- $this->subscribe2_options['exclude'] = implode(',', $excluded_cats);
925
- update_option('subscribe2_options', $this->subscribe2_options);
926
  }
927
  } // end new_category()
928
 
929
  /**
930
  Automatically delete subscriptions to a category when it is deleted
931
  */
932
- function delete_category($deleted_category='') {
933
  global $wpdb;
934
 
935
  if ( $this->s2_mu ) {
936
- $sql = $wpdb->prepare("SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key=%s AND b.meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $deleted_category, $this->get_usermeta_keyname('s2_subscribed'));
937
  } else {
938
- $sql = $wpdb->prepare("SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $deleted_category);
939
  }
940
- $user_IDs = $wpdb->get_col($sql);
941
- if ( '' == $user_IDs ) { return; }
942
 
943
  foreach ( $user_IDs as $user_ID ) {
944
- $old_cats = explode(',', get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true));
945
- if ( !is_array($old_cats) ) {
946
- $old_cats = array($old_cats);
947
  }
948
  // add subscription to these cat IDs
949
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $deleted_category);
950
- $remain = array_diff($old_cats, (array)$deleted_category);
951
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $remain));
952
  }
953
  } // end delete_category()
954
 
955
- /* ===== functions to show & handle one-click subscription ===== */
956
  /**
957
  Show form for one-click subscription on user profile page
958
  */
959
- function one_click_profile_form($user) {
960
- echo "<h3>" . __('Email subscription', 'subscribe2') . "</h3>\r\n";
961
- echo "<table class=\"form-table\">\r\n";
962
- echo "<tr><th scope=\"row\">" . __('Subscribe / Unsubscribe', 'subscribe2') . "</th>\r\n";
963
- echo "<td><label><input type=\"checkbox\" name=\"sub2-one-click-subscribe\" value=\"1\" " . checked( ! get_user_meta($user->ID, $this->get_usermeta_keyname('s2_subscribed'), true), false, false ) . " /> " . __('Receive notifications', 'subscribe2') . "</label><br />\r\n";
964
- echo "<span class=\"description\">" . __('Check if you want to receive email notification when new posts are published', 'subscribe2') . "</span>\r\n";
965
- echo "</td></tr></table>\r\n";
966
  } // end one_click_profile_form()
967
 
968
  /**
969
  Handle submission from profile one-click subscription
970
  */
971
- function one_click_profile_form_save($user_ID) {
972
- if ( !current_user_can( 'edit_user', $user_ID ) ) {
973
  return false;
974
  }
975
 
976
- if ( isset( $_POST['sub2-one-click-subscribe'] ) && 1 == $_POST['sub2-one-click-subscribe'] ) {
977
  // Subscribe
978
- $this->one_click_handler($user_ID, 'subscribe');
979
  } else {
980
  // Unsubscribe
981
- $this->one_click_handler($user_ID, 'unsubscribe');
982
  }
983
  } // end one_click_profile_form_save()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
984
  }
985
  ?>
1
  <?php
2
+ class S2_Admin extends S2_Core {
3
+ /* ===== WordPress menu registration and scripts ===== */
4
  /**
5
  Hook the menu
6
  */
7
  function admin_menu() {
8
+ add_menu_page( __( 'Subscribe2', 'subscribe2' ), __( 'Subscribe2', 'subscribe2' ), apply_filters( 's2_capability', 'read', 'user' ), 's2', null, S2URL . 'include/email-edit.png' );
9
+
10
+ $s2user = add_submenu_page( 's2', __( 'Your Subscriptions', 'subscribe2' ), __( 'Your Subscriptions', 'subscribe2' ), apply_filters( 's2_capability', 'read', 'user' ), 's2', array( &$this, 'user_menu' ), S2URL . 'include/email-edit.png' );
11
+ add_action( "admin_print_scripts-$s2user", array( &$this, 'checkbox_form_js' ) );
12
+ add_action( "admin_print_styles-$s2user", array( &$this, 'user_admin_css' ) );
13
+ add_action( 'load-' . $s2user, array( &$this, 'user_help' ) );
14
+
15
+ $s2subscribers = add_submenu_page( 's2', __( 'Subscribers', 'subscribe2' ), __( 'Subscribers', 'subscribe2' ), apply_filters( 's2_capability', 'manage_options', 'manage' ), 's2_tools', array( &$this, 'subscribers_menu' ) );
16
+ add_action( "admin_print_scripts-$s2subscribers", array( &$this, 'checkbox_form_js' ) );
17
+ add_action( "admin_print_scripts-$s2subscribers", array( &$this, 'subscribers_form_js' ) );
18
+ add_action( 'load-' . $s2subscribers, array( &$this, 'subscribers_help' ) );
19
+
20
+ $s2settings = add_submenu_page( 's2', __( 'Settings', 'subscribe2' ), __( 'Settings', 'subscribe2' ), apply_filters( 's2_capability', 'manage_options', 'settings' ), 's2_settings', array( &$this, 'settings_menu' ) );
21
+ add_action( "admin_print_scripts-$s2settings", array( &$this, 'checkbox_form_js' ) );
22
+ add_action( "admin_print_scripts-$s2settings", array( &$this, 'option_form_js' ) );
23
+ add_action( "admin_print_scripts-$s2settings", array( &$this, 'dismiss_js' ) );
24
+ add_filter( 'plugin_row_meta', array( &$this, 'plugin_links' ), 10, 2 );
25
+ add_action( 'load-' . $s2settings, array( &$this, 'settings_help' ) );
26
+
27
+ $s2mail = add_submenu_page( 's2', __( 'Send Email', 'subscribe2' ), __( 'Send Email', 'subscribe2' ), apply_filters( 's2_capability', 'publish_posts', 'send' ), 's2_posts', array( &$this, 'write_menu' ) );
28
+ add_action( 'load-' . $s2mail, array( &$this, 'mail_help' ) );
29
  } // end admin_menu()
30
 
31
  /**
33
  */
34
  function user_help() {
35
  $screen = get_current_screen();
36
+ if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
37
+ $screen->add_help_tab( array(
38
  'id' => 's2-user-help1',
39
+ 'title' => __( 'Overview', 'subscribe2' ),
40
+ 'content' => '<p>' . __( 'From this page you can opt in or out of receiving a periodical digest style email of blog posts.', 'subscribe2' ) . '</p>',
41
+ ) );
42
  } else {
43
+ $screen->add_help_tab( array(
44
  'id' => 's2-user-help1',
45
+ 'title' => __( 'Overview', 'subscribe2' ),
46
+ 'content' => '<p>' . __( 'From this page you can control your subscription preferences. Choose the email format you wish to receive, which categories you would like to receive notification for and depending on the site settings which authors you would like to read.', 'subscribe2' ) . '</p>',
47
+ ) );
48
  }
49
  } // end user_help()
50
 
51
  function subscribers_help() {
52
  $screen = get_current_screen();
53
+ $screen->add_help_tab( array(
54
  'id' => 's2-subscribers-help1',
55
+ 'title' => __( 'Overview', 'subscribe2' ),
56
+ 'content' => '<p>' . __( 'From this page you can manage your subscribers.', 'subscribe2' ) . '</p>',
57
+ ) );
58
+ $screen->add_help_tab( array(
59
  'id' => 's2-subscribers-help2',
60
+ 'title' => __( 'Public Subscribers', 'subscribe2' ),
61
+ 'content' => '<p>' . __( 'Public Subscribers are subscribers who have used the plugin form and only provided their email address.', 'subscribe2' ) . '</p><p>' . __( 'On this page public subscribers can be viewed, searched, deleted and also toggled between Confirmed and Unconfirmed status.', 'subscribe2' ) . '</p>',
62
+ ) );
63
+ $screen->add_help_tab( array(
64
  'id' => 's2-subscribers-help3',
65
+ 'title' => __( 'Registered Subscribers', 'subscribe2' ),
66
+ 'content' => '<p>' . __( 'Registered Subscribers are subscribers who have registered in WordPress and have a username and password.', 'subscribe2' ) .
67
+ '</p><p>' . __( 'Registered Subscribers have greater personal control over their subscription. They can change the format of the email and also select which categories and authors they want to receive notifications about.', 'subscribe2' ) .
68
+ '</p><p>' . __( 'On this page registered subscribers can be viewed and searched. User accounts can be deleted from here with any posts created by those users being assigned to the currently logged in user. Bulk changes can be applied to all user settings changing their subscription email format and categories.', 'subscribe2' ) . '</p>',
69
+ ) );
70
  } // end subscribers_help()
71
 
72
  function settings_help() {
73
  $screen = get_current_screen();
74
+ $screen->add_help_tab( array(
75
  'id' => 's2-settings-help1',
76
+ 'title' => __( 'Overview', 'subscribe2' ),
77
+ 'content' => '<p>' . __( 'From this page you can adjust the Settings for Subscribe2.', 'subscribe2' ) . '</p>',
78
+ ) );
79
+ $screen->add_help_tab( array(
80
  'id' => 's2-settings-help2',
81
+ 'title' => __( 'Email Settings', 'subscribe2' ),
82
+ 'content' => '<p>' . __( 'This section allows you to specify settings that apply to the emails generated by the site.', 'subscribe2' ) .
83
+ '</p><p>' . __( 'Emails can be sent to individual subscribers by setting the number of recipients per email to 1. A setting greater than one will group recipients together and make use of the BCC emails header. A setting of 0 sends a single email with all subscribers in one large BCC group. A setting of 1 looks less like spam email to filters but takes longer to process.', 'subscribe2' ) .
84
+ '</p><p>' . __( 'This section is also where the sender of the email on this page is chosen. You can choose Post Author or your Blogname but it is recommended to create a user account with an email address that really exists and shares the same domain name as your site (the bit after the @ should be the same as your sites web address) and then use this account.', 'subscribe2' ) .
85
+ '</p><p>' . __( 'This page also configures the frequency of emails. This can be at the time new posts are made (per post) or periodically with an excerpt of each post made (digest). Additionally the post types (pages, private, password protected) can also be configured here.', 'subscribe2' ) . '</p>',
86
+ ) );
87
+ $screen->add_help_tab( array(
88
  'id' => 's2-settings-help3',
89
+ 'title' => __( 'Templates', 'subscribe2' ),
90
+ 'content' => '<p>' . __( 'This section allows you to customise the content of your notification emails.', 'subscribe2' ) .
91
+ '</p><p>' . __( 'There are special {KEYWORDS} that are used by Subscribe2 to place content into the final email. The template also accepts regular text and HTML as desired in the final emails.', 'subscribe2' ) .
92
+ '</p><p>' . __( 'The {KEYWORDS} are listed on the right of the templates, note that some are for per post emails only and some are for digest emails only. Make sure the correct keywords are used based upon the Email Settings.', 'subscribe2' ) .
93
+ '</p><p>' . __( 'The Notification Email template is used for sending notifications of new posts. The Subscribe / Unsubscribe confirmation template is sent when a new subscription or unsubscription request is made. The Reminder template is used to send reminder emails; this is done automatically or can be done manually.', 'subscribe2' ) . '</p>',
94
+ ) );
95
+ $screen->add_help_tab( array(
96
  'id' => 's2-settings-help4',
97
+ 'title' => __( 'Registered Users', 'subscribe2' ),
98
+ 'content' => '<p>' . __( 'This section allows settings that apply to Registered Subscribers to be configured.', 'subscribe2' ) .
99
+ '</p><p>' . __( 'Categories can be made compulsory so emails are always sent for posts in these categories. They can also be excludes so that emails are not generated. Excluded categories take precedence over Compulsory categories.', 'subscribe2' ) .
100
+ '</p><p>' . __( 'A set of default settings for new users can also be specified using the Auto Subscribe section. Settings specified here will be applied to any newly created user accounts while Subscribe2 is activated.', 'subscribe2' ) . '</p>',
101
+ ) );
102
+ $screen->add_help_tab( array(
103
  'id' => 's2-settings-help5',
104
+ 'title' => __( 'Appearance', 'subscribe2' ),
105
+ 'content' => '<p>' . __( 'This section allows you to enable several aspect of the plugin such as Widgets and editor buttons.', 'subscribe2' ) .
106
+ '</p><p>' . __( 'AJAX mode can be enabled that is intended to work with the shortcode link parameter so that a dialog opens in the centre of the browser rather then using the regular form.', 'subscribe2' ) .
107
+ '</p><p>' . __( 'The email over ride check box can be set to be automatically checked for every new post and page from here to, this may be useful if you will only want to send very occasional notifications for specific posts. You can then uncheck this box just before you publish your content.', 'subscribe2' ) . '</p>',
108
+ ) );
109
+ $screen->add_help_tab( array(
110
  'id' => 's2-settings-help6',
111
+ 'title' => __( 'Miscellaneous', 'subscribe2' ),
112
+ 'content' => '<p>' . __( 'This section contains a place to bar specified domains from becoming Public Subscribers and links to help and support pages.', 'subscribe2' ) .
113
+ '</p><p>' . __( 'In the paid Subscribe2 HTML version there is also a place here to enter a license code so that updates can be accessed automatically.', 'subscribe2' ) .
114
+ '</p>',
115
+ ) );
116
  } // end settings_help()
117
 
118
  function mail_help() {
119
  $screen = get_current_screen();
120
+ $screen->add_help_tab( array(
121
  'id' => 's2-send-mail-help1',
122
+ 'title' => __( 'Overview', 'subscribe2' ),
123
+ 'content' => '<p>' . __( 'From this page you can send emails to the recipients in the group selected in the drop down.', 'subscribe2' ) .
124
+ '</p><p>' . __( '<strong>Preview</strong> will send a preview of the email to the currently logged in user. <strong>Send</strong> will send the email to the recipient list.', 'subscribe2' ) . '</p>',
125
+ ) );
126
  } // end send_email_help()
127
 
128
  /**
129
  Hook for Admin Drop Down Icons
130
  */
131
  function ozh_s2_icon() {
132
+ return S2URL . 'include/email-edit.png';
133
  } // end ozh_s2_icon()
134
 
135
  /**
136
+ Insert Javascript and CSS into admin_headers
137
  */
138
  function checkbox_form_js() {
139
+ wp_register_script( 's2_checkbox', S2URL . 'include/s2-checkbox' . $this->script_debug . '.js', array( 'jquery' ), '1.3' );
140
+ wp_enqueue_script( 's2_checkbox' );
141
  } //end checkbox_form_js()
142
 
143
  function user_admin_css() {
144
+ wp_register_style( 's2_user_admin', S2URL . 'include/s2-user-admin.css', array(), '1.0' );
145
+ wp_enqueue_style( 's2_user_admin' );
146
  } // end user_admin_css()
147
 
148
  function option_form_js() {
149
+ wp_register_script( 's2_edit', S2URL . 'include/s2-edit' . $this->script_debug . '.js', array( 'jquery' ), '1.2' );
150
+ wp_enqueue_script( 's2_edit' );
151
+ if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
152
+ wp_enqueue_script( 'jquery-ui-datepicker' );
153
+ wp_enqueue_style( 'jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css' );
154
+ wp_register_script( 's2_date_time', S2URL . 'include/s2-date-time' . $this->script_debug . '.js', array( 'jquery-ui-datepicker' ), '1.0' );
155
+ wp_enqueue_script( 's2_date_time' );
156
+ }
157
  } // end option_form_js()
158
 
159
+ function dismiss_js() {
160
+ wp_register_script( 's2_dismiss', S2URL . 'include/s2-dismiss' . $this->script_debug . '.js', array( 'jquery' ), '1.0', true );
161
+ $translation_array = array(
162
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
163
+ 'nonce' => wp_create_nonce( 's2_dismiss_nonce' ),
164
+ );
165
+ wp_localize_script( 's2_dismiss', 's2_dismiss_script_strings', $translation_array );
166
+ wp_enqueue_script( 's2_dismiss' );
167
+ } // end dismiss_js()
168
+
169
+ function s2_dismiss_notice_handler() {
170
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 's2_dismiss_nonce' ) ) {
171
+ return false;
172
+ }
173
+ $this->subscribe2_options['dismiss_sender_warning'] = '1';
174
+ update_option( 'subscribe2_options', $this->subscribe2_options );
175
+ wp_die();
176
+ } // end s2_dismiss_notice_handler()
177
+
178
+ function subscribers_form_js() {
179
+ wp_register_script( 's2_subscribers', S2URL . 'include/s2-subscribers' . $this->script_debug . '.js', array(), '1.2' );
180
+ $translation_array = array(
181
+ 'registered_confirm_single' => __( 'You are about to delete a registered user account, any posts made by this user will be assigned to you. Are you sure?', 'subscribe2' ),
182
+ 'registered_confirm_plural' => __( 'You are about to delete registered user accounts, any posts made by these users will be assigned to you. Are you sure?', 'subscribe2' ),
183
+ 'public_confirm_single' => __( 'You are about to delete a public subscriber. Are you sure?', 'subscribe2' ),
184
+ 'public_confirm_plural' => __( 'You are about to delete public subscribers. Are you sure?', 'subscribe2' ),
185
+ );
186
+ wp_localize_script( 's2_subscribers', 's2_script_strings', $translation_array );
187
+ wp_enqueue_script( 's2_subscribers' );
188
+ } // end subscribers_form_js()
189
+
190
  /**
191
  Adds a links directly to the settings page from the plugin page
192
  */
193
+ function plugin_links( $links, $file ) {
194
+ if ( S2DIR . 'subscribe2.php' === $file ) {
195
+ $links[] = '<a href="admin.php?page=s2_settings">' . __( 'Settings', 'subscribe2' ) . '</a>';
196
+ $links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904"><b>' . __( 'Donate', 'subscribe2' ) . '</b></a>';
 
197
  }
198
  return $links;
199
  } // end plugin_links()
203
  Our subscriber management page
204
  */
205
  function subscribers_menu() {
206
+ require_once( S2PATH . 'admin/subscribers.php' );
207
  } // end subscribers_menu()
208
 
209
+ /**
210
  Our settings page
211
  */
212
  function settings_menu() {
213
+ require_once( S2PATH . 'admin/settings.php' );
214
  } // end settings_menu()
215
 
216
  /**
217
  Our profile menu
218
  */
219
  function user_menu() {
220
+ require_once( S2PATH . 'admin/your-subscriptions.php' );
221
  } // end user_menu()
222
 
223
  /**
224
  Display the Write sub-menu
225
  */
226
  function write_menu() {
227
+ require_once( S2PATH . 'admin/send-email.php' );
228
  } // end write_menu()
229
 
230
+ /* ===== Write Toolbar Button Functions ===== */
231
  /**
232
  Register our button in the QuickTags bar
233
  */
234
  function button_init() {
235
  global $pagenow;
236
+ if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ) ) && ! strpos( esc_url( $_SERVER['REQUEST_URI'] ), 'page=s2_posts' ) ) { return; }
237
+ if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { return; }
238
+ if ( 'true' === get_user_option( 'rich_editing' ) ) {
239
  // Hook into the rich text editor
240
+ add_filter( 'mce_external_plugins', array( &$this, 'mce_plugin' ) );
241
+ add_filter( 'mce_buttons', array( &$this, 'mce_button' ) );
242
  } else {
243
+ wp_enqueue_script( 'subscribe2_button', S2URL . 'include/s2-button' . $this->script_debug . '.js', array( 'quicktags' ), '2.0' );
244
  }
245
  } // end button_init()
246
 
247
  /**
248
  Add buttons for Rich Text Editor
249
  */
250
+ function mce_plugin( $arr ) {
251
+ if ( version_compare( $this->wp_release, '3.9', '<' ) ) {
252
+ $path = S2URL . 'tinymce/editor-plugin3' . $this->script_debug . '.js';
253
  } else {
254
+ $path = S2URL . 'tinymce/editor-plugin4' . $this->script_debug . '.js';
255
  }
256
  $arr['subscribe2'] = $path;
257
  return $arr;
258
  } // end mce_plugin()
259
 
260
+ function mce_button( $arr ) {
261
  $arr[] = 'subscribe2';
262
  return $arr;
263
  } // end mce_button()
264
 
265
+ /* ===== widget functions ===== */
266
  /**
267
  Function to add css and js files to admin header
268
  */
269
  function widget_s2counter_css_and_js() {
270
  // ensure we only add colorpicker js to widgets page
271
+ if ( false !== stripos( esc_url( $_SERVER['REQUEST_URI'] ), 'widgets.php' ) ) {
272
+ wp_enqueue_style( 'farbtastic' );
273
+ wp_enqueue_script( 'farbtastic' );
274
+ wp_register_script( 's2_colorpicker', S2URL . 'include/s2-colorpicker' . $this->script_debug . '.js', array( 'farbtastic' ), '1.2' );
275
+ wp_enqueue_script( 's2_colorpicker' );
276
  }
277
  } // end widget_s2_counter_css_and_js()
278
 
279
+ /* ===== meta box functions to allow per-post override ===== */
 
280
  /**
281
  Create meta box on write pages
282
  */
287
  $s2_post_types = array( 'post' );
288
  }
289
  $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
290
+ foreach ( $s2_post_types as $s2_post_type ) {
291
+ add_meta_box( 'subscribe2', __( 'Subscribe2 Notification Override', 'subscribe2' ), array( &$this, 's2-meta-box' ), $s2_post_type, 'advanced' );
292
  }
293
  } // end s2_meta_init()
294
 
295
  /**
296
+ Meta override box code
297
  */
298
+ function s2_override_meta() {
299
  global $post_ID;
300
+ $s2mail = get_post_meta( $post_ID, '_s2mail', true );
301
+ echo '<input type="hidden" name="s2meta_nonce" id="s2meta_nonce" value="' . wp_create_nonce( wp_hash( plugin_basename( __FILE__ ) ) ) . '" />';
302
+ echo __( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' );
303
+ echo '&nbsp;&nbsp;<input type="checkbox" name="s2_meta_field" value="no"';
304
+ if ( 'no' === $s2mail || ( '1' === $this->subscribe2_options['s2meta_default'] && '' === $s2mail ) ) {
305
+ echo ' checked="checked"';
306
  }
307
+ echo ' />';
308
+ } // end s2_override_meta()
309
 
310
  /**
311
+ Meta override box form handler
312
  */
313
+ function s2_meta_handler( $post_id ) {
314
+ if ( ! isset( $_POST['s2meta_nonce'] ) || ! wp_verify_nonce( $_POST['s2meta_nonce'], wp_hash( plugin_basename( __FILE__ ) ) ) ) { return $post_id; }
315
 
316
+ if ( 'page' === $_POST['post_type'] ) {
317
+ if ( ! current_user_can( 'edit_page', $post_id ) ) { return $post_id; }
318
  } else {
319
+ if ( ! current_user_can( 'edit_post', $post_id ) ) { return $post_id; }
320
  }
321
 
322
+ if ( isset( $_POST['s2_meta_field'] ) && 'no' === $_POST['s2_meta_field'] ) {
323
+ update_post_meta( $post_id, '_s2mail', $_POST['s2_meta_field'] );
324
  } else {
325
+ update_post_meta( $post_id, '_s2mail', 'yes' );
326
  }
327
  } // end s2_meta_box_handler()
328
 
329
+ /* ===== WordPress menu helper functions ===== */
330
  /**
331
  Collects the signup date for all public subscribers
332
  */
333
+ function signup_date( $email = '' ) {
334
+ if ( '' === $email ) { return false; }
335
 
336
  global $wpdb;
337
+ if ( ! empty( $this->signup_dates ) ) {
338
+ return $this->signup_dates[ $email ];
339
  } else {
340
+ $results = $wpdb->get_results( "SELECT email, date FROM $this->public", ARRAY_N );
341
  foreach ( $results as $result ) {
342
+ $this->signup_dates[ $result[0] ] = $result[1];
343
  }
344
+ return $this->signup_dates[ $email ];
345
  }
346
  } // end signup_date()
347
 
348
  /**
349
  Collects the ip address for all public subscribers
350
  */
351
+ function signup_ip( $email = '' ) {
352
+ if ( '' === $email ) {return false; }
353
 
354
  global $wpdb;
355
+ if ( ! empty( $this->signup_ips ) ) {
356
+ return $this->signup_ips[ $email ];
357
  } else {
358
+ $results = $wpdb->get_results( "SELECT email, ip FROM $this->public", ARRAY_N );
359
  foreach ( $results as $result ) {
360
+ $this->signup_ips[ $result[0] ] = $result[1];
361
  }
362
+ return $this->signup_ips[ $email ];
363
  }
364
  } // end signup_ip()
365
 
367
  Export subscriber emails and other details to CSV
368
  */
369
  function prepare_export( $subscribers ) {
370
+ if ( empty( $subscribers ) ) { return; }
371
+ $subscribers = explode( ",\r\n", $subscribers );
372
+ natcasesort( $subscribers );
373
 
374
+ $exportcsv = _x( 'User Email,User Type,User Name,Confirm Date,IP', 'Comma Separated Column Header names for CSV Export' , 'subscribe2' );
375
+ $all_cats = $this->all_cats( false, 'ID' );
376
 
377
+ foreach ( $all_cats as $cat ) {
378
+ $exportcsv .= ',' . html_entity_decode( $cat->cat_name, ENT_QUOTES );
379
  $cat_ids[] = $cat->term_id;
380
  }
381
  $exportcsv .= "\r\n";
382
 
 
 
 
 
383
  foreach ( $subscribers as $subscriber ) {
384
+ if ( $this->is_registered( $subscriber ) ) {
385
  $user_ID = $this->get_user_id( $subscriber );
386
  $user_info = get_userdata( $user_ID );
387
 
388
+ $cats = explode( ',', get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
389
  $subscribed_cats = '';
390
  foreach ( $cat_ids as $cat ) {
391
+ (in_array( $cat, $cats )) ? $subscribed_cats .= ',Yes' : $subscribed_cats .= ',No';
392
  }
393
 
394
  $exportcsv .= $subscriber . ',';
395
+ $exportcsv .= __( 'Registered User', 'subscribe2' );
396
  $exportcsv .= ',' . $user_info->display_name;
397
  $exportcsv .= ',,' . $subscribed_cats . "\r\n";
398
  } else {
399
+ if ( '1' === $this->is_public( $subscriber ) ) {
400
+ $exportcsv .= $subscriber . ',' . __( 'Confirmed Public Subscriber', 'subscribe2' ) . ',,' . $this->signup_date( $subscriber ) . ',' . $this->signup_ip( $subscriber ) . "\r\n";
401
+ } elseif ( '0' === $this->is_public( $subscriber ) ) {
402
+ $exportcsv .= $subscriber . ',' . __( 'Unconfirmed Public Subscriber', 'subscribe2' ) . ',,' . $this->signup_date( $subscriber ) . ',' . $this->signup_ip( $subscriber ) . "\r\n";
403
  }
404
  }
405
  }
407
  return $exportcsv;
408
  } // end prepare_export()
409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  /**
411
  Display a table of post formats supported by the currently active theme
412
  */
413
+ function display_format_form( $formats, $selected = array() ) {
414
+ $half = (count( $formats[0] ) / 2);
415
  $i = 0;
416
  $j = 0;
417
+ echo '<table style="width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression(\'separate\', cellSpacing = \'2px\');" class="editform">' . "\r\n";
418
+ echo '<tr><td style="text-align: left;" colspan="2">' . "\r\n";
419
+ echo '<label><input type="checkbox" name="checkall" value="checkall_format" /> ' . __( 'Select / Unselect All', 'subscribe2' ) . '</label>' . "\r\n";
420
+ echo '</td></tr>' . "\r\n";
421
+ echo '<tr style="vertical-align: top;"><td style="width: 50%; text-align: left">' . "\r\n";
422
  foreach ( $formats[0] as $format ) {
423
+ if ( $i >= $half && 0 === $j ) {
424
+ echo '</td><td style="width: 50%; text-align: left">' . "\r\n";
425
  $j++;
426
  }
427
 
428
+ if ( 0 === $j ) {
429
+ echo '<label><input class="checkall_format" type="checkbox" name="format[]" value="' . $format . '"';
430
+ if ( in_array( $format, $selected ) ) {
431
+ echo ' checked="checked"';
432
  }
433
+ echo ' /> ' . ucwords( $format ) . '</label><br />' . "\r\n";
434
  } else {
435
+ echo '<label><input class="checkall_format" type="checkbox" name="format[]" value="' . $format . '"';
436
+ if ( in_array( $format, $selected ) ) {
437
+ echo ' checked="checked"';
438
  }
439
+ echo ' /> ' . ucwords( $format ) . '</label><br />' . "\r\n";
440
  }
441
  $i++;
442
  }
443
+ echo '</td></tr>' . "\r\n";
444
+ echo '</table>' . "\r\n";
445
  } // end display_format_form()
446
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  /**
448
  Display a drop-down form to select subscribers
449
  $selected is the option to select
450
  $submit is the text to use on the Submit button
451
  */
452
+ function display_subscriber_dropdown( $selected = 'registered', $submit = '', $exclude = array() ) {
453
  global $wpdb;
454
 
455
+ $who = array(
456
+ 'all' => __( 'All Users and Subscribers', 'subscribe2' ),
457
+ 'public' => __( 'Public Subscribers', 'subscribe2' ),
458
+ 'confirmed' => ' &nbsp;&nbsp;' . __( 'Confirmed', 'subscribe2' ),
459
+ 'unconfirmed' => ' &nbsp;&nbsp;' . __( 'Unconfirmed', 'subscribe2' ),
460
+ 'all_users' => __( 'All Registered Users', 'subscribe2' ),
461
+ 'registered' => __( 'Registered Subscribers', 'subscribe2' ),
462
+ );
463
 
464
+ $all_cats = $this->all_cats( false );
465
 
466
  // count the number of subscribers
467
+ $count['confirmed'] = $wpdb->get_var( "SELECT COUNT(id) FROM $this->public WHERE active='1'" );
468
+ $count['unconfirmed'] = $wpdb->get_var( "SELECT COUNT(id) FROM $this->public WHERE active='0'" );
469
+ if ( in_array( 'unconfirmed', $exclude ) ) {
470
  $count['public'] = $count['confirmed'];
471
+ } elseif ( in_array( 'confirmed', $exclude ) ) {
472
  $count['public'] = $count['unconfirmed'];
473
  } else {
474
  $count['public'] = ($count['confirmed'] + $count['unconfirmed']);
475
  }
476
  if ( $this->s2_mu ) {
477
+ $count['all_users'] = $wpdb->get_var( "SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'" );
478
  } else {
479
+ $count['all_users'] = $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->users" );
480
  }
481
  if ( $this->s2_mu ) {
482
+ $count['registered'] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(b.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=%s AND b.meta_value <> ''", $this->get_usermeta_keyname( 's2_subscribed' ) ) );
483
  } else {
484
+ $count['registered'] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value <> ''", $this->get_usermeta_keyname( 's2_subscribed' ) ) );
485
  }
486
  $count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
487
  // get subscribers to individual categories but only if we are using per-post notifications
488
+ if ( 'never' === $this->subscribe2_options['email_freq'] ) {
489
+ $compulsory = explode( ',', $this->subscribe2_options['compulsory'] );
490
  if ( $this->s2_mu ) {
491
  foreach ( $all_cats as $cat ) {
492
+ if ( in_array( $cat->term_id, $compulsory ) ) {
493
+ $count[ $cat->name ] = $count['all_users'];
494
  } else {
495
+ $count[ $cat->name ] = $wpdb->get_var( $wpdb->prepare( "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=%s", $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id ) );
496
  }
497
  }
498
  } else {
499
  foreach ( $all_cats as $cat ) {
500
+ if ( in_array( $cat->term_id, $compulsory ) ) {
501
+ $count[ $cat->name ] = $count['all_users'];
502
  } else {
503
+ $count[ $cat->name ] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id ) );
504
  }
505
  }
506
  }
507
  }
508
 
509
+ echo '<select name="what">' . "\r\n";
 
 
 
 
 
 
510
  foreach ( $who as $whom => $display ) {
511
+ if ( in_array( $whom, $exclude ) ) { continue; }
 
512
 
513
+ echo '<option value="' . $whom . '"';
514
+ if ( $whom === $selected ) { echo ' selected="selected" '; }
515
+ echo '>' . $display . ' (' . ($count[ $whom ]) . ')</option>' . "\r\n";
516
  }
517
 
518
+ if ( $count['registered'] > 0 && 'never' === $this->subscribe2_options['email_freq'] ) {
519
  foreach ( $all_cats as $cat ) {
520
+ if ( in_array( $cat->term_id, $exclude ) ) { continue; }
521
+ echo '<option value="' . $cat->term_id . '"';
522
+ if ( $cat->term_id === $selected ) { echo ' selected="selected" '; }
523
+ echo '> &nbsp;&nbsp;' . $cat->name . '&nbsp;(' . $count[ $cat->name ] . ') </option>' . "\r\n";
524
  }
525
  }
526
+ echo '</select>';
527
  if ( false !== $submit ) {
528
+ echo '&nbsp;<input type="submit" class="button-secondary" value="' . $submit . '" />' . "\r\n";
529
  }
530
  } // end display_subscriber_dropdown()
531
 
533
  Display a drop down list of administrator level users and
534
  optionally include a choice for Post Author
535
  */
536
+ function admin_dropdown( $inc_author = false ) {
537
  global $wpdb;
538
 
539
+ $args = array(
540
+ 'fields' => array(
541
+ 'ID',
542
+ 'display_name',
543
+ ),
544
+ 'role' => 'administrator',
545
+ );
546
  $wp_user_query = get_users( $args );
547
+ if ( ! empty( $wp_user_query ) ) {
548
+ foreach ( $wp_user_query as $user ) {
549
  $admins[] = $user;
550
  }
551
  } else {
553
  }
554
 
555
  if ( $inc_author ) {
556
+ $author[] = (object) array(
557
+ 'ID' => 'author',
558
+ 'display_name' => __( 'Post Author', 'subscribe2' ),
559
+ );
560
+ $author[] = (object) array(
561
+ 'ID' => 'blogname',
562
+ 'display_name' => html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ),
563
+ );
564
+ $admins = array_merge( $author, $admins );
565
+ }
566
+
567
+ echo '<select name="sender">' . "\r\n";
568
  foreach ( $admins as $admin ) {
569
+ echo '<option value="' . $admin->ID . '"';
570
+ if ( $admin->ID === $this->subscribe2_options['sender'] ) {
571
+ echo ' selected="selected"';
572
  }
573
+ echo '>' . $admin->display_name . '</option>' . "\r\n";
574
  }
575
+ echo '</select>' . "\r\n";
576
  } // end admin_dropdown()
577
 
578
  /**
582
  function display_digest_choices() {
583
  global $wpdb;
584
  $cron_file = ABSPATH . 'wp-cron.php';
585
+ if ( ! is_readable( $cron_file ) ) {
586
+ echo '<strong><em style="color: red">' . __( 'The WordPress cron functions may be disabled on this server. Digest notifications may not work.', 'subscribe2' ) . '</em></strong><br />' . "\r\n";
587
+ }
588
+ $scheduled_time = wp_next_scheduled( 's2_digest_cron' );
589
+ $offset = get_option( 'gmt_offset' ) * 60 * 60;
590
+ $schedule = (array) wp_get_schedules();
591
+ $schedule = array_merge( array(
592
+ 'never' => array(
593
+ 'interval' => 0,
594
+ 'display' => __( 'For each Post', 'subscribe2' ),
595
+ ),
596
+ ), $schedule );
597
  $sort = array();
598
+ foreach ( (array) $schedule as $key => $value ) {
599
+ $sort[ $key ] = $value['interval'];
600
  }
601
+ asort( $sort );
602
  $schedule_sorted = array();
603
  foreach ( $sort as $key => $value ) {
604
+ $schedule_sorted[ $key ] = $schedule[ $key ];
605
  }
606
  foreach ( $schedule_sorted as $key => $value ) {
607
+ echo '<label><input type="radio" name="email_freq" value="' . $key . '"' . checked( $this->subscribe2_options['email_freq'], $key, false ) . ' />';
608
+ echo ' ' . $value['display'] . '</label><br />' . "\r\n";
609
  }
610
  if ( $scheduled_time ) {
611
+ $date_format = get_option( 'date_format' );
612
+ $time_format = get_option( 'time_format' );
613
+ echo '<p>' . __( 'Current UTC time is', 'subscribe2' ) . ': ' . "\r\n";
614
+ echo '<strong>' . date_i18n( $date_format . ' @ ' . $time_format, false, 'gmt' ) . '</strong></p>' . "\r\n";
615
+ echo '<p>' . __( 'Current blog time is', 'subscribe2' ) . ': ' . "\r\n";
616
+ echo '<strong>' . date_i18n( $date_format . ' @ ' . $time_format ) . '</strong></p>' . "\r\n";
617
+ echo '<p>' . __( 'Next email notification will be sent when your blog time is after', 'subscribe2' ) . ': ' . "\r\n";
618
+ echo '<input type="hidden" id="jscrondate" value="' . date_i18n( $date_format, $scheduled_time + $offset ) . '" />';
619
+ echo '<input type="hidden" id="jscrontime" value="' . date_i18n( $time_format, $scheduled_time + $offset ) . '" />';
620
+ echo '<span id="s2cron_1"><span id="s2crondate" style="background-color: #FFFBCC">' . date_i18n( $date_format, $scheduled_time + $offset ) . '</span>';
621
+ echo ' @ <span id="s2crontime" style="background-color: #FFFBCC">' . date_i18n( $time_format, $scheduled_time + $offset ) . '</span> ';
622
+ echo '<a href="#" onclick="s2_show(\'cron\'); return false;">' . __( 'Edit', 'subscribe2' ) . '</a></span>' . "\r\n";
623
+ echo '<span id="s2cron_2">' . "\r\n";
624
+ echo '<input id="s2datepicker" name="crondate" value="' . date_i18n( $date_format, $scheduled_time + $offset ) . '">' . "\r\n";
625
+ $hours = array( '12:00 am', '1:00 am', '2:00 am', '3:00 am', '4:00 am', '5:00 am', '6:00 am', '7:00 am', '8:00 am', '9:00 am', '10:00 am', '11:00 am', '12:00 pm', '1:00 pm', '2:00 pm', '3:00 pm', '4:00 pm', '5:00 pm', '6:00 pm', '7:00 pm', '8:00 pm', '9:00 pm', '10:00 pm', '11:00 pm' );
626
+ $current_hour = intval( date_i18n( 'G', $scheduled_time + $offset ) );
627
+ echo '<select name="crontime">' . "\r\n";
628
  foreach ( $hours as $key => $value ) {
629
+ echo '<option value="' . $key . '"';
630
+ if ( ! empty( $scheduled_time ) && $key === $current_hour ) {
631
+ echo ' selected="selected"';
632
  }
633
+ echo '>' . $value . '</option>' . "\r\n";
634
  }
635
+ echo '</select>' . "\r\n";
636
+ echo '<a href="#" onclick="s2_cron_update(\'cron\'); return false;">' . __( 'Update', 'subscribe2' ) . '</a>' . "\r\n";
637
+ echo '<a href="#" onclick="s2_cron_revert(\'cron\'); return false;">' . __( 'Revert', 'subscribe2' ) . '</a></span>' . "\r\n";
638
+ if ( ! empty( $this->subscribe2_options['last_s2cron'] ) ) {
639
+ echo '<p>' . __( 'Attempt to resend the last Digest Notification email', 'subscribe2' ) . ': ';
640
+ echo '<input type="submit" class="button-secondary" name="resend" value="' . __( 'Resend Digest', 'subscribe2' ) . '" /></p>' . "\r\n";
641
  }
642
  } else {
643
+ echo '<br />';
644
  }
645
  } // end display_digest_choices()
646
 
647
  /**
648
  Create and display a dropdown list of pages
649
  */
650
+ function pages_dropdown( $s2page ) {
651
  $pages = get_pages();
652
+ if ( empty( $pages ) ) { return; }
653
 
654
  $option = '';
655
  foreach ( $pages as $page ) {
656
+ $option .= '<option value="' . $page->ID . '"';
657
+ if ( $page->ID === $s2page ) {
658
+ $option .= ' selected="selected"';
659
  }
660
+ $option .= '>';
661
+ $parents = array_reverse( get_ancestors( $page->ID, 'page' ) );
662
  if ( $parents ) {
663
  foreach ( $parents as $parent ) {
664
+ $option .= get_the_title( $parent ) . ' &raquo; ';
665
  }
666
  }
667
+ $option .= $page->post_title . '</option>' . "\r\n";
668
  }
669
 
670
  echo $option;
673
  /**
674
  Subscribe all registered users to category selected on Admin Manage Page
675
  */
676
+ function subscribe_registered_users( $emails = '', $cats = array() ) {
677
+ if ( '' === $emails || '' === $cats ) { return false; }
678
  global $wpdb;
679
 
680
+ $useremails = explode( ",\r\n", $emails );
681
+ $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
682
 
683
  $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
684
+ $user_IDs = $wpdb->get_col( $sql );
685
 
686
  foreach ( $user_IDs as $user_ID ) {
687
+ $old_cats = get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true );
688
+ if ( ! empty( $old_cats ) ) {
689
+ $old_cats = explode( ',', $old_cats );
690
+ $newcats = array_unique( array_merge( $cats, $old_cats ) );
691
  } else {
692
  $newcats = $cats;
693
  }
694
+ if ( ! empty( $newcats ) && $newcats !== $old_cats ) {
695
  // add subscription to these cat IDs
696
  foreach ( $newcats as $id ) {
697
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $id, $id );
698
  }
699
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $newcats ) );
700
  }
701
+ unset( $newcats );
702
  }
703
  } // end subscribe_registered_users()
704
 
705
  /**
706
  Unsubscribe all registered users to category selected on Admin Manage Page
707
  */
708
+ function unsubscribe_registered_users( $emails = '', $cats = array() ) {
709
+ if ( '' === $emails || '' === $cats ) { return false; }
710
  global $wpdb;
711
 
712
+ $useremails = explode( ",\r\n", $emails );
713
+ $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
714
 
715
  $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
716
+ $user_IDs = $wpdb->get_col( $sql );
717
 
718
  foreach ( $user_IDs as $user_ID ) {
719
+ $old_cats = explode( ',', get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
720
+ $remain = array_diff( $old_cats, $cats );
721
+ if ( ! empty( $remain ) && $remain !== $old_cats ) {
722
  // remove subscription to these cat IDs and update s2_subscribed
723
  foreach ( $cats as $id ) {
724
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $id );
725
  }
726
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $remain ) );
727
  } else {
728
  // remove subscription to these cat IDs and update s2_subscribed to ''
729
  foreach ( $cats as $id ) {
730
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $id );
731
  }
732
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ) );
733
  }
734
+ unset( $remain );
735
  }
736
  } // end unsubscribe_registered_users()
737
 
738
  /**
739
  Handles bulk changes to email format for Registered Subscribers
740
  */
741
+ function format_change( $emails, $format ) {
742
+ if ( empty( $format ) ) { return; }
743
 
744
  global $wpdb;
745
+ $useremails = explode( ",\r\n", $emails );
746
+ $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
747
+ $ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" );
748
+ $ids = implode( ',', array_map( array( $this, 'prepare_in_data' ), $ids ) );
749
+ $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname( 's2_format' ) . "' AND user_id IN ($ids)";
750
+ $wpdb->query( $sql );
751
  } // end format_change()
752
 
753
  /**
754
  Handles bulk update to digest preferences
755
  */
756
+ function digest_change( $emails, $digest ) {
757
+ if ( empty( $digest ) ) { return; }
758
 
759
  global $wpdb;
760
+ $useremails = explode( ",\r\n", $emails );
761
+ $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
762
 
763
  $sql = "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)";
764
+ $user_IDs = $wpdb->get_col( $sql );
765
 
766
+ if ( 'digest' === $digest ) {
767
+ $exclude = explode( ',', $this->subscribe2_options['exclude'] );
768
+ if ( ! empty( $exclude ) ) {
769
+ $all_cats = $this->all_cats( true, 'ID' );
770
  } else {
771
+ $all_cats = $this->all_cats( false, 'ID' );
772
  }
773
 
774
  $cats_string = '';
775
  foreach ( $all_cats as $cat ) {
776
+ ('' === $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
777
  }
778
 
779
  foreach ( $user_IDs as $user_ID ) {
780
  foreach ( $all_cats as $cat ) {
781
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id, $cat->term_id );
782
  }
783
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), $cats_string );
784
  }
785
+ } elseif ( '-1' === $digest ) {
786
  foreach ( $user_IDs as $user_ID ) {
787
+ $cats = explode( ',', get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
788
  foreach ( $cats as $id ) {
789
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $id );
790
  }
791
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ) );
792
  }
793
  }
794
  } // end digest_change()
795
 
796
+ /* ===== functions to handle addition and removal of WordPress categories ===== */
797
  /**
798
  Autosubscribe registered users to newly created categories
799
  if registered user has selected this option
800
  */
801
+ function new_category( $new_category = '' ) {
802
+ if ( 'no' === $this->subscribe2_options['show_autosub'] ) { return; }
803
 
804
  global $wpdb;
805
+ if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
806
  // if we are doing digests add new categories to users who are currently opted in
807
+ $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value<>''", $this->get_usermeta_keyname( 's2_subscribed' ) );
808
+ $user_IDs = $wpdb->get_col( $sql );
809
  foreach ( $user_IDs as $user_ID ) {
810
+ $old_cats = get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true );
811
+ $old_cats = explode( ',', $old_cats );
812
+ $newcats = array_merge( $old_cats, (array) $new_category );
813
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $new_category, $new_category );
814
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $newcats ) );
815
  }
816
  return;
817
  }
818
 
819
+ if ( 'yes' === $this->subscribe2_options['show_autosub'] ) {
820
  if ( $this->s2_mu ) {
821
+ $sql = $wpdb->prepare( "SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key=%s AND a.meta_value='yes' AND b.meta_key=%s", $this->get_usermeta_keyname( 's2_autosub' ), $this->get_usermeta_keyname( 's2_subscribed' ) );
822
  } else {
823
+ $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE $wpdb->usermeta.meta_key=%s AND $wpdb->usermeta.meta_value='yes'", $this->get_usermeta_keyname( 's2_autosub' ) );
824
  }
825
+ $user_IDs = $wpdb->get_col( $sql );
826
+ if ( '' === $user_IDs ) { return; }
827
 
828
  foreach ( $user_IDs as $user_ID ) {
829
+ $old_cats = get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true );
830
+ if ( empty( $old_cats ) ) {
831
+ $newcats = (array) $new_category;
832
  } else {
833
+ $old_cats = explode( ',', $old_cats );
834
+ $newcats = array_merge( $old_cats, (array) $new_category );
835
  }
836
  // add subscription to these cat IDs
837
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $new_category, $new_category );
838
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $newcats ) );
839
  }
840
+ } elseif ( 'exclude' === $this->subscribe2_options['show_autosub'] ) {
841
+ $excluded_cats = explode( ',', $this->subscribe2_options['exclude'] );
842
  $excluded_cats[] = $new_category;
843
+ $this->subscribe2_options['exclude'] = implode( ',', $excluded_cats );
844
+ update_option( 'subscribe2_options', $this->subscribe2_options );
845
  }
846
  } // end new_category()
847
 
848
  /**
849
  Automatically delete subscriptions to a category when it is deleted
850
  */
851
+ function delete_category( $deleted_category = '' ) {
852
  global $wpdb;
853
 
854
  if ( $this->s2_mu ) {
855
+ $sql = $wpdb->prepare( "SELECT DISTINCT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b WHERE a.user_id = b.user_id AND a.meta_key=%s AND b.meta_key=%s", $this->get_usermeta_keyname( 's2_cat' ) . $deleted_category, $this->get_usermeta_keyname( 's2_subscribed' ) );
856
  } else {
857
+ $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname( 's2_cat' ) . $deleted_category );
858
  }
859
+ $user_IDs = $wpdb->get_col( $sql );
860
+ if ( '' === $user_IDs ) { return; }
861
 
862
  foreach ( $user_IDs as $user_ID ) {
863
+ $old_cats = explode( ',', get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
864
+ if ( ! is_array( $old_cats ) ) {
865
+ $old_cats = array( $old_cats );
866
  }
867
  // add subscription to these cat IDs
868
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $deleted_category );
869
+ $remain = array_diff( $old_cats, (array) $deleted_category );
870
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $remain ) );
871
  }
872
  } // end delete_category()
873
 
874
+ /* ===== functions to show & handle one-click subscription ===== */
875
  /**
876
  Show form for one-click subscription on user profile page
877
  */
878
+ function one_click_profile_form( $user ) {
879
+ echo '<h3>' . __( 'Email subscription', 'subscribe2' ) . '</h3>' . "\r\n";
880
+ echo '<table class="form-table">' . "\r\n";
881
+ echo '<tr><th scope="row">' . __( 'Subscribe / Unsubscribe', 'subscribe2' ) . '</th>' . "\r\n";
882
+ echo '<td><label><input type="checkbox" name="sub2-one-click-subscribe" value="1" ' . checked( ! get_user_meta( $user->ID, $this->get_usermeta_keyname( 's2_subscribed' ), true ), false, false ) . ' /> ' . __( 'Receive notifications', 'subscribe2' ) . '</label><br />' . "\r\n";
883
+ echo '<span class="description">' . __( 'Check if you want to receive email notification when new posts are published', 'subscribe2' ) . '</span>' . "\r\n";
884
+ echo '</td></tr></table>' . "\r\n";
885
  } // end one_click_profile_form()
886
 
887
  /**
888
  Handle submission from profile one-click subscription
889
  */
890
+ function one_click_profile_form_save( $user_ID ) {
891
+ if ( ! current_user_can( 'edit_user', $user_ID ) ) {
892
  return false;
893
  }
894
 
895
+ if ( isset( $_POST['sub2-one-click-subscribe'] ) && 1 === $_POST['sub2-one-click-subscribe'] ) {
896
  // Subscribe
897
+ $this->one_click_handler( $user_ID, 'subscribe' );
898
  } else {
899
  // Unsubscribe
900
+ $this->one_click_handler( $user_ID, 'unsubscribe' );
901
  }
902
  } // end one_click_profile_form_save()
903
+
904
+ /**
905
+ Core function to hook the digest email preview to the action on the Settings page
906
+ */
907
+ function digest_preview( $user_email = '' ) {
908
+ if ( ! is_email( $user_email ) ) { return; }
909
+ $this->subscribe2_cron( $user_email );
910
+ } // end digest_preview()
911
+
912
+ /**
913
+ Core function to hook the resent digest email to the action on the Settings page
914
+ */
915
+ function digest_resend( $resend ) {
916
+ if ( 'resend' === $resend ) {
917
+ $this->subscribe2_cron( '', 'resend' );
918
+ }
919
+ } // end digest_resend()
920
  }
921
  ?>
classes/class-s2-ajax.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
- // Copyright Matthew Robinson 2015
3
- class S2_Ajax_Class {
4
  /**
5
  Constructor
6
  */
@@ -31,19 +30,20 @@ class S2_Ajax_Class {
31
  function add_ajax() {
32
  // enqueue the jQuery script we need and let WordPress handle the dependencies
33
  wp_enqueue_script( 'jquery-ui-dialog' );
34
- $css = apply_filters( 's2_jqueryui_css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-darkness/jquery-ui.css' );
35
  if ( is_ssl() ) {
36
  $css = str_replace( 'http:', 'https:', $css );
37
  }
38
  wp_register_style( 'jquery-ui-style', $css );
39
  wp_enqueue_style( 'jquery-ui-style' );
40
- wp_register_script( 's2_ajax', S2URL . 'include/s2_ajax' . $this->script_debug . '.js', array(), '1.0' );
41
  $translation_array = array(
42
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
43
  'title' => __( 'Subscribe to this blog', 'subscribe2' ),
 
44
  );
45
- wp_localize_script( 's2_ajax', 's2_script_strings', $translation_array );
46
- wp_enqueue_script( 's2_ajax' );
47
  } // end add_ajax()
48
 
49
  /**
@@ -60,13 +60,17 @@ class S2_Ajax_Class {
60
  $content = $s2_frontend->shortcode( $atts );
61
  $content = apply_filters( 's2_ajax_form', $content );
62
  echo $content;
63
- wp_die();
64
  } // end s2_ajax_handler()
65
 
66
  /**
67
  Ajax submit handler
68
  */
69
  function s2_ajax_submit_handler() {
 
 
 
 
70
  $data = $_POST['data'];
71
  if ( ( isset( $data['firstname'] ) && '' !== $data['firstname'] ) || ( isset( $data['lastname'] ) && '' !== $data['lastname'] ) || ( isset( $data['uri'] ) && 'http://' !== $data['uri'] ) ) {
72
  // looks like some invisible-to-user fields were changed; falsely report success
@@ -79,23 +83,19 @@ class S2_Ajax_Class {
79
  $s2_frontend->ip = $data['ip'];
80
  if ( ! is_email( $s2_frontend->email ) ) {
81
  echo '<p>' . __( 'Sorry, but that does not look like an email address to me.', 'subscribe2' ) . '</p>';
82
- wp_die();
83
  } elseif ( $s2_frontend->is_barred( $s2_frontend->email ) ) {
84
  echo '<p>' . __( 'Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2' ) . '</p>';
85
- wp_die();
86
  } else {
87
  if ( is_int( $s2_frontend->lockout ) && $s2_frontend->lockout > 0 ) {
88
  $date = date( 'H:i:s.u', $s2_frontend->lockout );
89
  $ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $s2_frontend->public WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
90
  if ( in_array( $s2_frontend->ip, $ips ) ) {
91
  echo '<p>' . __( 'Slow down, you move too fast.', 'subscribe2' ) . '</p>';
92
- wp_die();
93
  }
94
  }
95
  $check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email = %s", $s2_frontend->email ) );
96
  if ( null !== $check ) {
97
  printf( __( 'To manage your subscription options please <a href="%1$s">login.</a>', 'subscribe2' ), get_option( 'siteurl' ) . '/wp-login.php' );
98
- wp_die();
99
  }
100
  if ( 'subscribe' === $data['button'] ) {
101
  if ( '1' !== $s2_frontend->is_public( $s2_frontend->email ) ) {
@@ -111,7 +111,6 @@ class S2_Ajax_Class {
111
  // they're already subscribed
112
  echo '<p>' . __( 'That email address is already subscribed.', 'subscribe2' ) . '</p>';
113
  }
114
- wp_die();
115
  } elseif ( 'unsubscribe' === $data['button'] ) {
116
  if ( false === $s2_frontend->is_public( $s2_frontend->email ) ) {
117
  echo '<p>' . __( 'That email address is not subscribed.', 'subscribe2' ) . '</p>';
@@ -123,7 +122,6 @@ class S2_Ajax_Class {
123
  echo '<p>' . __( 'Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2' ) . '</p>';
124
  }
125
  }
126
- wp_die();
127
  }
128
  }
129
  wp_die();
1
  <?php
2
+ class S2_Ajax {
 
3
  /**
4
  Constructor
5
  */
30
  function add_ajax() {
31
  // enqueue the jQuery script we need and let WordPress handle the dependencies
32
  wp_enqueue_script( 'jquery-ui-dialog' );
33
+ $css = apply_filters( 's2_jqueryui_css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-darkness/jquery-ui.css' );
34
  if ( is_ssl() ) {
35
  $css = str_replace( 'http:', 'https:', $css );
36
  }
37
  wp_register_style( 'jquery-ui-style', $css );
38
  wp_enqueue_style( 'jquery-ui-style' );
39
+ wp_register_script( 's2-ajax', S2URL . 'include/s2-ajax' . $this->script_debug . '.js', array(), '1.2' );
40
  $translation_array = array(
41
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
42
  'title' => __( 'Subscribe to this blog', 'subscribe2' ),
43
+ 'nonce' => wp_create_nonce( 's2_ajax_form_nonce' ),
44
  );
45
+ wp_localize_script( 's2-ajax', 's2_ajax_script_strings', $translation_array );
46
+ wp_enqueue_script( 's2-ajax' );
47
  } // end add_ajax()
48
 
49
  /**
60
  $content = $s2_frontend->shortcode( $atts );
61
  $content = apply_filters( 's2_ajax_form', $content );
62
  echo $content;
63
+ exit();
64
  } // end s2_ajax_handler()
65
 
66
  /**
67
  Ajax submit handler
68
  */
69
  function s2_ajax_submit_handler() {
70
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 's2_ajax_form_nonce' ) ) {
71
+ echo '<p>' . __( 'There was an error validating your request. Please try again later.', 'subscribe2' ) . '</p>';
72
+ wp_die();
73
+ }
74
  $data = $_POST['data'];
75
  if ( ( isset( $data['firstname'] ) && '' !== $data['firstname'] ) || ( isset( $data['lastname'] ) && '' !== $data['lastname'] ) || ( isset( $data['uri'] ) && 'http://' !== $data['uri'] ) ) {
76
  // looks like some invisible-to-user fields were changed; falsely report success
83
  $s2_frontend->ip = $data['ip'];
84
  if ( ! is_email( $s2_frontend->email ) ) {
85
  echo '<p>' . __( 'Sorry, but that does not look like an email address to me.', 'subscribe2' ) . '</p>';
 
86
  } elseif ( $s2_frontend->is_barred( $s2_frontend->email ) ) {
87
  echo '<p>' . __( 'Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2' ) . '</p>';
 
88
  } else {
89
  if ( is_int( $s2_frontend->lockout ) && $s2_frontend->lockout > 0 ) {
90
  $date = date( 'H:i:s.u', $s2_frontend->lockout );
91
  $ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $s2_frontend->public WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
92
  if ( in_array( $s2_frontend->ip, $ips ) ) {
93
  echo '<p>' . __( 'Slow down, you move too fast.', 'subscribe2' ) . '</p>';
 
94
  }
95
  }
96
  $check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email = %s", $s2_frontend->email ) );
97
  if ( null !== $check ) {
98
  printf( __( 'To manage your subscription options please <a href="%1$s">login.</a>', 'subscribe2' ), get_option( 'siteurl' ) . '/wp-login.php' );
 
99
  }
100
  if ( 'subscribe' === $data['button'] ) {
101
  if ( '1' !== $s2_frontend->is_public( $s2_frontend->email ) ) {
111
  // they're already subscribed
112
  echo '<p>' . __( 'That email address is already subscribed.', 'subscribe2' ) . '</p>';
113
  }
 
114
  } elseif ( 'unsubscribe' === $data['button'] ) {
115
  if ( false === $s2_frontend->is_public( $s2_frontend->email ) ) {
116
  echo '<p>' . __( 'That email address is not subscribed.', 'subscribe2' ) . '</p>';
122
  echo '<p>' . __( 'Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2' ) . '</p>';
123
  }
124
  }
 
125
  }
126
  }
127
  wp_die();
classes/class-s2-core.php CHANGED
@@ -1,29 +1,39 @@
1
  <?php
2
- class s2class {
3
- // variables and constructor are declared at the end
4
  /**
5
  Load translations
6
  */
7
  function load_translations() {
8
- load_plugin_textdomain('subscribe2', false, S2DIR);
9
- load_plugin_textdomain('subscribe2', false, S2DIR . "languages/");
10
- $mofile = WP_LANG_DIR . '/subscribe2-' . apply_filters('plugin_locale', get_locale(), 'subscribe2') . '.mo';
11
- load_textdomain('subscribe2', $mofile);
12
  } // end load_translations()
13
 
14
- /* ===== Install, upgrade, reset ===== */
15
  /**
16
  Install our table
17
  */
18
  function install() {
 
19
  // load our translations and strings
20
  $this->load_translations();
21
 
22
  // include upgrade-functions for maybe_create_table;
23
- if ( !function_exists('maybe_create_table') ) {
24
- require_once(ABSPATH . 'wp-admin/install-helper.php');
 
 
 
 
 
 
 
 
25
  }
26
- $date = date('Y-m-d');
 
27
  $sql = "CREATE TABLE $this->public (
28
  id int(11) NOT NULL auto_increment,
29
  email varchar(64) NOT NULL default '',
@@ -34,105 +44,29 @@ class s2class {
34
  conf_date DATE,
35
  conf_time TIME,
36
  conf_ip char(64),
37
- PRIMARY KEY (id) )";
38
 
39
  // create the table, as needed
40
- maybe_create_table($this->public, $sql);
 
 
 
 
 
41
 
42
  // create table entries for registered users
43
- $users = $this->get_all_registered('ID');
44
- if ( !empty($users) ) {
45
  foreach ( $users as $user_ID ) {
46
- $check_format = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true);
47
- if ( empty($check_format) ) {
48
  // no prior settings so create them
49
- $this->register($user_ID);
50
  }
51
  }
52
  }
53
-
54
- // safety check if options exist and if not create them
55
- if ( !is_array($this->subscribe2_options) ) {
56
- $this->reset();
57
- }
58
  } // end install()
59
 
60
- /**
61
- Upgrade function for the database and settings
62
- */
63
- function upgrade() {
64
- // load our translations and strings
65
- $this->load_translations();
66
-
67
- require(S2PATH . "classes/class-s2-upgrade.php");
68
- global $s2_upgrade;
69
- $s2_upgrade = new s2class_upgrade;
70
-
71
- // ensure that the options are in the database
72
- require(S2PATH . "include/options.php");
73
- // catch older versions that didn't use serialised options
74
- if ( !isset($this->subscribe2_options['version']) ) {
75
- $this->subscribe2_options['version'] = '2.0';
76
- }
77
-
78
- // let's take the time to ensure that database entries exist for all registered users
79
- $s2_upgrade->upgrade_core();
80
- if ( version_compare($this->subscribe2_options['version'], '2.3', '<') ) {
81
- $s2_upgrade->upgrade23();
82
- $this->subscribe2_options['version'] = '2.3';
83
- update_option('subscribe2_options', $this->subscribe2_options);
84
- }
85
- if ( version_compare($this->subscribe2_options['version'], '5.1', '<') ) {
86
- $s2_upgrade->upgrade51();
87
- $this->subscribe2_options['version'] = '5.1';
88
- update_option('subscribe2_options', $this->subscribe2_options);
89
- }
90
- if ( version_compare($this->subscribe2_options['version'], '5.6', '<') ) {
91
- $s2_upgrade->upgrade56();
92
- $this->subscribe2_options['version'] = '5.6';
93
- update_option('subscribe2_options', $this->subscribe2_options);
94
- }
95
- if ( version_compare($this->subscribe2_options['version'], '5.9', '<') ) {
96
- $s2_upgrade->upgrade59();
97
- $this->subscribe2_options['version'] = '5.9';
98
- update_option('subscribe2_options', $this->subscribe2_options);
99
- }
100
- if ( version_compare($this->subscribe2_options['version'], '6.4', '<') ) {
101
- $s2_upgrade->upgrade64();
102
- $this->subscribe2_options['version'] = '6.4';
103
- update_option('subscribe2_options', $this->subscribe2_options);
104
- }
105
- if ( version_compare($this->subscribe2_options['version'], '7.0', '<') ) {
106
- $s2_upgrade->upgrade70();
107
- $this->subscribe2_options['version'] = '7.0';
108
- update_option('subscribe2_options', $this->subscribe2_options);
109
- }
110
- if ( version_compare($this->subscribe2_options['version'], '8.5', '<') ) {
111
- $s2_upgrade->upgrade85();
112
- $this->subscribe2_options['version'] = '8.5';
113
- update_option('subscribe2_options', $this->subscribe2_options);
114
- }
115
- if ( version_compare($this->subscribe2_options['version'], '8.6', '<') ) {
116
- $s2_upgrade->upgrade86();
117
- $this->subscribe2_options['version'] = '8.6';
118
- update_option('subscribe2_options', $this->subscribe2_options);
119
- }
120
- if ( version_compare($this->subscribe2_options['version'], '8.8', '<') ) {
121
- $s2_upgrade->upgrade88();
122
- $this->subscribe2_options['version'] = '8.8';
123
- update_option('subscribe2_options', $this->subscribe2_options);
124
- }
125
- if ( version_compare($this->subscribe2_options['version'], '9.5', '<') ) {
126
- $s2_upgrade->upgrade95();
127
- $this->subscribe2_options['version'] = '9.5';
128
- }
129
-
130
- $this->subscribe2_options['version'] = S2VERSION;
131
- update_option('subscribe2_options', $this->subscribe2_options);
132
-
133
- return;
134
- } // end upgrade()
135
-
136
  /**
137
  Reset our options
138
  */
@@ -140,98 +74,100 @@ class s2class {
140
  // load our translations and strings
141
  $this->load_translations();
142
 
143
- delete_option('subscribe2_options');
144
- wp_clear_scheduled_hook('s2_digest_cron');
145
- unset($this->subscribe2_options);
146
- require(S2PATH . "include/options.php");
147
  $this->subscribe2_options['version'] = S2VERSION;
148
- update_option('subscribe2_options', $this->subscribe2_options);
149
  } // end reset()
150
 
151
- /* ===== mail handling ===== */
152
  /**
153
  Performs string substitutions for subscribe2 mail tags
154
  */
155
- function substitute($string = '') {
156
- if ( '' == $string ) {
157
  return;
158
  }
159
- $string = str_replace("{BLOGNAME}", html_entity_decode(get_option('blogname'), ENT_QUOTES), $string);
160
- $string = str_replace("{BLOGLINK}", get_option('home'), $string);
161
- $string = str_replace("{TITLE}", stripslashes($this->post_title), $string);
162
- $link = "<a href=\"" . $this->get_tracking_link($this->permalink) . "\">" . $this->get_tracking_link($this->permalink) . "</a>";
163
- $string = str_replace("{PERMALINK}", $link, $string);
164
- if ( strstr($string, "{TINYLINK}") ) {
165
- $tinylink = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode($this->get_tracking_link($this->permalink)));
166
- if ( $tinylink !== 'Error' && $tinylink != false ) {
167
- $tlink = "<a href=\"" . $tinylink . "\">" . $tinylink . "</a>";
168
- $string = str_replace("{TINYLINK}", $tlink, $string);
 
 
169
  } else {
170
- $string = str_replace("{TINYLINK}", $link, $string);
171
  }
172
  }
173
- $string = str_replace("{DATE}", $this->post_date, $string);
174
- $string = str_replace("{TIME}", $this->post_time, $string);
175
- $string = str_replace("{MYNAME}", stripslashes($this->myname), $string);
176
- $string = str_replace("{EMAIL}", $this->myemail, $string);
177
- $string = str_replace("{AUTHORNAME}", stripslashes($this->authorname), $string);
178
- $string = str_replace("{CATS}", $this->post_cat_names, $string);
179
- $string = str_replace("{TAGS}", $this->post_tag_names, $string);
180
- $string = str_replace("{COUNT}", $this->post_count, $string);
181
 
182
- return apply_filters('s2_custom_keywords', $string);
183
  } // end substitute()
184
 
185
  /**
186
  Delivers email to recipients in HTML or plaintext
187
  */
188
- function mail($recipients = array(), $subject = '', $message = '', $type = 'text', $attachments = array()) {
189
- if ( empty($recipients) || '' == $message ) { return; }
190
 
191
  // Replace any escaped html symbols in subject then apply filter
192
- $subject = strip_tags(html_entity_decode($subject, ENT_QUOTES));
193
- $subject = apply_filters('s2_email_subject', $subject);
194
-
195
- if ( 'html' == $type ) {
196
- $headers = $this->headers('html', $attachments);
197
- if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
198
- $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>", $subject, $message);
 
199
  } else {
200
- $mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>", $subject, $message);
201
  }
202
  } else {
203
- $headers = $this->headers('text', $attachments);
204
- $message = html_entity_decode($message, ENT_NOQUOTES, 'UTF-8');
205
- $message = wordwrap(strip_tags($message), $this->word_wrap, "\n");
206
- $mailtext = apply_filters('s2_plain_email', $message);
207
  }
208
 
209
  // Construct BCC headers for sending or send individual emails
210
  $bcc = '';
211
- natcasesort($recipients);
212
- if ( function_exists('wpmq_mail') || $this->subscribe2_options['bcclimit'] == 1 || count($recipients) == 1 ) {
213
  // BCCLimit is 1 so send individual emails or we only have 1 recipient
214
  foreach ( $recipients as $recipient ) {
215
- $recipient = trim($recipient);
216
  // sanity check -- make sure we have a valid email
217
- if ( !is_email($recipient) || empty($recipient) ) { continue; }
218
  // Use the mail queue provided we are not sending a preview
219
- if ( function_exists('wpmq_mail') && !$this->preview_email ) {
220
- @wp_mail($recipient, $subject, $mailtext, $headers, $attachments, 0);
221
  } else {
222
- @wp_mail($recipient, $subject, $mailtext, $headers, $attachments);
223
  }
224
  }
225
  return true;
226
- } elseif ( $this->subscribe2_options['bcclimit'] == 0 ) {
227
- // we're not using BCCLimit
228
  foreach ( $recipients as $recipient ) {
229
- $recipient = trim($recipient);
230
  // sanity check -- make sure we have a valid email
231
- if ( !is_email($recipient) ) { continue; }
232
  // and NOT the sender's email, since they'll get a copy anyway
233
- if ( !empty($recipient) && $this->myemail != $recipient ) {
234
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
235
  // Bcc Headers now constructed by phpmailer class
236
  }
237
  }
@@ -241,15 +177,15 @@ class s2class {
241
  $count = 1;
242
  $batch = array();
243
  foreach ( $recipients as $recipient ) {
244
- $recipient = trim($recipient);
245
  // sanity check -- make sure we have a valid email
246
- if ( !is_email($recipient) ) { continue; }
247
  // and NOT the sender's email, since they'll get a copy anyway
248
- if ( !empty($recipient) && $this->myemail != $recipient ) {
249
- ('' == $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
250
  // Bcc Headers now constructed by phpmailer class
251
  }
252
- if ( $this->subscribe2_options['bcclimit'] == $count ) {
253
  $count = 0;
254
  $batch[] = $bcc;
255
  $bcc = '';
@@ -257,21 +193,24 @@ class s2class {
257
  $count++;
258
  }
259
  // add any partially completed batches to our batch array
260
- if ( '' != $bcc ) {
261
  $batch[] = $bcc;
262
  }
263
  }
264
  // rewind the array, just to be safe
265
- reset($recipients);
 
 
 
266
 
267
  // actually send mail
268
- if ( isset($batch) && !empty($batch) ) {
269
  foreach ( $batch as $bcc ) {
270
  $newheaders = $headers . "$bcc\n";
271
- $status = @wp_mail($this->myemail, $subject, $mailtext, $newheaders, $attachments);
272
  }
273
  } else {
274
- $status = @wp_mail($this->myemail, $subject, $mailtext, $headers, $attachments);
275
  }
276
  return $status;
277
  } // end mail()
@@ -279,23 +218,23 @@ class s2class {
279
  /**
280
  Construct standard set of email headers
281
  */
282
- function headers($type = 'text', $attachments = array()) {
283
- if ( empty($this->myname) || empty($this->myemail) ) {
284
- if ( $this->subscribe2_options['sender'] == 'blogname' ) {
285
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
286
- $this->myemail = get_option('admin_email');
287
  } else {
288
- $admin = $this->get_userdata($this->subscribe2_options['sender']);
289
- $this->myname = html_entity_decode($admin->display_name, ENT_QUOTES);
290
  $this->myemail = $admin->user_email;
291
  // fail safe to ensure sender details are not empty
292
- if ( empty($this->myname) ) {
293
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
294
  }
295
- if ( empty($this->myemail) ) {
296
  // Get the site domain and get rid of www.
297
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
298
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
299
  $sitename = substr( $sitename, 4 );
300
  }
301
  $this->myemail = 'wordpress@' . $sitename;
@@ -303,51 +242,58 @@ class s2class {
303
  }
304
  }
305
 
306
- $char_set = get_option('blog_charset');
307
- if ( function_exists('mb_encode_mimeheader') ) {
308
- $header['From'] = mb_encode_mimeheader($this->myname, $char_set, 'Q') . " <" . $this->myemail . ">";
309
- $header['Reply-To'] = mb_encode_mimeheader($this->myname, $char_set, 'Q') . " <" . $this->myemail . ">";
310
  } else {
311
- $header['From'] = $this->myname. " <" . $this->myemail . ">";
312
- $header['Reply-To'] = $this->myname . " <" . $this->myemail . ">";
313
  }
314
- $header['Return-path'] = "<" . $this->myemail . ">";
315
- $header['Precedence'] = "list\nList-Id: " . html_entity_decode(get_option('blogname'), ENT_QUOTES) . "";
316
- if ( empty($attachments) && $type == 'html' ) {
317
  // To send HTML mail, the Content-Type header must be set
318
- $header['Content-Type'] = get_option('html_type') . "; charset=\"". $char_set . "\"";
319
- } elseif ( empty($attachments) && $type == 'text' ) {
320
- $header['Content-Type'] = "text/plain; charset=\"". $char_set . "\"";
321
  }
322
 
323
  // apply header filter to allow on-the-fly amendments
324
- $header = apply_filters('s2_email_headers', $header);
325
  // collapse the headers using $key as the header name
326
  foreach ( $header as $key => $value ) {
327
- $headers[$key] = $key . ": " . $value;
328
  }
329
- $headers = implode("\n", $headers);
330
  $headers .= "\n";
331
 
332
  return $headers;
333
  } // end headers()
334
 
 
 
 
 
 
 
 
335
  /**
336
  Function to add UTM tracking details to links
337
  */
338
- function get_tracking_link($link) {
339
- if ( empty($link) ) { return; }
340
- if ( !empty($this->subscribe2_options['tracking']) ) {
341
- (strpos($link, '?') > 0) ? $delimiter .= '&' : $delimiter = '?';
342
  $tracking = $this->subscribe2_options['tracking'];
343
- if ( strpos($tracking, "{ID}") ) {
344
- $id = url_to_postid($link);
345
- $tracking = str_replace("{ID}", $id, $tracking);
346
  }
347
- if ( strpos($tracking, "{TITLE}") ) {
348
- $id = url_to_postid($link);
349
- $title = urlencode(htmlentities(get_the_title($id),1));
350
- $tracking = str_replace("{TITLE}", $title, $tracking);
351
  }
352
  return $link . $delimiter . $tracking;
353
  } else {
@@ -358,53 +304,60 @@ class s2class {
358
  /**
359
  Sends an email notification of a new post
360
  */
361
- function publish($post, $preview = '') {
362
- if ( !$post ) { return $post; }
363
 
364
- if ( $this->s2_mu && !apply_filters('s2_allow_site_switching', $this->site_switching) ) {
365
  global $switched;
366
  if ( $switched ) { return; }
367
  }
368
 
369
- if ( $preview == '' ) {
370
  // we aren't sending a Preview to the current user so carry out checks
371
- $s2mail = get_post_meta($post->ID, '_s2mail', true);
372
- if ( (isset($_POST['s2_meta_field']) && $_POST['s2_meta_field'] == 'no') || strtolower(trim($s2mail)) == 'no' ) { return $post; }
373
 
374
  // are we doing daily digests? If so, don't send anything now
375
- if ( $this->subscribe2_options['email_freq'] != 'never' ) { return $post; }
376
 
377
  // is the current post of a type that should generate a notification email?
378
  // uses s2_post_types filter to allow for custom post types in WP 3.0
379
- if ( $this->subscribe2_options['pages'] == 'yes' ) {
380
- $s2_post_types = array('page', 'post');
381
  } else {
382
- $s2_post_types = array('post');
383
  }
384
- $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
385
- if ( !in_array($post->post_type, $s2_post_types) ) {
386
  return $post;
387
  }
388
 
389
  // Are we sending notifications for password protected posts?
390
- if ( $this->subscribe2_options['password'] == "no" && $post->post_password != '' ) {
391
  return $post;
392
  }
393
 
394
  // Is the post assigned to a format for which we should not be sending posts
395
- $post_format = get_post_format($post->ID);
396
- $excluded_formats = explode(',', $this->subscribe2_options['exclude_formats']);
397
- if ( $post_format !== false && in_array($post_format, $excluded_formats) ) {
 
 
 
 
 
 
 
 
 
398
  return $post;
399
  }
400
 
401
- $s2_taxonomies = apply_filters('s2_taxonomies', array('category'));
402
- $post_cats = wp_get_object_terms($post->ID, $s2_taxonomies, array('fields' => 'ids'));
403
  $check = false;
404
  // is the current post assigned to any categories
405
  // which should not generate a notification email?
406
- foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
407
- if ( in_array($cat, $post_cats) ) {
408
  $check = true;
409
  }
410
  }
@@ -412,7 +365,7 @@ class s2class {
412
  if ( $check ) {
413
  // hang on -- can registered users subscribe to
414
  // excluded categories?
415
- if ( '0' == $this->subscribe2_options['reg_override'] ) {
416
  // nope? okay, let's leave
417
  return $post;
418
  }
@@ -420,238 +373,218 @@ class s2class {
420
 
421
  // Are we sending notifications for Private posts?
422
  // Action is added if we are, but double check option and post status
423
- if ( $this->subscribe2_options['private'] == "yes" && $post->post_status == 'private' ) {
424
  // don't send notification to public users
425
  $check = true;
426
  }
427
 
428
  // lets collect our subscribers
429
  $public = array();
430
- if ( !$check ) {
431
  // if this post is assigned to an excluded
432
  // category, or is a private post then
433
  // don't send public subscribers a notification
434
  $public = $this->get_public();
435
  }
436
- if ( $post->post_type == 'page' ) {
437
- $post_cats_string = implode(',', get_all_category_ids());
438
  } else {
439
- $post_cats_string = implode(',', $post_cats);
440
  }
441
- $registered = $this->get_registered("cats=$post_cats_string");
442
 
443
  // do we have subscribers?
444
- if ( empty($public) && empty($registered) ) {
445
  // if not, no sense doing anything else
446
  return $post;
447
  }
448
  } else {
449
  // make sure we prime the taxonomy variable for preview posts
450
- $s2_taxonomies = apply_filters('s2_taxonomies', array('category'));
451
  }
452
 
453
  // we set these class variables so that we can avoid
454
  // passing them in function calls a little later
455
- $this->post_title = "<a href=\"" . get_permalink($post->ID) . "\">" . html_entity_decode($post->post_title, ENT_QUOTES) . "</a>";
456
- $this->permalink = get_permalink($post->ID);
457
- $this->post_date = get_the_time(get_option('date_format'), $post);
458
- $this->post_time = get_the_time('', $post);
 
459
 
460
- $author = get_userdata($post->post_author);
461
- $this->authorname = html_entity_decode(apply_filters('the_author', $author->display_name), ENT_QUOTES);
462
 
463
  // do we send as admin, or post author?
464
- if ( 'author' == $this->subscribe2_options['sender'] ) {
465
  // get author details
466
  $user = &$author;
467
  $this->myemail = $user->user_email;
468
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
469
- } elseif ( 'blogname' == $this->subscribe2_options['sender'] ) {
470
- $this->myemail = get_option('admin_email');
471
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
472
  } else {
473
  // get admin details
474
- $user = $this->get_userdata($this->subscribe2_options['sender']);
475
  $this->myemail = $user->user_email;
476
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
477
  }
478
 
479
- $this->post_cat_names = implode(', ', wp_get_object_terms($post->ID, $s2_taxonomies, array('fields' => 'names')));
480
- $this->post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
 
 
 
 
481
 
482
  // Get email subject
483
- $subject = html_entity_decode(stripslashes(wp_kses($this->substitute($this->subscribe2_options['notification_subject']), '')));
484
  // Get the message template
485
- $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
486
- $mailtext = stripslashes($this->substitute($mailtext));
487
 
488
  $plaintext = $post->post_content;
489
- $plaintext = strip_shortcodes($plaintext);
490
 
491
- $plaintext = preg_replace('|<s[^>]*>(.*)<\/s>|Ui','', $plaintext);
492
- $plaintext = preg_replace('|<strike[^>]*>(.*)<\/strike>|Ui','', $plaintext);
493
- $plaintext = preg_replace('|<del[^>]*>(.*)<\/del>|Ui','', $plaintext);
494
  $excerpttext = $plaintext;
495
 
496
- if ( strstr($mailtext, "{REFERENCELINKS}") ) {
497
- $mailtext = str_replace("{REFERENCELINKS}", '', $mailtext);
498
  $plaintext_links = '';
499
  $i = 0;
500
- while ( preg_match('|<a([^>]*)>(.*)<\/a>|Ui', $plaintext, $matches) ) {
501
- if ( preg_match('|href="([^"]*)"|', $matches[1], $link_matches) ){
502
  $plaintext_links .= sprintf( "[%d] %s\r\n", ++$i, $link_matches[1] );
503
- $link_replacement = sprintf( "%s [%d]", $matches[2], $i );
504
  } else {
505
  $link_replacement = $matches[2];
506
  }
507
- $plaintext = preg_replace('|<a[^>]*>(.*)<\/a>|Ui', $link_replacement, $plaintext, 1);
508
  }
509
  }
510
 
511
- $plaintext = trim(strip_tags($plaintext));
512
 
513
  if ( isset( $plaintext_links ) && '' !== $plaintext_links ) {
514
- $plaintext .= "\r\n\r\n" . trim($plaintext_links);
515
  }
516
 
517
  $gallid = '[gallery id="' . $post->ID . '"';
518
- $content = str_replace('[gallery', $gallid, $post->post_content);
519
 
520
  // remove the autoembed filter to remove iframes from notification emails
521
- if ( get_option('embed_autourls') ) {
522
  global $wp_embed;
523
- $priority = has_filter('the_content', array(&$wp_embed, 'autoembed'));
524
- if ( $priority !== false ) {
525
- remove_filter('the_content', array(&$wp_embed, 'autoembed'), $priority);
526
  }
527
  }
528
 
529
- $content = apply_filters('the_content', $content);
530
- $content = str_replace("]]>", "]]&gt", $content);
531
 
532
- $excerpt = trim($post->post_excerpt);
533
- if ( '' == $excerpt ) {
534
  // no excerpt, is there a <!--more--> ?
535
- if ( false !== strpos($excerpttext, '<!--more-->') ) {
536
- list($excerpt, $more) = explode('<!--more-->', $excerpttext, 2);
537
  // strip tags and trailing whitespace
538
- $excerpt = trim(strip_tags($excerpt));
539
  } else {
540
  // no <!--more-->, so grab the first 55 words
541
- $excerpt = trim(strip_tags($excerpttext));
542
- $words = explode(' ', $excerpt, $this->excerpt_length + 1);
543
- if (count($words) > $this->excerpt_length) {
544
- array_pop($words);
545
- array_push($words, '[...]');
546
- $excerpt = implode(' ', $words);
547
  }
548
  }
549
  }
550
- $html_excerpt = trim($post->post_excerpt);
551
- if ( '' == $html_excerpt ) {
552
  // no excerpt, is there a <!--more--> ?
553
- if ( false !== strpos($content, '<!--more-->') ) {
554
- list($html_excerpt, $more) = explode('<!--more-->', $content, 2);
555
  // balance HTML tags and then strip leading and trailing whitespace
556
- $html_excerpt = trim(balanceTags($html_excerpt, true));
557
  } else {
558
  // no <!--more-->, so grab the first 55 words
559
- $words = explode(' ', $content, $this->excerpt_length + 1);
560
- if (count($words) > $this->excerpt_length) {
561
- array_pop($words);
562
- array_push($words, '[...]');
563
- $html_excerpt = implode(' ', $words);
564
  // balance HTML tags and then strip leading and trailing whitespace
565
- $html_excerpt = trim(balanceTags($html_excerpt, true));
566
  } else {
567
  $html_excerpt = $content;
568
  }
569
  }
570
  }
571
 
572
- // maybe add social media sharing buttons
573
- $social = apply_filters('s2_social_links', array('facebook', 'twitter'));
574
- if ( !empty($social) ) {
575
- $social_buttons = $this->social_buttons($social);
576
- $content .= $social_buttons;
577
- $html_excerpt .= $social_buttons;
578
- }
579
-
580
  // remove excess white space from with $excerpt and $plaintext
581
- $excerpt = preg_replace('|[ ]+|', ' ', $excerpt);
582
- $plaintext = preg_replace('|[ ]+|', ' ', $plaintext);
583
 
584
  // prepare mail body texts
585
- $plain_excerpt_body = str_replace("{POST}", $excerpt, $mailtext);
586
- $plain_body = str_replace("{POST}", $plaintext, $mailtext);
587
- $html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
588
- $html_body = str_replace("{POST}", $content, $html_body);
589
- $html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
590
- $html_excerpt_body = str_replace("{POST}", $html_excerpt, $html_excerpt_body);
591
-
592
- if ( $preview != '' ) {
593
  $this->myemail = $preview;
594
- $this->myname = __('Plain Text Excerpt Preview', 'subscribe2');
595
- $this->mail(array($preview), $subject, $plain_excerpt_body);
596
- $this->myname = __('Plain Text Full Preview', 'subscribe2');
597
- $this->mail(array($preview), $subject, $plain_body);
598
- $this->myname = __('HTML Excerpt Preview', 'subscribe2');
599
- $this->mail(array($preview), $subject, $html_excerpt_body, 'html');
600
- $this->myname = __('HTML Full Preview', 'subscribe2');
601
- $this->mail(array($preview), $subject, $html_body, 'html');
602
  } else {
603
  // Registered Subscribers first
604
  // first we send plaintext summary emails
605
- $recipients = $this->get_registered("cats=$post_cats_string&format=excerpt&author=$post->post_author");
606
- $recipients = apply_filters('s2_send_plain_excerpt_subscribers', $recipients, $post->ID);
607
- $this->mail($recipients, $subject, $plain_excerpt_body);
608
 
609
  // next we send plaintext full content emails
610
- $recipients = $this->get_registered("cats=$post_cats_string&format=post&author=$post->post_author");
611
- $recipients = apply_filters('s2_send_plain_fullcontent_subscribers', $recipients, $post->ID);
612
- $this->mail($recipients, $subject, $plain_body);
613
 
614
  // next we send html excerpt content emails
615
- $recipients = $this->get_registered("cats=$post_cats_string&format=html_excerpt&author=$post->post_author");
616
- $recipients = apply_filters('s2_send_html_excerpt_subscribers', $recipients, $post->ID);
617
- $this->mail($recipients, $subject, $html_excerpt_body, 'html');
618
 
619
  // next we send html full content emails
620
- $recipients = $this->get_registered("cats=$post_cats_string&format=html&author=$post->post_author");
621
- $recipients = apply_filters('s2_send_html_fullcontent_subscribers', $recipients, $post->ID);
622
- $this->mail($recipients, $subject, $html_body, 'html');
623
 
624
  // and finally we send to Public Subscribers
625
- $recipients = apply_filters('s2_send_public_subscribers', $public, $post->ID);
626
- $this->mail($recipients, $subject, $plain_excerpt_body, 'text');
627
  }
628
  } // end publish()
629
 
630
- /**
631
- Function to create social network sharing buttons
632
- */
633
- function social_buttons($social) {
634
- $social_buttons = '';
635
- if ( in_array('facebook', $social) ) {
636
- $social_buttons .= '<a href="http://api.addthis.com/oexchange/0.8/forward/facebook/offer?url=' . urlencode($this->permalink) . '" target="_blank" ><img src="http://cache.addthiscdn.com/icons/v1/thumbs/facebook.gif" border="0" style="margin: 1px;" alt="' . __('Like', 'subscribe2') . '" /></a>';
637
- }
638
- if ( in_array('twitter', $social) ) {
639
- $social_buttons .= '<a href="http://api.addthis.com/oexchange/0.8/forward/twitter/offer?url=' . urlencode($this->permalink) . '&amp;title=' . urlencode(strip_tags($this->post_title)) . '" target="_blank" ><img src="http://cache.addthiscdn.com/icons/v1/thumbs/twitter.gif" border="0" style="margin: 1px;" alt="' . __('Tweet', 'subscribe2') . '" /></a>';
640
- }
641
- if ( in_array('google', $social) ) {
642
- $social_buttons .= '<a href="http://api.addthis.com/oexchange/0.8/forward/google_plusone_share/offer?url=' . urlencode($this->permalink) . '&amp;title=' . urlencode(strip_tags($this->post_title)) . '" target="_blank" ><img src="http://cache.addthiscdn.com/icons/v1/thumbs/google_plusone.gif" border="0" style="margin: 1px;" alt="' . __('Google+', 'subscribe2') . '" /></a>';
643
- }
644
- return apply_filters('s2_social_buttons', $social_buttons);
645
- } // end social_buttons()
646
-
647
  /**
648
  Send confirmation email to a public subscriber
649
  */
650
- function send_confirm($what = '', $is_remind = false) {
651
- if ( $this->filtered == 1 ) { return true; }
652
- if ( !$this->email || !$what ) { return false; }
653
- $id = $this->get_id($this->email);
654
- if ( !$id ) {
655
  return false;
656
  }
657
 
@@ -660,59 +593,59 @@ class s2class {
660
  // HASH = wp_hash of email address
661
  // ID = user's ID in the subscribe2 table
662
  // use home instead of siteurl incase index.php is not in core wordpress directory
663
- $link = apply_filters('s2_confirm_link', get_option('home')) . "/?s2=";
664
 
665
- if ( 'add' == $what ) {
666
  $link .= '1';
667
- } elseif ( 'del' == $what ) {
668
  $link .= '0';
669
  }
670
- $link .= wp_hash($this->email);
671
  $link .= $id;
672
 
673
  // sort the headers now so we have all substitute information
674
  $mailheaders = $this->headers();
675
 
676
- if ( $is_remind == true ) {
677
- $body = $this->substitute(stripslashes($this->subscribe2_options['remind_email']));
678
- $subject = $this->substitute(stripslashes($this->subscribe2_options['remind_subject']));
679
  } else {
680
- $body = apply_filters('s2_confirm_email', stripslashes($this->subscribe2_options['confirm_email']), $what);
681
- $body = $this->substitute($body);
682
- if ( 'add' == $what ) {
683
- $body = str_replace("{ACTION}", $this->subscribe, $body);
684
- $subject = str_replace("{ACTION}", $this->subscribe, $this->subscribe2_options['confirm_subject']);
685
- } elseif ( 'del' == $what ) {
686
- $body = str_replace("{ACTION}", $this->unsubscribe, $body);
687
- $subject = str_replace("{ACTION}", $this->unsubscribe, $this->subscribe2_options['confirm_subject']);
688
  }
689
- $subject = html_entity_decode($this->substitute(stripslashes($subject)), ENT_QUOTES);
690
  }
691
 
692
- $body = str_replace("{LINK}", $link, $body);
693
 
694
- if ( $is_remind == true && function_exists('wpmq_mail') ) {
695
  // could be sending lots of reminders so queue them if wpmq is enabled
696
- @wp_mail($this->email, $subject, $body, $mailheaders, '', 0);
697
  } else {
698
- return @wp_mail($this->email, $subject, $body, $mailheaders);
699
  }
700
  } // end send_confirm()
701
 
702
- /* ===== Public Subscriber functions ===== */
703
  /**
704
  Return an array of all the public subscribers
705
  */
706
- function get_public($confirmed = 1) {
707
  global $wpdb;
708
- if ( 1 == $confirmed ) {
709
- if ( '' == $this->all_confirmed ) {
710
- $this->all_confirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='1'");
711
  }
712
  return $this->all_confirmed;
713
  } else {
714
- if ( '' == $this->all_unconfirmed ) {
715
- $this->all_unconfirmed = $wpdb->get_col("SELECT email FROM $this->public WHERE active='0'");
716
  }
717
  return $this->all_unconfirmed;
718
  }
@@ -721,52 +654,52 @@ class s2class {
721
  /**
722
  Given a public subscriber ID, returns the email address
723
  */
724
- function get_email($id = 0) {
725
  global $wpdb;
726
 
727
- if ( !$id ) {
728
  return false;
729
  }
730
- return $wpdb->get_var($wpdb->prepare("SELECT email FROM $this->public WHERE id=%d", $id));
731
  } // end get_email()
732
 
733
  /**
734
  Given a public subscriber email, returns the subscriber ID
735
  */
736
- function get_id($email = '') {
737
  global $wpdb;
738
 
739
- if ( !$email ) {
740
  return false;
741
  }
742
- return $wpdb->get_var($wpdb->prepare("SELECT id FROM $this->public WHERE email=%s", $email));
743
  } // end get_id()
744
 
745
  /**
746
  Add an public subscriber to the subscriber table
747
  If added by admin it is immediately confirmed, otherwise as unconfirmed
748
  */
749
- function add($email = '', $confirm = false) {
750
- if ( $this->filtered == 1 ) { return; }
751
  global $wpdb;
752
 
753
- if ( !is_email($email) ) { return false; }
754
 
755
- if ( false !== $this->is_public($email) ) {
756
  // is this an email for a registered user
757
- $check = $wpdb->get_var($wpdb->prepare("SELECT user_email FROM $wpdb->users WHERE user_email=%s", $this->email));
758
  if ( $check ) { return; }
759
  if ( $confirm ) {
760
- $wpdb->query($wpdb->prepare("UPDATE $this->public SET active='1', ip=%s WHERE CAST(email as binary)=%s", $this->ip, $email));
761
  } else {
762
- $wpdb->query($wpdb->prepare("UPDATE $this->public SET date=CURDATE(), time=CURTIME() WHERE CAST(email as binary)=%s", $email));
763
  }
764
  } else {
765
  if ( $confirm ) {
766
  global $current_user;
767
- $wpdb->query($wpdb->prepare("INSERT INTO $this->public (email, active, date, time, ip) VALUES (%s, %d, CURDATE(), CURTIME(), %s)", $email, 1, $current_user->user_login));
768
  } else {
769
- $wpdb->query($wpdb->prepare("INSERT INTO $this->public (email, active, date, time, ip) VALUES (%s, %d, CURDATE(), CURTIME(), %s)", $email, 0, $this->ip));
770
  }
771
  }
772
  } // end add()
@@ -774,73 +707,73 @@ class s2class {
774
  /**
775
  Remove a public subscriber user from the subscription table
776
  */
777
- function delete($email = '') {
778
  global $wpdb;
779
 
780
- if ( !is_email($email) ) { return false; }
781
- $wpdb->query($wpdb->prepare("DELETE FROM $this->public WHERE CAST(email as binary)=%s", $email));
782
  } // end delete()
783
 
784
  /**
785
  Toggle a public subscriber's status
786
  */
787
- function toggle($email = '') {
788
  global $wpdb;
789
 
790
- if ( '' == $email || !is_email($email) ) { return false; }
791
 
792
  // let's see if this is a public user
793
- $status = $this->is_public($email);
794
  if ( false === $status ) { return false; }
795
 
796
- if ( '0' == $status ) {
797
- $wpdb->query($wpdb->prepare("UPDATE $this->public SET active='1', conf_date=CURDATE(), conf_time=CURTIME(), conf_ip=%s WHERE CAST(email as binary)=%s", $this->ip, $email));
798
  } else {
799
- $wpdb->query($wpdb->prepare("UPDATE $this->public SET active='0', conf_date=CURDATE(), conf_time=CURTIME(), conf_ip=%s WHERE CAST(email as binary)=%s", $this->ip, $email));
800
  }
801
  } // end toggle()
802
 
803
  /**
804
  Send reminder email to unconfirmed public subscribers
805
  */
806
- function remind($emails = '') {
807
- if ( '' == $emails ) { return false; }
808
 
809
- $recipients = explode(",", $emails);
810
- if ( !is_array($recipients) ) { $recipients = (array)$recipients; }
811
  foreach ( $recipients as $recipient ) {
812
  $this->email = $recipient;
813
- $this->send_confirm('add', true);
814
  }
815
  } //end remind()
816
 
817
  /**
818
  Is the supplied email address a public subscriber?
819
  */
820
- function is_public($email = '') {
821
  global $wpdb;
822
 
823
- if ( '' == $email ) { return false; }
824
 
825
  // run the query and force case sensitivity
826
- $check = $wpdb->get_var($wpdb->prepare("SELECT active FROM $this->public WHERE CAST(email as binary)=%s", $email));
827
- if ( '0' == $check || '1' == $check ) {
828
  return $check;
829
  } else {
830
  return false;
831
  }
832
  } // end is_public()
833
 
834
- /* ===== Registered User and Subscriber functions ===== */
835
  /**
836
  Is the supplied email address a registered user of the blog?
837
  */
838
- function is_registered($email = '') {
839
  global $wpdb;
840
 
841
- if ( '' == $email ) { return false; }
842
 
843
- $check = $wpdb->get_var($wpdb->prepare("SELECT user_email FROM $wpdb->users WHERE user_email=%s", $email));
844
  if ( $check ) {
845
  return true;
846
  } else {
@@ -851,12 +784,12 @@ class s2class {
851
  /**
852
  Return Registered User ID from email
853
  */
854
- function get_user_id($email = '') {
855
  global $wpdb;
856
 
857
- if ( '' == $email ) { return false; }
858
 
859
- $id = $wpdb->get_var($wpdb->prepare("SELECT id FROM $wpdb->users WHERE user_email=%s", $email));
860
 
861
  return $id;
862
  } // end get_user_id()
@@ -864,30 +797,33 @@ class s2class {
864
  /**
865
  Return an array of all subscribers emails or IDs
866
  */
867
- function get_all_registered($return = 'email') {
868
  global $wpdb;
869
 
870
  if ( $this->s2_mu ) {
871
- if ( $return === 'ID' ) {
872
- if ( $this->all_registered_id === '' ) {
873
- $this->all_registered_id = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'");
874
  }
875
  return $this->all_registered_id;
876
  } else {
877
- if ( $this->all_registered_email === '' ) {
878
- $this->all_registered_email = $wpdb->get_col("SELECT a.user_email FROM $wpdb->users AS a INNER JOIN $wpdb->usermeta AS b ON a.ID = b.user_id WHERE b.meta_key='" . $wpdb->prefix . "capabilities'");
879
  }
880
  return $this->all_registered_email;
881
  }
882
  } else {
883
- if ( $return === 'ID' ) {
884
- if ( $this->all_registered_id === '' ) {
885
- $this->all_registered_id = $wpdb->get_col("SELECT ID FROM $wpdb->users");
886
  }
887
  return $this->all_registered_id;
 
 
 
888
  } else {
889
- if ( $this->all_registered_email === '' ) {
890
- $this->all_registered_email = $wpdb->get_col("SELECT user_email FROM $wpdb->users");
891
  }
892
  return $this->all_registered_email;
893
  }
@@ -898,141 +834,155 @@ class s2class {
898
  Return an array of registered subscribers
899
  Collect all the registered users of the blog who are subscribed to the specified categories
900
  */
901
- function get_registered($args = '') {
902
  global $wpdb;
903
 
904
- parse_str($args, $r);
905
- if ( !isset($r['format']) )
906
  $r['format'] = 'all';
907
- if ( !isset($r['cats']) )
 
908
  $r['cats'] = '';
909
- if ( !isset($r['author']) )
 
910
  $r['author'] = '';
 
 
 
 
911
 
912
  // collect all subscribers for compulsory categories
913
- $compulsory = explode(',', $this->subscribe2_options['compulsory']);
914
- foreach ( explode(',', $r['cats']) as $cat ) {
915
- if ( in_array($cat, $compulsory) ) {
916
  $r['cats'] = '';
917
  }
918
  }
919
 
920
  $JOIN = ''; $AND = '';
921
  // text or HTML subscribers
922
- if ( 'all' != $r['format'] ) {
923
  $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
924
- $AND .= $wpdb->prepare(" AND b.meta_key=%s AND b.meta_value=", $this->get_usermeta_keyname('s2_format'));
925
- if ( 'html' == $r['format'] ) {
926
  $AND .= "'html'";
927
- } elseif ( 'html_excerpt' == $r['format'] ) {
928
  $AND .= "'html_excerpt'";
929
- } elseif ( 'post' == $r['format'] ) {
930
  $AND .= "'post'";
931
- } elseif ( 'excerpt' == $r['format'] ) {
932
  $AND .= "'excerpt'";
933
  }
934
  }
935
 
936
  // specific category subscribers
937
- if ( '' != $r['cats'] ) {
938
  $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
939
  $and = '';
940
- foreach ( explode(',', $r['cats']) as $cat ) {
941
- ('' == $and) ? $and = $wpdb->prepare("c.meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $cat) : $and .= $wpdb->prepare(" OR c.meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $cat);
942
  }
943
  $AND .= " AND ($and)";
944
  }
945
 
946
  // specific authors
947
- if ( '' != $r['author'] ) {
948
  $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
949
- $AND .= $wpdb->prepare(" AND (d.meta_key=%s AND NOT FIND_IN_SET(%s, d.meta_value))", $this->get_usermeta_keyname('s2_authors'), $r['author']);
950
  }
951
 
952
  if ( $this->s2_mu ) {
953
- $sql = $wpdb->prepare("SELECT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS e ON a.user_id = e.user_id " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND e.meta_key=%s AND e.meta_value <> ''" . $AND, $this->get_usermeta_keyname('s2_subscribed'));
 
 
 
 
 
 
 
954
  } else {
955
- $sql = $wpdb->prepare("SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key=%s AND a.meta_value <> ''" . $AND, $this->get_usermeta_keyname('s2_subscribed'));
956
  }
957
- $result = $wpdb->get_col($sql);
958
- if ( $result ) {
959
- $ids = implode(',', array_map(array($this, 'prepare_in_data'), $result));
960
- $registered = $wpdb->get_col("SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)");
 
961
  }
962
 
963
- if ( empty($registered) ) { return array(); }
964
 
965
  // apply filter to registered users to add or remove additional addresses, pass args too for additional control
966
- $registered = apply_filters('s2_registered_subscribers', $registered, $args);
967
  return $registered;
968
  } // end get_registered()
969
 
970
  /**
971
  Function to ensure email is compliant with internet messaging standards
972
  */
973
- function sanitize_email($email) {
974
- $email = trim($email);
975
- if ( !is_email($email) ) { return; }
976
 
977
  // ensure that domain is in lowercase as per internet email standards http://www.ietf.org/rfc/rfc5321.txt
978
- list($name, $domain) = explode('@', $email, 2);
979
- return $name . "@" . strtolower($domain);
980
  } // end sanitize_email()
981
 
982
  /**
983
  Create the appropriate usermeta values when a user registers
984
  If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
985
  */
986
- function register($user_ID = 0, $consent = false) {
987
  global $wpdb;
988
 
989
- if ( 0 == $user_ID ) { return $user_ID; }
990
- $user = get_userdata($user_ID);
991
 
992
  // Subscribe registered users to categories obeying excluded categories
993
- if ( 0 == $this->subscribe2_options['reg_override'] || 'no' == $this->subscribe2_options['newreg_override'] ) {
994
- $all_cats = $this->all_cats(true, 'ID');
995
  } else {
996
- $all_cats = $this->all_cats(false, 'ID');
997
  }
998
 
999
  $cats = '';
1000
  foreach ( $all_cats as $cat ) {
1001
- ('' == $cats) ? $cats = "$cat->term_id" : $cats .= ",$cat->term_id";
1002
  }
1003
 
1004
- if ( '' == $cats ) {
1005
  // sanity check, might occur if all cats excluded and reg_override = 0
1006
  return $user_ID;
1007
  }
1008
 
1009
  // has this user previously signed up for email notification?
1010
- if ( false !== $this->is_public($this->sanitize_email($user->user_email)) ) {
1011
  // delete this user from the public table, and subscribe them to all the categories
1012
- $this->delete($user->user_email);
1013
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1014
- foreach ( explode(',', $cats) as $cat ) {
1015
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, $cat);
1016
- }
1017
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
1018
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $this->subscribe2_options['autosub_def']);
1019
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
1020
  } else {
1021
  // create post format entries for all users
1022
- if ( in_array($this->subscribe2_options['autoformat'], array('html', 'html_excerpt', 'post', 'excerpt')) ) {
1023
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $this->subscribe2_options['autoformat']);
1024
  } else {
1025
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), 'excerpt');
1026
  }
1027
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $this->subscribe2_options['autosub_def']);
1028
  // if the are no existing subscriptions, create them if we have consent
1029
  if ( true === $consent ) {
1030
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats);
1031
- foreach ( explode(',', $cats) as $cat ) {
1032
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat, $cat);
1033
  }
1034
  }
1035
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), '');
1036
  }
1037
  return $user_ID;
1038
  } // end register()
@@ -1040,20 +990,22 @@ class s2class {
1040
  /**
1041
  Get admin data from record 1 or first user with admin rights
1042
  */
1043
- function get_userdata($admin_id) {
1044
  global $wpdb, $userdata;
1045
 
1046
- if ( is_numeric($admin_id) ) {
1047
- $admin = get_userdata($admin_id);
1048
- } elseif ( $admin_id == 'admin' ) {
1049
  //ensure compatibility with < 4.16
1050
- $admin = get_userdata('1');
1051
  } else {
1052
  $admin = &$userdata;
1053
  }
1054
 
1055
- if ( empty($admin) || $admin->ID == 0 ) {
1056
- $role = array('role' => 'administrator');
 
 
1057
  $wp_user_query = get_users( $role );
1058
  $admin = $wp_user_query[0];
1059
  }
@@ -1064,58 +1016,62 @@ class s2class {
1064
  /**
1065
  Subscribe/unsubscribe user from one-click submission
1066
  */
1067
- function one_click_handler($user_ID, $action) {
1068
- if ( !isset($user_ID) || !isset($action) ) { return; }
1069
 
1070
- $all_cats = $this->all_cats(true);
1071
 
1072
- if ( 'subscribe' == $action ) {
1073
  // Subscribe
1074
  $new_cats = array();
1075
  foreach ( $all_cats as $cat ) {
1076
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
1077
  $new_cats[] = $cat->term_id;
1078
  }
1079
 
1080
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $new_cats));
1081
 
1082
- if ( 'yes' == $this->subscribe2_options['show_autosub'] && 'no' != get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true) ) {
1083
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'yes');
1084
  }
1085
- } elseif ( 'unsubscribe' == $action ) {
1086
  // Unsubscribe
1087
  foreach ( $all_cats as $cat ) {
1088
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $cat->term_id);
1089
  }
1090
 
1091
- delete_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'));
1092
- update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), 'no');
1093
  }
1094
  } //end one_click_handler()
1095
 
1096
- /* ===== helper functions: forms and stuff ===== */
1097
  /**
1098
  Get an object of all categories, include default and custom type
1099
  */
1100
- function all_cats($exclude = false, $orderby = 'slug') {
1101
  $all_cats = array();
1102
- $s2_taxonomies = apply_filters('s2_taxonomies', array('category'));
1103
 
1104
  foreach ( $s2_taxonomies as $taxonomy ) {
1105
- if ( taxonomy_exists($taxonomy) ) {
1106
- $all_cats = array_merge($all_cats, get_categories(array('hide_empty' => false, 'orderby' => $orderby, 'taxonomy' => $taxonomy)));
 
 
 
 
1107
  }
1108
  }
1109
 
1110
- if ( $exclude === true ) {
1111
  // remove excluded categories from the returned object
1112
- $excluded = explode(',', $this->subscribe2_options['exclude']);
1113
 
1114
  // need to use $id like this as this is a mixed array / object
1115
  $id = 0;
1116
- foreach ( $all_cats as $cat) {
1117
- if ( in_array($cat->term_id, $excluded) ) {
1118
- unset($all_cats[$id]);
1119
  }
1120
  $id++;
1121
  }
@@ -1127,20 +1083,20 @@ class s2class {
1127
  /**
1128
  Function to sanitise array of data for SQL
1129
  */
1130
- function prepare_in_data($data) {
1131
  global $wpdb;
1132
- return $wpdb->prepare('%s', $data);
1133
  } // end prepare_in_data()
1134
 
1135
  /**
1136
  Filter for usermeta table key names to adjust them if needed for WPMU blogs
1137
  */
1138
- function get_usermeta_keyname($metaname) {
1139
  global $wpdb;
1140
 
1141
  // Is this WordPressMU or not?
1142
- if ( $this->s2_mu === true ) {
1143
- switch( $metaname ) {
1144
  case 's2_subscribed':
1145
  case 's2_cat':
1146
  case 's2_format':
@@ -1158,65 +1114,71 @@ class s2class {
1158
  Adds information to the WordPress registration screen for new users
1159
  */
1160
  function register_form() {
1161
- if ( 'no' == $this->subscribe2_options['autosub'] ) { return; }
1162
- if ( 'wpreg' == $this->subscribe2_options['autosub'] ) {
1163
- echo "<p>\r\n<label>";
1164
- echo __('Check here to Subscribe to email notifications for new posts', 'subscribe2') . ":<br />\r\n";
1165
- echo "<input type=\"checkbox\" name=\"reg_subscribe\"" . checked($this->subscribe2_options['wpregdef'], 'yes', false) . " />";
1166
- echo "</label>\r\n";
1167
- echo "</p>\r\n";
1168
- } elseif ( 'yes' == $this->subscribe2_options['autosub'] ) {
1169
- echo "<p>\r\n<center>\r\n";
1170
- 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";
1171
- echo "</center></p>\r\n";
1172
  }
1173
  } // end register_form()
1174
 
1175
  /**
1176
  Process function to add action if user selects to subscribe to posts during registration
1177
  */
1178
- function register_post($user_ID = 0) {
1179
  global $_POST;
1180
- if ( 0 == $user_ID ) { return; }
1181
- if ( 'yes' == $this->subscribe2_options['autosub'] || ( isset($_POST['reg_subscribe']) && 'on' == $_POST['reg_subscribe'] && 'wpreg' == $this->subscribe2_options['autosub'] ) ) {
1182
- $this->register($user_ID, true);
1183
  } else {
1184
- $this->register($user_ID, false);
1185
  }
1186
  } // end register_post()
1187
 
1188
- /* ===== comment subscriber functions ===== */
1189
  /**
1190
  Display check box on comment page
1191
  */
1192
- function s2_comment_meta_form() {
1193
  if ( is_user_logged_in() ) {
1194
- echo $this->profile;
 
 
 
 
 
1195
  } else {
1196
- echo "<p style=\"width: auto;\"><label><input type=\"checkbox\" name=\"s2_comment_request\" value=\"1\" " . checked($this->subscribe2_options['comment_def'], 'yes', false) . "/> " . __('Check here to Subscribe to notifications for new posts', 'subscribe2') . "</label></p>";
1197
  }
1198
  } // end s2_comment_meta_form()
1199
 
1200
  /**
1201
  Process comment meta data
1202
  */
1203
- function s2_comment_meta($comment_ID, $approved = 0) {
1204
- if ( $_POST['s2_comment_request'] == '1' ) {
1205
- switch ($approved) {
 
 
1206
  case '0':
1207
  // Unapproved so hold in meta data pending moderation
1208
- add_comment_meta($comment_ID, 's2_comment_request', $_POST['s2_comment_request']);
1209
  break;
1210
  case '1':
1211
  // Approved so add
1212
- $comment = get_comment($comment_ID);
1213
- $is_public = $this->is_public($comment->comment_author_email);
1214
- if ( $is_public == 0 ) {
1215
- $this->toggle($comment->comment_author_email);
1216
  }
1217
- $is_registered = $this->is_registered($comment->comment_author_email);
1218
- if ( !$is_public && !$is_registered ) {
1219
- $this->add($comment->comment_author_email, true);
1220
  }
1221
  break;
1222
  default :
@@ -1228,71 +1190,74 @@ class s2class {
1228
  /**
1229
  Action subscribe requests made on comment forms when comments are approved
1230
  */
1231
- function comment_status($comment_ID = 0) {
1232
  global $wpdb;
1233
 
1234
  // get meta data
1235
- $subscribe = get_comment_meta($comment_ID, 's2_comment_request', true);
1236
- if ( $subscribe != '1' ) { return $comment_ID; }
1237
 
1238
  // Retrieve the information about the comment
1239
- $sql = $wpdb->prepare("SELECT comment_author_email, comment_approved FROM $wpdb->comments WHERE comment_ID=%s LIMIT 1", $comment_ID);
1240
- $comment = $wpdb->get_row($sql, OBJECT);
1241
- if ( empty($comment) ) { return $comment_ID; }
1242
 
1243
- switch ($comment->comment_approved) {
1244
  case '0': // Unapproved
1245
  break;
1246
  case '1': // Approved
1247
- $is_public = $this->is_public($comment->comment_author_email);
1248
- if ( $is_public == 0 ) {
1249
- $this->toggle($comment->comment_author_email);
1250
  }
1251
- $is_registered = $this->is_registered($comment->comment_author_email);
1252
- if ( !$is_public && !$is_registered ) {
1253
- $this->add($comment->comment_author_email, true);
1254
  }
1255
- delete_comment_meta($comment_ID, 's2_comment_request');
1256
  break;
1257
  default: // post is trash, spam or deleted
1258
- delete_comment_meta($comment_ID, 's2_comment_request');
1259
  break;
1260
  }
1261
 
1262
  return $comment_ID;
1263
  } // end comment_status()
1264
 
1265
- /* ===== widget functions ===== */
1266
  /**
1267
  Register the form widget
1268
  */
1269
  function subscribe2_widget() {
1270
- require_once( S2PATH . 'include/widget.php');
1271
- register_widget('S2_Form_widget');
1272
  } // end subscribe2_widget()
1273
 
1274
  /**
1275
  Register the counter widget
1276
  */
1277
  function counter_widget() {
1278
- require_once( S2PATH . 'include/counterwidget.php');
1279
- register_widget('S2_Counter_widget');
1280
  } // end counter_widget()
1281
 
1282
- /* ===== wp-cron functions ===== */
1283
  /**
1284
  Add a weekly event to cron
1285
  */
1286
- function add_weekly_sched($scheds) {
1287
  $exists = false;
1288
  foreach ( $scheds as $sched ) {
1289
- if ( array_search(604800, $sched) ) {
1290
  $exists = true;
1291
  }
1292
  }
1293
 
1294
- if ( !$exists ) {
1295
- $scheds['weekly'] = array('interval' => 604800, 'display' => __('Weekly', 'subscribe2'));
 
 
 
1296
  }
1297
 
1298
  return $scheds;
@@ -1301,16 +1266,16 @@ class s2class {
1301
  /**
1302
  Handle post transitions for the digest email
1303
  */
1304
- function digest_post_transitions($new_status, $old_status, $post) {
1305
  if ( $new_status === $old_status ) { return; }
1306
 
1307
- if ( $this->subscribe2_options['pages'] == 'yes' ) {
1308
- $s2_post_types = array('page', 'post');
1309
  } else {
1310
- $s2_post_types = array('post');
1311
  }
1312
- $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
1313
- if ( !in_array($post->post_type, $s2_post_types) ) { return; }
1314
 
1315
  update_post_meta( $post->ID, '_s2_digest_post_status', ( 'publish' === $new_status ) ? 'pending' : 'draft' );
1316
  } // end digest_post_transitions()
@@ -1318,14 +1283,14 @@ class s2class {
1318
  /**
1319
  Send a daily digest of today's new posts
1320
  */
1321
- function subscribe2_cron($preview = '', $resend = '') {
1322
- if ( defined('DOING_S2_CRON') && DOING_S2_CRON ) { return; }
1323
  define( 'DOING_S2_CRON', true );
1324
  global $wpdb, $post;
1325
 
1326
- if ( '' == $preview ) {
1327
  // set up SQL query based on options
1328
- if ( $this->subscribe2_options['private'] == 'yes' ) {
1329
  $status = "'publish', 'private'";
1330
  } else {
1331
  $status = "'publish'";
@@ -1333,102 +1298,141 @@ class s2class {
1333
 
1334
  // send notifications for allowed post type (defaults for posts and pages)
1335
  // uses s2_post_types filter to allow for custom post types in WP 3.0
1336
- if ( $this->subscribe2_options['pages'] == 'yes' ) {
1337
- $s2_post_types = array('page', 'post');
1338
  } else {
1339
- $s2_post_types = array('post');
1340
  }
1341
- $s2_post_types = apply_filters('s2_post_types', $s2_post_types);
1342
  foreach ( $s2_post_types as $post_type ) {
1343
- if ( !isset($type) ) {
1344
- $type = $wpdb->prepare("%s", $post_type);
1345
  } else {
1346
- $type .= $wpdb->prepare(", %s", $post_type);
1347
  }
1348
  }
1349
 
1350
  // collect posts
1351
- if ( $resend == 'resend' ) {
1352
  $query = new WP_Query( array(
1353
- 'post__in' => explode(',', $this->subscribe2_options['last_s2cron']),
1354
  'ignore_sticky_posts' => 1,
1355
- 'order' => ($this->subscribe2_options['cron_order'] === 'desc') ? "DESC" : "ASC"
1356
- ) );
1357
  $posts = $query->posts;
1358
  } else {
1359
  $sql = "SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts AS a INNER JOIN $wpdb->postmeta AS b ON b.post_id = a.ID";
1360
- $sql .= " AND b.meta_key = '_s2_digest_post_status' AND b.meta_value = 'pending' WHERE post_status IN ($status) AND post_type IN ($type) ORDER BY post_date " . (($this->subscribe2_options['cron_order'] === 'desc') ? 'DESC' : 'ASC');
1361
- $posts = $wpdb->get_results($sql);
1362
  }
1363
  } else {
1364
  // we are sending a preview
1365
- // $posts = get_posts('numberposts=1');
1366
- $posts = get_posts('numberposts=3');
1367
- $posts = apply_filters('s2_cron_preview_posts', $posts, $this);
1368
  }
1369
 
1370
  // Collect sticky posts if desired
1371
  $sticky_ids = array();
1372
- if ( $this->subscribe2_options['stickies'] == 'yes' ) {
1373
- $sticky_ids = get_option('sticky_posts');
1374
- if ( !empty($sticky_ids) ) {
1375
- $sticky_posts = get_posts( array('post__in' => $sticky_ids) );
1376
- $posts = array_merge((array)$sticky_posts, (array)$posts);
 
 
1377
  }
1378
  }
1379
 
1380
  // do we have any posts?
1381
- if ( empty($posts) && !has_filter('s2_digest_email') ) { return false; }
 
 
 
 
 
 
 
 
 
1382
 
1383
  // if we have posts, let's prepare the digest
1384
  // define some variables needed for the digest
1385
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
1386
  $all_post_cats = array();
1387
  $ids = array();
1388
  $digest_post_ids = array();
1389
- $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
1390
  $table = '';
1391
  $tablelinks = '';
1392
- $message_post= '';
1393
  $message_posttime = '';
1394
- $this->post_count = count($posts);
1395
- $s2_taxonomies = apply_filters('s2_taxonomies', array('category'));
1396
 
1397
  foreach ( $posts as $post ) {
1398
  // keep an array of post ids and skip if we've already done it once
1399
- if ( in_array($post->ID, $ids) ) { continue; }
1400
  $ids[] = $post->ID;
1401
- $post_cats = wp_get_object_terms($post->ID, $s2_taxonomies, array('fields' => 'ids'));
1402
- $post_cats_string = implode(',', $post_cats);
1403
- $all_post_cats = array_unique(array_merge($all_post_cats, $post_cats));
 
 
 
 
1404
  $check = false;
1405
- // Pages are put into category 1 so make sure we don't exclude
1406
- // pages if category 1 is excluded
1407
- if ( $post->post_type != 'page' ) {
1408
- // is the current post assigned to any categories
1409
- // which should not generate a notification email?
1410
- foreach ( explode(',', $this->subscribe2_options['exclude']) as $cat ) {
1411
- if ( in_array($cat, $post_cats) ) {
1412
- $check = true;
 
 
1413
  }
1414
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1415
  }
1416
  // is the current post set by the user to
1417
  // not generate a notification email?
1418
- $s2mail = get_post_meta($post->ID, '_s2mail', true);
1419
- if ( strtolower(trim($s2mail)) == 'no' ) {
1420
  $check = true;
1421
  }
1422
  // is the current post private
1423
  // and should this not generate a notification email?
1424
- if ( $this->subscribe2_options['password'] == 'no' && $post->post_password != '' ) {
1425
  $check = true;
1426
  }
1427
  // is the post assigned a format that should
1428
  // not be included in the notification email?
1429
- $post_format = get_post_format($post->ID);
1430
- $excluded_formats = explode(',', $this->subscribe2_options['exclude_formats']);
1431
- if ( $post_format !== false && in_array($post_format, $excluded_formats) ) {
1432
  $check = true;
1433
  }
1434
  // if this post is excluded
@@ -1439,71 +1443,76 @@ class s2class {
1439
 
1440
  $digest_post_ids[] = $post->ID;
1441
 
1442
- $post_title = html_entity_decode(__($post->post_title), ENT_QUOTES);
1443
- ('' == $table) ? $table .= "* " . $post_title : $table .= "\r\n* " . $post_title;
1444
- ('' == $tablelinks) ? $tablelinks .= "* " . $post_title : $tablelinks .= "\r\n* " . $post_title;
1445
  $message_post .= $post_title;
1446
  $message_posttime .= $post_title;
1447
- if ( strstr($mailtext, "{AUTHORNAME}") ) {
1448
- $author = get_userdata($post->post_author);
1449
- if ( $author->display_name != '' ) {
1450
- $message_post .= " (" . __('Author', 'subscribe2') . ": " . html_entity_decode(apply_filters('the_author', $author->display_name), ENT_QUOTES) . ")";
1451
- $message_posttime .= " (" . __('Author', 'subscribe2') . ": " . html_entity_decode(apply_filters('the_author', $author->display_name), ENT_QUOTES) . ")";
1452
  }
1453
  }
1454
  $message_post .= "\r\n";
1455
  $message_posttime .= "\r\n";
1456
 
1457
- $message_posttime .= __('Posted on', 'subscribe2') . ": " . mysql2date($datetime, $post->post_date) . "\r\n";
1458
- if ( strstr($mailtext, "{TINYLINK}") ) {
1459
- $tinylink = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode($this->get_tracking_link(get_permalink($post->ID))));
1460
  } else {
1461
  $tinylink = false;
1462
  }
1463
- if ( strstr($mailtext, "{TINYLINK}") && $tinylink !== 'Error' && $tinylink !== false ) {
1464
  $tablelinks .= "\r\n" . $tinylink . "\r\n";
1465
  $message_post .= $tinylink . "\r\n";
1466
  $message_posttime .= $tinylink . "\r\n";
1467
  } else {
1468
- $tablelinks .= "\r\n" . $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
1469
- $message_post .= $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
1470
- $message_posttime .= $this->get_tracking_link(get_permalink($post->ID)) . "\r\n";
1471
- }
1472
-
1473
- if ( strstr($mailtext, "{CATS}") ) {
1474
- $post_cat_names = implode(', ', wp_get_object_terms($post->ID, $s2_taxonomies, array('fields' => 'names')));
1475
- $message_post .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
1476
- $message_posttime .= __('Posted in', 'subscribe2') . ": " . $post_cat_names . "\r\n";
1477
- }
1478
- if ( strstr($mailtext, "{TAGS}") ) {
1479
- $post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
1480
- if ( $post_tag_names != '' ) {
1481
- $message_post .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
1482
- $message_posttime .= __('Tagged as', 'subscribe2') . ": " . $post_tag_names . "\r\n";
 
 
 
 
1483
  }
1484
  }
1485
  $message_post .= "\r\n";
1486
  $message_posttime .= "\r\n";
1487
 
1488
- ( !empty($post->post_excerpt) ) ? $excerpt = trim($post->post_excerpt) : $excerpt = '';
1489
- if ( '' == $excerpt ) {
 
1490
  // no excerpt, is there a <!--more--> ?
1491
- if ( false !== strpos($post->post_content, '<!--more-->') ) {
1492
- list($excerpt, $more) = explode('<!--more-->', $post->post_content, 2);
1493
- $excerpt = strip_tags($excerpt);
1494
- $excerpt = strip_shortcodes($excerpt);
1495
  } else {
1496
- $excerpt = strip_tags($post->post_content);
1497
- $excerpt = strip_shortcodes($excerpt);
1498
- $words = explode(' ', $excerpt, $this->excerpt_length + 1);
1499
- if ( count($words) > $this->excerpt_length ) {
1500
- array_pop($words);
1501
- array_push($words, '[...]');
1502
- $excerpt = implode(' ', $words);
1503
  }
1504
  }
1505
  // strip leading and trailing whitespace
1506
- $excerpt = trim($excerpt);
1507
  }
1508
  $message_post .= $excerpt . "\r\n\r\n";
1509
  $message_posttime .= $excerpt . "\r\n\r\n";
@@ -1523,72 +1532,75 @@ class s2class {
1523
  }
1524
 
1525
  // we add a blank line after each post excerpt now trim white space that occurs for the last post
1526
- $message_post = trim($message_post);
1527
- $message_posttime = trim($message_posttime);
1528
  // remove excess white space from within $message_post and $message_posttime
1529
- $message_post = preg_replace('|[ ]+|', ' ', $message_post);
1530
- $message_posttime = preg_replace('|[ ]+|', ' ', $message_posttime);
1531
- $message_post = preg_replace("|[\r\n]{3,}|", "\r\n\r\n", $message_post);
1532
- $message_posttime = preg_replace("|[\r\n]{3,}|", "\r\n\r\n", $message_posttime);
1533
 
1534
  // apply filter to allow external content to be inserted or content manipulated
1535
- $message_post = apply_filters('s2_digest_email', $message_post);
1536
- $message_posttime = apply_filters('s2_digest_email', $message_posttime);
1537
 
1538
  //sanity check - don't send a mail if the content is empty
1539
- if ( !$message_post && !$message_posttime && !$table && !$tablelinks ) {
1540
  return;
1541
  }
1542
 
1543
  // get sender details
1544
- if ( $this->subscribe2_options['sender'] == 'blogname' ) {
1545
- $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
1546
- $this->myemail = get_bloginfo('admin_email');
1547
  } else {
1548
- $user = $this->get_userdata($this->subscribe2_options['sender']);
1549
  $this->myemail = $user->user_email;
1550
- $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
1551
  }
1552
 
1553
- $scheds = (array)wp_get_schedules();
1554
  $email_freq = $this->subscribe2_options['email_freq'];
1555
- $display = $scheds[$email_freq]['display'];
1556
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
1557
- $subject .= $display . " " . __('Digest Email', 'subscribe2');
1558
- $mailtext = str_replace("{TABLELINKS}", $tablelinks, $mailtext);
1559
- $mailtext = str_replace("{TABLE}", $table, $mailtext);
1560
- $mailtext = str_replace("{POSTTIME}", $message_posttime, $mailtext);
1561
- $mailtext = str_replace("{POST}", $message_post, $mailtext);
1562
 
1563
  // apply filter to allow custom keywords
1564
- $mailtext = apply_filters('s2_custom_keywords', $mailtext, $digest_post_ids);
1565
- $mailtext = stripslashes($this->substitute($mailtext));
1566
 
1567
  // prepare recipients
1568
- if ( $preview != '' ) {
1569
  $this->myemail = $preview;
1570
- $this->myname = __('Digest Preview', 'subscribe2');
1571
- $this->mail(array($preview), $subject, $mailtext);
1572
  } else {
1573
  $public = $this->get_public();
1574
- $all_post_cats_string = implode(',', $all_post_cats);
1575
- $registered = $this->get_registered("cats=$all_post_cats_string");
1576
- $recipients = array_merge((array)$public, (array)$registered);
1577
- $this->mail($recipients, $subject, $mailtext);
1578
  }
1579
  } // end subscribe2_cron()
1580
 
 
 
 
1581
  function s2cleaner_task() {
1582
- $unconfirmed = $this->get_public('0');
1583
- if ( empty($unconfirmed) ) { return; }
1584
  global $wpdb;
1585
- $sql = "SELECT email FROM $this->public WHERE active='0' AND date < DATE_SUB(CURDATE(), INTERVAL " . $this->clean_interval . " DAY)";
1586
  $old_unconfirmed = $wpdb->get_col( $sql );
1587
- if ( empty($old_unconfirmed) ) {
1588
  return;
1589
  } else {
1590
  foreach ( $old_unconfirmed as $email ) {
1591
- $this->delete($email);
1592
  }
1593
  }
1594
  return;
@@ -1597,206 +1609,227 @@ class s2class {
1597
  /**
1598
  Jetpack comments doesn't play nice, this function kills that module
1599
  */
1600
- function s2_hide_jetpack_comments($modules) {
1601
- unset($modules['comments']);
1602
  return $modules;
1603
  } // end s2_kill_jetpack_comments()
1604
 
1605
- /* ===== Our constructor ===== */
1606
  /**
1607
  Subscribe2 constructor
1608
  */
1609
  function s2init() {
1610
  global $wpdb, $wp_version, $wpmu_version;
1611
  // load the options
1612
- $this->subscribe2_options = get_option('subscribe2_options');
1613
  // if SCRIPT_DEBUG is true, use dev scripts
1614
- $this->script_debug = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '' : '.min';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1615
 
1616
  // get the WordPress release number for in code version comparisons
1617
- $tmp = explode('-', $wp_version, 2);
1618
  $this->wp_release = $tmp[0];
1619
 
1620
  // Is this WordPressMU or not?
1621
- if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
1622
  $this->s2_mu = true;
1623
  }
1624
- if ( function_exists('is_multisite') && is_multisite() ) {
1625
  $this->s2_mu = true;
1626
  }
1627
 
1628
  // add action to handle WPMU subscriptions and unsubscriptions
1629
- if ( $this->s2_mu === true ) {
1630
- require_once(S2PATH . "classes/class-s2-multisite.php");
1631
  global $s2class_multisite;
1632
- $s2class_multisite = new s2_multisite;
1633
- if ( isset($_GET['s2mu_subscribe']) || isset($_GET['s2mu_unsubscribe']) ) {
1634
- add_action('init', array(&$s2class_multisite, 'wpmu_subscribe'));
1635
  }
1636
  }
1637
 
1638
  // load our translations
1639
- add_action('plugins_loaded', array(&$this, 'load_translations'));
1640
 
1641
  // do we need to install anything?
1642
- $this->public = $wpdb->prefix . "subscribe2";
1643
- if ( $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $this->public)) != $this->public ) { $this->install(); }
 
 
 
1644
  //do we need to upgrade anything?
1645
- if ( $this->subscribe2_options === false || is_array($this->subscribe2_options) && $this->subscribe2_options['version'] !== S2VERSION ) {
1646
- add_action('shutdown', array(&$this, 'upgrade'));
 
 
 
1647
  }
1648
 
1649
  // add core actions
1650
- add_filter('cron_schedules', array(&$this, 'add_weekly_sched'), 20);
1651
  // add actions for automatic subscription based on option settings
1652
  if ( $this->s2_mu ) {
1653
- add_action('wpmu_activate_user', array(&$s2class_multisite, 'wpmu_add_user'));
1654
- add_action('add_user_to_blog', array(&$s2class_multisite, 'wpmu_add_user'), 10);
1655
- add_action('remove_user_from_blog', array(&$s2class_multisite, 'wpmu_remove_user'), 10);
1656
  } else {
1657
- add_action('register_form', array(&$this, 'register_form'));
1658
- add_action('user_register', array(&$this, 'register_post'));
1659
  }
 
1660
  // add actions for processing posts based on per-post or cron email settings
1661
- if ( $this->subscribe2_options['email_freq'] != 'never' ) {
1662
- add_action('s2_digest_cron', array(&$this, 'subscribe2_cron'));
1663
- add_action('transition_post_status', array(&$this, 'digest_post_transitions'), 10, 3);
1664
  } else {
1665
- $statuses = apply_filters('s2_post_statuses', array('new', 'draft', 'auto-draft', 'pending'));
1666
- if ( $this->subscribe2_options['private'] == 'yes' ) {
1667
  foreach ( $statuses as $status ) {
1668
- add_action("{$status}_to_private", array(&$this, 'publish'));
1669
  }
1670
  }
1671
- array_push($statuses, 'private', 'future');
1672
  foreach ( $statuses as $status ) {
1673
- add_action("{$status}_to_publish", array(&$this, 'publish'));
1674
  }
1675
  }
 
1676
  // add actions for comment subscribers
1677
  if ( 'no' !== $this->subscribe2_options['comment_subs'] ) {
1678
- add_filter('jetpack_get_available_modules', array(&$this, 's2_hide_jetpack_comments'));
1679
- if ( 'before' == $this->subscribe2_options['comment_subs'] ) {
1680
- add_action('comment_form_after_fields', array(&$this, 's2_comment_meta_form'));
1681
- } else {
1682
- add_action('comment_form', array(&$this, 's2_comment_meta_form'));
1683
- }
1684
- add_action('comment_post', array(&$this, 's2_comment_meta'), 1, 2);
1685
- add_action('wp_set_comment_status', array(&$this, 'comment_status'));
1686
  }
 
1687
  // add action to display widget if option is enabled
1688
- if ( '1' == $this->subscribe2_options['widget'] ) {
1689
- add_action('widgets_init', array(&$this, 'subscribe2_widget'));
1690
  }
1691
  // add action to display counter widget if option is enabled
1692
- if ( '1' == $this->subscribe2_options['counterwidget'] ) {
1693
- add_action('widgets_init', array(&$this, 'counter_widget'));
1694
  }
1695
 
1696
  // add action to 'clean' unconfirmed Public Subscribers
1697
- if ( $this->clean_interval > 0 ) {
1698
- add_action('wp_scheduled_delete', array(&$this, 's2cleaner_task'));
1699
  }
1700
 
1701
  // add ajax class if enabled
1702
  if ( '1' === $this->subscribe2_options['ajax'] ) {
1703
  require_once( S2PATH . 'classes/class-s2-ajax.php' );
1704
  global $mysubscribe2_ajax;
1705
- $mysubscribe2_ajax = new S2_Ajax_Class;
1706
  }
1707
 
1708
  // Add actions specific to admin or frontend
1709
  if ( is_admin() ) {
1710
  //add menu, authoring and category admin actions
1711
- add_action('admin_menu', array(&$this, 'admin_menu'));
1712
- add_action('admin_menu', array(&$this, 's2_meta_init'));
1713
- add_action('save_post', array(&$this, 's2_meta_handler'));
1714
- add_action('create_category', array(&$this, 'new_category'));
1715
- add_action('delete_category', array(&$this, 'delete_category'));
1716
 
1717
  // Add filters for Ozh Admin Menu
1718
- if ( function_exists('wp_ozh_adminmenu') ) {
1719
- add_filter('ozh_adminmenu_icon_s2_posts', array(&$this, 'ozh_s2_icon'));
1720
- add_filter('ozh_adminmenu_icon_s2_users', array(&$this, 'ozh_s2_icon'));
1721
- add_filter('ozh_adminmenu_icon_s2_tools', array(&$this, 'ozh_s2_icon'));
1722
- add_filter('ozh_adminmenu_icon_s2_settings', array(&$this, 'ozh_s2_icon'));
1723
  }
1724
 
1725
  // add write button
1726
- if ( '1' == $this->subscribe2_options['show_button'] ) {
1727
- add_action('admin_init', array(&$this, 'button_init'));
1728
  }
1729
 
1730
  // add counterwidget css and js
1731
- if ( '1' == $this->subscribe2_options['counterwidget'] ) {
1732
- add_action('admin_init', array(&$this, 'widget_s2counter_css_and_js'));
1733
  }
1734
 
1735
  // add one-click handlers
1736
- if ( 'yes' == $this->subscribe2_options['one_click_profile'] ) {
1737
- add_action( 'show_user_profile', array(&$this, 'one_click_profile_form') );
1738
- add_action( 'edit_user_profile', array(&$this, 'one_click_profile_form') );
1739
- add_action( 'personal_options_update', array(&$this, 'one_click_profile_form_save') );
1740
- add_action( 'edit_user_profile_update', array(&$this, 'one_click_profile_form_save') );
1741
  }
1742
 
 
 
 
 
 
 
 
1743
  // capture CSV export
1744
- if ( isset($_POST['s2_admin']) && isset($_POST['csv']) ) {
1745
- $date = date('Y-m-d');
1746
- header("Content-Description: File Transfer");
1747
- header("Content-type: application/octet-stream");
1748
- header("Content-Disposition: attachment; filename=subscribe2_users_$date.csv");
1749
- header("Pragma: no-cache");
1750
- header("Expires: 0");
1751
- echo $this->prepare_export($_POST['exportcsv']);
1752
- exit(0);
1753
  }
1754
  } else {
1755
  // load strings later on frontend for polylang plugin compatibility
1756
- add_action('wp', array(&$this, 'load_strings'));
1757
 
1758
- if ( isset($_GET['s2']) ) {
1759
  // someone is confirming a request
1760
- if ( defined('DOING_S2_CONFIRM') && DOING_S2_CONFIRM ) { return; }
1761
- define( 'DOING_S2_CONFIRM', true );
1762
- add_filter('request', array(&$this, 'query_filter'));
1763
- add_filter('the_title', array(&$this, 'title_filter'));
1764
- add_filter('the_content', array(&$this, 'confirm'));
1765
  }
1766
 
1767
  // add the frontend filters
1768
- add_shortcode('subscribe2', array(&$this, 'shortcode'));
1769
- add_filter('the_content', array(&$this, 'filter'), 10);
1770
 
1771
  // add actions for other plugins
1772
- if ( '1' == $this->subscribe2_options['show_meta'] ) {
1773
- add_action('wp_meta', array(&$this, 'add_minimeta'), 0);
 
 
 
 
 
 
1774
  }
1775
  }
1776
  } // end s2init()
1777
 
1778
- /**
1779
- PHP5 Constructor
1780
- Allows dynamic variable setting
1781
- */
1782
- function __construct() {
1783
- $this->word_wrap = apply_filters('s2_word_wrap', 80);
1784
- $this->excerpt_length = apply_filters('s2_excerpt_length', 55);
1785
- $this->site_switching = apply_filters('s2_allow_site_switching', false);
1786
- $this->clean_interval = apply_filters('s2_clean_interval', 28);
1787
- $this->lockout = apply_filters('s2_lockout', 0);
1788
- } // end __construct()
1789
-
1790
- /* ===== our variables ===== */
1791
  // cache variables
1792
  var $subscribe2_options = array();
1793
  var $all_confirmed = '';
1794
  var $all_unconfirmed = '';
1795
  var $all_registered_id = '';
1796
  var $all_registered_email = '';
1797
- var $all_authors = '';
1798
  var $excluded_cats = '';
1799
  var $post_title = '';
 
1800
  var $permalink = '';
1801
  var $post_date = '';
1802
  var $post_time = '';
@@ -1825,7 +1858,7 @@ class s2class {
1825
  var $profile = '';
1826
  var $confirmation_sent = '';
1827
  var $already_subscribed = '';
1828
- var $not_subscribed ='';
1829
  var $not_an_email = '';
1830
  var $barred_domain = '';
1831
  var $error = '';
1
  <?php
2
+ class S2_Core {
3
+ // variables and constructor are declared at the end
4
  /**
5
  Load translations
6
  */
7
  function load_translations() {
8
+ load_plugin_textdomain( 'subscribe2', false, S2DIR );
9
+ load_plugin_textdomain( 'subscribe2', false, S2DIR . 'languages/' );
10
+ $mofile = WP_LANG_DIR . '/subscribe2-' . apply_filters( 'plugin_locale', get_locale(), 'subscribe2' ) . '.mo';
11
+ load_textdomain( 'subscribe2', $mofile );
12
  } // end load_translations()
13
 
14
+ /* ===== Install and reset ===== */
15
  /**
16
  Install our table
17
  */
18
  function install() {
19
+ global $wpdb;
20
  // load our translations and strings
21
  $this->load_translations();
22
 
23
  // include upgrade-functions for maybe_create_table;
24
+ if ( ! function_exists( 'maybe_create_table' ) ) {
25
+ require_once( ABSPATH . 'wp-admin/install-helper.php' );
26
+ }
27
+ $charset_collate = '';
28
+ if ( ! empty( $wpdb->charset ) ) {
29
+ $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
30
+ }
31
+
32
+ if ( ! empty( $wpdb->collate ) ) {
33
+ $charset_collate .= " COLLATE {$wpdb->collate}";
34
  }
35
+
36
+ $date = date( 'Y-m-d' );
37
  $sql = "CREATE TABLE $this->public (
38
  id int(11) NOT NULL auto_increment,
39
  email varchar(64) NOT NULL default '',
44
  conf_date DATE,
45
  conf_time TIME,
46
  conf_ip char(64),
47
+ PRIMARY KEY (id) ) $charset_collate";
48
 
49
  // create the table, as needed
50
+ maybe_create_table( $this->public, $sql );
51
+
52
+ // safety check if options exist and if not create them
53
+ if ( ! is_array( $this->subscribe2_options ) ) {
54
+ $this->reset();
55
+ }
56
 
57
  // create table entries for registered users
58
+ $users = $this->get_all_registered( 'ID' );
59
+ if ( ! empty( $users ) ) {
60
  foreach ( $users as $user_ID ) {
61
+ $check_format = get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), true );
62
+ if ( empty( $check_format ) ) {
63
  // no prior settings so create them
64
+ $this->register( $user_ID );
65
  }
66
  }
67
  }
 
 
 
 
 
68
  } // end install()
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  /**
71
  Reset our options
72
  */
74
  // load our translations and strings
75
  $this->load_translations();
76
 
77
+ delete_option( 'subscribe2_options' );
78
+ wp_clear_scheduled_hook( 's2_digest_cron' );
79
+ unset( $this->subscribe2_options );
80
+ require( S2PATH . 'include/options.php' );
81
  $this->subscribe2_options['version'] = S2VERSION;
82
+ update_option( 'subscribe2_options', $this->subscribe2_options );
83
  } // end reset()
84
 
85
+ /* ===== mail handling ===== */
86
  /**
87
  Performs string substitutions for subscribe2 mail tags
88
  */
89
+ function substitute( $string = '' ) {
90
+ if ( '' === $string ) {
91
  return;
92
  }
93
+ $string = str_replace( '{BLOGNAME}', html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ), $string );
94
+ $string = str_replace( '{BLOGLINK}', get_option( 'home' ), $string );
95
+ $string = str_replace( '{TITLE}', stripslashes( $this->post_title ), $string );
96
+ $string = str_replace( '{TITLETEXT}', stripslashes( $this->post_title_text ), $string );
97
+ $string = str_replace( '{PERMAURL}', $this->get_tracking_link( $this->permalink ), $string );
98
+ $link = '<a href="' . $this->get_tracking_link( $this->permalink ) . '">' . $this->get_tracking_link( $this->permalink ) . '</a>';
99
+ $string = str_replace( '{PERMALINK}', $link, $string );
100
+ if ( strstr( $string, '{TINYLINK}' ) ) {
101
+ $tinylink = file_get_contents( 'http://tinyurl.com/api-create.php?url=' . urlencode( $this->get_tracking_link( $this->permalink ) ) );
102
+ if ( 'Error' !== $tinylink && false !== $tinylink ) {
103
+ $tlink = '<a href="' . $tinylink . '">' . $tinylink . '</a>';
104
+ $string = str_replace( '{TINYLINK}', $tlink, $string );
105
  } else {
106
+ $string = str_replace( '{TINYLINK}', $link, $string );
107
  }
108
  }
109
+ $string = str_replace( '{DATE}', $this->post_date, $string );
110
+ $string = str_replace( '{TIME}', $this->post_time, $string );
111
+ $string = str_replace( '{MYNAME}', stripslashes( $this->myname ), $string );
112
+ $string = str_replace( '{EMAIL}', $this->myemail, $string );
113
+ $string = str_replace( '{AUTHORNAME}', stripslashes( $this->authorname ), $string );
114
+ $string = str_replace( '{CATS}', $this->post_cat_names, $string );
115
+ $string = str_replace( '{TAGS}', $this->post_tag_names, $string );
116
+ $string = str_replace( '{COUNT}', $this->post_count, $string );
117
 
118
+ return apply_filters( 's2_custom_keywords', $string );
119
  } // end substitute()
120
 
121
  /**
122
  Delivers email to recipients in HTML or plaintext
123
  */
124
+ function mail( $recipients = array(), $subject = '', $message = '', $type = 'text', $attachments = array() ) {
125
+ if ( empty( $recipients ) || '' === $message ) { return; }
126
 
127
  // Replace any escaped html symbols in subject then apply filter
128
+ $subject = strip_tags( html_entity_decode( $subject, ENT_QUOTES ) );
129
+ $subject = apply_filters( 's2_email_subject', $subject );
130
+
131
+ if ( 'html' === $type ) {
132
+ $headers = $this->headers( 'html' );
133
+ add_filter( 'wp_mail_content_type', array( $this, 'html_email' ) );
134
+ if ( 'yes' === $this->subscribe2_options['stylesheet'] ) {
135
+ $mailtext = apply_filters( 's2_html_email', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>' . $subject . '</title><link rel="stylesheet" href="' . get_stylesheet_directory_uri() . apply_filters( 's2_stylesheet_name', '/style.css' ) . '" type="text/css" media="screen" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>' . $message . '</body></html>', $subject, $message );
136
  } else {
137
+ $mailtext = apply_filters( 's2_html_email', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>' . $subject . '</title></head><body>' . $message . '</body></html>', $subject, $message );
138
  }
139
  } else {
140
+ $headers = $this->headers( 'text' );
141
+ $message = html_entity_decode( strip_tags( $message ), ENT_NOQUOTES, 'UTF-8' );
142
+ $mailtext = apply_filters( 's2_plain_email', $message );
 
143
  }
144
 
145
  // Construct BCC headers for sending or send individual emails
146
  $bcc = '';
147
+ natcasesort( $recipients );
148
+ if ( function_exists( 'wpmq_mail' ) || 1 === $this->subscribe2_options['bcclimit'] || 1 === count( $recipients ) ) {
149
  // BCCLimit is 1 so send individual emails or we only have 1 recipient
150
  foreach ( $recipients as $recipient ) {
151
+ $recipient = trim( $recipient );
152
  // sanity check -- make sure we have a valid email
153
+ if ( ! is_email( $recipient ) || empty( $recipient ) ) { continue; }
154
  // Use the mail queue provided we are not sending a preview
155
+ if ( function_exists( 'wpmq_mail' ) && ! $this->preview_email ) {
156
+ @wp_mail( $recipient, $subject, $mailtext, $headers, $attachments, 0 );
157
  } else {
158
+ @wp_mail( $recipient, $subject, $mailtext, $headers, $attachments );
159
  }
160
  }
161
  return true;
162
+ } elseif ( 0 === $this->subscribe2_options['bcclimit'] ) {
163
+ // we're using BCCLimit
164
  foreach ( $recipients as $recipient ) {
165
+ $recipient = trim( $recipient );
166
  // sanity check -- make sure we have a valid email
167
+ if ( ! is_email( $recipient ) ) { continue; }
168
  // and NOT the sender's email, since they'll get a copy anyway
169
+ if ( ! empty( $recipient ) && $this->myemail !== $recipient ) {
170
+ ('' === $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
171
  // Bcc Headers now constructed by phpmailer class
172
  }
173
  }
177
  $count = 1;
178
  $batch = array();
179
  foreach ( $recipients as $recipient ) {
180
+ $recipient = trim( $recipient );
181
  // sanity check -- make sure we have a valid email
182
+ if ( ! is_email( $recipient ) ) { continue; }
183
  // and NOT the sender's email, since they'll get a copy anyway
184
+ if ( ! empty( $recipient ) && $this->myemail !== $recipient ) {
185
+ ('' === $bcc) ? $bcc = "Bcc: $recipient" : $bcc .= ", $recipient";
186
  // Bcc Headers now constructed by phpmailer class
187
  }
188
+ if ( $this->subscribe2_options['bcclimit'] === $count ) {
189
  $count = 0;
190
  $batch[] = $bcc;
191
  $bcc = '';
193
  $count++;
194
  }
195
  // add any partially completed batches to our batch array
196
+ if ( '' !== $bcc ) {
197
  $batch[] = $bcc;
198
  }
199
  }
200
  // rewind the array, just to be safe
201
+ reset( $recipients );
202
+
203
+ // Ensure body is wrapped at 78 characters for RFC 5322
204
+ $mailtext = wordwrap( $mailtext, $this->word_wrap, "\n" );
205
 
206
  // actually send mail
207
+ if ( isset( $batch ) && ! empty( $batch ) ) {
208
  foreach ( $batch as $bcc ) {
209
  $newheaders = $headers . "$bcc\n";
210
+ $status = @wp_mail( $this->myemail, $subject, $mailtext, $newheaders, $attachments );
211
  }
212
  } else {
213
+ $status = @wp_mail( $this->myemail, $subject, $mailtext, $headers, $attachments );
214
  }
215
  return $status;
216
  } // end mail()
218
  /**
219
  Construct standard set of email headers
220
  */
221
+ function headers( $type = 'text' ) {
222
+ if ( empty( $this->myname ) || empty( $this->myemail ) ) {
223
+ if ( 'blogname' === $this->subscribe2_options['sender'] ) {
224
+ $this->myname = html_entity_decode( get_option( 'blogname' ), ENT_QUOTES );
225
+ $this->myemail = get_option( 'admin_email' );
226
  } else {
227
+ $admin = $this->get_userdata( $this->subscribe2_options['sender'] );
228
+ $this->myname = html_entity_decode( $admin->display_name, ENT_QUOTES );
229
  $this->myemail = $admin->user_email;
230
  // fail safe to ensure sender details are not empty
231
+ if ( empty( $this->myname ) ) {
232
+ $this->myname = html_entity_decode( get_option( 'blogname' ), ENT_QUOTES );
233
  }
234
+ if ( empty( $this->myemail ) ) {
235
  // Get the site domain and get rid of www.
236
+ $sitename = strtolower( esc_html( $_SERVER['SERVER_NAME'] ) );
237
+ if ( 'www.' === substr( $sitename, 0, 4 ) ) {
238
  $sitename = substr( $sitename, 4 );
239
  }
240
  $this->myemail = 'wordpress@' . $sitename;
242
  }
243
  }
244
 
245
+ $char_set = get_option( 'blog_charset' );
246
+ if ( function_exists( 'mb_encode_mimeheader' ) ) {
247
+ $header['From'] = mb_encode_mimeheader( $this->myname, $char_set, 'Q' ) . ' <' . $this->myemail . '>';
248
+ $header['Reply-To'] = mb_encode_mimeheader( $this->myname, $char_set, 'Q' ) . ' <' . $this->myemail . '>';
249
  } else {
250
+ $header['From'] = $this->myname . ' <' . $this->myemail . '>';
251
+ $header['Reply-To'] = $this->myname . ' <' . $this->myemail . '>';
252
  }
253
+ $header['Return-Path'] = '<' . $this->myemail . '>';
254
+ $header['Precedence'] = "list\nList-Id: " . html_entity_decode( get_option( 'blogname' ), ENT_QUOTES );
255
+ if ( 'html' === $type ) {
256
  // To send HTML mail, the Content-Type header must be set
257
+ $header['Content-Type'] = get_option( 'html_type' ) . '; charset="' . $char_set . '"';
258
+ } elseif ( 'text' === $type ) {
259
+ $header['Content-Type'] = 'text/plain; charset="' . $char_set . '"';
260
  }
261
 
262
  // apply header filter to allow on-the-fly amendments
263
+ $header = apply_filters( 's2_email_headers', $header );
264
  // collapse the headers using $key as the header name
265
  foreach ( $header as $key => $value ) {
266
+ $headers[ $key ] = $key . ': ' . $value;
267
  }
268
+ $headers = implode( "\n", $headers );
269
  $headers .= "\n";
270
 
271
  return $headers;
272
  } // end headers()
273
 
274
+ /**
275
+ Function to set HTML Email in wp_mail()
276
+ */
277
+ function html_email() {
278
+ return 'text/html';
279
+ }
280
+
281
  /**
282
  Function to add UTM tracking details to links
283
  */
284
+ function get_tracking_link( $link ) {
285
+ if ( empty( $link ) ) { return; }
286
+ if ( ! empty( $this->subscribe2_options['tracking'] ) ) {
287
+ (strpos( $link, '?' ) > 0) ? $delimiter .= '&' : $delimiter = '?';
288
  $tracking = $this->subscribe2_options['tracking'];
289
+ if ( strpos( $tracking, '{ID}' ) ) {
290
+ $id = url_to_postid( $link );
291
+ $tracking = str_replace( '{ID}', $id, $tracking );
292
  }
293
+ if ( strpos( $tracking, '{TITLE}' ) ) {
294
+ $id = url_to_postid( $link );
295
+ $title = urlencode( htmlentities( get_the_title( $id ), 1 ) );
296
+ $tracking = str_replace( '{TITLE}', $title, $tracking );
297
  }
298
  return $link . $delimiter . $tracking;
299
  } else {
304
  /**
305
  Sends an email notification of a new post
306
  */
307
+ function publish( $post, $preview = '' ) {
308
+ if ( ! $post ) { return $post; }
309
 
310
+ if ( $this->s2_mu && ! apply_filters( 's2_allow_site_switching', $this->site_switching ) ) {
311
  global $switched;
312
  if ( $switched ) { return; }
313
  }
314
 
315
+ if ( '' === $preview ) {
316
  // we aren't sending a Preview to the current user so carry out checks
317
+ $s2mail = get_post_meta( $post->ID, '_s2mail', true );
318
+ if ( ( isset( $_POST['s2_meta_field'] ) && 'no' === $_POST['s2_meta_field'] ) || 'no' === strtolower( trim( $s2mail ) ) ) { return $post; }
319
 
320
  // are we doing daily digests? If so, don't send anything now
321
+ if ( 'never' !== $this->subscribe2_options['email_freq'] ) { return $post; }
322
 
323
  // is the current post of a type that should generate a notification email?
324
  // uses s2_post_types filter to allow for custom post types in WP 3.0
325
+ if ( 'yes' === $this->subscribe2_options['pages'] ) {
326
+ $s2_post_types = array( 'page', 'post' );
327
  } else {
328
+ $s2_post_types = array( 'post' );
329
  }
330
+ $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
331
+ if ( ! in_array( $post->post_type, $s2_post_types ) ) {
332
  return $post;
333
  }
334
 
335
  // Are we sending notifications for password protected posts?
336
+ if ( 'no' === $this->subscribe2_options['password'] && '' !== $post->post_password ) {
337
  return $post;
338
  }
339
 
340
  // Is the post assigned to a format for which we should not be sending posts
341
+ $post_format = get_post_format( $post->ID );
342
+ $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
343
+ if ( false !== $post_format && in_array( $post_format, $excluded_formats ) ) {
344
+ return $post;
345
+ }
346
+
347
+ $s2_taxonomies = apply_filters( 's2_taxonomies', array( 'category' ) );
348
+ $post_cats = wp_get_object_terms( $post->ID, $s2_taxonomies, array(
349
+ 'fields' => 'ids',
350
+ ) );
351
+ // Fail gracefully if we have a post but no category assigned or a taxonomy error
352
+ if ( is_wp_error( $post_cats ) || ( empty( $post_cats ) && 'post' === $post->post_type ) ) {
353
  return $post;
354
  }
355
 
 
 
356
  $check = false;
357
  // is the current post assigned to any categories
358
  // which should not generate a notification email?
359
+ foreach ( explode( ',', $this->subscribe2_options['exclude'] ) as $cat ) {
360
+ if ( in_array( $cat, $post_cats ) ) {
361
  $check = true;
362
  }
363
  }
365
  if ( $check ) {
366
  // hang on -- can registered users subscribe to
367
  // excluded categories?
368
+ if ( '0' === $this->subscribe2_options['reg_override'] ) {
369
  // nope? okay, let's leave
370
  return $post;
371
  }
373
 
374
  // Are we sending notifications for Private posts?
375
  // Action is added if we are, but double check option and post status
376
+ if ( 'yes' === $this->subscribe2_options['private'] && 'private' === $post->post_status ) {
377
  // don't send notification to public users
378
  $check = true;
379
  }
380
 
381
  // lets collect our subscribers
382
  $public = array();
383
+ if ( ! $check ) {
384
  // if this post is assigned to an excluded
385
  // category, or is a private post then
386
  // don't send public subscribers a notification
387
  $public = $this->get_public();
388
  }
389
+ if ( 'page' === $post->post_type ) {
390
+ $post_cats_string = implode( ',', get_all_category_ids() );
391
  } else {
392
+ $post_cats_string = implode( ',', $post_cats );
393
  }
394
+ $registered = $this->get_registered( "cats=$post_cats_string" );
395
 
396
  // do we have subscribers?
397
+ if ( empty( $public ) && empty( $registered ) ) {
398
  // if not, no sense doing anything else
399
  return $post;
400
  }
401
  } else {
402
  // make sure we prime the taxonomy variable for preview posts
403
+ $s2_taxonomies = apply_filters( 's2_taxonomies', array( 'category' ) );
404
  }
405
 
406
  // we set these class variables so that we can avoid
407
  // passing them in function calls a little later
408
+ $this->post_title = '<a href="' . $this->get_tracking_link( get_permalink( $post->ID ) ) . '">' . html_entity_decode( __( $post->post_title ), ENT_QUOTES ) . '</a>';
409
+ $this->post_title_text = html_entity_decode( __( $post->post_title ), ENT_QUOTES );
410
+ $this->permalink = get_permalink( $post->ID );
411
+ $this->post_date = get_the_time( get_option( 'date_format' ), $post );
412
+ $this->post_time = get_the_time( '', $post );
413
 
414
+ $author = get_userdata( $post->post_author );
415
+ $this->authorname = html_entity_decode( apply_filters( 'the_author', $author->display_name ), ENT_QUOTES );
416
 
417
  // do we send as admin, or post author?
418
+ if ( 'author' === $this->subscribe2_options['sender'] ) {
419
  // get author details
420
  $user = &$author;
421
  $this->myemail = $user->user_email;
422
+ $this->myname = html_entity_decode( $user->display_name, ENT_QUOTES );
423
+ } elseif ( 'blogname' === $this->subscribe2_options['sender'] ) {
424
+ $this->myemail = get_option( 'admin_email' );
425
+ $this->myname = html_entity_decode( get_option( 'blogname' ), ENT_QUOTES );
426
  } else {
427
  // get admin details
428
+ $user = $this->get_userdata( $this->subscribe2_options['sender'] );
429
  $this->myemail = $user->user_email;
430
+ $this->myname = html_entity_decode( $user->display_name, ENT_QUOTES );
431
  }
432
 
433
+ $this->post_cat_names = implode( ', ', wp_get_object_terms( $post->ID, $s2_taxonomies, array(
434
+ 'fields' => 'names',
435
+ ) ) );
436
+ $this->post_tag_names = implode( ', ', wp_get_post_tags( $post->ID, array(
437
+ 'fields' => 'names',
438
+ ) ) );
439
 
440
  // Get email subject
441
+ $subject = html_entity_decode( stripslashes( wp_kses( $this->substitute( $this->subscribe2_options['notification_subject'] ), '' ) ) );
442
  // Get the message template
443
+ $mailtext = apply_filters( 's2_email_template', $this->subscribe2_options['mailtext'] );
444
+ $mailtext = stripslashes( $this->substitute( $mailtext ) );
445
 
446
  $plaintext = $post->post_content;
447
+ $plaintext = strip_shortcodes( $plaintext );
448
 
449
+ $plaintext = preg_replace( '/<s[^>]*>(.*)<\/s>/Ui','', $plaintext );
450
+ $plaintext = preg_replace( '/<strike[^>]*>(.*)<\/strike>/Ui','', $plaintext );
451
+ $plaintext = preg_replace( '/<del[^>]*>(.*)<\/del>/Ui','', $plaintext );
452
  $excerpttext = $plaintext;
453
 
454
+ if ( strstr( $mailtext, '{REFERENCELINKS}' ) ) {
455
+ $mailtext = str_replace( '{REFERENCELINKS}', '', $mailtext );
456
  $plaintext_links = '';
457
  $i = 0;
458
+ while ( preg_match( '/<a([^>]*)>(.*)<\/a>/Ui', $plaintext, $matches ) ) {
459
+ if ( preg_match( '/href="([^"]*)"/', $matches[1], $link_matches ) ) {
460
  $plaintext_links .= sprintf( "[%d] %s\r\n", ++$i, $link_matches[1] );
461
+ $link_replacement = sprintf( '%s [%d]', $matches[2], $i );
462
  } else {
463
  $link_replacement = $matches[2];
464
  }
465
+ $plaintext = preg_replace( '/<a[^>]*>(.*)<\/a>/Ui', $link_replacement, $plaintext, 1 );
466
  }
467
  }
468
 
469
+ $plaintext = trim( strip_tags( $plaintext ) );
470
 
471
  if ( isset( $plaintext_links ) && '' !== $plaintext_links ) {
472
+ $plaintext .= "\r\n\r\n" . trim( $plaintext_links );
473
  }
474
 
475
  $gallid = '[gallery id="' . $post->ID . '"';
476
+ $content = str_replace( '[gallery', $gallid, $post->post_content );
477
 
478
  // remove the autoembed filter to remove iframes from notification emails
479
+ if ( get_option( 'embed_autourls' ) ) {
480
  global $wp_embed;
481
+ $priority = has_filter( 'the_content', array( &$wp_embed, 'autoembed' ) );
482
+ if ( false !== $priority ) {
483
+ remove_filter( 'the_content', array( &$wp_embed, 'autoembed' ), $priority );
484
  }
485
  }
486
 
487
+ $content = apply_filters( 'the_content', $content );
488
+ $content = str_replace( ']]>', ']]&gt', $content );
489
 
490
+ $excerpt = trim( $post->post_excerpt );
491
+ if ( '' === $excerpt ) {
492
  // no excerpt, is there a <!--more--> ?
493
+ if ( false !== strpos( $excerpttext, '<!--more-->' ) ) {
494
+ list( $excerpt, $more ) = explode( '<!--more-->', $excerpttext, 2 );
495
  // strip tags and trailing whitespace
496
+ $excerpt = trim( strip_tags( $excerpt ) );
497
  } else {
498
  // no <!--more-->, so grab the first 55 words
499
+ $excerpt = trim( strip_tags( $excerpttext ) );
500
+ $words = explode( ' ', $excerpt, $this->excerpt_length + 1 );
501
+ if ( count( $words ) > $this->excerpt_length ) {
502
+ array_pop( $words );
503
+ array_push( $words, '[...]' );
504
+ $excerpt = implode( ' ', $words );
505
  }
506
  }
507
  }
508
+ $html_excerpt = trim( $post->post_excerpt );
509
+ if ( '' === $html_excerpt ) {
510
  // no excerpt, is there a <!--more--> ?
511
+ if ( false !== strpos( $content, '<!--more-->' ) ) {
512
+ list( $html_excerpt, $more ) = explode( '<!--more-->', $content, 2 );
513
  // balance HTML tags and then strip leading and trailing whitespace
514
+ $html_excerpt = trim( balanceTags( $html_excerpt, true ) );
515
  } else {
516
  // no <!--more-->, so grab the first 55 words
517
+ $words = explode( ' ', $content, $this->excerpt_length + 1 );
518
+ if ( count( $words ) > $this->excerpt_length ) {
519
+ array_pop( $words );
520
+ array_push( $words, '[...]' );
521
+ $html_excerpt = implode( ' ', $words );
522
  // balance HTML tags and then strip leading and trailing whitespace
523
+ $html_excerpt = trim( balanceTags( $html_excerpt, true ) );
524
  } else {
525
  $html_excerpt = $content;
526
  }
527
  }
528
  }
529
 
 
 
 
 
 
 
 
 
530
  // remove excess white space from with $excerpt and $plaintext
531
+ $excerpt = preg_replace( '/[ ]+/', ' ', $excerpt );
532
+ $plaintext = preg_replace( '/[ ]+/', ' ', $plaintext );
533
 
534
  // prepare mail body texts
535
+ $plain_excerpt_body = str_replace( '{POST}', $excerpt, $mailtext );
536
+ $plain_body = str_replace( '{POST}', $plaintext, $mailtext );
537
+ $html_body = str_replace( "\r\n", "<br />\r\n", $mailtext );
538
+ $html_body = str_replace( '{POST}', $content, $html_body );
539
+ $html_excerpt_body = str_replace( "\r\n", "<br />\r\n", $mailtext );
540
+ $html_excerpt_body = str_replace( '{POST}', $html_excerpt, $html_excerpt_body );
541
+
542
+ if ( '' !== $preview ) {
543
  $this->myemail = $preview;
544
+ $this->myname = __( 'Plain Text Excerpt Preview', 'subscribe2' );
545
+ $this->mail( array( $preview ), $subject, $plain_excerpt_body );
546
+ $this->myname = __( 'Plain Text Full Preview', 'subscribe2' );
547
+ $this->mail( array( $preview ), $subject, $plain_body );
548
+ $this->myname = __( 'HTML Excerpt Preview', 'subscribe2' );
549
+ $this->mail( array( $preview ), $subject, $html_excerpt_body, 'html' );
550
+ $this->myname = __( 'HTML Full Preview', 'subscribe2' );
551
+ $this->mail( array( $preview ), $subject, $html_body, 'html' );
552
  } else {
553
  // Registered Subscribers first
554
  // first we send plaintext summary emails
555
+ $recipients = $this->get_registered( "cats=$post_cats_string&format=excerpt&author=$post->post_author" );
556
+ $recipients = apply_filters( 's2_send_plain_excerpt_subscribers', $recipients, $post->ID );
557
+ $this->mail( $recipients, $subject, $plain_excerpt_body );
558
 
559
  // next we send plaintext full content emails
560
+ $recipients = $this->get_registered( "cats=$post_cats_string&format=post&author=$post->post_author" );
561
+ $recipients = apply_filters( 's2_send_plain_fullcontent_subscribers', $recipients, $post->ID );
562
+ $this->mail( $recipients, $subject, $plain_body );
563
 
564
  // next we send html excerpt content emails
565
+ $recipients = $this->get_registered( "cats=$post_cats_string&format=html_excerpt&author=$post->post_author" );
566
+ $recipients = apply_filters( 's2_send_html_excerpt_subscribers', $recipients, $post->ID );
567
+ $this->mail( $recipients, $subject, $html_excerpt_body, 'html' );
568
 
569
  // next we send html full content emails
570
+ $recipients = $this->get_registered( "cats=$post_cats_string&format=html&author=$post->post_author" );
571
+ $recipients = apply_filters( 's2_send_html_fullcontent_subscribers', $recipients, $post->ID );
572
+ $this->mail( $recipients, $subject, $html_body, 'html' );
573
 
574
  // and finally we send to Public Subscribers
575
+ $recipients = apply_filters( 's2_send_public_subscribers', $public, $post->ID );
576
+ $this->mail( $recipients, $subject, $plain_excerpt_body, 'text' );
577
  }
578
  } // end publish()
579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
  /**
581
  Send confirmation email to a public subscriber
582
  */
583
+ function send_confirm( $what = '', $is_remind = false ) {
584
+ if ( 1 === $this->filtered ) { return true; }
585
+ if ( ! $this->email || ! $what ) { return false; }
586
+ $id = $this->get_id( $this->email );
587
+ if ( ! $id ) {
588
  return false;
589
  }
590
 
593
  // HASH = wp_hash of email address
594
  // ID = user's ID in the subscribe2 table
595
  // use home instead of siteurl incase index.php is not in core wordpress directory
596
+ $link = apply_filters( 's2_confirm_link', get_option( 'home' ) ) . '/?s2=';
597
 
598
+ if ( 'add' === $action ) {
599
  $link .= '1';
600
+ } elseif ( 'del' === $action && true === $public ) {
601
  $link .= '0';
602
  }
603
+ $link .= wp_hash( $this->email );
604
  $link .= $id;
605
 
606
  // sort the headers now so we have all substitute information
607
  $mailheaders = $this->headers();
608
 
609
+ if ( true === $is_remind ) {
610
+ $body = $this->substitute( stripslashes( $this->subscribe2_options['remind_email'] ) );
611
+ $subject = $this->substitute( stripslashes( $this->subscribe2_options['remind_subject'] ) );
612
  } else {
613
+ $body = apply_filters( 's2_confirm_email', stripslashes( $this->subscribe2_options['confirm_email'] ), $what );
614
+ $body = $this->substitute( $body );
615
+ if ( 'add' === $what ) {
616
+ $body = str_replace( '{ACTION}', $this->subscribe, $body );
617
+ $subject = str_replace( '{ACTION}', $this->subscribe, $this->subscribe2_options['confirm_subject'] );
618
+ } elseif ( 'del' === $what ) {
619
+ $body = str_replace( '{ACTION}', $this->unsubscribe, $body );
620
+ $subject = str_replace( '{ACTION}', $this->unsubscribe, $this->subscribe2_options['confirm_subject'] );
621
  }
622
+ $subject = html_entity_decode( $this->substitute( stripslashes( $subject ) ), ENT_QUOTES );
623
  }
624
 
625
+ $body = str_replace( '{LINK}', $link, $body );
626
 
627
+ if ( true === $is_remind && function_exists( 'wpmq_mail' ) ) {
628
  // could be sending lots of reminders so queue them if wpmq is enabled
629
+ @wp_mail( $this->email, $subject, $body, $mailheaders, '', 0 );
630
  } else {
631
+ return @wp_mail( $this->email, $subject, $body, $mailheaders );
632
  }
633
  } // end send_confirm()
634
 
635
+ /* ===== Public Subscriber functions ===== */
636
  /**
637
  Return an array of all the public subscribers
638
  */
639
+ function get_public( $confirmed = 1 ) {
640
  global $wpdb;
641
+ if ( 1 === $confirmed ) {
642
+ if ( '' === $this->all_confirmed ) {
643
+ $this->all_confirmed = $wpdb->get_col( "SELECT email FROM $this->public WHERE active='1'" );
644
  }
645
  return $this->all_confirmed;
646
  } else {
647
+ if ( '' === $this->all_unconfirmed ) {
648
+ $this->all_unconfirmed = $wpdb->get_col( "SELECT email FROM $this->public WHERE active='0'" );
649
  }
650
  return $this->all_unconfirmed;
651
  }
654
  /**
655
  Given a public subscriber ID, returns the email address
656
  */
657
+ function get_email( $id = 0 ) {
658
  global $wpdb;
659
 
660
+ if ( ! $id ) {
661
  return false;
662
  }
663
+ return $wpdb->get_var( $wpdb->prepare( "SELECT email FROM $this->public WHERE id=%d", $id ) );
664
  } // end get_email()
665
 
666
  /**
667
  Given a public subscriber email, returns the subscriber ID
668
  */
669
+ function get_id( $email = '' ) {
670
  global $wpdb;
671
 
672
+ if ( ! $email ) {
673
  return false;
674
  }
675
+ return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $this->public WHERE email=%s", $email ) );
676
  } // end get_id()
677
 
678
  /**
679
  Add an public subscriber to the subscriber table
680
  If added by admin it is immediately confirmed, otherwise as unconfirmed
681
  */
682
+ function add( $email = '', $confirm = false ) {
683
+ if ( 1 === $this->filtered ) { return; }
684
  global $wpdb;
685
 
686
+ if ( ! is_email( $email ) ) { return false; }
687
 
688
+ if ( false !== $this->is_public( $email ) ) {
689
  // is this an email for a registered user
690
+ $check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email=%s", $this->email ) );
691
  if ( $check ) { return; }
692
  if ( $confirm ) {
693
+ $wpdb->query( $wpdb->prepare( "UPDATE $this->public SET active='1', ip=%s WHERE CAST(email as binary)=%s", $this->ip, $email ) );
694
  } else {
695
+ $wpdb->query( $wpdb->prepare( "UPDATE $this->public SET date=CURDATE(), time=CURTIME() WHERE CAST(email as binary)=%s", $email ) );
696
  }
697
  } else {
698
  if ( $confirm ) {
699
  global $current_user;
700
+ $wpdb->query( $wpdb->prepare( "INSERT INTO $this->public (email, active, date, time, ip) VALUES (%s, %d, CURDATE(), CURTIME(), %s)", $email, 1, $current_user->user_login ) );
701
  } else {
702
+ $wpdb->query( $wpdb->prepare( "INSERT INTO $this->public (email, active, date, time, ip) VALUES (%s, %d, CURDATE(), CURTIME(), %s)", $email, 0, $this->ip ) );
703
  }
704
  }
705
  } // end add()
707
  /**
708
  Remove a public subscriber user from the subscription table
709
  */
710
+ function delete( $email = '' ) {
711
  global $wpdb;
712
 
713
+ if ( ! is_email( $email ) ) { return false; }
714
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $this->public WHERE CAST(email as binary)=%s LIMIT 1", $email ) );
715
  } // end delete()
716
 
717
  /**
718
  Toggle a public subscriber's status
719
  */
720
+ function toggle( $email = '' ) {
721
  global $wpdb;
722
 
723
+ if ( '' === $email || ! is_email( $email ) ) { return false; }
724
 
725
  // let's see if this is a public user
726
+ $status = $this->is_public( $email );
727
  if ( false === $status ) { return false; }
728
 
729
+ if ( '0' === $status ) {
730
+ $wpdb->query( $wpdb->prepare( "UPDATE $this->public SET active='1', conf_date=CURDATE(), conf_time=CURTIME(), conf_ip=%s WHERE CAST(email as binary)=%s LIMIT 1", $this->ip, $email ) );
731
  } else {
732
+ $wpdb->query( $wpdb->prepare( "UPDATE $this->public SET active='0', conf_date=CURDATE(), conf_time=CURTIME(), conf_ip=%s WHERE CAST(email as binary)=%s LIMIT 1", $this->ip, $email ) );
733
  }
734
  } // end toggle()
735
 
736
  /**
737
  Send reminder email to unconfirmed public subscribers
738
  */
739
+ function remind( $emails = '' ) {
740
+ if ( '' === $emails ) { return false; }
741
 
742
+ $recipients = explode( ',', $emails );
743
+ if ( ! is_array( $recipients ) ) { $recipients = (array) $recipients; }
744
  foreach ( $recipients as $recipient ) {
745
  $this->email = $recipient;
746
+ $this->send_confirm( 'add', true );
747
  }
748
  } //end remind()
749
 
750
  /**
751
  Is the supplied email address a public subscriber?
752
  */
753
+ function is_public( $email = '' ) {
754
  global $wpdb;
755
 
756
+ if ( '' === $email ) { return false; }
757
 
758
  // run the query and force case sensitivity
759
+ $check = $wpdb->get_var( $wpdb->prepare( "SELECT active FROM $this->public WHERE CAST(email as binary)=%s", $email ) );
760
+ if ( '0' === $check || '1' === $check ) {
761
  return $check;
762
  } else {
763
  return false;
764
  }
765
  } // end is_public()
766
 
767
+ /* ===== Registered User and Subscriber functions ===== */
768
  /**
769
  Is the supplied email address a registered user of the blog?
770
  */
771
+ function is_registered( $email = '' ) {
772
  global $wpdb;
773
 
774
+ if ( '' === $email ) { return false; }
775
 
776
+ $check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email=%s", $email ) );
777
  if ( $check ) {
778
  return true;
779
  } else {
784
  /**
785
  Return Registered User ID from email
786
  */
787
+ function get_user_id( $email = '' ) {
788
  global $wpdb;
789
 
790
+ if ( '' === $email ) { return false; }
791
 
792
+ $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->users WHERE user_email=%s", $email ) );
793
 
794
  return $id;
795
  } // end get_user_id()
797
  /**
798
  Return an array of all subscribers emails or IDs
799
  */
800
+ function get_all_registered( $return = 'email' ) {
801
  global $wpdb;
802
 
803
  if ( $this->s2_mu ) {
804
+ if ( 'ID' === $return ) {
805
+ if ( '' === $this->all_registered_id ) {
806
+ $this->all_registered_id = $wpdb->get_col( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities'" );
807
  }
808
  return $this->all_registered_id;
809
  } else {
810
+ if ( '' === $this->all_registered_email ) {
811
+ $this->all_registered_email = $wpdb->get_col( "SELECT a.user_email FROM $wpdb->users AS a INNER JOIN $wpdb->usermeta AS b ON a.ID = b.user_id WHERE b.meta_key='" . $wpdb->prefix . "capabilities'" );
812
  }
813
  return $this->all_registered_email;
814
  }
815
  } else {
816
+ if ( 'ID' === $return ) {
817
+ if ( '' === $this->all_registered_id ) {
818
+ $this->all_registered_id = $wpdb->get_col( "SELECT ID FROM $wpdb->users" );
819
  }
820
  return $this->all_registered_id;
821
+ } elseif ( 'emailid' === $return ) {
822
+ $this->all_registered_email_id = $wpdb->get_results( "SELECT user_email, ID FROM $wpdb->users", ARRAY_A );
823
+ return $this->all_registered_email_id;
824
  } else {
825
+ if ( '' === $this->all_registered_email ) {
826
+ $this->all_registered_email = $wpdb->get_col( "SELECT user_email FROM $wpdb->users" );
827
  }
828
  return $this->all_registered_email;
829
  }
834
  Return an array of registered subscribers
835
  Collect all the registered users of the blog who are subscribed to the specified categories
836
  */
837
+ function get_registered( $args = '' ) {
838
  global $wpdb;
839
 
840
+ parse_str( $args, $r );
841
+ if ( ! isset( $r['format'] ) ) {
842
  $r['format'] = 'all';
843
+ }
844
+ if ( ! isset( $r['cats'] ) ) {
845
  $r['cats'] = '';
846
+ }
847
+ if ( ! isset( $r['author'] ) ) {
848
  $r['author'] = '';
849
+ }
850
+ if ( ! isset( $r['return'] ) ) {
851
+ $r['return'] = 'email';
852
+ }
853
 
854
  // collect all subscribers for compulsory categories
855
+ $compulsory = explode( ',', $this->subscribe2_options['compulsory'] );
856
+ foreach ( explode( ',', $r['cats'] ) as $cat ) {
857
+ if ( in_array( $cat, $compulsory ) ) {
858
  $r['cats'] = '';
859
  }
860
  }
861
 
862
  $JOIN = ''; $AND = '';
863
  // text or HTML subscribers
864
+ if ( 'all' !== $r['format'] ) {
865
  $JOIN .= "INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id ";
866
+ $AND .= $wpdb->prepare( ' AND b.meta_key=%s AND b.meta_value=', $this->get_usermeta_keyname( 's2_format' ) );
867
+ if ( 'html' === $r['format'] ) {
868
  $AND .= "'html'";
869
+ } elseif ( 'html_excerpt' === $r['format'] ) {
870
  $AND .= "'html_excerpt'";
871
+ } elseif ( 'post' === $r['format'] ) {
872
  $AND .= "'post'";
873
+ } elseif ( 'excerpt' === $r['format'] ) {
874
  $AND .= "'excerpt'";
875
  }
876
  }
877
 
878
  // specific category subscribers
879
+ if ( '' !== $r['cats'] ) {
880
  $JOIN .= "INNER JOIN $wpdb->usermeta AS c ON a.user_id = c.user_id ";
881
  $and = '';
882
+ foreach ( explode( ',', $r['cats'] ) as $cat ) {
883
+ ('' === $and) ? $and = $wpdb->prepare( 'c.meta_key=%s', $this->get_usermeta_keyname( 's2_cat' ) . $cat ) : $and .= $wpdb->prepare( ' OR c.meta_key=%s', $this->get_usermeta_keyname( 's2_cat' ) . $cat );
884
  }
885
  $AND .= " AND ($and)";
886
  }
887
 
888
  // specific authors
889
+ if ( '' !== $r['author'] ) {
890
  $JOIN .= "INNER JOIN $wpdb->usermeta AS d ON a.user_id = d.user_id ";
891
+ $AND .= $wpdb->prepare( ' AND (d.meta_key=%s AND NOT FIND_IN_SET(%s, d.meta_value))', $this->get_usermeta_keyname( 's2_authors' ), $r['author'] );
892
  }
893
 
894
  if ( $this->s2_mu ) {
895
+ $sql = $wpdb->prepare( "SELECT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS e ON a.user_id = e.user_id " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND e.meta_key=%s AND e.meta_value <> ''" . $AND, $this->get_usermeta_keyname( 's2_subscribed' ) );
896
+ } else {
897
+ $sql = $wpdb->prepare( "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key=%s AND a.meta_value <> ''" . $AND, $this->get_usermeta_keyname( 's2_subscribed' ) );
898
+ }
899
+ $result = $wpdb->get_col( $sql );
900
+
901
+ if ( empty( $result ) || false === $result ) {
902
+ return array();
903
  } else {
904
+ $ids = implode( ',', array_map( array( $this, 'prepare_in_data' ), $result ) );
905
  }
906
+
907
+ if ( 'emailid' === $r['return'] ) {
908
+ $registered = $wpdb->get_results( "SELECT user_email, ID FROM $wpdb->users WHERE ID IN ($ids)", ARRAY_A );
909
+ } else {
910
+ $registered = $wpdb->get_col( "SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)" );
911
  }
912
 
913
+ if ( empty( $registered ) ) { return array(); }
914
 
915
  // apply filter to registered users to add or remove additional addresses, pass args too for additional control
916
+ $registered = apply_filters( 's2_registered_subscribers', $registered, $args );
917
  return $registered;
918
  } // end get_registered()
919
 
920
  /**
921
  Function to ensure email is compliant with internet messaging standards
922
  */
923
+ function sanitize_email( $email ) {
924
+ $email = trim( $email );
925
+ if ( ! is_email( $email ) ) { return; }
926
 
927
  // ensure that domain is in lowercase as per internet email standards http://www.ietf.org/rfc/rfc5321.txt
928
+ list( $name, $domain ) = explode( '@', $email, 2 );
929
+ return apply_filters( 's2_sanitize_email', $name . '@' . strtolower( $domain ) );
930
  } // end sanitize_email()
931
 
932
  /**
933
  Create the appropriate usermeta values when a user registers
934
  If the registering user had previously subscribed to notifications, this function will delete them from the public subscriber list first
935
  */
936
+ function register( $user_ID = 0, $consent = false ) {
937
  global $wpdb;
938
 
939
+ if ( 0 === $user_ID ) { return $user_ID; }
940
+ $user = get_userdata( $user_ID );
941
 
942
  // Subscribe registered users to categories obeying excluded categories
943
+ if ( 0 === $this->subscribe2_options['reg_override'] || 'no' === $this->subscribe2_options['newreg_override'] ) {
944
+ $all_cats = $this->all_cats( true, 'ID' );
945
  } else {
946
+ $all_cats = $this->all_cats( false, 'ID' );
947
  }
948
 
949
  $cats = '';
950
  foreach ( $all_cats as $cat ) {
951
+ ('' === $cats) ? $cats = "$cat->term_id" : $cats .= ",$cat->term_id";
952
  }
953
 
954
+ if ( '' === $cats ) {
955
  // sanity check, might occur if all cats excluded and reg_override = 0
956
  return $user_ID;
957
  }
958
 
959
  // has this user previously signed up for email notification?
960
+ if ( false !== $this->is_public( $this->sanitize_email( $user->user_email ) ) ) {
961
  // delete this user from the public table, and subscribe them to all the categories
962
+ $this->delete( $user->user_email );
963
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), $cats );
964
+ foreach ( explode( ',', $cats ) as $cat ) {
965
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $cat, $cat );
966
+ }
967
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), 'excerpt' );
968
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_autosub' ), $this->subscribe2_options['autosub_def'] );
969
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_authors' ), '' );
970
  } else {
971
  // create post format entries for all users
972
+ if ( in_array( $this->subscribe2_options['autoformat'], array( 'html', 'html_excerpt', 'post', 'excerpt' ) ) ) {
973
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), $this->subscribe2_options['autoformat'] );
974
  } else {
975
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), 'excerpt' );
976
  }
977
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_autosub' ), $this->subscribe2_options['autosub_def'] );
978
  // if the are no existing subscriptions, create them if we have consent
979
  if ( true === $consent ) {
980
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), $cats );
981
+ foreach ( explode( ',', $cats ) as $cat ) {
982
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $cat, $cat );
983
  }
984
  }
985
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_authors' ), '' );
986
  }
987
  return $user_ID;
988
  } // end register()
990
  /**
991
  Get admin data from record 1 or first user with admin rights
992
  */
993
+ function get_userdata( $admin_id ) {
994
  global $wpdb, $userdata;
995
 
996
+ if ( is_numeric( $admin_id ) ) {
997
+ $admin = get_userdata( $admin_id );
998
+ } elseif ( 'admin' === $admin_id ) {
999
  //ensure compatibility with < 4.16
1000
+ $admin = get_userdata( '1' );
1001
  } else {
1002
  $admin = &$userdata;
1003
  }
1004
 
1005
+ if ( empty( $admin ) || 0 === $admin->ID ) {
1006
+ $role = array(
1007
+ 'role' => 'administrator',
1008
+ );
1009
  $wp_user_query = get_users( $role );
1010
  $admin = $wp_user_query[0];
1011
  }
1016
  /**
1017
  Subscribe/unsubscribe user from one-click submission
1018
  */
1019
+ function one_click_handler( $user_ID, $action ) {
1020
+ if ( ! isset( $user_ID ) || ! isset( $action ) ) { return; }
1021
 
1022
+ $all_cats = $this->all_cats( true );
1023
 
1024
+ if ( 'subscribe' === $action ) {
1025
  // Subscribe
1026
  $new_cats = array();
1027
  foreach ( $all_cats as $cat ) {
1028
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id, $cat->term_id );
1029
  $new_cats[] = $cat->term_id;
1030
  }
1031
 
1032
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $new_cats ) );
1033
 
1034
+ if ( 'yes' === $this->subscribe2_options['show_autosub'] && 'no' !== get_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ), true ) ) {
1035
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_autosub' ), 'yes' );
1036
  }
1037
+ } elseif ( 'unsubscribe' === $action ) {
1038
  // Unsubscribe
1039
  foreach ( $all_cats as $cat ) {
1040
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id );
1041
  }
1042
 
1043
+ delete_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_subscribed' ) );
1044
+ update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_autosub' ), 'no' );
1045
  }
1046
  } //end one_click_handler()
1047
 
1048
+ /* ===== helper functions: forms and stuff ===== */
1049
  /**
1050
  Get an object of all categories, include default and custom type
1051
  */
1052
+ function all_cats( $exclude = false, $orderby = 'slug' ) {
1053
  $all_cats = array();
1054
+ $s2_taxonomies = apply_filters( 's2_taxonomies', array( 'category' ) );
1055
 
1056
  foreach ( $s2_taxonomies as $taxonomy ) {
1057
+ if ( taxonomy_exists( $taxonomy ) ) {
1058
+ $all_cats = array_merge( $all_cats, get_categories( array(
1059
+ 'hide_empty' => false,
1060
+ 'orderby' => $orderby,
1061
+ 'taxonomy' => $taxonomy,
1062
+ ) ) );
1063
  }
1064
  }
1065
 
1066
+ if ( true === $exclude ) {
1067
  // remove excluded categories from the returned object
1068
+ $excluded = explode( ',', $this->subscribe2_options['exclude'] );
1069
 
1070
  // need to use $id like this as this is a mixed array / object
1071
  $id = 0;
1072
+ foreach ( $all_cats as $cat ) {
1073
+ if ( in_array( $cat->term_id, $excluded ) ) {
1074
+ unset( $all_cats[ $id ] );
1075
  }
1076
  $id++;
1077
  }
1083
  /**
1084
  Function to sanitise array of data for SQL
1085
  */
1086
+ function prepare_in_data( $data ) {
1087
  global $wpdb;
1088
+ return $wpdb->prepare( '%s', $data );
1089
  } // end prepare_in_data()
1090
 
1091
  /**
1092
  Filter for usermeta table key names to adjust them if needed for WPMU blogs
1093
  */
1094
+ function get_usermeta_keyname( $metaname ) {
1095
  global $wpdb;
1096
 
1097
  // Is this WordPressMU or not?
1098
+ if ( true === $this->s2_mu ) {
1099
+ switch ( $metaname ) {
1100
  case 's2_subscribed':
1101
  case 's2_cat':
1102
  case 's2_format':
1114
  Adds information to the WordPress registration screen for new users
1115
  */
1116
  function register_form() {
1117
+ if ( 'no' === $this->subscribe2_options['autosub'] ) { return; }
1118
+ if ( 'wpreg' === $this->subscribe2_options['autosub'] ) {
1119
+ echo '<p><label>';
1120
+ echo __( 'Check here to Subscribe to email notifications for new posts', 'subscribe2' ) . ':<br />' . "\r\n";
1121
+ echo '<input type="checkbox" name="reg_subscribe"' . checked( $this->subscribe2_options['wpregdef'], 'yes', false ) . ' />';
1122
+ echo '</label></p>' . "\r\n";
1123
+ } elseif ( 'yes' === $this->subscribe2_options['autosub'] ) {
1124
+ echo '<p><center>' . "\r\n";
1125
+ 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";
1126
+ echo '</center></p>' . "\r\n";
 
1127
  }
1128
  } // end register_form()
1129
 
1130
  /**
1131
  Process function to add action if user selects to subscribe to posts during registration
1132
  */
1133
+ function register_post( $user_ID = 0 ) {
1134
  global $_POST;
1135
+ if ( 0 === $user_ID ) { return; }
1136
+ if ( 'yes' === $this->subscribe2_options['autosub'] || ( isset( $_POST['reg_subscribe'] ) && 'on' === $_POST['reg_subscribe'] && 'wpreg' === $this->subscribe2_options['autosub'] ) ) {
1137
+ $this->register( $user_ID, true );
1138
  } else {
1139
+ $this->register( $user_ID, false );
1140
  }
1141
  } // end register_post()
1142
 
1143
+ /* ===== comment subscriber functions ===== */
1144
  /**
1145
  Display check box on comment page
1146
  */
1147
+ function s2_comment_meta_form( $submit_field ) {
1148
  if ( is_user_logged_in() ) {
1149
+ $comment_meta_form = $this->profile;
1150
+ } else {
1151
+ $comment_meta_form = '<p style="width: auto;"><label><input type="checkbox" name="s2_comment_request" value="1" ' . checked( $this->subscribe2_options['comment_def'], 'yes', false ) . '/> ' . __( 'Check here to Subscribe to notifications for new posts', 'subscribe2' ) . '</label></p>';
1152
+ }
1153
+ if ( 'before' === $this->subscribe2_options['comment_subs'] ) {
1154
+ return $comment_meta_form . $submit_field;
1155
  } else {
1156
+ return $submit_field . '<br />' . $comment_meta_form;
1157
  }
1158
  } // end s2_comment_meta_form()
1159
 
1160
  /**
1161
  Process comment meta data
1162
  */
1163
+ function s2_comment_meta( $comment_ID, $approved = 0 ) {
1164
+ // return if email is empty - can happen if setting to require name and email for comments is disabled
1165
+ if ( isset( $_POST['email'] ) && empty( $_POST['email'] ) ) { return; }
1166
+ if ( isset( $_POST['s2_comment_request'] ) && '1' === $_POST['s2_comment_request'] ) {
1167
+ switch ( $approved ) {
1168
  case '0':
1169
  // Unapproved so hold in meta data pending moderation
1170
+ add_comment_meta( $comment_ID, 's2_comment_request', $_POST['s2_comment_request'] );
1171
  break;
1172
  case '1':
1173
  // Approved so add
1174
+ $comment = get_comment( $comment_ID );
1175
+ $is_public = $this->is_public( $comment->comment_author_email );
1176
+ if ( 0 === $is_public ) {
1177
+ $this->toggle( $comment->comment_author_email );
1178
  }
1179
+ $is_registered = $this->is_registered( $comment->comment_author_email );
1180
+ if ( ! $is_public && ! $is_registered ) {
1181
+ $this->add( $comment->comment_author_email, true );
1182
  }
1183
  break;
1184
  default :
1190
  /**
1191
  Action subscribe requests made on comment forms when comments are approved
1192
  */
1193
+ function comment_status( $comment_ID = 0 ) {
1194
  global $wpdb;
1195
 
1196
  // get meta data
1197
+ $subscribe = get_comment_meta( $comment_ID, 's2_comment_request', true );
1198
+ if ( '1' !== $subscribe ) { return $comment_ID; }
1199
 
1200
  // Retrieve the information about the comment
1201
+ $sql = $wpdb->prepare( "SELECT comment_author_email, comment_approved FROM $wpdb->comments WHERE comment_ID=%s LIMIT 1", $comment_ID );
1202
+ $comment = $wpdb->get_row( $sql, OBJECT );
1203
+ if ( empty( $comment ) ) { return $comment_ID; }
1204
 
1205
+ switch ( $comment->comment_approved ) {
1206
  case '0': // Unapproved
1207
  break;
1208
  case '1': // Approved
1209
+ $is_public = $this->is_public( $comment->comment_author_email );
1210
+ if ( 0 === $is_public ) {
1211
+ $this->toggle( $comment->comment_author_email );
1212
  }
1213
+ $is_registered = $this->is_registered( $comment->comment_author_email );
1214
+ if ( ! $is_public && ! $is_registered ) {
1215
+ $this->add( $comment->comment_author_email, true );
1216
  }
1217
+ delete_comment_meta( $comment_ID, 's2_comment_request' );
1218
  break;
1219
  default: // post is trash, spam or deleted
1220
+ delete_comment_meta( $comment_ID, 's2_comment_request' );
1221
  break;
1222
  }
1223
 
1224
  return $comment_ID;
1225
  } // end comment_status()
1226
 
1227
+ /* ===== widget functions ===== */
1228
  /**
1229
  Register the form widget
1230
  */
1231
  function subscribe2_widget() {
1232
+ require_once( S2PATH . 'classes/class-s2-form-widget.php' );
1233
+ register_widget( 'S2_Form_Widget' );
1234
  } // end subscribe2_widget()
1235
 
1236
  /**
1237
  Register the counter widget
1238
  */
1239
  function counter_widget() {
1240
+ require_once( S2PATH . 'classes/class-s2-counter-widget.php' );
1241
+ register_widget( 'S2_Counter_Widget' );
1242
  } // end counter_widget()
1243
 
1244
+ /* ===== wp-cron functions ===== */
1245
  /**
1246
  Add a weekly event to cron
1247
  */
1248
+ function add_weekly_sched( $scheds ) {
1249
  $exists = false;
1250
  foreach ( $scheds as $sched ) {
1251
+ if ( array_search( 604800, $sched ) ) {
1252
  $exists = true;
1253
  }
1254
  }
1255
 
1256
+ if ( ! $exists ) {
1257
+ $scheds['weekly'] = array(
1258
+ 'interval' => 604800,
1259
+ 'display' => __( 'Weekly', 'subscribe2' ),
1260
+ );
1261
  }
1262
 
1263
  return $scheds;
1266
  /**
1267
  Handle post transitions for the digest email
1268
  */
1269
+ function digest_post_transitions( $new_status, $old_status, $post ) {
1270
  if ( $new_status === $old_status ) { return; }
1271
 
1272
+ if ( 'yes' === $this->subscribe2_options['pages'] ) {
1273
+ $s2_post_types = array( 'page', 'post' );
1274
  } else {
1275
+ $s2_post_types = array( 'post' );
1276
  }
1277
+ $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
1278
+ if ( ! in_array( $post->post_type, $s2_post_types ) ) { return; }
1279
 
1280
  update_post_meta( $post->ID, '_s2_digest_post_status', ( 'publish' === $new_status ) ? 'pending' : 'draft' );
1281
  } // end digest_post_transitions()
1283
  /**
1284
  Send a daily digest of today's new posts
1285
  */
1286
+ function subscribe2_cron( $preview = '', $resend = '' ) {
1287
+ if ( defined( 'DOING_S2_CRON' ) && DOING_S2_CRON ) { return; }
1288
  define( 'DOING_S2_CRON', true );
1289
  global $wpdb, $post;
1290
 
1291
+ if ( '' === $preview ) {
1292
  // set up SQL query based on options
1293
+ if ( 'yes' === $this->subscribe2_options['private'] ) {
1294
  $status = "'publish', 'private'";
1295
  } else {
1296
  $status = "'publish'";
1298
 
1299
  // send notifications for allowed post type (defaults for posts and pages)
1300
  // uses s2_post_types filter to allow for custom post types in WP 3.0
1301
+ if ( 'yes' === $this->subscribe2_options['pages'] ) {
1302
+ $s2_post_types = array( 'page', 'post' );
1303
  } else {
1304
+ $s2_post_types = array( 'post' );
1305
  }
1306
+ $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
1307
  foreach ( $s2_post_types as $post_type ) {
1308
+ if ( ! isset( $type ) ) {
1309
+ $type = $wpdb->prepare( '%s', $post_type );
1310
  } else {
1311
+ $type .= $wpdb->prepare( ', %s', $post_type );
1312
  }
1313
  }
1314
 
1315
  // collect posts
1316
+ if ( 'resend' === $resend ) {
1317
  $query = new WP_Query( array(
1318
+ 'post__in' => explode( ',', $this->subscribe2_options['last_s2cron'] ),
1319
  'ignore_sticky_posts' => 1,
1320
+ 'order' => ( 'desc' === $this->subscribe2_options['cron_order'] ) ? 'DESC' : 'ASC',
1321
+ ) );
1322
  $posts = $query->posts;
1323
  } else {
1324
  $sql = "SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts AS a INNER JOIN $wpdb->postmeta AS b ON b.post_id = a.ID";
1325
+ $sql .= " AND b.meta_key = '_s2_digest_post_status' AND b.meta_value = 'pending' WHERE post_status IN ($status) AND post_type IN ($type) ORDER BY post_date " . ( ( 'desc' === $this->subscribe2_options['cron_order'] ) ? 'DESC' : 'ASC' );
1326
+ $posts = $wpdb->get_results( $sql );
1327
  }
1328
  } else {
1329
  // we are sending a preview
1330
+ $posts = get_posts( 'numberposts=1' );
 
 
1331
  }
1332
 
1333
  // Collect sticky posts if desired
1334
  $sticky_ids = array();
1335
+ if ( 'yes' === $this->subscribe2_options['stickies'] ) {
1336
+ $sticky_ids = get_option( 'sticky_posts' );
1337
+ if ( ! empty( $sticky_ids ) ) {
1338
+ $sticky_posts = get_posts( array(
1339
+ 'post__in' => $sticky_ids,
1340
+ ) );
1341
+ $posts = array_merge( (array) $sticky_posts, (array) $posts );
1342
  }
1343
  }
1344
 
1345
  // do we have any posts?
1346
+ if ( empty( $posts ) && ! has_filter( 's2_digest_email' ) ) { return false; }
1347
+
1348
+ // remove the autoembed filter to remove iframes from notification emails
1349
+ if ( get_option( 'embed_autourls' ) ) {
1350
+ global $wp_embed;
1351
+ $priority = has_filter( 'the_content', array( &$wp_embed, 'autoembed' ) );
1352
+ if ( false !== $priority ) {
1353
+ remove_filter( 'the_content', array( &$wp_embed, 'autoembed' ), $priority );
1354
+ }
1355
+ }
1356
 
1357
  // if we have posts, let's prepare the digest
1358
  // define some variables needed for the digest
1359
+ $datetime = get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' );
1360
  $all_post_cats = array();
1361
  $ids = array();
1362
  $digest_post_ids = array();
1363
+ $mailtext = apply_filters( 's2_email_template', $this->subscribe2_options['mailtext'] );
1364
  $table = '';
1365
  $tablelinks = '';
1366
+ $message_post = '';
1367
  $message_posttime = '';
1368
+ $this->post_count = count( $posts );
1369
+ $s2_taxonomies = apply_filters( 's2_taxonomies', array( 'category' ) );
1370
 
1371
  foreach ( $posts as $post ) {
1372
  // keep an array of post ids and skip if we've already done it once
1373
+ if ( in_array( $post->ID, $ids ) ) { continue; }
1374
  $ids[] = $post->ID;
1375
+ $post_cats = wp_get_object_terms( $post->ID, $s2_taxonomies, array(
1376
+ 'fields' => 'ids',
1377
+ ) );
1378
+ $post_cats_string = implode( ',', $post_cats );
1379
+ $all_post_cats = array_unique( array_merge( $all_post_cats, $post_cats ) );
1380
+
1381
+ // make sure we exclude posts from live emails if so configured
1382
  $check = false;
1383
+ if ( '' === $preview ) {
1384
+ // Pages are put into category 1 so make sure we don't exclude
1385
+ // pages if category 1 is excluded
1386
+ if ( 'page' !== $post->post_type ) {
1387
+ // is the current post assigned to any categories
1388
+ // which should not generate a notification email?
1389
+ foreach ( explode( ',', $this->subscribe2_options['exclude'] ) as $cat ) {
1390
+ if ( in_array( $cat, $post_cats ) ) {
1391
+ $check = true;
1392
+ }
1393
  }
1394
  }
1395
+ // is the current post set by the user to
1396
+ // not generate a notification email?
1397
+ $s2mail = get_post_meta( $post->ID, '_s2mail', true );
1398
+ if ( 'no' === strtolower( trim( $s2mail ) ) ) {
1399
+ $check = true;
1400
+ }
1401
+ // is the current post private
1402
+ // and should this not generate a notification email?
1403
+ if ( 'no' === $this->subscribe2_options['password'] && '' !== $post->post_password ) {
1404
+ $check = true;
1405
+ }
1406
+ // is the post assigned a format that should
1407
+ // not be included in the notification email?
1408
+ $post_format = get_post_format( $post->ID );
1409
+ $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
1410
+ if ( false !== $post_format && in_array( $post_format, $excluded_formats ) ) {
1411
+ $check = true;
1412
+ }
1413
+ // if this post is excluded
1414
+ // don't include it in the digest
1415
+ if ( $check ) {
1416
+ $this->post_count --;
1417
+ continue;
1418
+ }
1419
  }
1420
  // is the current post set by the user to
1421
  // not generate a notification email?
1422
+ $s2mail = get_post_meta( $post->ID, '_s2mail', true );
1423
+ if ( 'no' === strtolower( trim( $s2mail ) ) ) {
1424
  $check = true;
1425
  }
1426
  // is the current post private
1427
  // and should this not generate a notification email?
1428
+ if ( 'no' === $this->subscribe2_options['password'] && '' !== $post->post_password ) {
1429
  $check = true;
1430
  }
1431
  // is the post assigned a format that should
1432
  // not be included in the notification email?
1433
+ $post_format = get_post_format( $post->ID );
1434
+ $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
1435
+ if ( false !== $post_format && in_array( $post_format, $excluded_formats ) ) {
1436
  $check = true;
1437
  }
1438
  // if this post is excluded
1443
 
1444
  $digest_post_ids[] = $post->ID;
1445
 
1446
+ $post_title = html_entity_decode( __( $post->post_title ), ENT_QUOTES );
1447
+ ('' === $table) ? $table .= '* ' . $post_title : $table .= "\r\n* " . $post_title;
1448
+ ('' === $tablelinks) ? $tablelinks .= '* ' . $post_title : $tablelinks .= "\r\n* " . $post_title;
1449
  $message_post .= $post_title;
1450
  $message_posttime .= $post_title;
1451
+ if ( strstr( $mailtext, '{AUTHORNAME}' ) ) {
1452
+ $author = get_userdata( $post->post_author );
1453
+ if ( '' !== $author->display_name ) {
1454
+ $message_post .= ' (' . __( 'Author', 'subscribe2' ) . ': ' . html_entity_decode( apply_filters( 'the_author', $author->display_name ), ENT_QUOTES ) . ')';
1455
+ $message_posttime .= ' (' . __( 'Author', 'subscribe2' ) . ': ' . html_entity_decode( apply_filters( 'the_author', $author->display_name ), ENT_QUOTES ) . ')';
1456
  }
1457
  }
1458
  $message_post .= "\r\n";
1459
  $message_posttime .= "\r\n";
1460
 
1461
+ $message_posttime .= __( 'Posted on', 'subscribe2' ) . ': ' . mysql2date( $datetime, $post->post_date ) . "\r\n";
1462
+ if ( strstr( $mailtext, '{TINYLINK}' ) ) {
1463
+ $tinylink = file_get_contents( 'http://tinyurl.com/api-create.php?url=' . urlencode( $this->get_tracking_link( get_permalink( $post->ID ) ) ) );
1464
  } else {
1465
  $tinylink = false;
1466
  }
1467
+ if ( strstr( $mailtext, '{TINYLINK}' ) && 'Error' !== $tinylink && false !== $tinylink ) {
1468
  $tablelinks .= "\r\n" . $tinylink . "\r\n";
1469
  $message_post .= $tinylink . "\r\n";
1470
  $message_posttime .= $tinylink . "\r\n";
1471
  } else {
1472
+ $tablelinks .= "\r\n" . $this->get_tracking_link( get_permalink( $post->ID ) ) . "\r\n";
1473
+ $message_post .= $this->get_tracking_link( get_permalink( $post->ID ) ) . "\r\n";
1474
+ $message_posttime .= $this->get_tracking_link( get_permalink( $post->ID ) ) . "\r\n";
1475
+ }
1476
+
1477
+ if ( strstr( $mailtext, '{CATS}' ) ) {
1478
+ $post_cat_names = implode( ', ', wp_get_object_terms( $post->ID, $s2_taxonomies, array(
1479
+ 'fields' => 'names',
1480
+ ) ) );
1481
+ $message_post .= __( 'Posted in', 'subscribe2' ) . ': ' . $post_cat_names . "\r\n";
1482
+ $message_posttime .= __( 'Posted in', 'subscribe2' ) . ': ' . $post_cat_names . "\r\n";
1483
+ }
1484
+ if ( strstr( $mailtext, '{TAGS}' ) ) {
1485
+ $post_tag_names = implode( ', ', wp_get_post_tags( $post->ID, array(
1486
+ 'fields' => 'names',
1487
+ ) ) );
1488
+ if ( '' !== $post_tag_names ) {
1489
+ $message_post .= __( 'Tagged as', 'subscribe2' ) . ': ' . $post_tag_names . "\r\n";
1490
+ $message_posttime .= __( 'Tagged as', 'subscribe2' ) . ': ' . $post_tag_names . "\r\n";
1491
  }
1492
  }
1493
  $message_post .= "\r\n";
1494
  $message_posttime .= "\r\n";
1495
 
1496
+ ( ! empty( $post->post_excerpt ) ) ? $excerpt = trim( $post->post_excerpt ) : $excerpt = '';
1497
+ if ( '' === $excerpt ) {
1498
+ $excerpt = apply_filters( 'the_content', $post->post_content );
1499
  // no excerpt, is there a <!--more--> ?
1500
+ if ( false !== strpos( $post->post_content, '<!--more-->' ) ) {
1501
+ list($excerpt, $more) = explode( '<!--more-->', $post->post_content, 2 );
1502
+ $excerpt = strip_tags( $excerpt );
1503
+ $excerpt = strip_shortcodes( $excerpt );
1504
  } else {
1505
+ $excerpt = strip_tags( $post->post_content );
1506
+ $excerpt = strip_shortcodes( $excerpt );
1507
+ $words = explode( ' ', $excerpt, $this->excerpt_length + 1 );
1508
+ if ( count( $words ) > $this->excerpt_length ) {
1509
+ array_pop( $words );
1510
+ array_push( $words, '[...]' );
1511
+ $excerpt = implode( ' ', $words );
1512
  }
1513
  }
1514
  // strip leading and trailing whitespace
1515
+ $excerpt = trim( $excerpt );
1516
  }
1517
  $message_post .= $excerpt . "\r\n\r\n";
1518
  $message_posttime .= $excerpt . "\r\n\r\n";
1532
  }
1533
 
1534
  // we add a blank line after each post excerpt now trim white space that occurs for the last post
1535
+ $message_post = trim( $message_post );
1536
+ $message_posttime = trim( $message_posttime );
1537
  // remove excess white space from within $message_post and $message_posttime
1538
+ $message_post = preg_replace( '/[ ]+/', ' ', $message_post );
1539
+ $message_posttime = preg_replace( '/[ ]+/', ' ', $message_posttime );
1540
+ $message_post = preg_replace( "/[\r\n]{3,}/", "\r\n\r\n", $message_post );
1541
+ $message_posttime = preg_replace( "/[\r\n]{3,}/", "\r\n\r\n", $message_posttime );
1542
 
1543
  // apply filter to allow external content to be inserted or content manipulated
1544
+ $message_post = apply_filters( 's2_digest_email', $message_post );
1545
+ $message_posttime = apply_filters( 's2_digest_email', $message_posttime );
1546
 
1547
  //sanity check - don't send a mail if the content is empty
1548
+ if ( ! $message_post && ! $message_posttime && ! $table && ! $tablelinks ) {
1549
  return;
1550
  }
1551
 
1552
  // get sender details
1553
+ if ( 'blogname' === $this->subscribe2_options['sender'] ) {
1554
+ $this->myname = html_entity_decode( get_option( 'blogname' ), ENT_QUOTES );
1555
+ $this->myemail = get_bloginfo( 'admin_email' );
1556
  } else {
1557
+ $user = $this->get_userdata( $this->subscribe2_options['sender'] );
1558
  $this->myemail = $user->user_email;
1559
+ $this->myname = html_entity_decode( $user->display_name, ENT_QUOTES );
1560
  }
1561
 
1562
+ $scheds = (array) wp_get_schedules();
1563
  $email_freq = $this->subscribe2_options['email_freq'];
1564
+ $display = $scheds[ $email_freq ]['display'];
1565
+ ( '' === get_option( 'blogname' ) ) ? $subject = '' : $subject = '[' . stripslashes( html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . '] ';
1566
+ $subject .= $display . ' ' . __( 'Digest Email', 'subscribe2' );
1567
+ $mailtext = str_replace( '{TABLELINKS}', $tablelinks, $mailtext );
1568
+ $mailtext = str_replace( '{TABLE}', $table, $mailtext );
1569
+ $mailtext = str_replace( '{POSTTIME}', $message_posttime, $mailtext );
1570
+ $mailtext = str_replace( '{POST}', $message_post, $mailtext );
1571
 
1572
  // apply filter to allow custom keywords
1573
+ $mailtext = apply_filters( 's2_custom_keywords', $mailtext, $digest_post_ids );
1574
+ $mailtext = stripslashes( $this->substitute( $mailtext ) );
1575
 
1576
  // prepare recipients
1577
+ if ( '' !== $preview ) {
1578
  $this->myemail = $preview;
1579
+ $this->myname = __( 'Digest Preview', 'subscribe2' );
1580
+ $this->mail( array( $preview ), $subject, $mailtext );
1581
  } else {
1582
  $public = $this->get_public();
1583
+ $all_post_cats_string = implode( ',', $all_post_cats );
1584
+ $registered = $this->get_registered( "cats=$all_post_cats_string" );
1585
+ $recipients = array_merge( (array) $public, (array) $registered );
1586
+ $this->mail( $recipients, $subject, $mailtext );
1587
  }
1588
  } // end subscribe2_cron()
1589
 
1590
+ /**
1591
+ Task to delete unconfirmed public subscribers after a defined interval
1592
+ */
1593
  function s2cleaner_task() {
1594
+ $unconfirmed = $this->get_public( 0 );
1595
+ if ( empty( $unconfirmed ) ) { return; }
1596
  global $wpdb;
1597
+ $sql = $wpdb->prepare( "SELECT email FROM $this->public WHERE active='0' AND date < DATE_SUB(CURDATE(), INTERVAL %d DAY) AND conf_date IS NULL", $this->clean_interval );
1598
  $old_unconfirmed = $wpdb->get_col( $sql );
1599
+ if ( empty( $old_unconfirmed ) ) {
1600
  return;
1601
  } else {
1602
  foreach ( $old_unconfirmed as $email ) {
1603
+ $this->delete( $email );
1604
  }
1605
  }
1606
  return;
1609
  /**
1610
  Jetpack comments doesn't play nice, this function kills that module
1611
  */
1612
+ function s2_hide_jetpack_comments( $modules ) {
1613
+ unset( $modules['comments'] );
1614
  return $modules;
1615
  } // end s2_kill_jetpack_comments()
1616
 
1617
+ /* ===== Our constructor ===== */
1618
  /**
1619
  Subscribe2 constructor
1620
  */
1621
  function s2init() {
1622
  global $wpdb, $wp_version, $wpmu_version;
1623
  // load the options
1624
+ $this->subscribe2_options = get_option( 'subscribe2_options' );
1625
  // if SCRIPT_DEBUG is true, use dev scripts
1626
+ $this->script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1627
+
1628
+ $this->word_wrap = apply_filters( 's2_word_wrap', 78 );
1629
+ // RFC5322 states line length MUST be no more than 998 characters
1630
+ // and SHOULD be no more than 78 characters
1631
+ // Use 78 as default and cap user values above 998
1632
+ if ( $this->word_wrap > 998 ) {
1633
+ $this->word_wrap = 998;
1634
+ }
1635
+ $this->excerpt_length = apply_filters( 's2_excerpt_length', 55 );
1636
+ $this->site_switching = apply_filters( 's2_allow_site_switching', false );
1637
+ $this->clean_interval = apply_filters( 's2_clean_interval', 28 );
1638
+ $this->lockout = apply_filters( 's2_lockout', 0 );
1639
+ // lockout is for a maximum of 24 hours so cap the value
1640
+ if ( $this->lockout > 86399 ) {
1641
+ $this->lockout > 86399;
1642
+ }
1643
 
1644
  // get the WordPress release number for in code version comparisons
1645
+ $tmp = explode( '-', $wp_version, 2 );
1646
  $this->wp_release = $tmp[0];
1647
 
1648
  // Is this WordPressMU or not?
1649
+ if ( isset( $wpmu_version ) || strpos( $wp_version, 'wordpress-mu' ) ) {
1650
  $this->s2_mu = true;
1651
  }
1652
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
1653
  $this->s2_mu = true;
1654
  }
1655
 
1656
  // add action to handle WPMU subscriptions and unsubscriptions
1657
+ if ( true === $this->s2_mu ) {
1658
+ require_once( S2PATH . 'classes/class-s2-multisite.php' );
1659
  global $s2class_multisite;
1660
+ $s2class_multisite = new S2_Multisite;
1661
+ if ( isset( $_GET['s2mu_subscribe'] ) || isset( $_GET['s2mu_unsubscribe'] ) ) {
1662
+ add_action( 'init', array( &$s2class_multisite, 'wpmu_subscribe' ) );
1663
  }
1664
  }
1665
 
1666
  // load our translations
1667
+ add_action( 'plugins_loaded', array( &$this, 'load_translations' ) );
1668
 
1669
  // do we need to install anything?
1670
+ $this->public = $wpdb->prefix . 'subscribe2';
1671
+ if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $this->public ) ) !== $this->public ) {
1672
+ $this->install();
1673
+ }
1674
+
1675
  //do we need to upgrade anything?
1676
+ if ( false === $this->subscribe2_options || is_array( $this->subscribe2_options ) && S2VERSION !== $this->subscribe2_options['version'] ) {
1677
+ require_once( S2PATH . 'classes/class-s2-upgrade.php' );
1678
+ global $s2_upgrade;
1679
+ $s2_upgrade = new S2_Upgrade;
1680
+ add_action( 'shutdown', array( &$s2_upgrade, 'upgrade' ) );
1681
  }
1682
 
1683
  // add core actions
1684
+ add_filter( 'cron_schedules', array( &$this, 'add_weekly_sched' ), 20 );
1685
  // add actions for automatic subscription based on option settings
1686
  if ( $this->s2_mu ) {
1687
+ add_action( 'wpmu_activate_user', array( &$s2class_multisite, 'wpmu_add_user' ) );
1688
+ add_action( 'add_user_to_blog', array( &$s2class_multisite, 'wpmu_add_user' ), 10 );
1689
+ add_action( 'remove_user_from_blog', array( &$s2class_multisite, 'wpmu_remove_user' ), 10 );
1690
  } else {
1691
+ add_action( 'register_form', array( &$this, 'register_form' ) );
1692
+ add_action( 'user_register', array( &$this, 'register_post' ) );
1693
  }
1694
+
1695
  // add actions for processing posts based on per-post or cron email settings
1696
+ if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
1697
+ add_action( 's2_digest_cron', array( &$this, 'subscribe2_cron' ) );
1698
+ add_action( 'transition_post_status', array( &$this, 'digest_post_transitions' ), 10, 3 );
1699
  } else {
1700
+ $statuses = apply_filters( 's2_post_statuses', array( 'new', 'draft', 'auto-draft', 'pending' ) );
1701
+ if ( 'yes' === $this->subscribe2_options['private'] ) {
1702
  foreach ( $statuses as $status ) {
1703
+ add_action( "{$status}_to_private", array( &$this, 'publish' ) );
1704
  }
1705
  }
1706
+ array_push( $statuses, 'private', 'future' );
1707
  foreach ( $statuses as $status ) {
1708
+ add_action( "{$status}_to_publish", array( &$this, 'publish' ) );
1709
  }
1710
  }
1711
+
1712
  // add actions for comment subscribers
1713
  if ( 'no' !== $this->subscribe2_options['comment_subs'] ) {
1714
+ add_filter( 'jetpack_get_available_modules', array( &$this, 's2_hide_jetpack_comments' ) );
1715
+ add_filter( 'comment_form_submit_field', array( &$this, 's2_comment_meta_form' ) );
1716
+ add_action( 'comment_post', array( &$this, 's2_comment_meta' ), 1, 2 );
1717
+ add_action( 'wp_set_comment_status', array( &$this, 'comment_status' ) );
 
 
 
 
1718
  }
1719
+
1720
  // add action to display widget if option is enabled
1721
+ if ( '1' === $this->subscribe2_options['widget'] ) {
1722
+ add_action( 'widgets_init', array( &$this, 'subscribe2_widget' ) );
1723
  }
1724
  // add action to display counter widget if option is enabled
1725
+ if ( '1' === $this->subscribe2_options['counterwidget'] ) {
1726
+ add_action( 'widgets_init', array( &$this, 'counter_widget' ) );
1727
  }
1728
 
1729
  // add action to 'clean' unconfirmed Public Subscribers
1730
+ if ( is_int( $this->clean_interval ) && $this->clean_interval > 0 ) {
1731
+ add_action( 'wp_scheduled_delete', array( &$this, 's2cleaner_task' ) );
1732
  }
1733
 
1734
  // add ajax class if enabled
1735
  if ( '1' === $this->subscribe2_options['ajax'] ) {
1736
  require_once( S2PATH . 'classes/class-s2-ajax.php' );
1737
  global $mysubscribe2_ajax;
1738
+ $mysubscribe2_ajax = new S2_Ajax;
1739
  }
1740
 
1741
  // Add actions specific to admin or frontend
1742
  if ( is_admin() ) {
1743
  //add menu, authoring and category admin actions
1744
+ add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
1745
+ add_action( 'admin_menu', array( &$this, 's2_meta_init' ) );
1746
+ add_action( 'save_post', array( &$this, 's2_meta_handler' ) );
1747
+ add_action( 'create_category', array( &$this, 'new_category' ) );
1748
+ add_action( 'delete_category', array( &$this, 'delete_category' ) );
1749
 
1750
  // Add filters for Ozh Admin Menu
1751
+ if ( function_exists( 'wp_ozh_adminmenu' ) ) {
1752
+ add_filter( 'ozh_adminmenu_icon_s2_posts', array( &$this, 'ozh_s2_icon' ) );
1753
+ add_filter( 'ozh_adminmenu_icon_s2_users', array( &$this, 'ozh_s2_icon' ) );
1754
+ add_filter( 'ozh_adminmenu_icon_s2_tools', array( &$this, 'ozh_s2_icon' ) );
1755
+ add_filter( 'ozh_adminmenu_icon_s2_settings', array( &$this, 'ozh_s2_icon' ) );
1756
  }
1757
 
1758
  // add write button
1759
+ if ( '1' === $this->subscribe2_options['show_button'] ) {
1760
+ add_action( 'admin_init', array( &$this, 'button_init' ) );
1761
  }
1762
 
1763
  // add counterwidget css and js
1764
+ if ( '1' === $this->subscribe2_options['counterwidget'] ) {
1765
+ add_action( 'admin_init', array( &$this, 'widget_s2counter_css_and_js' ) );
1766
  }
1767
 
1768
  // add one-click handlers
1769
+ if ( 'yes' === $this->subscribe2_options['one_click_profile'] ) {
1770
+ add_action( 'show_user_profile', array( &$this, 'one_click_profile_form' ) );
1771
+ add_action( 'edit_user_profile', array( &$this, 'one_click_profile_form' ) );
1772
+ add_action( 'personal_options_update', array( &$this, 'one_click_profile_form_save' ) );
1773
+ add_action( 'edit_user_profile_update', array( &$this, 'one_click_profile_form_save' ) );
1774
  }
1775
 
1776
+ // digest email preview and resend actions
1777
+ add_action( 's2_digest_preview', array( &$this, 'digest_preview' ) );
1778
+ add_action( 's2_digest_resend', array( &$this, 'digest_resend' ) );
1779
+
1780
+ // add handler to dismiss sender error notice
1781
+ add_action( 'wp_ajax_s2_dismiss_notice', array( &$this, 's2_dismiss_notice_handler' ) );
1782
+
1783
  // capture CSV export
1784
+ if ( isset( $_POST['s2_admin'] ) && isset( $_POST['csv'] ) ) {
1785
+ $date = date( 'Y-m-d' );
1786
+ header( 'Content-Description: File Transfer' );
1787
+ header( 'Content-type: application/octet-stream' );
1788
+ header( "Content-Disposition: attachment; filename=subscribe2_users_$date.csv" );
1789
+ header( 'Pragma: no-cache' );
1790
+ header( 'Expires: 0' );
1791
+ echo $this->prepare_export( $_POST['exportcsv'] );
1792
+ exit( 0 );
1793
  }
1794
  } else {
1795
  // load strings later on frontend for polylang plugin compatibility
1796
+ add_action( 'wp', array( &$this, 'load_strings' ) );
1797
 
1798
+ if ( isset( $_GET['s2'] ) ) {
1799
  // someone is confirming a request
1800
+ add_filter( 'request', array( &$this, 'query_filter' ) );
1801
+ add_filter( 'the_title', array( &$this, 'title_filter' ) );
1802
+ add_filter( 'the_content', array( &$this, 'confirm' ) );
 
 
1803
  }
1804
 
1805
  // add the frontend filters
1806
+ add_shortcode( 'subscribe2', array( &$this, 'shortcode' ) );
1807
+ add_filter( 'the_content', array( &$this, 'filter' ), 10 );
1808
 
1809
  // add actions for other plugins
1810
+ if ( '1' === $this->subscribe2_options['show_meta'] ) {
1811
+ add_action( 'wp_meta', array( &$this, 'add_minimeta' ), 0 );
1812
+ }
1813
+
1814
+ // add action for adding javascript IP updating code
1815
+ if ( '1' === $this->subscribe2_options['js_ip_updater'] ) {
1816
+ add_action( 'wp_enqueue_scripts', array( &$this, 'js_ip_script' ), 10 );
1817
+ add_action( 'wp_footer', array( &$this, 'js_ip_library_script' ), 20 );
1818
  }
1819
  }
1820
  } // end s2init()
1821
 
1822
+ /* ===== our variables ===== */
 
 
 
 
 
 
 
 
 
 
 
 
1823
  // cache variables
1824
  var $subscribe2_options = array();
1825
  var $all_confirmed = '';
1826
  var $all_unconfirmed = '';
1827
  var $all_registered_id = '';
1828
  var $all_registered_email = '';
1829
+ var $all_registered_email_id = '';
1830
  var $excluded_cats = '';
1831
  var $post_title = '';
1832
+ var $post_title_text = '';
1833
  var $permalink = '';
1834
  var $post_date = '';
1835
  var $post_time = '';
1858
  var $profile = '';
1859
  var $confirmation_sent = '';
1860
  var $already_subscribed = '';
1861
+ var $not_subscribed = '';
1862
  var $not_an_email = '';
1863
  var $barred_domain = '';
1864
  var $error = '';
include/counterwidget.php → classes/class-s2-counter-widget.php RENAMED
@@ -1,11 +1,18 @@
1
  <?php
2
- class S2_Counter_widget extends WP_Widget {
3
  /**
4
  Declares the S2_Counter_widget class.
5
  */
6
  function __construct() {
7
- $widget_options = array( 'classname' => 's2_counter', 'description' => esc_html__( 'Subscriber Counter widget for Subscribe2', 'subscribe2' ) );
8
- $control_options = array( 'width' => 250, 'height' => 500 );
 
 
 
 
 
 
 
9
  parent::__construct( 's2_counter', esc_html__( 'Subscribe2 Counter', 'subscribe2' ), $widget_options, $control_options );
10
  }
11
 
@@ -56,9 +63,23 @@ class S2_Counter_widget extends WP_Widget {
56
  // set some defaults
57
  $options = get_option( 'widget_s2counter' );
58
  if ( false === $options ) {
59
- $defaults = array( 'title' => 'Subscriber Count', 's2w_bg' => '#e3dacf', 's2w_fg' => '#345797', 's2w_width' => '82', 's2w_height' => '16', 's2w_font' => '11' );
 
 
 
 
 
 
 
60
  } else {
61
- $defaults = array( 'title' => $options['title'], 's2w_bg' => $options['s2w_bg'], 's2w_fg' => $options['s2w_fg'], 's2w_width' => $options['s2w_width'], 's2w_height' => $options['s2w_height'], 's2w_font' => $options['s2w_font'] );
 
 
 
 
 
 
 
62
  delete_option( 'widget_s2counter' );
63
  }
64
  $instance = wp_parse_args( (array) $instance, $defaults );
@@ -71,7 +92,7 @@ class S2_Counter_widget extends WP_Widget {
71
  $s2w_font = htmlspecialchars( $instance['s2w_font'], ENT_QUOTES );
72
  echo '<div>' . "\r\n";
73
  echo '<fieldset><legend><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Widget Title', 'subscribe2' ) . '</label></legend>' . "\r\n";
74
- echo '<input type="text" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" value="' . esc_html__( $s2w_title ) . '" />' . "\r\n";
75
  echo '</fieldset>' . "\r\n";
76
 
77
  echo '<fieldset>' . "\r\n";
1
  <?php
2
+ class S2_Counter_Widget extends WP_Widget {
3
  /**
4
  Declares the S2_Counter_widget class.
5
  */
6
  function __construct() {
7
+ $widget_options = array(
8
+ 'classname' => 's2_counter',
9
+ 'description' => esc_html__( 'Subscriber Counter widget for Subscribe2', 'subscribe2' ),
10
+ 'customize_selective_refresh' => true,
11
+ );
12
+ $control_options = array(
13
+ 'width' => 250,
14
+ 'height' => 500,
15
+ );
16
  parent::__construct( 's2_counter', esc_html__( 'Subscribe2 Counter', 'subscribe2' ), $widget_options, $control_options );
17
  }
18
 
63
  // set some defaults
64
  $options = get_option( 'widget_s2counter' );
65
  if ( false === $options ) {
66
+ $defaults = array(
67
+ 'title' => 'Subscriber Count',
68
+ 's2w_bg' => '#e3dacf',
69
+ 's2w_fg' => '#345797',
70
+ 's2w_width' => '82',
71
+ 's2w_height' => '16',
72
+ 's2w_font' => '11',
73
+ );
74
  } else {
75
+ $defaults = array(
76
+ 'title' => $options['title'],
77
+ 's2w_bg' => $options['s2w_bg'],
78
+ 's2w_fg' => $options['s2w_fg'],
79
+ 's2w_width' => $options['s2w_width'],
80
+ 's2w_height' => $options['s2w_height'],
81
+ 's2w_font' => $options['s2w_font'],
82
+ );
83
  delete_option( 'widget_s2counter' );
84
  }
85
  $instance = wp_parse_args( (array) $instance, $defaults );
92
  $s2w_font = htmlspecialchars( $instance['s2w_font'], ENT_QUOTES );
93
  echo '<div>' . "\r\n";
94
  echo '<fieldset><legend><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Widget Title', 'subscribe2' ) . '</label></legend>' . "\r\n";
95
+ echo '<input type="text" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" value="' . esc_attr( $s2w_title ) . '" />' . "\r\n";
96
  echo '</fieldset>' . "\r\n";
97
 
98
  echo '<fieldset>' . "\r\n";
include/widget.php → classes/class-s2-form-widget.php RENAMED
@@ -1,11 +1,18 @@
1
  <?php
2
- class S2_Form_widget extends WP_Widget {
3
  /**
4
  Declares the Subscribe2 widget class.
5
  */
6
  function __construct() {
7
- $widget_ops = array( 'classname' => 's2_form_widget', 'description' => esc_html__( 'Sidebar Widget for Subscribe2', 'subscribe2' ) );
8
- $control_ops = array( 'width' => 250, 'height' => 300 );
 
 
 
 
 
 
 
9
  parent::__construct( 's2_form_widget', esc_html__( 'Subscribe2 Widget', 'subscribe2' ), $widget_ops, $control_ops );
10
  }
11
 
@@ -88,9 +95,31 @@ class S2_Form_widget extends WP_Widget {
88
  // set some defaults, getting any old options first
89
  $options = get_option( 'widget_subscribe2widget' );
90
  if ( false === $options ) {
91
- $defaults = array( 'title' => 'Subscribe2', 'div' => 'search', 'widgetprecontent' => '', 'widgetpostcontent' => '', 'size' => 20, 'hidebutton' => 'none', 'postto' => '', 'js' => '', 'noantispam' => '', 'nowrap' => '' );
 
 
 
 
 
 
 
 
 
 
 
92
  } else {
93
- $defaults = array( 'title' => $options['title'], 'div' => $options['div'], 'widgetprecontent' => $options['widgetprecontent'], 'widgetpostcontent' => $options['widgetpostcontent'], 'size' => $options['size'], 'hidebutton' => $options['hidebutton'], 'postto' => $options['postto'], 'js' => $options['js'], 'noantispam' => $options['noantispam'], 'nowrap' => $options['nowrap'] );
 
 
 
 
 
 
 
 
 
 
 
94
  delete_option( 'widget_subscribe2widget' );
95
  }
96
  // code to obtain old settings too
@@ -111,22 +140,22 @@ class S2_Form_widget extends WP_Widget {
111
  $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
112
 
113
  echo '<div>' . "\r\n";
114
- echo '<p><label for="'. esc_attr( $this->get_field_id( 'title' ) ) . '">' . __( 'Title', 'subscribe2' ) . ':' . "\r\n";
115
- echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_html__( $title ) . '" /></label></p>' . "\r\n";
116
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'div' ) ) . '">' . __( 'Div class name', 'subscribe2' ) . ':' . "\r\n";
117
- echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'div' ) ) . '" name="' . esc_attr( $this->get_field_name( 'div' ) ) . '" type="text" value="' . esc_html__( $div ) . '" /></label></p>' . "\r\n";
118
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '">' . esc_html__( 'Pre-Content', 'subscribe2' ) . ':' . "\r\n";
119
- echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetprecontent' ) ) . '" rows="2" cols="25">' . esc_html__( $widgetprecontent ) . '</textarea></label></p>' . "\r\n";
120
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '">' . __( 'Post-Content', 'subscribe2' ) . ':' . "\r\n";
121
- echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetpostcontent' ) ) . '" rows="2" cols="25">' . esc_html__( $widgetpostcontent ) . '</textarea></label></p>' . "\r\n";
122
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'size' ) ) . '">' . esc_html__( 'Text Box Size', 'subscribe2' ) . ':' . "\r\n";
123
- echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'size' ) ) . '" name="' . esc_attr( $this->get_field_name( 'size' ) ) . '" type="text" value="' . esc_html__( $size ) . '" /></label></p>' . "\r\n";
124
  echo '<p>' . __( 'Display options', 'subscribe2' ) . ':<br />' . "\r\n";
125
- echo '<label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="none"'. checked( 'none', $hidebutton, false ) . '/> ' . esc_html__( 'Show complete form', 'subscribe2' ) . '</label>' . "\r\n";
126
  echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="subscribe"' . checked( 'subscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Subscribe button', 'subscribe2' ) . '</label>' . "\r\n";
127
- echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="unsubscribe"'. checked( 'unsubscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Unsubscribe button', 'subscribe2' ) . '</label>' . "\r\n";
128
  if ( '1' === $mysubscribe2->subscribe2_options['ajax'] ) {
129
- echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="link"'. checked( 'link', $hidebutton, false ) . '/> ' . esc_html__( 'Show as link', 'subscribe2' ) . '</label>' . "\r\n";
130
  }
131
  echo '</p>' . "\r\n";
132
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'postto' ) ) . '">' . esc_html__( 'Post form content to page', 'subscribe2' ) . ':' . "\r\n";
1
  <?php
2
+ class S2_Form_Widget extends WP_Widget {
3
  /**
4
  Declares the Subscribe2 widget class.
5
  */
6
  function __construct() {
7
+ $widget_ops = array(
8
+ 'classname' => 's2_form_widget',
9
+ 'description' => esc_html__( 'Sidebar Widget for Subscribe2', 'subscribe2' ),
10
+ 'customize_selective_refresh' => true,
11
+ );
12
+ $control_ops = array(
13
+ 'width' => 250,
14
+ 'height' => 300,
15
+ );
16
  parent::__construct( 's2_form_widget', esc_html__( 'Subscribe2 Widget', 'subscribe2' ), $widget_ops, $control_ops );
17
  }
18
 
95
  // set some defaults, getting any old options first
96
  $options = get_option( 'widget_subscribe2widget' );
97
  if ( false === $options ) {
98
+ $defaults = array(
99
+ 'title' => 'Subscribe2',
100
+ 'div' => 'search',
101
+ 'widgetprecontent' => '',
102
+ 'widgetpostcontent' => '',
103
+ 'size' => 20,
104
+ 'hidebutton' => 'none',
105
+ 'postto' => '',
106
+ 'js' => '',
107
+ 'noantispam' => '',
108
+ 'nowrap' => '',
109
+ );
110
  } else {
111
+ $defaults = array(
112
+ 'title' => $options['title'],
113
+ 'div' => $options['div'],
114
+ 'widgetprecontent' => $options['widgetprecontent'],
115
+ 'widgetpostcontent' => $options['widgetpostcontent'],
116
+ 'size' => $options['size'],
117
+ 'hidebutton' => $options['hidebutton'],
118
+ 'postto' => $options['postto'],
119
+ 'js' => $options['js'],
120
+ 'noantispam' => $options['noantispam'],
121
+ 'nowrap' => $options['nowrap'],
122
+ );
123
  delete_option( 'widget_subscribe2widget' );
124
  }
125
  // code to obtain old settings too
140
  $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
141
 
142
  echo '<div>' . "\r\n";
143
+ echo '<p><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . __( 'Title', 'subscribe2' ) . ':' . "\r\n";
144
+ echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_attr( $title ) . '" /></label></p>' . "\r\n";
145
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'div' ) ) . '">' . __( 'Div class name', 'subscribe2' ) . ':' . "\r\n";
146
+ echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'div' ) ) . '" name="' . esc_attr( $this->get_field_name( 'div' ) ) . '" type="text" value="' . esc_attr( $div ) . '" /></label></p>' . "\r\n";
147
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '">' . esc_html__( 'Pre-Content', 'subscribe2' ) . ':' . "\r\n";
148
+ echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetprecontent' ) ) . '" rows="2" cols="25">' . esc_attr( $widgetprecontent ) . '</textarea></label></p>' . "\r\n";
149
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '">' . __( 'Post-Content', 'subscribe2' ) . ':' . "\r\n";
150
+ echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetpostcontent' ) ) . '" rows="2" cols="25">' . esc_attr( $widgetpostcontent ) . '</textarea></label></p>' . "\r\n";
151
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'size' ) ) . '">' . esc_html__( 'Text Box Size', 'subscribe2' ) . ':' . "\r\n";
152
+ echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'size' ) ) . '" name="' . esc_attr( $this->get_field_name( 'size' ) ) . '" type="text" value="' . esc_attr( $size ) . '" /></label></p>' . "\r\n";
153
  echo '<p>' . __( 'Display options', 'subscribe2' ) . ':<br />' . "\r\n";
154
+ echo '<label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="none"' . checked( 'none', $hidebutton, false ) . '/> ' . esc_html__( 'Show complete form', 'subscribe2' ) . '</label>' . "\r\n";
155
  echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="subscribe"' . checked( 'subscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Subscribe button', 'subscribe2' ) . '</label>' . "\r\n";
156
+ echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="unsubscribe"' . checked( 'unsubscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Unsubscribe button', 'subscribe2' ) . '</label>' . "\r\n";
157
  if ( '1' === $mysubscribe2->subscribe2_options['ajax'] ) {
158
+ echo '<br /><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="link"' . checked( 'link', $hidebutton, false ) . '/> ' . esc_html__( 'Show as link', 'subscribe2' ) . '</label>' . "\r\n";
159
  }
160
  echo '</p>' . "\r\n";
161
  echo '<p><label for="' . esc_attr( $this->get_field_id( 'postto' ) ) . '">' . esc_html__( 'Post form content to page', 'subscribe2' ) . ':' . "\r\n";
classes/class-s2-forms.php ADDED
@@ -0,0 +1,410 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class S2_Forms {
3
+ /**
4
+ Functions to Display content of Your Subscriptions page and process any input
5
+ */
6
+ function init() {
7
+ add_action( 's2_subscription_submit', array( &$this, 's2_your_subscription_submit' ) );
8
+ add_action( 's2_subscription_form', array( &$this, 's2_your_subscription_form' ), 10, 2 );
9
+ } // end init()
10
+
11
+ /**
12
+ Return appropriate user ID if user can edit other users subscriptions
13
+ */
14
+ function get_userid() {
15
+ global $user_ID;
16
+ if ( current_user_can( apply_filters( 's2_capability', 'manage_options', 'manage' ) ) && isset( $_GET['id'] ) ) {
17
+ $userid = (int) $_GET['id'];
18
+ } else {
19
+ $userid = $user_ID;
20
+ }
21
+ return $userid;
22
+ } // end get_userid()
23
+
24
+ /**
25
+ Display the form to allow Regsitered users to amend their subscription
26
+ */
27
+ function s2_your_subscription_form( $userid ) {
28
+ if ( ! is_int( $userid ) ) { return false; }
29
+ global $mysubscribe2;
30
+
31
+ echo '<input type="hidden" name="s2_admin" value="user" />';
32
+ if ( 'never' === $mysubscribe2->subscribe2_options['email_freq'] ) {
33
+ echo __( 'Receive email as', 'subscribe2' ) . ': &nbsp;&nbsp;';
34
+ echo '<label><input type="radio" name="s2_format" value="html"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'html', false ) . ' />';
35
+ echo ' ' . __( 'HTML - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
36
+ echo '<label><input type="radio" name="s2_format" value="html_excerpt"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'html_excerpt', false ) . ' />';
37
+ echo ' ' . __( 'HTML - Excerpt', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
38
+ echo '<label><input type="radio" name="s2_format" value="post"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'post', false ) . ' />';
39
+ echo ' ' . __( 'Plain Text - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
40
+ echo '<label><input type="radio" name="s2_format" value="excerpt"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'excerpt', false ) . ' />';
41
+ echo ' ' . __( 'Plain Text - Excerpt', 'subscribe2' ) . '</label><br /><br />' . "\r\n";
42
+
43
+ if ( 'yes' === $mysubscribe2->subscribe2_options['show_autosub'] ) {
44
+ echo __( 'Automatically subscribe me to newly created categories', 'subscribe2' ) . ': &nbsp;&nbsp;';
45
+ echo '<label><input type="radio" name="new_category" value="yes"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), true ), 'yes', false ) . ' />';
46
+ echo ' ' . __( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
47
+ echo '<label><input type="radio" name="new_category" value="no"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), true ), 'no', false ) . ' />';
48
+ echo ' ' . __( 'No', 'subscribe2' ) . '</label>';
49
+ echo '</p>';
50
+ }
51
+
52
+ if ( 'yes' === $mysubscribe2->subscribe2_options['one_click_profile'] ) {
53
+ // One-click subscribe and unsubscribe buttons
54
+ echo '<h2>' . __( 'One Click Subscription / Unsubscription', 'subscribe2' ) . "</h2>\r\n";
55
+ echo '<p class="submit"><input type="submit" class="button-primary" name="subscribe" value="' . __( 'Subscribe to All', 'subscribe2' ) . '" />&nbsp;&nbsp;';
56
+ echo '<input type="submit" class="button-primary" name="unsubscribe" value="' . __( 'Unsubscribe from All', 'subscribe2' ) . '" /></p>';
57
+ }
58
+
59
+ // subscribed categories
60
+ if ( $mysubscribe2->s2_mu ) {
61
+ global $blog_id;
62
+ $subscribed = get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
63
+ // if we are subscribed to the current blog display an "unsubscribe" link
64
+ if ( ! empty( $subscribed ) ) {
65
+ $unsubscribe_link = esc_url( add_query_arg( 's2mu_unsubscribe', $blog_id ) );
66
+ echo '<p><a href="' . $unsubscribe_link . '" class="button">' . __( 'Unsubscribe me from this blog', 'subscribe2' ) . '</a></p>';
67
+ } else {
68
+ // else we show a "subscribe" link
69
+ $subscribe_link = esc_url( add_query_arg( 's2mu_subscribe', $blog_id ) );
70
+ echo '<p><a href="' . $subscribe_link . '" class="button">' . __( 'Subscribe to all categories', 'subscribe2' ) . '</a></p>';
71
+ }
72
+ echo '<h2>' . __( 'Subscribed Categories on', 'subscribe2' ) . ' ' . get_option( 'blogname' ) . ' </h2>' . "\r\n";
73
+ } else {
74
+ echo '<h2>' . __( 'Subscribed Categories', 'subscribe2' ) . '</h2>' . "\r\n";
75
+ }
76
+ ('' === $mysubscribe2->subscribe2_options['compulsory']) ? $compulsory = array() : $compulsory = explode( ',', $mysubscribe2->subscribe2_options['compulsory'] );
77
+ $this->display_category_form( explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) ), $mysubscribe2->subscribe2_options['reg_override'], $compulsory );
78
+ } else {
79
+ // we're doing daily digests, so just show
80
+ // subscribe / unnsubscribe
81
+ echo __( 'Receive periodic summaries of new posts?', 'subscribe2' ) . ': &nbsp;&nbsp;';
82
+ echo '<label>';
83
+ echo '<input type="radio" name="category" value="digest"';
84
+ if ( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) ) {
85
+ echo ' checked="checked"';
86
+ }
87
+ echo ' /> ' . __( 'Yes', 'subscribe2' ) . '</label> <label><input type="radio" name="category" value="-1" ';
88
+ if ( ! get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) ) {
89
+ echo ' checked="checked"';
90
+ }
91
+ echo ' /> ' . __( 'No', 'subscribe2' );
92
+ echo '</label></p>';
93
+ }
94
+
95
+ if ( count( $this->get_authors() ) > 1 && 'never' === $mysubscribe2->subscribe2_options['email_freq'] ) {
96
+ echo '<div class="s2_admin" id="s2_authors">' . "\r\n";
97
+ echo '<h2>' . __( 'Do not send notifications for post made by these authors', 'subscribe2' ) . '</h2>' . "\r\n";
98
+ $this->display_author_form( explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), true ) ) );
99
+ echo '</div>' . "\r\n";
100
+ }
101
+
102
+ // list of subscribed blogs on wordpress mu
103
+ if ( $mysubscribe2->s2_mu && ! isset( $_GET['email'] ) ) {
104
+ global $blog_id, $current_user, $s2class_multisite;
105
+ $s2blog_id = $blog_id;
106
+ $current_user = wp_get_current_user();
107
+ $blogs = $s2class_multisite->get_mu_blog_list();
108
+
109
+ $blogs_subscribed = array();
110
+ $blogs_notsubscribed = array();
111
+
112
+ foreach ( $blogs as $blog ) {
113
+ // switch to blog
114
+ switch_to_blog( $blog['blog_id'] );
115
+
116
+ // check that the Subscribe2 plugin is active on the current blog
117
+ $current_plugins = get_option( 'active_plugins' );
118
+ if ( ! is_array( $current_plugins ) ) {
119
+ $current_plugins = (array) $current_plugins;
120
+ }
121
+ if ( ! in_array( S2DIR . 'subscribe2.php', $current_plugins ) ) {
122
+ continue;
123
+ }
124
+
125
+ // check if we're subscribed to the blog
126
+ $subscribed = get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
127
+
128
+ $blogname = get_option( 'blogname' );
129
+ if ( strlen( $blogname ) > 30 ) {
130
+ $blog['blogname'] = wp_html_excerpt( $blogname, 30 ) . '..';
131
+ } else {
132
+ $blog['blogname'] = $blogname;
133
+ }
134
+ $blog['description'] = get_option( 'blogdescription' );
135
+ $blog['blogurl'] = get_option( 'home' );
136
+ $blog['subscribe_page'] = get_option( 'home' ) . '/wp-admin/admin.php?page=s2';
137
+
138
+ $key = strtolower( $blog['blogname'] . '-' . $blog['blog_id'] );
139
+ if ( ! empty( $subscribed ) ) {
140
+ $blogs_subscribed[ $key ] = $blog;
141
+ } else {
142
+ $blogs_notsubscribed[ $key ] = $blog;
143
+ }
144
+ restore_current_blog();
145
+ }
146
+
147
+ echo '<div class="s2_admin" id="s2_mu_sites">' . "\r\n";
148
+ if ( ! empty( $blogs_subscribed ) ) {
149
+ ksort( $blogs_subscribed );
150
+ echo '<h2>' . __( 'Subscribed Blogs', 'subscribe2' ) . '</h2>' . "\r\n";
151
+ echo '<ul class="s2_blogs">' . "\r\n";
152
+ foreach ( $blogs_subscribed as $blog ) {
153
+ echo '<li><span class="name"><a href="' . $blog['blogurl'] . '" title="' . $blog['description'] . '">' . $blog['blogname'] . '</a></span>' . "\r\n";
154
+ if ( $s2blog_id === $blog['blog_id'] ) {
155
+ echo '<span class="buttons">' . __( 'Viewing Settings Now', 'subscribe2' ) . '</span>' . "\r\n";
156
+ } else {
157
+ echo '<span class="buttons">';
158
+ if ( is_user_member_of_blog( $current_user->id, $blog['blog_id'] ) ) {
159
+ echo '<a href="' . $blog['subscribe_page'] . '">' . __( 'View Settings', 'subscribe2' ) . '</a>' . "\r\n";
160
+ }
161
+ echo '<a href="' . esc_url( add_query_arg( 's2mu_unsubscribe', $blog['blog_id'] ) ) . '">' . __( 'Unsubscribe', 'subscribe2' ) . '</a></span>' . "\r\n";
162
+ }
163
+ echo '<div class="additional_info">' . $blog['description'] . '</div>' . "\r\n";
164
+ echo '</li>';
165
+ }
166
+ echo '</ul>' . "\r\n";
167
+ }
168
+
169
+ if ( ! empty( $blogs_notsubscribed ) ) {
170
+ ksort( $blogs_notsubscribed );
171
+ echo '<h2>' . __( 'Subscribe to new blogs', 'subscribe2' ) . "</h2>\r\n";
172
+ echo '<ul class="s2_blogs">';
173
+ foreach ( $blogs_notsubscribed as $blog ) {
174
+ echo '<li><span class="name"><a href="' . $blog['blogurl'] . '" title="' . $blog['description'] . '">' . $blog['blogname'] . '</a></span>' . "\r\n";
175
+ if ( $s2blog_id === $blog['blog_id'] ) {
176
+ echo '<span class="buttons">' . __( 'Viewing Settings Now', 'subscribe2' ) . '</span>' . "\r\n";
177
+ } else {
178
+ echo '<span class="buttons">';
179
+ if ( is_user_member_of_blog( $current_user->id, $blog['blog_id'] ) ) {
180
+ echo '<a href="' . $blog['subscribe_page'] . '">' . __( 'View Settings', 'subscribe2' ) . '</a>' . "\r\n";
181
+ }
182
+ echo '<a href="' . esc_url( add_query_arg( 's2mu_subscribe', $blog['blog_id'] ) ) . '">' . __( 'Subscribe', 'subscribe2' ) . '</a></span>' . "\r\n";
183
+ }
184
+ echo '<div class="additional_info">' . $blog['description'] . '</div>' . "\r\n";
185
+ echo '</li>';
186
+ }
187
+ echo '</ul>' . "\r\n";
188
+ }
189
+ echo '</div>' . "\r\n";
190
+ }
191
+ } // end s2_your_subscription_form()
192
+
193
+ /**
194
+ Process input from the form that allows Regsitered users to amend their subscription
195
+ */
196
+ function s2_your_subscription_submit() {
197
+ global $mysubscribe2, $user_ID;
198
+
199
+ $userid = $this->get_userid();
200
+
201
+ if ( isset( $_POST['submit'] ) ) {
202
+ if ( isset( $_POST['s2_format'] ) ) {
203
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), $_POST['s2_format'] );
204
+ } else {
205
+ // value has not been set so use default
206
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), 'excerpt' );
207
+ }
208
+ if ( isset( $_POST['new_category'] ) ) {
209
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), $_POST['new_category'] );
210
+ } else {
211
+ // value has not been passed so use Settings defaults
212
+ if ( 'yes' === $mysubscribe2->subscribe2_options['show_autosub'] && 'yes' === $mysubscribe2->subscribe2_options['autosub_def'] ) {
213
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), 'yes' );
214
+ } else {
215
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), 'no' );
216
+ }
217
+ }
218
+
219
+ $cats = ( isset( $_POST['category'] ) ) ? $_POST['category'] : '';
220
+
221
+ if ( empty( $cats ) || '-1' === $cats ) {
222
+ $oldcats = explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) );
223
+ if ( $oldcats ) {
224
+ foreach ( $oldcats as $cat ) {
225
+ delete_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat );
226
+ }
227
+ }
228
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), '' );
229
+ } elseif ( 'digest' === $cats ) {
230
+ $all_cats = $mysubscribe2->all_cats( false, 'ID' );
231
+ foreach ( $all_cats as $cat ) {
232
+ ('' === $catids) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
233
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat->term_id, $cat->term_id );
234
+ }
235
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $catids );
236
+ } else {
237
+ if ( ! is_array( $cats ) ) {
238
+ $cats = (array) $_POST['category'];
239
+ }
240
+ sort( $cats );
241
+ $old_cats = explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) );
242
+ $remove = array_diff( $old_cats, $cats );
243
+ $new = array_diff( $cats, $old_cats );
244
+ if ( ! empty( $remove ) ) {
245
+ // remove subscription to these cat IDs
246
+ foreach ( $remove as $id ) {
247
+ delete_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $id );
248
+ }
249
+ }
250
+ if ( ! empty( $new ) ) {
251
+ // add subscription to these cat IDs
252
+ foreach ( $new as $id ) {
253
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $id, $id );
254
+ }
255
+ }
256
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $cats ) );
257
+ }
258
+
259
+ $authors = ( isset( $_POST['author'] ) ) ? $_POST['author'] : '';
260
+ if ( is_array( $authors ) ) {
261
+ $authors = implode( ',', $authors );
262
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), $authors );
263
+ } elseif ( empty( $authors ) ) {
264
+ update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), '' );
265
+ }
266
+ } elseif ( isset( $_POST['subscribe'] ) ) {
267
+ $mysubscribe2->one_click_handler( $userid, 'subscribe' );
268
+ } elseif ( isset( $_POST['unsubscribe'] ) ) {
269
+ $mysubscribe2->one_click_handler( $userid, 'unsubscribe' );
270
+ }
271
+
272
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Subscription preferences updated.', 'subscribe2' ) . '</strong></p></div>' . "\r\n";
273
+ } // end s2_your_subscription_submit()
274
+
275
+ /**
276
+ Display a table of categories with checkboxes
277
+ Optionally pre-select those categories specified
278
+ */
279
+ function display_category_form( $selected = array(), $override = 1, $compulsory = array(), $name = 'category' ) {
280
+ global $wpdb, $mysubscribe2;
281
+
282
+ if ( 0 === $override ) {
283
+ $all_cats = $mysubscribe2->all_cats( true );
284
+ } else {
285
+ $all_cats = $mysubscribe2->all_cats( false );
286
+ }
287
+
288
+ $half = (count( $all_cats ) / 2);
289
+ $i = 0;
290
+ $j = 0;
291
+ echo '<table style="width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression(\'separate\', cellSpacing = \'2px\');" class="editform">' . "\r\n";
292
+ echo '<tr><td style="text-align: left;" colspan="2">' . "\r\n";
293
+ echo '<label><input type="checkbox" name="checkall" value="checkall_' . $name . '" /> ' . __( 'Select / Unselect All', 'subscribe2' ) . '</label>' . "\r\n";
294
+ echo '</td></tr>' . "\r\n";
295
+ echo '<tr style="vertical-align: top;"><td style="width: 50%; text-align: left;">' . "\r\n";
296
+ foreach ( $all_cats as $cat ) {
297
+ if ( $i >= $half && 0 === $j ) {
298
+ echo '</td><td style="width: 50%; text-align: left;">' . "\r\n";
299
+ $j++;
300
+ }
301
+ $catName = '';
302
+ $parents = array_reverse( get_ancestors( $cat->term_id, $cat->taxonomy ) );
303
+ if ( $parents ) {
304
+ foreach ( $parents as $parent ) {
305
+ $parent = get_term( $parent, $cat->taxonomy );
306
+ $catName .= $parent->name . ' &raquo; ';
307
+ }
308
+ }
309
+ $catName .= $cat->name;
310
+
311
+ if ( 0 === $j ) {
312
+ echo '<label><input class="checkall_' . $name . '" type="checkbox" name="' . $name . '[]" value="' . $cat->term_id . '"';
313
+ if ( in_array( $cat->term_id, $selected ) || in_array( $cat->term_id, $compulsory ) ) {
314
+ echo ' checked="checked"';
315
+ }
316
+ if ( in_array( $cat->term_id, $compulsory ) && 'category' === $name ) {
317
+ echo ' DISABLED';
318
+ }
319
+ echo ' /> <abbr title="' . $cat->slug . '">' . $catName . '</abbr></label><br />' . "\r\n";
320
+ } else {
321
+ echo '<label><input class="checkall_' . $name . '" type="checkbox" name="' . $name . '[]" value="' . $cat->term_id . '"';
322
+ if ( in_array( $cat->term_id, $selected ) || in_array( $cat->term_id, $compulsory ) ) {
323
+ echo ' checked="checked"';
324
+ }
325
+ if ( in_array( $cat->term_id, $compulsory ) && 'category' === $name ) {
326
+ echo ' DISABLED';
327
+ }
328
+ echo ' /> <abbr title="' . $cat->slug . '">' . $catName . '</abbr></label><br />' . "\r\n";
329
+ }
330
+ $i++;
331
+ }
332
+ if ( ! empty( $compulsory ) ) {
333
+ foreach ( $compulsory as $cat ) {
334
+ echo '<input type="hidden" name="' . $name . '[]" value="' . $cat . '">' . "\r\n";
335
+ }
336
+ }
337
+ echo '</td></tr>' . "\r\n";
338
+ echo '</table>' . "\r\n";
339
+ } // end display_category_form()
340
+
341
+ /**
342
+ Display a table of authors with checkboxes
343
+ Optionally pre-select those authors specified
344
+ */
345
+ function display_author_form( $selected = array() ) {
346
+ $all_authors = $this->get_authors();
347
+
348
+ $half = (count( $all_authors ) / 2);
349
+ $i = 0;
350
+ $j = 0;
351
+ echo '<table style="width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression(\'separate\', cellSpacing = \'2px\');" class="editform">' . "\r\n";
352
+ echo '<tr><td style="text-align: left;" colspan="2">' . "\r\n";
353
+ echo '<label><input type="checkbox" name="checkall" value="checkall_author" /> ' . __( 'Select / Unselect All', 'subscribe2' ) . '</label>' . "\r\n";
354
+ echo '</td></tr>' . "\r\n";
355
+ echo '<tr style="vertical-align: top;"><td style="width: 50%; test-align: left;">' . "\r\n";
356
+ foreach ( $all_authors as $author ) {
357
+ if ( $i >= $half && 0 === $j ) {
358
+ echo '</td><td style="width: 50%; text-align: left;">' . "\r\n";
359
+ $j++;
360
+ }
361
+ if ( 0 === $j ) {
362
+ echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . $author->ID . '"';
363
+ if ( in_array( $author->ID, $selected ) ) {
364
+ echo ' checked="checked"';
365
+ }
366
+ echo ' /> ' . $author->display_name . '</label><br />' . "\r\n";
367
+ } else {
368
+ echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . $author->ID . '"';
369
+ if ( in_array( $author->ID, $selected ) ) {
370
+ echo ' checked="checked"';
371
+ }
372
+ echo ' /> ' . $author->display_name . '</label><br />' . "\r\n";
373
+ $i++;
374
+ }
375
+ }
376
+ echo '</td></tr>' . "\r\n";
377
+ echo '</table>' . "\r\n";
378
+ } // end display_author_form()
379
+
380
+ /**
381
+ Collect an array of all author level users and above
382
+ */
383
+ function get_authors() {
384
+ if ( '' === $this->all_authors ) {
385
+ $role = array(
386
+ 'fields' => array( 'ID', 'display_name' ),
387
+ 'role' => 'administrator',
388
+ );
389
+ $administrators = get_users( $role );
390
+ $role = array(
391
+ 'fields' => array( 'ID', 'display_name' ),
392
+ 'role' => 'editor',
393
+ );
394
+ $editors = get_users( $role );
395
+ $role = array(
396
+ 'fields' => array( 'ID', 'display_name' ),
397
+ 'role' => 'author',
398
+ );
399
+ $authors = get_users( $role );
400
+
401
+ $this->all_authors = array_merge( $administrators, $editors, $authors );
402
+ }
403
+ return apply_filters( 's2_authors', $this->all_authors );
404
+ } // end get_authors()
405
+
406
+ /* ===== our variables ===== */
407
+ // cache variables
408
+ var $all_authors = '';
409
+ }
410
+ ?>
classes/class-s2-frontend.php CHANGED
@@ -1,167 +1,187 @@
1
  <?php
2
- class s2_frontend extends s2class {
3
  /**
4
  Load all our strings
5
  */
6
  function load_strings() {
7
- $this->please_log_in = "<p class=\"s2_message\">" . sprintf(__('To manage your subscription options please <a href="%1$s">login.</a>', 'subscribe2'), get_option('siteurl') . '/wp-login.php') . "</p>";
8
 
9
- $this->profile = "<p class=\"s2_message\">" . sprintf(__('You may manage your subscription options from your <a href="%1$s">profile</a>', 'subscribe2'), get_option('siteurl') . "/wp-admin/admin.php?page=s2") . "</p>";
10
- if ( $this->s2_mu === true ) {
 
11
  global $blog_id;
12
  $user_ID = get_current_user_id();
13
- if ( !is_user_member_of_blog($user_ID, $blog_id) ) {
14
  // if we are on multisite and the user is not a member of this blog change the link
15
- $this->profile = "<p class=\"s2_message\">" . sprintf(__('<a href="%1$s">Subscribe</a> to email notifications when this blog posts new content.', 'subscribe2'), get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id) . "</p>";
 
16
  }
17
  }
18
 
19
- $this->confirmation_sent = "<p class=\"s2_message\">" . __('A confirmation message is on its way!', 'subscribe2') . "</p>";
20
 
21
- $this->already_subscribed = "<p class=\"s2_error\">" . __('That email address is already subscribed.', 'subscribe2') . "</p>";
22
 
23
- $this->not_subscribed = "<p class=\"s2_error\">" . __('That email address is not subscribed.', 'subscribe2') . "</p>";
24
 
25
- $this->not_an_email = "<p class=\"s2_error\">" . __('Sorry, but that does not look like an email address to me.', 'subscribe2') . "</p>";
26
 
27
- $this->barred_domain = "<p class=\"s2_error\">" . __('Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2') . "</p>";
28
 
29
- $this->error = "<p class=\"s2_error\">" . __('Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2') . "</p>";
30
 
31
  // confirmation messages
32
- $this->no_such_email = "<p class=\"s2_error\">" . __('No such email address is registered.', 'subscribe2') . "</p>";
33
 
34
- $this->added = "<p class=\"s2_message\">" . __('You have successfully subscribed!', 'subscribe2') . "</p>";
35
 
36
- $this->deleted = "<p class=\"s2_message\">" . __('You have successfully unsubscribed.', 'subscribe2') . "</p>";
37
 
38
- /**/$this->subscribe = __('subscribe', 'subscribe2'); //ACTION replacement in subscribing confirmation email
39
 
40
- /**/$this->unsubscribe = __('unsubscribe', 'subscribe2'); //ACTION replacement in unsubscribing in confirmation email
41
  } // end load_strings()
42
 
43
- /* ===== template and filter functions ===== */
44
  /**
45
  Display our form; also handles (un)subscribe requests
46
  */
47
- function shortcode($atts) {
48
- $args = shortcode_atts(array(
49
  'hide' => '',
50
  'id' => '',
51
  'nojs' => 'false',
52
  'noantispam' => 'false',
53
  'link' => '',
54
  'size' => 20,
55
- 'wrap' => 'true'
56
- ), $atts);
57
 
58
  // if link is true return a link to the page with the ajax class
59
- if ( '' !== $args['link'] && !is_user_logged_in() ) {
60
- $hide_id = ('' === $args['hide']) ? "": " id=\"" . strtolower($args['hide']) . "\"";
61
- $this->s2form = "<a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\" class=\"s2popup\"" . $hide_id . ">" . $args['link'] . "</a>\r\n";
 
 
 
 
 
 
 
 
62
  return $this->s2form;
63
  }
64
 
65
  // Apply filters to button text
66
- $unsubscribe_button_value = apply_filters('s2_unsubscribe_button', __('Unsubscribe', 'subscribe2'));
67
- $subscribe_button_value = apply_filters('s2_subscribe_button', __('Subscribe', 'subscribe2'));
68
 
69
  // if a button is hidden, show only other
70
- if ( strtolower($args['hide']) == 'subscribe' ) {
71
- $this->input_form_action = "<input type=\"submit\" name=\"unsubscribe\" value=\"" . esc_attr($unsubscribe_button_value) . "\" />";
72
- } elseif ( strtolower($args['hide']) == 'unsubscribe' ) {
73
- $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . esc_attr($subscribe_button_value) . "\" />";
 
74
  } else {
75
  // both form input actions
76
- $this->input_form_action = "<input type=\"submit\" name=\"subscribe\" value=\"" . esc_attr($subscribe_button_value) . "\" />&nbsp;<input type=\"submit\" name=\"unsubscribe\" value=\"" . esc_attr($unsubscribe_button_value) . "\" />";
77
  }
78
 
79
  // if ID is provided, get permalink
80
  $action = '';
81
- if ( is_numeric($args['id']) ) {
82
- $action = " action=\"" . get_permalink( $args['id'] ) . "\"";
83
  } elseif ( 'home' === $args['id'] ) {
84
- $action = " action=\"" . get_site_url() . "\"";
85
  } elseif ( 'self' === $args['id'] ) {
86
- $action = '';
 
 
 
 
 
 
87
  } elseif ( $this->subscribe2_options['s2page'] > 0 ) {
88
- $action = " action=\"" . get_permalink( $this->subscribe2_options['s2page'] ) . "\"";
89
  }
90
 
91
  // allow remote setting of email in form
92
- if ( isset($_REQUEST['email']) && is_email($_REQUEST['email']) ) {
93
- $value = $this->sanitize_email($_REQUEST['email']);
94
- } elseif ( 'true' == strtolower($args['nojs']) ) {
95
  $value = '';
96
  } else {
97
- $value = __('Enter email address...', 'subscribe2');
98
  }
99
 
100
  // if wrap is true add paragraph html tags
101
  $wrap_text = '';
102
- if ( 'true' == strtolower($args['wrap']) ) {
103
  $wrap_text = '</p><p>';
104
  }
105
 
106
  // deploy some anti-spam measures
107
  $antispam_text = '';
108
- if ( 'true' != strtolower($args['noantispam']) ) {
109
- $antispam_text = "<span style=\"display:none !important\">";
110
- $antispam_text .= "<label for=\"name\">Leave Blank:</label><input type=\"text\" id=\"name\" name=\"name\" />";
111
- $antispam_text .= "<label for=\"uri\">Do Not Change:</label><input type=\"text\" id=\"uri\" name=\"uri\" value=\"http://\" />";
112
- $antispam_text .= "</span>";
 
113
  }
114
 
 
 
 
115
  // build default form
116
- if ( 'true' == strtolower($args['nojs']) ) {
117
- $this->form = "<form method=\"post\"" . $action . "><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" />" . $antispam_text . "<p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . $value . "\" size=\"" . $args['size'] . "\" />" . $wrap_text . $this->input_form_action . "</p></form>";
118
  } else {
119
- $this->form = "<form method=\"post\"" . $action . "><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" />" . $antispam_text . "<p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . $value . "\" size=\"" . $args['size'] . "\" onfocus=\"if (this.value == '" . $value . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . $value . "';}\" />" . $wrap_text . $this->input_form_action . "</p></form>\r\n";
120
  }
121
- $this->s2form = apply_filters('s2_form', $this->form);
122
 
123
  global $user_ID;
124
- get_currentuserinfo();
125
  if ( $user_ID ) {
126
  $this->s2form = $this->profile;
127
  }
128
 
129
- if ( isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) {
130
  // anti spam sign up measure
131
- if ( ( isset($_POST['name']) && '' != $_POST['name'] ) || ( isset($_POST['uri']) && 'http://' != $_POST['uri'] ) ) {
132
  // looks like some invisible-to-user fields were changed; falsely report success
133
  return $this->confirmation_sent;
134
  }
135
  global $wpdb;
136
- $this->email = $this->sanitize_email($_POST['email']);
137
- if ( !is_email($this->email) ) {
138
- $this->s2form = $this->form . $this->not_an_email;
139
- } elseif ( $this->is_barred($this->email) ) {
140
- $this->s2form = $this->form . $this->barred_domain;
141
  } else {
142
  $this->ip = $_POST['ip'];
143
- if ( is_int($this->lockout) && $this->lockout > 0 ) {
144
- $date = date('H:i:s.u', $this->lockout);
145
- $ips = $wpdb->get_col($wpdb->prepare("SELECT ip FROM $this->public WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date));
146
- if ( in_array($this->ip, $ips) ) {
147
- return __('Slow down, you move too fast.', 'subscribe2');
148
  }
149
  }
150
  // does the supplied email belong to a registered user?
151
- $check = $wpdb->get_var($wpdb->prepare("SELECT user_email FROM $wpdb->users WHERE user_email = %s", $this->email));
152
- if ( '' != $check ) {
153
  // this is a registered email
154
  $this->s2form = $this->please_log_in;
155
  } else {
156
  // this is not a registered email
157
  // what should we do?
158
- if ( isset($_POST['subscribe']) ) {
159
  // someone is trying to subscribe
160
  // lets see if they've tried to subscribe previously
161
- if ( '1' !== $this->is_public($this->email) ) {
162
  // the user is unknown or inactive
163
- $this->add($this->email);
164
- $status = $this->send_confirm('add');
165
  // set a variable to denote that we've already run, and shouldn't run again
166
  $this->filtered = 1;
167
  if ( $status ) {
@@ -174,12 +194,12 @@ class s2_frontend extends s2class {
174
  $this->s2form = $this->already_subscribed;
175
  }
176
  $this->action = 'subscribe';
177
- } elseif ( isset($_POST['unsubscribe']) ) {
178
  // is this email a subscriber?
179
- if ( false == $this->is_public($this->email) ) {
180
- $this->s2form = $this->form . $this->not_subscribed;
181
  } else {
182
- $status = $this->send_confirm('del');
183
  // set a variable to denote that we've already run, and shouldn't run again
184
  $this->filtered = 1;
185
  if ( $status ) {
@@ -199,10 +219,10 @@ class s2_frontend extends s2class {
199
  /**
200
  Display form when deprecated <!--subscribe2--> is used
201
  */
202
- function filter($content = '') {
203
- if ( '' == $content || !strstr($content, '<!--subscribe2-->') ) { return $content; }
204
 
205
- return preg_replace('|(<p>)?(\n)*<!--subscribe2-->(\n)*(</p>)?|', do_shortcode( '[subscribe2]' ), $content);
206
  } // end filter()
207
 
208
  /**
@@ -212,24 +232,30 @@ class s2_frontend extends s2class {
212
  */
213
  function query_filter() {
214
  // don't interfere if we've already done our thing
215
- if ( 1 == $this->filtered ) { return; }
216
 
217
  global $wpdb;
218
 
219
  // brute force Simple Facebook Connect to bypass compatiblity issues
220
- $priority = has_filter('wp_head', 'sfc_base_meta');
221
- if ( $priority !== false ) {
222
- remove_action('wp_head', 'sfc_base_meta', $priority);
223
  }
224
 
225
- if ( 0 != $this->subscribe2_options['s2page'] ) {
226
- return array('page_id' => $this->subscribe2_options['s2page']);
 
 
227
  } else {
228
- $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
229
  if ( $id ) {
230
- return array('page_id' => $id);
 
 
231
  } else {
232
- return array('showposts' => 1);
 
 
233
  }
234
  }
235
  } // end query_filter()
@@ -237,15 +263,14 @@ class s2_frontend extends s2class {
237
  /**
238
  Overrides the page title
239
  */
240
- function title_filter($title) {
241
- // don't interfere if we've already done our thing
242
  if ( in_the_loop() ) {
243
  $code = $_GET['s2'];
244
- $action = intval(substr($code, 0, 1));
245
- if ( $action == '1' ) {
246
- return __('Subscription Confirmation', 'subscribe2');
247
  } else {
248
- return __('Unsubscription Confirmation', 'subscribe2');
249
  }
250
  } else {
251
  return $title;
@@ -255,18 +280,22 @@ class s2_frontend extends s2class {
255
  /**
256
  Confirm request from the link emailed to the user and email the admin
257
  */
258
- function confirm($content = '') {
259
  global $wpdb;
260
 
261
- if ( 1 == $this->filtered ) { return $content; }
 
 
 
 
262
 
263
  $code = $_GET['s2'];
264
- $action = intval(substr($code, 0, 1));
265
- $hash = substr($code, 1, 32);
266
- $id = intval(substr($code, 33));
267
  if ( $id ) {
268
- $this->email = $this->sanitize_email($this->get_email($id));
269
- if ( !$this->email || $hash !== wp_hash($this->email) ) {
270
  return $this->no_such_email;
271
  }
272
  } else {
@@ -274,131 +303,163 @@ class s2_frontend extends s2class {
274
  }
275
 
276
  // get current status of email so messages are only sent once per emailed link
277
- $current = $this->is_public($this->email);
278
 
279
- if ( '1' == $action ) {
280
  // make this subscription active
281
- $this->message = apply_filters('s2_subscribe_confirmed', $this->added);
282
- if ( '1' != $current ) {
283
- $this->ip = $_SERVER['REMOTE_ADDR'];
284
- $this->toggle($this->email);
285
- if ( $this->subscribe2_options['admin_email'] == 'subs' || $this->subscribe2_options['admin_email'] == 'both' ) {
286
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
287
- $subject .= __('New Subscription', 'subscribe2');
288
- $subject = html_entity_decode($subject, ENT_QUOTES);
289
- $message = $this->email . " " . __('subscribed to email notifications!', 'subscribe2');
290
- $role = array('fields' => array('user_email'), 'role' => 'administrator');
291
- $wp_user_query = get_users( $role );
292
- foreach ($wp_user_query as $user) {
293
- $recipients[] = $user->user_email;
294
- }
295
- $recipients = apply_filters('s2_admin_email', $recipients, 'subscribe');
296
- $headers = $this->headers();
297
- // send individual emails so we don't reveal admin emails to each other
298
- foreach ( $recipients as $recipient ) {
299
- @wp_mail($recipient, $subject, $message, $headers);
300
- }
301
  }
302
  }
303
  $this->filtered = 1;
304
- } elseif ( '0' == $action ) {
305
- // remove this subscriber
306
- $this->message = apply_filters('s2_unsubscribe_confirmed', $this->deleted);
307
- if ( '0' != $current ) {
308
- $this->delete($this->email);
309
- if ( $this->subscribe2_options['admin_email'] == 'unsubs' || $this->subscribe2_options['admin_email'] == 'both' ) {
310
- ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(html_entity_decode(get_option('blogname'), ENT_QUOTES)) . "] ";
311
- $subject .= __('New Unsubscription', 'subscribe2');
312
- $subject = html_entity_decode($subject, ENT_QUOTES);
313
- $message = $this->email . " " . __('unsubscribed from email notifications!', 'subscribe2');
314
- $role = array('fields' => array('user_email'), 'role' => 'administrator');
315
- $wp_user_query = get_users( $role );
316
- foreach ($wp_user_query as $user) {
317
- $recipients[] = $user->user_email;
318
- }
319
- $recipients = apply_filters('s2_admin_email', $recipients, 'unsubscribe');
320
- $headers = $this->headers();
321
- // send individual emails so we don't reveal admin emails to each other
322
- foreach ( $recipients as $recipient ) {
323
- @wp_mail($recipient, $subject, $message, $headers);
324
- }
325
  }
326
  }
327
  $this->filtered = 1;
328
  }
329
 
330
- if ( '' != $this->message ) {
331
  return $this->message;
332
  }
333
  } // end confirm()
334
 
335
  /**
336
- Add hook for Minimeta Widget plugin
337
  */
338
- function add_minimeta() {
339
- if ( $this->subscribe2_options['s2page'] != 0 ) {
340
- echo "<li><a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\">" . __('[Un]Subscribe to Posts', 'subscribe2') . "</a></li>\r\n";
341
  }
342
- } // end add_minimeta()
343
 
344
- /**
345
- Add jQuery code and CSS to front pages for ajax form
346
- */
347
- function add_ajax() {
348
- // enqueue the jQuery script we need and let WordPress handle the dependencies
349
- wp_enqueue_script('jquery-ui-dialog');
350
- $css = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-darkness/jquery-ui.css';
351
- if ( is_ssl() ) {
352
- $css = str_replace('http:', 'https:', $css);
 
 
 
 
 
 
 
 
 
353
  }
354
- wp_register_style('jquery-ui-style', apply_filters('s2_jqueryui_css', $css));
355
- wp_enqueue_style('jquery-ui-style');
356
- } // end add_ajax()
 
 
 
 
357
 
358
  /**
359
- Write Subscribe2 form js code dynamically so we can pull WordPress functions
360
  */
361
- function add_s2_ajax() {
362
- echo "<script type=\"text/javascript\">\r\n";
363
- echo "//<![CDATA[\r\n";
364
- echo "var s2jQuery = jQuery.noConflict();\r\n";
365
- echo "s2jQuery(document).ready(function() {\r\n";
366
- echo " var dialog = s2jQuery('<div></div>');\r\n";
367
- echo " if (s2jQuery('a.s2popup').attr('id') === 'unsubscribe') {\r\n";
368
- echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="unsubscribe"]') . "');\r\n";
369
- echo " } else if (s2jQuery('a.s2popup').attr('id') === 'subscribe') {\r\n";
370
- echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="subscribe"]') . "');\r\n";
371
- echo " } else {\r\n";
372
- echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true"]') . "');\r\n";
373
- echo " }\r\n";
374
- if ( $this->s2form != $this->form && !is_user_logged_in() ) {
375
- echo " dialog.dialog({modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
376
- } else {
377
- echo " dialog.dialog({autoOpen: false, modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
378
  }
379
- echo " s2jQuery('a.s2popup').click(function(){\r\n";
380
- echo " dialog.dialog('open');\r\n";
381
- echo " return false;\r\n";
382
- echo " });\r\n";
383
- echo "});\r\n";
384
- echo "//]]>\r\n";
385
- echo "</script>\r\n";
386
- } // end add_s2_ajax()
387
 
388
  /**
389
  Check email is not from a barred domain
390
  */
391
- function is_barred($email = '') {
392
- if ( '' == $email ) { return false; }
393
-
394
- $bar_check = false;
395
- list($user, $domain) = explode('@', $email, 2);
396
- foreach ( preg_split("|[\s,]+|", $this->subscribe2_options['barred']) as $barred_domain ) {
397
- if ( strtolower($domain) === strtolower(trim($barred_domain)) ) {
398
- $bar_check = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  }
400
  }
401
- return $bar_check;
402
  } // end is_barred()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
403
  }
404
  ?>
1
  <?php
2
+ class S2_Frontend extends S2_Core {
3
  /**
4
  Load all our strings
5
  */
6
  function load_strings() {
7
+ $this->please_log_in = '<p class="s2_message">' . sprintf( __( 'To manage your subscription options please <a href="%1$s">login.</a>', 'subscribe2' ), get_option( 'siteurl' ) . '/wp-login.php' ) . '</p>';
8
 
9
+ $profile = apply_filters( 's2_profile_link', get_option( 'siteurl' ) . '/wp-admin/admin.php?page=s2' );
10
+ $this->profile = '<p class="s2_message">' . sprintf( __( 'You may manage your subscription options from your <a href="%1$s">profile</a>', 'subscribe2' ), $profile ) . '</p>';
11
+ if ( true === $this->s2_mu ) {
12
  global $blog_id;
13
  $user_ID = get_current_user_id();
14
+ if ( ! is_user_member_of_blog( $user_ID, $blog_id ) ) {
15
  // if we are on multisite and the user is not a member of this blog change the link
16
+ $mu_profile = apply_filters( 's2_mu_profile_link', get_option( 'siteurl' ) . '/wp-admin/?s2mu_subscribe=' . $blog_id );
17
+ $this->profile = '<p class="s2_message">' . sprintf( __( '<a href="%1$s">Subscribe</a> to email notifications when this blog posts new content.', 'subscribe2' ), $mu_profile ) . '</p>';
18
  }
19
  }
20
 
21
+ $this->confirmation_sent = '<p class="s2_message">' . __( 'A confirmation message is on its way!', 'subscribe2' ) . '</p>';
22
 
23
+ $this->already_subscribed = '<p class="s2_error">' . __( 'That email address is already subscribed.', 'subscribe2' ) . '</p>';
24
 
25
+ $this->not_subscribed = '<p class="s2_error">' . __( 'That email address is not subscribed.', 'subscribe2' ) . '</p>';
26
 
27
+ $this->not_an_email = '<p class="s2_error">' . __( 'Sorry, but that does not look like an email address to me.', 'subscribe2' ) . '</p>';
28
 
29
+ $this->barred_domain = '<p class="s2_error">' . __( 'Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2' ) . '</p>';
30
 
31
+ $this->error = '<p class="s2_error">' . __( 'Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2' ) . '</p>';
32
 
33
  // confirmation messages
34
+ $this->no_such_email = '<p class="s2_error">' . __( 'No such email address is registered.', 'subscribe2' ) . '</p>';
35
 
36
+ $this->added = '<p class="s2_message">' . __( 'You have successfully subscribed!', 'subscribe2' ) . '</p>';
37
 
38
+ $this->deleted = '<p class="s2_message">' . __( 'You have successfully unsubscribed.', 'subscribe2' ) . '</p>';
39
 
40
+ $this->subscribe = __( 'subscribe', 'subscribe2' ); //ACTION replacement in subscribing confirmation email
41
 
42
+ $this->unsubscribe = __( 'unsubscribe', 'subscribe2' ); //ACTION replacement in unsubscribing in confirmation email
43
  } // end load_strings()
44
 
45
+ /* ===== template and filter functions ===== */
46
  /**
47
  Display our form; also handles (un)subscribe requests
48
  */
49
+ function shortcode( $atts ) {
50
+ $args = shortcode_atts( array(
51
  'hide' => '',
52
  'id' => '',
53
  'nojs' => 'false',
54
  'noantispam' => 'false',
55
  'link' => '',
56
  'size' => 20,
57
+ 'wrap' => 'true',
58
+ ), $atts );
59
 
60
  // if link is true return a link to the page with the ajax class
61
+ if ( '1' === $this->subscribe2_options['ajax'] && '' !== $args['link'] && ! is_user_logged_in() ) {
62
+ $id = '';
63
+ foreach ( $args as $arg_name => $arg_value ) {
64
+ if ( ! empty( $arg_value ) && 'link' !== $arg_name && 'id' !== $arg_name ) {
65
+ if ( 'nojs' === $arg_name ) {
66
+ $arg_value = 'true';
67
+ }
68
+ ( '' === $id ) ? $id .= $arg_name . '-' . $arg_value : $id .= ':' . $arg_name . '-' . $arg_value;
69
+ }
70
+ }
71
+ $this->s2form = '<a href="#" class="s2popup" id="' . esc_attr( $id ) . '">' . esc_html( $args['link'] ) . '</a>' . "\r\n";
72
  return $this->s2form;
73
  }
74
 
75
  // Apply filters to button text
76
+ $unsubscribe_button_value = apply_filters( 's2_unsubscribe_button', __( 'Unsubscribe', 'subscribe2' ) );
77
+ $subscribe_button_value = apply_filters( 's2_subscribe_button', __( 'Subscribe', 'subscribe2' ) );
78
 
79
  // if a button is hidden, show only other
80
+ $hide = strtolower( $args['hide'] );
81
+ if ( 'subscribe' === $hide ) {
82
+ $this->input_form_action = '<input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
83
+ } elseif ( 'unsubscribe' === $hide ) {
84
+ $this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" />';
85
  } else {
86
  // both form input actions
87
+ $this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" />&nbsp;<input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
88
  }
89
 
90
  // if ID is provided, get permalink
91
  $action = '';
92
+ if ( is_numeric( $args['id'] ) ) {
93
+ $action = ' action="' . get_permalink( $args['id'] ) . '"';
94
  } elseif ( 'home' === $args['id'] ) {
95
+ $action = ' action="' . get_site_url() . '"';
96
  } elseif ( 'self' === $args['id'] ) {
97
+ // Correct for Static front page redirect behaviour
98
+ if ( 'page' === get_option( 'show_on_front' ) && is_front_page() ) {
99
+ $post = get_post( get_option( 'page_on_front' ) );
100
+ $action = ' action="' . get_option( 'home' ) . '/' . $post->post_name . '/"';
101
+ } else {
102
+ $action = '';
103
+ }
104
  } elseif ( $this->subscribe2_options['s2page'] > 0 ) {
105
+ $action = ' action="' . get_permalink( $this->subscribe2_options['s2page'] ) . '"';
106
  }
107
 
108
  // allow remote setting of email in form
109
+ if ( isset( $_REQUEST['email'] ) && is_email( $_REQUEST['email'] ) ) {
110
+ $value = $this->sanitize_email( $_REQUEST['email'] );
111
+ } elseif ( 'true' === strtolower( $args['nojs'] ) ) {
112
  $value = '';
113
  } else {
114
+ $value = __( 'Enter email address...', 'subscribe2' );
115
  }
116
 
117
  // if wrap is true add paragraph html tags
118
  $wrap_text = '';
119
+ if ( 'true' === strtolower( $args['wrap'] ) ) {
120
  $wrap_text = '</p><p>';
121
  }
122
 
123
  // deploy some anti-spam measures
124
  $antispam_text = '';
125
+ if ( 'true' !== strtolower( $args['noantispam'] ) ) {
126
+ $antispam_text = '<span style="display:none !important">';
127
+ $antispam_text .= '<label for="firstname">Leave This Blank:</label><input type="text" id="firstname" name="firstname" />';
128
+ $antispam_text .= '<label for="lastname">Leave This Blank Too:</label><input type="text" id="lastname" name="lastname" />';
129
+ $antispam_text .= '<label for="uri">Do Not Change This:</label><input type="text" id="uri" name="uri" value="http://" />';
130
+ $antispam_text .= '</span>';
131
  }
132
 
133
+ // get remote IP address
134
+ $remote_ip = $this->get_remote_ip();
135
+
136
  // build default form
137
+ if ( 'true' === strtolower( $args['nojs'] ) ) {
138
+ $this->form = '<form name="s2form" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_html( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br /><input type="text" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" />' . $wrap_text . $this->input_form_action . '</p></form>';
139
  } else {
140
+ $this->form = '<form name="s2form" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_html( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br /><input type="text" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" onfocus="if (this.value === \'' . $value . '\') {this.value = \'\';}" onblur="if (this.value === \'\') {this.value = \'' . $value . '\';}" />' . $wrap_text . $this->input_form_action . '</p></form>' . "\r\n";
141
  }
142
+ $this->s2form = apply_filters( 's2_form', $this->form );
143
 
144
  global $user_ID;
 
145
  if ( $user_ID ) {
146
  $this->s2form = $this->profile;
147
  }
148
 
149
+ if ( isset( $_POST['subscribe'] ) || isset( $_POST['unsubscribe'] ) ) {
150
  // anti spam sign up measure
151
+ if ( ( isset( $_POST['firstname'] ) && '' !== $_POST['firstname'] ) || ( isset( $_POST['lastname'] ) && '' !== $_POST['lastname'] ) || ( isset( $_POST['uri'] ) && 'http://' !== $_POST['uri'] ) ) {
152
  // looks like some invisible-to-user fields were changed; falsely report success
153
  return $this->confirmation_sent;
154
  }
155
  global $wpdb;
156
+ $this->email = $this->sanitize_email( $_POST['email'] );
157
+ if ( ! is_email( $this->email ) ) {
158
+ $this->s2form = $this->s2form . $this->not_an_email;
159
+ } elseif ( $this->is_barred( $this->email ) ) {
160
+ $this->s2form = $this->s2form . $this->barred_domain;
161
  } else {
162
  $this->ip = $_POST['ip'];
163
+ if ( is_int( $this->lockout ) && $this->lockout > 0 ) {
164
+ $date = date( 'H:i:s.u', $this->lockout );
165
+ $ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $this->public WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
166
+ if ( in_array( $this->ip, $ips ) ) {
167
+ return __( 'Slow down, you move too fast.', 'subscribe2' );
168
  }
169
  }
170
  // does the supplied email belong to a registered user?
171
+ $check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email = %s", $this->email ) );
172
+ if ( null !== $check ) {
173
  // this is a registered email
174
  $this->s2form = $this->please_log_in;
175
  } else {
176
  // this is not a registered email
177
  // what should we do?
178
+ if ( isset( $_POST['subscribe'] ) ) {
179
  // someone is trying to subscribe
180
  // lets see if they've tried to subscribe previously
181
+ if ( '1' !== $this->is_public( $this->email ) ) {
182
  // the user is unknown or inactive
183
+ $this->add( $this->email );
184
+ $status = $this->send_confirm( 'add' );
185
  // set a variable to denote that we've already run, and shouldn't run again
186
  $this->filtered = 1;
187
  if ( $status ) {
194
  $this->s2form = $this->already_subscribed;
195
  }
196
  $this->action = 'subscribe';
197
+ } elseif ( isset( $_POST['unsubscribe'] ) ) {
198
  // is this email a subscriber?
199
+ if ( false === $this->is_public( $this->email ) ) {
200
+ $this->s2form = $this->s2form . $this->not_subscribed;
201
  } else {
202
+ $status = $this->send_confirm( 'del' );
203
  // set a variable to denote that we've already run, and shouldn't run again
204
  $this->filtered = 1;
205
  if ( $status ) {
219
  /**
220
  Display form when deprecated <!--subscribe2--> is used
221
  */
222
+ function filter( $content = '' ) {
223
+ if ( '' === $content || ! strstr( $content, '<!--subscribe2-->' ) ) { return $content; }
224
 
225
+ return preg_replace( '/(<p>)?(\n)*<!--subscribe2-->(\n)*(</p>)?/', do_shortcode( '[subscribe2]' ), $content );
226
  } // end filter()
227
 
228
  /**
232
  */
233
  function query_filter() {
234
  // don't interfere if we've already done our thing
235
+ if ( 1 === $this->filtered ) { return; }
236
 
237
  global $wpdb;
238
 
239
  // brute force Simple Facebook Connect to bypass compatiblity issues
240
+ $priority = has_filter( 'wp_head', 'sfc_base_meta' );
241
+ if ( false !== $priority ) {
242
+ remove_action( 'wp_head', 'sfc_base_meta', $priority );
243
  }
244
 
245
+ if ( 0 !== $this->subscribe2_options['s2page'] ) {
246
+ return array(
247
+ 'page_id' => $this->subscribe2_options['s2page'],
248
+ );
249
  } else {
250
+ $id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1" );
251
  if ( $id ) {
252
+ return array(
253
+ 'page_id' => $id,
254
+ );
255
  } else {
256
+ return array(
257
+ 'showposts' => 1,
258
+ );
259
  }
260
  }
261
  } // end query_filter()
263
  /**
264
  Overrides the page title
265
  */
266
+ function title_filter( $title ) {
 
267
  if ( in_the_loop() ) {
268
  $code = $_GET['s2'];
269
+ $action = intval( substr( $code, 0, 1 ) );
270
+ if ( 1 === $action ) {
271
+ return __( 'Subscription Confirmation', 'subscribe2' );
272
  } else {
273
+ return __( 'Unsubscription Confirmation', 'subscribe2' );
274
  }
275
  } else {
276
  return $title;
280
  /**
281
  Confirm request from the link emailed to the user and email the admin
282
  */
283
+ function confirm( $content = '' ) {
284
  global $wpdb;
285
 
286
+ if ( 1 === $this->filtered && '' !== $this->message ) {
287
+ return $this->message;
288
+ } elseif ( 1 === $this->filtered ) {
289
+ return $content;
290
+ }
291
 
292
  $code = $_GET['s2'];
293
+ $action = substr( $code, 0, 1 );
294
+ $hash = substr( $code, 1, 32 );
295
+ $id = intval( substr( $code, 33 ) );
296
  if ( $id ) {
297
+ $this->email = $this->sanitize_email( $this->get_email( $id ) );
298
+ if ( ! $this->email || wp_hash( $this->email ) !== $hash ) {
299
  return $this->no_such_email;
300
  }
301
  } else {
303
  }
304
 
305
  // get current status of email so messages are only sent once per emailed link
306
+ $current = $this->is_public( $this->email );
307
 
308
+ if ( '1' === $action ) {
309
  // make this subscription active
310
+ $this->message = apply_filters( 's2_subscribe_confirmed', $this->added );
311
+ if ( '1' !== $this->is_public( $this->email ) ) {
312
+ $this->ip = esc_html( $this->get_remote_ip() );
313
+ $this->toggle( $this->email );
314
+ if ( 'subs' === $this->subscribe2_options['admin_email'] || 'both' === $this->subscribe2_options['admin_email'] ) {
315
+ $this->admin_email( 'subscribe' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
317
  }
318
  $this->filtered = 1;
319
+ } elseif ( '0' === $action ) {
320
+ // remove this public subscriber
321
+ $this->message = apply_filters( 's2_unsubscribe_confirmed', $this->deleted );
322
+ if ( '0' !== $this->is_public( $this->email ) ) {
323
+ $this->delete( $this->email );
324
+ if ( 'unsubs' === $this->subscribe2_options['admin_email'] || 'both' === $this->subscribe2_options['admin_email'] ) {
325
+ $this->admin_email( 'unsubscribe' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  }
327
  }
328
  $this->filtered = 1;
329
  }
330
 
331
+ if ( '' !== $this->message ) {
332
  return $this->message;
333
  }
334
  } // end confirm()
335
 
336
  /**
337
+ Prepare and send emails to admins on new subscriptions and unsubsriptions
338
  */
339
+ function admin_email( $action ) {
340
+ if ( ! in_array( $action, array( 'subscribe', 'unsubscribe' ) ) ) {
341
+ return false;
342
  }
 
343
 
344
+ ( '' === get_option( 'blogname' ) ) ? $subject = '' : $subject = '[' . stripslashes( html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . '] ';
345
+ if ( 'subscribe' === $action ) {
346
+ $subject .= __( 'New Subscription', 'subscribe2' );
347
+ $message = $this->email . ' ' . __( 'subscribed to email notifications!', 'subscribe2' );
348
+ } elseif ( 'unsubscribe' === $action ) {
349
+ $subject .= __( 'New Unsubscription', 'subscribe2' );
350
+ $message = $this->email . ' ' . __( 'unsubscribed from email notifications!', 'subscribe2' );
351
+ }
352
+ $subject = html_entity_decode( $subject, ENT_QUOTES );
353
+ $role = array(
354
+ 'fields' => array(
355
+ 'user_email',
356
+ ),
357
+ 'role' => 'administrator',
358
+ );
359
+ $wp_user_query = get_users( $role );
360
+ foreach ( $wp_user_query as $user ) {
361
+ $recipients[] = $user->user_email;
362
  }
363
+ $recipients = apply_filters( 's2_admin_email', $recipients, $action );
364
+ $headers = $this->headers();
365
+ // send individual emails so we don't reveal admin emails to each other
366
+ foreach ( $recipients as $recipient ) {
367
+ @wp_mail( $recipient, $subject, $message, $headers );
368
+ }
369
+ } // end admin_email()
370
 
371
  /**
372
+ Add hook for Minimeta Widget plugin
373
  */
374
+ function add_minimeta() {
375
+ if ( 0 !== $this->subscribe2_options['s2page'] ) {
376
+ echo '<li><a href="' . get_permalink( $this->subscribe2_options['s2page'] ) . '">' . __( '[Un]Subscribe to Posts', 'subscribe2' ) . '</a></li>' . "\r\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  }
378
+ } // end add_minimeta()
 
 
 
 
 
 
 
379
 
380
  /**
381
  Check email is not from a barred domain
382
  */
383
+ function is_barred( $email = '' ) {
384
+ if ( '' === $email ) { return false; }
385
+
386
+ list( $user, $domain ) = explode( '@', $email, 2 );
387
+ $domain = '@' . $domain;
388
+ foreach ( preg_split( '/[\s,]+/', $this->subscribe2_options['barred'] ) as $barred_domain ) {
389
+ if ( false !== strpos( $barred_domain, '*' ) ) {
390
+ // wildcard domain checking
391
+ $url = explode( '.', $barred_domain );
392
+ $count = count( $url );
393
+ // make sure our exploded domain has at least 2 components e.g. yahoo.*
394
+ if ( $count < 2 ) {
395
+ continue;
396
+ }
397
+ for ( $i = 0; $i < $count; $i++ ) {
398
+ if ( '*' === $url[ $i ] ) {
399
+ unset( $url[ $i ] );
400
+ }
401
+ }
402
+ $new_barred_domain = '@' . strtolower( trim( implode( '.', $url ) ) );
403
+ $new_barred_subdomain = '.' . strtolower( trim( implode( '.', $url ) ) );
404
+
405
+ if ( false !== stripos( $domain, $new_barred_domain ) || false !== stripos( $domain, $new_barred_subdomain ) ) {
406
+ return true;
407
+ }
408
+ } else {
409
+ // direct domain string comparison
410
+ $barred_domain = '@' . $barred_domain;
411
+ if ( strtolower( $domain ) === strtolower( trim( $barred_domain ) ) ) {
412
+ return true;
413
+ }
414
  }
415
  }
416
+ return false;
417
  } // end is_barred()
418
+
419
+ /**
420
+ Collect and return the IP address of the remote client machine
421
+ */
422
+ function get_remote_ip() {
423
+ $remote_ip = false;
424
+
425
+ // In order of preference, with the best ones for this purpose first
426
+ $address_headers = array(
427
+ 'HTTP_CLIENT_IP',
428
+ 'HTTP_X_FORWARDED_FOR',
429
+ 'HTTP_X_FORWARDED',
430
+ 'HTTP_X_CLUSTER_CLIENT_IP',
431
+ 'HTTP_FORWARDED_FOR',
432
+ 'HTTP_FORWARDED',
433
+ 'REMOTE_ADDR',
434
+ );
435
+
436
+ foreach ( $address_headers as $header ) {
437
+ if ( array_key_exists( $header, $_SERVER ) ) {
438
+ // HTTP_X_FORWARDED_FOR can contain a chain of comma-separated
439
+ // addresses. The first one is the original client. It can't be
440
+ // trusted for authenticity, but we don't need to for this purpose.
441
+ $address_chain = explode( ',', $_SERVER[ $header ] );
442
+ $remote_ip = trim( $address_chain[0] );
443
+ break;
444
+ }
445
+ }
446
+
447
+ return $remote_ip;
448
+ } // end get_remote_ip()
449
+
450
+ /*
451
+ Enqueue javascript ip updater code
452
+ */
453
+ function js_ip_script() {
454
+ wp_register_script( 's2_ip_updater', S2URL . 'include/s2-ip-updater' . $this->script_debug . '.js', array(), '1.0', true );
455
+ wp_enqueue_script( 's2_ip_updater' );
456
+ } // end js_ip_script()
457
+
458
+ /*
459
+ Add ip updater library to footer
460
+ */
461
+ function js_ip_library_script() {
462
+ echo '<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getip"></script>' . "\r\n";
463
+ } // end js_ip_library_script()
464
  }
465
  ?>
classes/class-s2-list-table-legacy.php ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ List Table class used in WordPress 4.2.x and below
4
+ */
5
+ class S2_List_Table_Legacy extends WP_List_Table {
6
+ function __construct() {
7
+ global $status, $page;
8
+
9
+ parent::__construct( array(
10
+ 'singular' => 'subscriber',
11
+ 'plural' => 'subscribers',
12
+ 'ajax' => false,
13
+ ) );
14
+ }
15
+
16
+ function column_default( $item, $column_name ) {
17
+ global $current_tab;
18
+ if ( 'registered' === $current_tab ) {
19
+ switch ( $column_name ) {
20
+ case 'email':
21
+ return $item[ $column_name ];
22
+ }
23
+ } else {
24
+ switch ( $column_name ) {
25
+ case 'email':
26
+ case 'date':
27
+ return $item[ $column_name ];
28
+ }
29
+ }
30
+ }
31
+
32
+ function column_email( $item ) {
33
+ global $current_tab;
34
+ if ( 'registered' === $current_tab ) {
35
+ $actions = array(
36
+ 'edit' => sprintf( '<a href="?page=%s&amp;id=%d">%s</a>', 's2', urlencode( $item['id'] ), __( 'Edit', 'subscribe2' ) ),
37
+ );
38
+ return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $actions ) );
39
+ } else {
40
+ global $mysubscribe2;
41
+ if ( '0' === $mysubscribe2->is_public( $item['email'] ) ) {
42
+ return sprintf( '<span style="color:#FF0000"><abbr title="' . $mysubscribe2->signup_ip( $item['email'] ) . '">%1$s</abbr></span>', $item['email'] );
43
+ } else {
44
+ return sprintf( '<abbr title="' . $mysubscribe2->signup_ip( $item['email'] ) . '">%1$s</abbr>', $item['email'] );
45
+ }
46
+ }
47
+ }
48
+
49
+ function column_cb( $item ) {
50
+ return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['email'] );
51
+ }
52
+
53
+ function get_columns() {
54
+ global $current_tab;
55
+ if ( 'registered' === $current_tab ) {
56
+ if ( is_multisite() ) {
57
+ $columns = array(
58
+ 'email' => _x( 'Email', 'column name', 'subscribe2' ),
59
+ );
60
+ } else {
61
+ $columns = array(
62
+ 'cb' => '<input type="checkbox" />',
63
+ 'email' => _x( 'Email', 'column name', 'subscribe2' ),
64
+ );
65
+ }
66
+ } else {
67
+ $columns = array(
68
+ 'cb' => '<input type="checkbox" />',
69
+ 'email' => _x( 'Email', 'column name', 'subscribe2' ),
70
+ 'date' => _x( 'Date', 'column name', 'subscribe2' ),
71
+ );
72
+ }
73
+ return $columns;
74
+ }
75
+
76
+ function get_sortable_columns() {
77
+ global $current_tab;
78
+ if ( 'registered' === $current_tab ) {
79
+ $sortable_columns = array(
80
+ 'email' => array( 'email', true ),
81
+ );
82
+ } else {
83
+ $sortable_columns = array(
84
+ 'email' => array( 'email', true ),
85
+ 'date' => array( 'date', false ),
86
+ );
87
+ }
88
+ return $sortable_columns;
89
+ }
90
+
91
+ function get_bulk_actions() {
92
+ global $current_tab;
93
+ if ( 'registered' === $current_tab ) {
94
+ if ( is_multisite() ) {
95
+ return array();
96
+ } else {
97
+ global $mysubscribe2;
98
+ if ( 'never' === $mysubscribe2->subscribe2_options['email_freq'] ) {
99
+ return array(
100
+ 'delete' => __( 'Delete', 'subscribe2' ),
101
+ 'subscribe' => __( 'Subscribe', 'subscribe2' ),
102
+ 'unsubscribe' => __( 'Unsubscribe', 'subscribe2' ),
103
+ 'format' => __( 'Change Email Format', 'subscribe2' ),
104
+ );
105
+ } else {
106
+ return array(
107
+ 'delete' => __( 'Delete', 'subscribe2' ),
108
+ 'digest' => __( 'Change Digest Subscription', 'subscribe2' ),
109
+ );
110
+ }
111
+ }
112
+ } else {
113
+ $actions = array(
114
+ 'delete' => __( 'Delete', 'subscribe2' ),
115
+ 'toggle' => __( 'Toggle', 'subscribe2' ),
116
+ );
117
+ return $actions;
118
+ }
119
+ }
120
+
121
+ function process_bulk_action() {
122
+ if ( in_array( $this->current_action(), array( 'delete', 'toggle', 'subscribe', 'unsubscribe', 'format', 'digest' ) ) ) {
123
+ if ( ! isset( $_REQUEST['subscriber'] ) ) {
124
+ echo '<div id="message" class="error"><p><strong>' . __( 'No users were selected.' , 'subscribe2' ) . '</strong></p></div>';
125
+ return;
126
+ }
127
+ }
128
+ if ( 'delete' === $this->current_action() ) {
129
+ global $mysubscribe2, $current_user, $subscribers;
130
+ $message = array();
131
+ foreach ( $_REQUEST['subscriber'] as $address ) {
132
+ if ( false !== $mysubscribe2->is_public( $address ) ) {
133
+ $mysubscribe2->delete( $address );
134
+ $key = array_search( $address, $subscribers );
135
+ unset( $subscribers[ $key ] );
136
+ $message['public_deleted'] = __( 'Address(es) deleted!', 'subscribe2' );
137
+ } else {
138
+ $user = get_user_by( 'email', $address );
139
+ if ( ! current_user_can( 'delete_user', $user->ID ) || $user->ID === $current_user->ID ) {
140
+ $message['reg_delete_error'] = __( 'Delete failed! You cannot delete some or all of these users.', 'subscribe2' );
141
+ continue;
142
+ } else {
143
+ $message['reg_deleted'] = __( 'Registered user(s) deleted! Any posts made by these users were assigned to you.', 'subscribe2' );
144
+ foreach ( $subscribers as $key => $data ) {
145
+ if ( in_array( $address, $data ) ) {
146
+ unset( $subscribers[ $key ] );
147
+ }
148
+ }
149
+ wp_delete_user( $user->ID, $current_user->ID );
150
+ }
151
+ }
152
+ }
153
+ $final_message = implode( '<br /><br />', array_filter( $message ) );
154
+ echo '<div id="message" class="updated fade"><p><strong>' . $final_message . '</strong></p></div>';
155
+ }
156
+ if ( 'toggle' === $this->current_action() ) {
157
+ global $mysubscribe2, $current_user, $subscribers;
158
+ $mysubscribe2->ip = $current_user->user_login;
159
+ foreach ( $_REQUEST['subscriber'] as $address ) {
160
+ $mysubscribe2->toggle( $address );
161
+ if ( 'confirmed' === $_POST['what'] || 'unconfirmed' === $_POST['what'] ) {
162
+ $key = array_search( $address, $subscribers );
163
+ unset( $subscribers[ $key ] );
164
+ }
165
+ }
166
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Status changed!', 'subscribe2' ) . '</strong></p></div>';
167
+ }
168
+ if ( 'subscribe' === $this->current_action() ) {
169
+ global $mysubscribe2;
170
+ $mysubscribe2->subscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['category'] );
171
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Registered Users Subscribed!', 'subscribe2' ) . '</strong></p></div>';
172
+ }
173
+ if ( 'unsubscribe' === $this->current_action() ) {
174
+ global $mysubscribe2;
175
+ $mysubscribe2->unsubscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['category'] );
176
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Registered Users Unsubscribed!', 'subscribe2' ) . '</strong></p></div>';
177
+ }
178
+ if ( 'format' === $this->current_action() ) {
179
+ global $mysubscribe2;
180
+ $mysubscribe2->format_change( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['format'] );
181
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Format updated for Selected Registered Users!', 'subscribe2' ) . '</strong></p></div>';
182
+ }
183
+ if ( 'digest' === $this->current_action() ) {
184
+ global $mysubscribe2;
185
+ $mysubscribe2->digest_change( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['sub_category'] );
186
+ echo '<div id="message" class="error"><p><strong>' . __( 'Digest Subscription updated for Selected Registered Users!', 'subscribe2' ) . '</strong></p></div>';
187
+ }
188
+ }
189
+
190
+ function pagination( $which ) {
191
+ if ( empty( $this->_pagination_args ) ) {
192
+ return;
193
+ }
194
+
195
+ $total_items = intval( $this->_pagination_args['total_items'] );
196
+ $total_pages = intval( $this->_pagination_args['total_pages'] );
197
+ $infinite_scroll = false;
198
+ if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
199
+ $infinite_scroll = $this->_pagination_args['infinite_scroll'];
200
+ }
201
+
202
+ $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'subscribe2' ), number_format_i18n( $total_items ) ) . '</span>';
203
+
204
+ if ( isset( $_POST['what'] ) ) {
205
+ $current = 1;
206
+ } else {
207
+ $current = intval( $this->get_pagenum() );
208
+ }
209
+
210
+ if ( version_compare( $GLOBALS['wp_version'], '3.5', '<' ) ) {
211
+ $current_url = esc_url( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
212
+ } else {
213
+ $current_url = esc_url( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
214
+ }
215
+
216
+ $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
217
+
218
+ if ( isset( $what ) ) {
219
+ $current_url = add_query_arg( array(
220
+ 'what' => $what,
221
+ ), $current_url );
222
+ } elseif ( isset( $_REQUEST['what'] ) ) {
223
+ $current_url = add_query_arg( array(
224
+ 'what' => $_REQUEST['what'],
225
+ ), $current_url );
226
+ }
227
+
228
+ if ( isset( $_POST['s'] ) ) {
229
+ $current_url = add_query_arg( array(
230
+ 's' => $_POST['s'],
231
+ ), $current_url );
232
+ }
233
+
234
+ $page_links = array();
235
+
236
+ $disable_first = $disable_last = '';
237
+ if ( 1 === $current ) {
238
+ $disable_first = ' disabled';
239
+ }
240
+ if ( $current === $total_pages ) {
241
+ $disable_last = ' disabled';
242
+ }
243
+
244
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
245
+ 'first-page' . $disable_first,
246
+ esc_attr__( 'Go to the first page', 'subscribe2' ),
247
+ remove_query_arg( 'paged', $current_url ),
248
+ '&laquo;'
249
+ );
250
+
251
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
252
+ 'prev-page' . $disable_first,
253
+ esc_attr__( 'Go to the previous page', 'subscribe2' ),
254
+ add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ),
255
+ '&lsaquo;'
256
+ );
257
+
258
+ if ( 'bottom' === $which ) {
259
+ $html_current_page = $current;
260
+ } else {
261
+ $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
262
+ esc_attr__( 'Current page', 'subscribe2' ),
263
+ $current,
264
+ strlen( $total_pages )
265
+ );
266
+ }
267
+
268
+ $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
269
+ $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging', 'subscribe2' ), $html_current_page, $html_total_pages ) . '</span>';
270
+
271
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
272
+ 'next-page' . $disable_last,
273
+ esc_attr__( 'Go to the next page', 'subscribe2' ),
274
+ add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ),
275
+ '&rsaquo;'
276
+ );
277
+
278
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
279
+ 'last-page' . $disable_last,
280
+ esc_attr__( 'Go to the last page', 'subscribe2' ),
281
+ add_query_arg( 'paged', $total_pages, $current_url ),
282
+ '&raquo;'
283
+ );
284
+
285
+ $pagination_links_class = 'pagination-links';
286
+ if ( ! empty( $infinite_scroll ) ) {
287
+ $pagination_links_class = ' hide-if-js';
288
+ }
289
+ $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
290
+
291
+ if ( $total_pages ) {
292
+ $page_class = $total_pages < 2 ? ' one-page' : '';
293
+ } else {
294
+ $page_class = ' no-pages';
295
+ }
296
+
297
+ $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
298
+
299
+ echo $this->_pagination;
300
+ }
301
+
302
+ function prepare_items() {
303
+ global $mysubscribe2, $subscribers, $current_tab;
304
+ if ( is_int( $mysubscribe2->subscribe2_options['entries'] ) ) {
305
+ $per_page = $mysubscribe2->subscribe2_options['entries'];
306
+ } else {
307
+ $per_page = 25;
308
+ }
309
+
310
+ $columns = $this->get_columns();
311
+ $hidden = array();
312
+ $sortable = $this->get_sortable_columns();
313
+ $this->_column_headers = array( $columns, $hidden, $sortable );
314
+
315
+ $this->process_bulk_action();
316
+
317
+ $data = array();
318
+ if ( 'public' === $current_tab ) {
319
+ foreach ( (array) $subscribers as $email ) {
320
+ $data[] = array(
321
+ 'email' => $email,
322
+ 'date' => $mysubscribe2->signup_date( $email ),
323
+ );
324
+ }
325
+ } else {
326
+ foreach ( (array) $subscribers as $subscriber ) {
327
+ $data[] = array(
328
+ 'email' => $subscriber['user_email'],
329
+ 'id' => $subscriber['ID'],
330
+ );
331
+ }
332
+ }
333
+
334
+ function usort_reorder( $a, $b ) {
335
+ $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'email';
336
+ $order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
337
+ $result = strcasecmp( $a[ $orderby ], $b[ $orderby ] );
338
+ return ( 'asc' === $order ) ? $result : -$result;
339
+ }
340
+ usort( $data, 'usort_reorder' );
341
+
342
+ if ( isset( $_POST['what'] ) ) {
343
+ $current_page = 1;
344
+ } else {
345
+ $current_page = $this->get_pagenum();
346
+ }
347
+ $total_items = count( $data );
348
+ $data = array_slice( $data,( ($current_page -1 ) * $per_page ), $per_page );
349
+ $this->items = $data;
350
+
351
+ $this->set_pagination_args( array(
352
+ 'total_items' => $total_items,
353
+ 'per_page' => $per_page,
354
+ 'total_pages' => ceil( $total_items / $per_page ),
355
+ ) );
356
+ }
357
+ }
358
+ ?>
classes/class-s2-list-table.php CHANGED
@@ -1,72 +1,73 @@
1
  <?php
2
- class Subscribe2_List_Table extends WP_List_Table {
 
 
 
3
  function __construct() {
4
  global $status, $page;
5
 
6
  parent::__construct( array(
7
  'singular' => 'subscriber',
8
  'plural' => 'subscribers',
9
- 'ajax' => false
10
  ) );
11
  }
12
 
13
- function column_default($item, $column_name) {
14
  global $current_tab;
15
- if ( $current_tab == 'registered' ) {
16
- switch($column_name) {
17
  case 'email':
18
- return $item[$column_name];
19
- default:
20
- return print_r($item,true);
21
  }
22
  } else {
23
- switch($column_name) {
24
  case 'email':
25
  case 'date':
26
- return $item[$column_name];
27
- default:
28
- return print_r($item,true);
29
  }
30
  }
31
  }
32
 
33
- function column_email($item) {
34
  global $current_tab;
35
- if ( $current_tab == 'registered' ) {
36
- $actions = array('edit' => sprintf('<a href="?page=%s&amp;email=%s">%s</a>', 's2', urlencode($item['email']), __('Edit', 'subscribe2')));
37
- return sprintf('%1$s %2$s', $item['email'], $this->row_actions($actions));
 
 
38
  } else {
39
  global $mysubscribe2;
40
- if ( '0' === $mysubscribe2->is_public($item['email']) ) {
41
- return sprintf('<span style="color:#FF0000"><abbr title="' . htmlentities($mysubscribe2->signup_ip($item['email'])) . '">%1$s</abbr></span>', $item['email']);
42
  } else {
43
- return sprintf('<abbr title="' . $mysubscribe2->signup_ip($item['email']) . '">%1$s</abbr>', $item['email']);
44
  }
45
  }
46
  }
47
 
48
- function column_cb($item) {
49
- return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['email']);
50
  }
51
 
52
  function get_columns() {
53
  global $current_tab;
54
- if ( $current_tab == 'registered' ) {
55
- if (is_multisite()) {
56
  $columns = array(
57
- 'email' => _x('Email', 'column name', 'subscribe2')
58
  );
59
  } else {
60
  $columns = array(
61
  'cb' => '<input type="checkbox" />',
62
- 'email' => _x('Email', 'column name', 'subscribe2')
63
  );
64
  }
65
  } else {
66
  $columns = array(
67
  'cb' => '<input type="checkbox" />',
68
- 'email' => _x('Email', 'column name', 'subscribe2'),
69
- 'date' => _x('Date', 'column name', 'subscribe2')
70
  );
71
  }
72
  return $columns;
@@ -74,12 +75,14 @@ class Subscribe2_List_Table extends WP_List_Table {
74
 
75
  function get_sortable_columns() {
76
  global $current_tab;
77
- if ( $current_tab == 'registered' ) {
78
- $sortable_columns = array('email' => array('email', true));
 
 
79
  } else {
80
  $sortable_columns = array(
81
- 'email' => array('email', true),
82
- 'date' => array('date', false)
83
  );
84
  }
85
  return $sortable_columns;
@@ -87,111 +90,221 @@ class Subscribe2_List_Table extends WP_List_Table {
87
 
88
  function get_bulk_actions() {
89
  global $current_tab;
90
- if ( $current_tab == 'registered' ) {
91
- if (is_multisite()) {
92
  return array();
93
  } else {
94
- return array(
95
- 'delete' => __('Delete', 'subscribe2')
96
- );
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
  } else {
99
  $actions = array(
100
- 'delete' => __('Delete', 'subscribe2'),
101
- 'toggle' => __('Toggle', 'subscribe2')
102
  );
103
  return $actions;
104
  }
105
  }
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  function pagination( $which ) {
108
  if ( empty( $this->_pagination_args ) ) {
109
  return;
110
  }
111
 
112
- $total_items = $this->_pagination_args['total_items'];
113
- $total_pages = $this->_pagination_args['total_pages'];
114
  $infinite_scroll = false;
115
  if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
116
  $infinite_scroll = $this->_pagination_args['infinite_scroll'];
117
  }
118
 
119
- $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items, 'subscribe2' ), number_format_i18n( $total_items ) ) . '</span>';
 
 
 
 
120
 
121
- if ( isset($_POST['what']) ) {
122
  $current = 1;
123
  } else {
124
- $current = $this->get_pagenum();
125
  }
126
 
127
- if ( version_compare($GLOBALS['wp_version'], '3.5', '<') ) {
128
- $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
129
- } else {
130
- $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
131
- }
132
 
133
- $current_url = remove_query_arg( array('hotkeys_highlight_last', 'hotkeys_highlight_first'), $current_url );
134
 
135
- if ( isset($what) ) {
136
- $current_url = add_query_arg( array('what' => $what), $current_url );
137
- } elseif ( isset($_REQUEST['what']) ) {
138
- $current_url = add_query_arg( array('what' => $_REQUEST['what']), $current_url );
 
 
 
 
139
  }
140
 
141
- if ( isset($_POST['s']) ) {
142
- $current_url = add_query_arg( array('s' => $_POST['s']), $current_url );
 
 
143
  }
144
 
145
  $page_links = array();
146
 
147
- $disable_first = $disable_last = '';
148
- if ( $current == 1 ) {
149
- $disable_first = ' disabled';
 
 
 
 
 
150
  }
151
- if ( $current == $total_pages ) {
152
- $disable_last = ' disabled';
 
 
 
 
 
 
 
153
  }
154
 
155
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
156
- 'first-page' . $disable_first,
157
- esc_attr__('Go to the first page', 'subscribe2'),
158
- esc_url( remove_query_arg( 'paged', $current_url ) ),
159
- '&laquo;'
160
- );
 
 
 
161
 
162
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
163
- 'prev-page' . $disable_first,
164
- esc_attr__('Go to the previous page', 'subscribe2'),
165
- esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
166
- '&lsaquo;'
167
- );
 
 
 
168
 
169
- if ( 'bottom' == $which ) {
170
- $html_current_page = $current;
 
171
  } else {
172
- $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
173
- esc_attr__('Current page', 'subscribe2'),
174
  $current,
175
  strlen( $total_pages )
176
  );
177
  }
178
-
179
  $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
180
- $page_links[] = '<span class="paging-input">' . sprintf( _x('%1$s of %2$s', 'paging', 'subscribe2'), $html_current_page, $html_total_pages ) . '</span>';
181
-
182
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
183
- 'next-page' . $disable_last,
184
- esc_attr__('Go to the next page', 'subscribe2'),
185
- esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
186
- '&rsaquo;'
187
- );
188
-
189
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
190
- 'last-page' . $disable_last,
191
- esc_attr__('Go to the last page', 'subscribe2'),
192
- esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
193
- '&raquo;'
194
- );
 
 
 
 
 
 
195
 
196
  $pagination_links_class = 'pagination-links';
197
  if ( ! empty( $infinite_scroll ) ) {
@@ -204,7 +317,6 @@ class Subscribe2_List_Table extends WP_List_Table {
204
  } else {
205
  $page_class = ' no-pages';
206
  }
207
-
208
  $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
209
 
210
  echo $this->_pagination;
@@ -212,7 +324,7 @@ class Subscribe2_List_Table extends WP_List_Table {
212
 
213
  function prepare_items() {
214
  global $mysubscribe2, $subscribers, $current_tab;
215
- if ( is_int($mysubscribe2->subscribe2_options['entries']) ) {
216
  $per_page = $mysubscribe2->subscribe2_options['entries'];
217
  } else {
218
  $per_page = 25;
@@ -221,40 +333,48 @@ class Subscribe2_List_Table extends WP_List_Table {
221
  $columns = $this->get_columns();
222
  $hidden = array();
223
  $sortable = $this->get_sortable_columns();
224
- $this->_column_headers = array($columns, $hidden, $sortable);
 
 
225
 
226
  $data = array();
227
- if ( $current_tab == 'public' ) {
228
- foreach((array)$subscribers as $email) {
229
- $data[] = array('email' => $email, 'date' => $mysubscribe2->signup_date($email));
 
 
 
230
  }
231
  } else {
232
- foreach((array)$subscribers as $email) {
233
- $data[] = array('email' => $email);
 
 
 
234
  }
235
  }
236
 
237
- function usort_reorder($a,$b) {
238
- $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'email';
239
- $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc';
240
- $result = strcasecmp($a[$orderby], $b[$orderby]);
241
- return ($order==='asc') ? $result : -$result;
242
  }
243
- usort($data, 'usort_reorder');
244
 
245
- if ( isset($_POST['what']) ) {
246
  $current_page = 1;
247
  } else {
248
  $current_page = $this->get_pagenum();
249
  }
250
- $total_items = count($data);
251
- $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
252
  $this->items = $data;
253
 
254
  $this->set_pagination_args( array(
255
  'total_items' => $total_items,
256
  'per_page' => $per_page,
257
- 'total_pages' => ceil($total_items/$per_page)
258
  ) );
259
  }
260
  }
1
  <?php
2
+ /**
3
+ List Table class used in WordPress 4.3.x and above
4
+ */
5
+ class S2_List_Table extends WP_List_Table {
6
  function __construct() {
7
  global $status, $page;
8
 
9
  parent::__construct( array(
10
  'singular' => 'subscriber',
11
  'plural' => 'subscribers',
12
+ 'ajax' => false,
13
  ) );
14
  }
15
 
16
+ function column_default( $item, $column_name ) {
17
  global $current_tab;
18
+ if ( 'registered' === $current_tab ) {
19
+ switch ( $column_name ) {
20
  case 'email':
21
+ return $item[ $column_name ];
 
 
22
  }
23
  } else {
24
+ switch ( $column_name ) {
25
  case 'email':
26
  case 'date':
27
+ return $item[ $column_name ];
 
 
28
  }
29
  }
30
  }
31
 
32
+ function column_email( $item ) {
33
  global $current_tab;
34
+ if ( 'registered' === $current_tab ) {
35
+ $actions = array(
36
+ 'edit' => sprintf( '<a href="?page=%s&amp;id=%d">%s</a>', 's2', urlencode( $item['id'] ), __( 'Edit', 'subscribe2' ) ),
37
+ );
38
+ return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $actions ) );
39
  } else {
40
  global $mysubscribe2;
41
+ if ( '0' === $mysubscribe2->is_public( $item['email'] ) ) {
42
+ return sprintf( '<span style="color:#FF0000"><abbr title="' . $mysubscribe2->signup_ip( $item['email'] ) . '">%1$s</abbr></span>', $item['email'] );
43
  } else {
44
+ return sprintf( '<abbr title="' . $mysubscribe2->signup_ip( $item['email'] ) . '">%1$s</abbr>', $item['email'] );
45
  }
46
  }
47
  }
48
 
49
+ function column_cb( $item ) {
50
+ return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['email'] );
51
  }
52
 
53
  function get_columns() {
54
  global $current_tab;
55
+ if ( 'registered' === $current_tab ) {
56
+ if ( is_multisite() ) {
57
  $columns = array(
58
+ 'email' => _x( 'Email', 'column name', 'subscribe2' ),
59
  );
60
  } else {
61
  $columns = array(
62
  'cb' => '<input type="checkbox" />',
63
+ 'email' => _x( 'Email', 'column name', 'subscribe2' ),
64
  );
65
  }
66
  } else {
67
  $columns = array(
68
  'cb' => '<input type="checkbox" />',
69
+ 'email' => _x( 'Email', 'column name', 'subscribe2' ),
70
+ 'date' => _x( 'Date', 'column name', 'subscribe2' ),
71
  );
72
  }
73
  return $columns;
75
 
76
  function get_sortable_columns() {
77
  global $current_tab;
78
+ if ( 'registered' === $current_tab ) {
79
+ $sortable_columns = array(
80
+ 'email' => array( 'email', true ),
81
+ );
82
  } else {
83
  $sortable_columns = array(
84
+ 'email' => array( 'email', true ),
85
+ 'date' => array( 'date', false ),
86
  );
87
  }
88
  return $sortable_columns;
90
 
91
  function get_bulk_actions() {
92
  global $current_tab;
93
+ if ( 'registered' === $current_tab ) {
94
+ if ( is_multisite() ) {
95
  return array();
96
  } else {
97
+ global $mysubscribe2;
98
+ if ( 'never' === $mysubscribe2->subscribe2_options['email_freq'] ) {
99
+ return array(
100
+ 'delete' => __( 'Delete', 'subscribe2' ),
101
+ 'subscribe' => __( 'Subscribe', 'subscribe2' ),
102
+ 'unsubscribe' => __( 'Unsubscribe', 'subscribe2' ),
103
+ 'format' => __( 'Change Email Format', 'subscribe2' ),
104
+ );
105
+ } else {
106
+ return array(
107
+ 'delete' => __( 'Delete', 'subscribe2' ),
108
+ 'digest' => __( 'Change Digest Subscription', 'subscribe2' ),
109
+ );
110
+ }
111
  }
112
  } else {
113
  $actions = array(
114
+ 'delete' => __( 'Delete', 'subscribe2' ),
115
+ 'toggle' => __( 'Toggle', 'subscribe2' ),
116
  );
117
  return $actions;
118
  }
119
  }
120
 
121
+ function process_bulk_action() {
122
+ if ( in_array( $this->current_action(), array( 'delete', 'toggle', 'subscribe', 'unsubscribe', 'format', 'digest' ) ) ) {
123
+ if ( ! isset( $_REQUEST['subscriber'] ) ) {
124
+ echo '<div id="message" class="error"><p><strong>' . __( 'No users were selected.' , 'subscribe2' ) . '</strong></p></div>';
125
+ return;
126
+ }
127
+ }
128
+ if ( 'delete' === $this->current_action() ) {
129
+ global $mysubscribe2, $current_user, $subscribers;
130
+ $message = array();
131
+ foreach ( $_REQUEST['subscriber'] as $address ) {
132
+ if ( false !== $mysubscribe2->is_public( $address ) ) {
133
+ $mysubscribe2->delete( $address );
134
+ $key = array_search( $address, $subscribers );
135
+ unset( $subscribers[ $key ] );
136
+ $message['public_deleted'] = __( 'Address(es) deleted!', 'subscribe2' );
137
+ } else {
138
+ $user = get_user_by( 'email', $address );
139
+ if ( ! current_user_can( 'delete_user', $user->ID ) || $user->ID === $current_user->ID ) {
140
+ $message['reg_delete_error'] = __( 'Delete failed! You cannot delete some or all of these users.', 'subscribe2' );
141
+ continue;
142
+ } else {
143
+ $message['reg_deleted'] = __( 'Registered user(s) deleted! Any posts made by these users were assigned to you.', 'subscribe2' );
144
+ foreach ( $subscribers as $key => $data ) {
145
+ if ( in_array( $address, $data ) ) {
146
+ unset( $subscribers[ $key ] );
147
+ }
148
+ }
149
+ wp_delete_user( $user->ID, $current_user->ID );
150
+ }
151
+ }
152
+ }
153
+ $final_message = implode( '<br /><br />', array_filter( $message ) );
154
+ echo '<div id="message" class="updated fade"><p><strong>' . $final_message . '</strong></p></div>';
155
+ }
156
+ if ( 'toggle' === $this->current_action() ) {
157
+ global $mysubscribe2, $current_user, $subscribers;
158
+ $mysubscribe2->ip = $current_user->user_login;
159
+ foreach ( $_REQUEST['subscriber'] as $address ) {
160
+ $mysubscribe2->toggle( $address );
161
+ if ( 'confirmed' === $_POST['what'] || 'unconfirmed' === $_POST['what'] ) {
162
+ $key = array_search( $address, $subscribers );
163
+ unset( $subscribers[ $key ] );
164
+ }
165
+ }
166
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Status changed!', 'subscribe2' ) . '</strong></p></div>';
167
+ }
168
+ if ( 'subscribe' === $this->current_action() ) {
169
+ global $mysubscribe2;
170
+ $mysubscribe2->subscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['category'] );
171
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Registered Users Subscribed!', 'subscribe2' ) . '</strong></p></div>';
172
+ }
173
+ if ( 'unsubscribe' === $this->current_action() ) {
174
+ global $mysubscribe2;
175
+ $mysubscribe2->unsubscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['category'] );
176
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Registered Users Unsubscribed!', 'subscribe2' ) . '</strong></p></div>';
177
+ }
178
+ if ( 'format' === $this->current_action() ) {
179
+ global $mysubscribe2;
180
+ $mysubscribe2->format_change( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['format'] );
181
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Format updated for Selected Registered Users!', 'subscribe2' ) . '</strong></p></div>';
182
+ }
183
+ if ( 'digest' === $this->current_action() ) {
184
+ global $mysubscribe2;
185
+ $mysubscribe2->digest_change( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['sub_category'] );
186
+ echo '<div id="message" class="error"><p><strong>' . __( 'Digest Subscription updated for Selected Registered Users!', 'subscribe2' ) . '</strong></p></div>';
187
+ }
188
+ }
189
+
190
  function pagination( $which ) {
191
  if ( empty( $this->_pagination_args ) ) {
192
  return;
193
  }
194
 
195
+ $total_items = intval( $this->_pagination_args['total_items'] );
196
+ $total_pages = intval( $this->_pagination_args['total_pages'] );
197
  $infinite_scroll = false;
198
  if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
199
  $infinite_scroll = $this->_pagination_args['infinite_scroll'];
200
  }
201
 
202
+ if ( 'top' === $which && $total_pages > 1 ) {
203
+ $this->screen->render_screen_reader_content( 'heading_pagination' );
204
+ }
205
+
206
+ $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'subscribe2' ), number_format_i18n( $total_items ) ) . '</span>';
207
 
208
+ if ( isset( $_POST['what'] ) ) {
209
  $current = 1;
210
  } else {
211
+ $current = intval( $this->get_pagenum() );
212
  }
213
 
214
+ $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
 
 
 
 
215
 
216
+ $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
217
 
218
+ if ( isset( $what ) ) {
219
+ $current_url = add_query_arg( array(
220
+ 'what' => $what,
221
+ ), $current_url );
222
+ } elseif ( isset( $_REQUEST['what'] ) ) {
223
+ $current_url = add_query_arg( array(
224
+ 'what' => $_REQUEST['what'],
225
+ ), $current_url );
226
  }
227
 
228
+ if ( isset( $_POST['s'] ) ) {
229
+ $current_url = add_query_arg( array(
230
+ 's' => $_POST['s'],
231
+ ), $current_url );
232
  }
233
 
234
  $page_links = array();
235
 
236
+ $total_pages_before = '<span class="paging-input">';
237
+ $total_pages_after = '</span>';
238
+
239
+ $disable_first = $disable_last = $disable_prev = $disable_next = false;
240
+
241
+ if ( 1 === $current ) {
242
+ $disable_first = true;
243
+ $disable_prev = true;
244
  }
245
+ if ( 2 === $current ) {
246
+ $disable_first = true;
247
+ }
248
+ if ( $current === $total_pages ) {
249
+ $disable_last = true;
250
+ $disable_next = true;
251
+ }
252
+ if ( $current === $total_pages - 1 ) {
253
+ $disable_last = true;
254
  }
255
 
256
+ if ( $disable_first ) {
257
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
258
+ } else {
259
+ $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
260
+ esc_url( remove_query_arg( 'paged', $current_url ) ),
261
+ __( 'First page', 'subscribe2' ),
262
+ '&laquo;'
263
+ );
264
+ }
265
 
266
+ if ( $disable_prev ) {
267
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
268
+ } else {
269
+ $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
270
+ esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
271
+ __( 'Previous page', 'subscribe2' ),
272
+ '&lsaquo;'
273
+ );
274
+ }
275
 
276
+ if ( 'bottom' === $which ) {
277
+ $html_current_page = $current;
278
+ $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'subscribe2' ) . '</span><span id="table-paging" class="paging-input">';
279
  } else {
280
+ $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
281
+ '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'subscribe2' ) . '</label>',
282
  $current,
283
  strlen( $total_pages )
284
  );
285
  }
 
286
  $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
287
+ $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging', 'subscribe2' ), $html_current_page, $html_total_pages ) . $total_pages_after;
288
+
289
+ if ( $disable_next ) {
290
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
291
+ } else {
292
+ $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
293
+ esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
294
+ __( 'Next page', 'subscribe2' ),
295
+ '&rsaquo;'
296
+ );
297
+ }
298
+
299
+ if ( $disable_last ) {
300
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
301
+ } else {
302
+ $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
303
+ esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
304
+ __( 'Last page', 'subscribe2' ),
305
+ '&raquo;'
306
+ );
307
+ }
308
 
309
  $pagination_links_class = 'pagination-links';
310
  if ( ! empty( $infinite_scroll ) ) {
317
  } else {
318
  $page_class = ' no-pages';
319
  }
 
320
  $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
321
 
322
  echo $this->_pagination;
324
 
325
  function prepare_items() {
326
  global $mysubscribe2, $subscribers, $current_tab;
327
+ if ( is_int( $mysubscribe2->subscribe2_options['entries'] ) ) {
328
  $per_page = $mysubscribe2->subscribe2_options['entries'];
329
  } else {
330
  $per_page = 25;
333
  $columns = $this->get_columns();
334
  $hidden = array();
335
  $sortable = $this->get_sortable_columns();
336
+ $this->_column_headers = array( $columns, $hidden, $sortable );
337
+
338
+ $this->process_bulk_action();
339
 
340
  $data = array();
341
+ if ( 'public' === $current_tab ) {
342
+ foreach ( (array) $subscribers as $email ) {
343
+ $data[] = array(
344
+ 'email' => $email,
345
+ 'date' => $mysubscribe2->signup_date( $email ),
346
+ );
347
  }
348
  } else {
349
+ foreach ( (array) $subscribers as $subscriber ) {
350
+ $data[] = array(
351
+ 'email' => $subscriber['user_email'],
352
+ 'id' => $subscriber['ID'],
353
+ );
354
  }
355
  }
356
 
357
+ function usort_reorder( $a, $b ) {
358
+ $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'email';
359
+ $order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
360
+ $result = strcasecmp( $a[ $orderby ], $b[ $orderby ] );
361
+ return ( 'asc' === $order ) ? $result : -$result;
362
  }
363
+ usort( $data, 'usort_reorder' );
364
 
365
+ if ( isset( $_POST['what'] ) ) {
366
  $current_page = 1;
367
  } else {
368
  $current_page = $this->get_pagenum();
369
  }
370
+ $total_items = count( $data );
371
+ $data = array_slice( $data,( ($current_page -1 ) * $per_page ), $per_page );
372
  $this->items = $data;
373
 
374
  $this->set_pagination_args( array(
375
  'total_items' => $total_items,
376
  'per_page' => $per_page,
377
+ 'total_pages' => ceil( $total_items / $per_page ),
378
  ) );
379
  }
380
  }
classes/class-s2-multisite.php CHANGED
@@ -1,87 +1,87 @@
1
  <?php
2
- class s2_multisite {
3
- /* === WP Multisite specific functions === */
4
  /**
5
  Handles subscriptions and unsubscriptions for different blogs on WPMU installs
6
  */
7
  function wpmu_subscribe() {
8
  global $mysubscribe2;
9
  // subscribe to new blog
10
- if ( !empty($_GET['s2mu_subscribe']) ) {
11
- $sub_id = intval($_GET['s2mu_subscribe']);
12
  if ( $sub_id >= 0 ) {
13
- switch_to_blog($sub_id);
14
 
15
  $user_ID = get_current_user_id();
16
 
17
  // if user is not a user of the current blog
18
- if ( !is_user_member_of_blog($user_ID, $sub_id) ) {
19
  // add user to current blog as subscriber
20
- add_user_to_blog($sub_id, $user_ID, 'subscriber');
21
  // add an action hook for external manipulation of blog and user data
22
- do_action_ref_array('subscribe2_wpmu_subscribe', array($user_ID, $sub_id));
23
  }
24
 
25
  // get categories, remove excluded ones if override is off
26
- if ( 0 == $mysubscribe2->subscribe2_options['reg_override'] ) {
27
- $all_cats = $mysubscribe2->all_cats(true, 'ID');
28
  } else {
29
- $all_cats = $mysubscribe2->all_cats(false, 'ID');
30
  }
31
 
32
  $cats_string = '';
33
  foreach ( $all_cats as $cat ) {
34
- ('' == $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
35
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
36
  }
37
- if ( empty($cats_string) ) {
38
- delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'));
39
  } else {
40
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), $cats_string);
41
  }
42
  }
43
- } elseif ( !empty($_GET['s2mu_unsubscribe']) ) {
44
  // unsubscribe from a blog
45
- $unsub_id = intval($_GET['s2mu_unsubscribe']);
46
  if ( $unsub_id >= 0 ) {
47
- switch_to_blog($unsub_id);
48
 
49
  $user_ID = get_current_user_id();
50
 
51
  // delete subscription to all categories on that blog
52
- $cats = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true);
53
- $cats = explode(',', $cats);
54
- if ( !is_array($cats) ) {
55
- $cats = array($cats);
56
  }
57
 
58
  foreach ( $cats as $id ) {
59
- delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_cat') . $id);
60
  }
61
- delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'));
62
 
63
  // add an action hook for external manipulation of blog and user data
64
- do_action_ref_array('subscribe2_wpmu_unsubscribe', array($user_ID, $unsub_id));
65
 
66
  restore_current_blog();
67
  }
68
  }
69
 
70
- if ( !is_user_member_of_blog($user_ID) ) {
71
- $user_blogs = get_active_blog_for_user($user_ID);
72
- if ( is_array($user_blogs) ) {
73
- switch_to_blog(key($user_blogs));
74
  } else {
75
  // no longer a member of a blog
76
- wp_redirect(get_option('siteurl')); // redirect to front page
77
- exit(0);
78
  }
79
  }
80
 
81
  // redirect to profile page
82
- $url = get_option('siteurl') . '/wp-admin/admin.php?page=s2';
83
- wp_redirect($url);
84
- exit(0);
85
  } // end wpmu_subscribe()
86
 
87
  /**
@@ -90,49 +90,49 @@ class s2_multisite {
90
  */
91
  function get_mu_blog_list() {
92
  global $wpdb;
93
- $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 );
94
 
95
  foreach ( $blogs as $details ) {
96
  //reindex the array so the key is the same as the blog_id
97
- $blog_list[$details['blog_id']] = $details;
98
  }
99
 
100
- if ( !is_array($blog_list) ) {
101
  return array();
102
  }
103
 
104
- return apply_filters('s2_mu_blog_list', $blog_list);
105
  } // end get_mu_blog_list()
106
 
107
  /**
108
  Register user details when new user is added to a multisite blog
109
  */
110
- function wpmu_add_user($user_ID = 0) {
111
  global $mysubscribe2;
112
- if ( 0 == $user_ID ) { return; }
113
- if ( 'yes' == $mysubscribe2->subscribe2_options['autosub'] ) {
114
- $mysubscribe2->register($user_ID, true);
115
  } else {
116
- $mysubscribe2->register($user_ID, false);
117
  }
118
  } // end wpmu_add_user()
119
 
120
  /**
121
  Delete user details when a user is removed from a multisite blog
122
  */
123
- function wpmu_remove_user($user_ID) {
124
  global $mysubscribe2;
125
- if ( 0 == $user_ID ) { return; }
126
- delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_format'));
127
- delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_autosub'));
128
- $cats = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true);
129
- if ( !empty($cats) ) {
130
- $cats = explode(',', $cats);
131
  foreach ( $cats as $cat ) {
132
- delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_cat') . $cat);
133
  }
134
  }
135
- delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'));
136
  } // end wpmu_remove_user()
137
 
138
  /**
@@ -140,25 +140,25 @@ class s2_multisite {
140
  */
141
  function namechange_subscribe2_widget() {
142
  global $wpdb;
143
- $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
144
 
145
  foreach ( $blogs as $blog ) {
146
- switch_to_blog($blog);
147
 
148
- $sidebars = get_option('sidebars_widgets');
149
- if ( empty($sidebars) || !is_array($sidebars) ) { return; }
150
  $changed = false;
151
- foreach ( $sidebars as $s =>$sidebar ) {
152
- if ( empty($sidebar) || !is_array($sidebar) ) { break; }
153
  foreach ( $sidebar as $w => $widget ) {
154
- if ( $widget == 'subscribe2widget' ) {
155
- $sidebars[$s][$w] = 'subscribe2';
156
  $changed = true;
157
  }
158
  }
159
  }
160
  if ( $changed ) {
161
- update_option('sidebar_widgets', $sidebars);
162
  }
163
  restore_current_blog();
164
  }
1
  <?php
2
+ class S2_Multisite {
3
+ /* === WP Multisite specific functions === */
4
  /**
5
  Handles subscriptions and unsubscriptions for different blogs on WPMU installs
6
  */
7
  function wpmu_subscribe() {
8
  global $mysubscribe2;
9
  // subscribe to new blog
10
+ if ( ! empty( $_GET['s2mu_subscribe'] ) ) {
11
+ $sub_id = intval( $_GET['s2mu_subscribe'] );
12
  if ( $sub_id >= 0 ) {
13
+ switch_to_blog( $sub_id );
14
 
15
  $user_ID = get_current_user_id();
16
 
17
  // if user is not a user of the current blog
18
+ if ( ! is_user_member_of_blog( $user_ID, $sub_id ) ) {
19
  // add user to current blog as subscriber
20
+ add_user_to_blog( $sub_id, $user_ID, 'subscriber' );
21
  // add an action hook for external manipulation of blog and user data
22
+ do_action_ref_array( 'subscribe2_wpmu_subscribe', array( $user_ID, $sub_id ) );
23
  }
24
 
25
  // get categories, remove excluded ones if override is off
26
+ if ( 0 === $mysubscribe2->subscribe2_options['reg_override'] ) {
27
+ $all_cats = $mysubscribe2->all_cats( true, 'ID' );
28
  } else {
29
+ $all_cats = $mysubscribe2->all_cats( false, 'ID' );
30
  }
31
 
32
  $cats_string = '';
33
  foreach ( $all_cats as $cat ) {
34
+ ('' === $cats_string) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
35
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat->term_id, $cat->term_id );
36
  }
37
+ if ( empty( $cats_string ) ) {
38
+ delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ) );
39
  } else {
40
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats_string );
41
  }
42
  }
43
+ } elseif ( ! empty( $_GET['s2mu_unsubscribe'] ) ) {
44
  // unsubscribe from a blog
45
+ $unsub_id = intval( $_GET['s2mu_unsubscribe'] );
46
  if ( $unsub_id >= 0 ) {
47
+ switch_to_blog( $unsub_id );
48
 
49
  $user_ID = get_current_user_id();
50
 
51
  // delete subscription to all categories on that blog
52
+ $cats = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
53
+ $cats = explode( ',', $cats );
54
+ if ( ! is_array( $cats ) ) {
55
+ $cats = array( $cats );
56
  }
57
 
58
  foreach ( $cats as $id ) {
59
+ delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $id );
60
  }
61
+ delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ) );
62
 
63
  // add an action hook for external manipulation of blog and user data
64
+ do_action_ref_array( 'subscribe2_wpmu_unsubscribe', array( $user_ID, $unsub_id ) );
65
 
66
  restore_current_blog();
67
  }
68
  }
69
 
70
+ if ( ! is_user_member_of_blog( $user_ID ) ) {
71
+ $user_blogs = get_active_blog_for_user( $user_ID );
72
+ if ( is_array( $user_blogs ) ) {
73
+ switch_to_blog( key( $user_blogs ) );
74
  } else {
75
  // no longer a member of a blog
76
+ wp_redirect( get_option( 'siteurl' ) ); // redirect to front page
77
+ exit( 0 );
78
  }
79
  }
80
 
81
  // redirect to profile page
82
+ $url = get_option( 'siteurl' ) . '/wp-admin/admin.php?page=s2';
83
+ wp_redirect( $url );
84
+ exit( 0 );
85
  } // end wpmu_subscribe()
86
 
87
  /**
90
  */
91
  function get_mu_blog_list() {
92
  global $wpdb;
93
+ $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 );
94
 
95
  foreach ( $blogs as $details ) {
96
  //reindex the array so the key is the same as the blog_id
97
+ $blog_list[ $details['blog_id'] ] = $details;
98
  }
99
 
100
+ if ( ! is_array( $blog_list ) ) {
101
  return array();
102
  }
103
 
104
+ return apply_filters( 's2_mu_blog_list', $blog_list );
105
  } // end get_mu_blog_list()
106
 
107
  /**
108
  Register user details when new user is added to a multisite blog
109
  */
110
+ function wpmu_add_user( $user_ID = 0 ) {
111
  global $mysubscribe2;
112
+ if ( 0 === $user_ID ) { return; }
113
+ if ( 'yes' === $mysubscribe2->subscribe2_options['autosub'] ) {
114
+ $mysubscribe2->register( $user_ID, true );
115
  } else {
116
+ $mysubscribe2->register( $user_ID, false );
117
  }
118
  } // end wpmu_add_user()
119
 
120
  /**
121
  Delete user details when a user is removed from a multisite blog
122
  */
123
+ function wpmu_remove_user( $user_ID ) {
124
  global $mysubscribe2;
125
+ if ( 0 === $user_ID ) { return; }
126
+ delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ) );
127
+ delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ) );
128
+ $cats = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
129
+ if ( ! empty( $cats ) ) {
130
+ $cats = explode( ',', $cats );
131
  foreach ( $cats as $cat ) {
132
+ delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat );
133
  }
134
  }
135
+ delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ) );
136
  } // end wpmu_remove_user()
137
 
138
  /**
140
  */
141
  function namechange_subscribe2_widget() {
142
  global $wpdb;
143
+ $blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
144
 
145
  foreach ( $blogs as $blog ) {
146
+ switch_to_blog( $blog );
147
 
148
+ $sidebars = get_option( 'sidebars_widgets' );
149
+ if ( empty( $sidebars ) || ! is_array( $sidebars ) ) { return; }
150
  $changed = false;
151
+ foreach ( $sidebars as $s => $sidebar ) {
152
+ if ( empty( $sidebar ) || ! is_array( $sidebar ) ) { break; }
153
  foreach ( $sidebar as $w => $widget ) {
154
+ if ( 'subscribe2widget' === $widget ) {
155
+ $sidebars[ $s ][ $w ] = 'subscribe2';
156
  $changed = true;
157
  }
158
  }
159
  }
160
  if ( $changed ) {
161
+ update_option( 'sidebar_widgets', $sidebars );
162
  }
163
  restore_current_blog();
164
  }
classes/class-s2-upgrade.php CHANGED
@@ -1,28 +1,115 @@
1
  <?php
2
- class s2class_upgrade {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function upgrade_core() {
4
  // let's take the time to double check data for registered users
5
  global $mysubscribe2;
6
- if ( version_compare($mysubscribe2->wp_release, '3.5', '<') ) {
7
  global $wpdb;
8
- $users = $wpdb->get_col($wpdb->prepare("SELECT ID from $wpdb->users WHERE ID NOT IN (SELECT user_id FROM $wpdb->usermeta WHERE meta_key=%s)", $mysubscribe2->get_usermeta_keyname('s2_format')));
9
- if ( !empty($users) ) {
10
- foreach ($users as $user_ID) {
11
- $mysubscribe2->register($user_ID);
12
  }
13
  }
14
  } else {
15
  $args = array(
16
  'meta_query' => array(
17
- array('key' => $mysubscribe2->get_usermeta_keyname('s2_format'), 'compare' => 'NOT EXISTS')
18
- )
 
 
 
19
  );
20
 
21
  $user_query = new WP_User_Query( $args );
22
  $users = $user_query->get_results();
23
- if ( !empty($users) ) {
24
- foreach ($users as $user) {
25
- $mysubscribe2->register($user->ID);
26
  }
27
  }
28
  }
@@ -34,21 +121,21 @@ class s2class_upgrade {
34
  global $mysubscribe2, $wpdb;
35
 
36
  // include upgrade-functions for maybe_add_column;
37
- if ( !function_exists('maybe_add_column') ) {
38
- require_once(ABSPATH . 'wp-admin/install-helper.php');
39
  }
40
- $date = date('Y-m-d');
41
- maybe_add_column($mysubscribe2->public, 'date', "ALTER TABLE $mysubscribe2->public ADD date DATE DEFAULT '$date' NOT NULL AFTER active");
42
 
43
  // update the options table to serialized format
44
- $old_options = $wpdb->get_col("SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name != 's2_future_posts'");
45
 
46
- if ( !empty($old_options) ) {
47
  foreach ( $old_options as $option ) {
48
- $value = get_option($option);
49
- $option_array = substr($option, 3);
50
- $mysubscribe2->subscribe2_options[$option_array] = $value;
51
- delete_option($option);
52
  }
53
  }
54
  } // end upgrade23()
@@ -57,19 +144,19 @@ class s2class_upgrade {
57
  global $mysubscribe2;
58
 
59
  // include upgrade-functions for maybe_add_column;
60
- if ( !function_exists('maybe_add_column') ) {
61
- require_once(ABSPATH . 'wp-admin/install-helper.php');
62
  }
63
- maybe_add_column($mysubscribe2->public, 'ip', "ALTER TABLE $mysubscribe2->public ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date");
64
  } // end upgrade51()
65
 
66
- function upgrade56(){
67
  global $mysubscribe2;
68
  // correct autoformat to upgrade from pre 5.6
69
- if ( $mysubscribe2->subscribe2_options['autoformat'] == 'text' ) {
70
  $mysubscribe2->subscribe2_options['autoformat'] = 'excerpt';
71
  }
72
- if ( $mysubscribe2->subscribe2_options['autoformat'] == 'full' ) {
73
  $mysubscribe2->subscribe2_options['autoformat'] = 'post';
74
  }
75
  } // end upgrade56()
@@ -78,13 +165,13 @@ class s2class_upgrade {
78
  global $mysubscribe2, $wpdb;
79
  // ensure existing public subscriber emails are all sanitized
80
  $confirmed = $mysubscribe2->get_public();
81
- $unconfirmed = $mysubscribe2->get_public(0);
82
- $public_subscribers = array_merge((array)$confirmed, (array)$unconfirmed);
83
 
84
  foreach ( $public_subscribers as $email ) {
85
- $new_email = $mysubscribe2->sanitize_email($email);
86
  if ( $email !== $new_email ) {
87
- $wpdb->get_results($wpdb->prepare("UPDATE $mysubscribe2->public SET email=%s WHERE CAST(email as binary)=%s", $new_email, $email));
88
  }
89
  }
90
  } // end upgrade59()
@@ -92,146 +179,156 @@ class s2class_upgrade {
92
  function upgrade64() {
93
  global $mysubscribe2;
94
  // change old CAPITALISED keywords to those in {PARENTHESES}; since version 6.4
95
- $keywords = array('BLOGNAME', 'BLOGLINK', 'TITLE', 'POST', 'POSTTIME', 'TABLE', 'TABLELINKS', 'PERMALINK', 'TINYLINK', 'DATE', 'TIME', 'MYNAME', 'EMAIL', 'AUTHORNAME', 'LINK', 'CATS', 'TAGS', 'COUNT', 'ACTION');
96
- $keyword = implode('|', $keywords);
97
- $regex = '/(?<!\{)\b('.$keyword.')\b(?!\{)/xm';
98
  $replace = '{\1}';
99
- $mysubscribe2->subscribe2_options['mailtext'] = preg_replace($regex, $replace, $mysubscribe2->subscribe2_options['mailtext']);
100
- $mysubscribe2->subscribe2_options['notification_subject'] = preg_replace($regex, $replace, $mysubscribe2->subscribe2_options['notification_subject']);
101
- $mysubscribe2->subscribe2_options['confirm_email'] = preg_replace($regex, $replace, $mysubscribe2->subscribe2_options['confirm_email']);
102
- $mysubscribe2->subscribe2_options['confirm_subject'] = preg_replace($regex, $replace, $mysubscribe2->subscribe2_options['confirm_subject']);
103
- $mysubscribe2->subscribe2_options['remind_email'] = preg_replace($regex, $replace, $mysubscribe2->subscribe2_options['remind_email']);
104
- $mysubscribe2->subscribe2_options['remind_subject'] = preg_replace($regex, $replace, $mysubscribe2->subscribe2_options['remind_subject']);
105
-
106
- if ( version_compare($mysubscribe2->wp_release, '3.5', '<') ) {
107
- $users = $mysubscribe2->get_all_registered('ID');
108
  foreach ( $users as $user_ID ) {
109
- $check_format = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_format'), true);
110
  // if user is already registered update format remove 's2_excerpt' field and update 's2_format'
111
- if ( 'html' == $check_format ) {
112
- delete_user_meta($user_ID, 's2_excerpt');
113
- } elseif ( 'text' == $check_format ) {
114
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_format'), get_user_meta($user_ID, 's2_excerpt'));
115
- delete_user_meta($user_ID, 's2_excerpt');
116
  }
117
- $subscribed = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true);
118
- if ( strstr($subscribed, '-1') ) {
119
  // make sure we remove '-1' from any settings
120
- $old_cats = explode(',', $subscribed);
121
- $pos = array_search('-1', $old_cats);
122
- unset($old_cats[$pos]);
123
- $cats = implode(',', $old_cats);
124
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), $cats);
125
  }
126
  }
127
  } else {
128
  $args = array(
129
  'relation' => 'AND',
130
  'meta_query' => array(
131
- array('key' => $mysubscribe2->get_usermeta_keyname('s2_format'),
132
- 'value' => 'html')
 
 
133
  ),
134
  'meta_query' => array(
135
- array('key' => 's2_excerpt',
136
- 'compare' => 'EXISTS')
137
- )
 
 
138
  );
139
 
140
  $user_query = new WP_User_Query( $args );
141
  $users = $user_query->get_results();
142
- if ( !empty($users) ) {
143
- foreach ($users as $user) {
144
- delete_user_meta($user->ID, 's2_excerpt');
145
  }
146
  }
147
 
148
  $args = array(
149
  'relation' => 'AND',
150
  'meta_query' => array(
151
- array('key' => $mysubscribe2->get_usermeta_keyname('s2_format'),
152
- 'value' => 'text')
 
 
153
  ),
154
  'meta_query' => array(
155
- array('key' => 's2_excerpt',
156
- 'compare' => 'EXISTS')
157
- )
 
 
158
  );
159
 
160
  $user_query = new WP_User_Query( $args );
161
  $users = $user_query->get_results();
162
- if ( !empty($users) ) {
163
- foreach ($users as $user) {
164
- update_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_format'), get_user_meta($user->ID, 's2_excerpt'));
165
- delete_user_meta($user->ID, 's2_excerpt');
166
  }
167
  }
168
 
169
  $args = array(
170
  'meta_query' => array(
171
- array('key' => $mysubscribe2->get_usermeta_keyname('s2_subscribed'),
172
- 'value' => '-1',
173
- 'compare' => 'LIKE')
174
- )
 
 
175
  );
176
 
177
  $user_query = new WP_User_Query( $args );
178
  $users = $user_query->get_results();
179
- if ( !empty($users) ) {
180
- foreach ($users as $user) {
181
- $subscribed = get_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true);
182
- $old_cats = explode(',', $subscribed);
183
- $pos = array_search('-1', $old_cats);
184
- unset($old_cats[$pos]);
185
- $cats = implode(',', $old_cats);
186
- update_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), $cats);
187
  }
188
  }
189
  }
190
 
191
  // upgrade old wpmu user meta data to new
192
- if ( $mysubscribe2->s2_mu === true ) {
193
  global $s2class_multisite, $wpdb;
194
  $s2class_multisite->namechange_subscribe2_widget();
195
  // loop through all users
196
  foreach ( $users as $user_ID ) {
197
  // get categories which the user is subscribed to (old ones)
198
- $categories = get_user_meta($user_ID, 's2_subscribed', true);
199
- $categories = explode(',', $categories);
200
- $format = get_user_meta($user_ID, 's2_format', true);
201
- $autosub = get_user_meta($user_ID, 's2_autosub', true);
202
 
203
  // load blogs of user (only if we need them)
204
  $blogs = array();
205
- if ( count($categories) > 0 && !in_array('-1', $categories) ) {
206
- $blogs = get_blogs_of_user($user_ID, true);
207
  }
208
 
209
  foreach ( $blogs as $blog ) {
210
- switch_to_blog($blog->userblog_id);
211
 
212
- $blog_categories = (array)$wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category'");
213
- $subscribed_categories = array_intersect($categories, $blog_categories);
214
- if ( !empty($subscribed_categories) ) {
215
  foreach ( $subscribed_categories as $subscribed_category ) {
216
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category);
217
  }
218
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories));
219
  }
220
- if ( !empty($format) ) {
221
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_format'), $format);
222
  }
223
- if ( !empty($autosub) ) {
224
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_autosub'), $autosub);
225
  }
226
  restore_current_blog();
227
  }
228
 
229
  // delete old user meta keys
230
- delete_user_meta($user_ID, 's2_subscribed');
231
- delete_user_meta($user_ID, 's2_format');
232
- delete_user_meta($user_ID, 's2_autosub');
233
  foreach ( $categories as $cat ) {
234
- delete_user_meta($user_ID, 's2_cat' . $cat);
235
  }
236
  }
237
  }
@@ -239,26 +336,29 @@ class s2class_upgrade {
239
 
240
  function upgrade70() {
241
  global $mysubscribe2, $wpdb;
242
- if ( version_compare($mysubscribe2->wp_release, '3.5', '<') ) {
243
- $users = $wpdb->get_col($wpdb->prepare("SELECT ID from $wpdb->users WHERE ID NOT IN (SELECT user_id from $wpdb->usermeta WHERE meta_key=%s", $mysubscribe2->get_usermeta_keyname('s2_authors')));
244
  foreach ( $users as $user_ID ) {
245
- $check_authors = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_authors'), true);
246
- if ( empty($check_authors) ) {
247
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_authors'), '');
248
  }
249
  }
250
  } else {
251
  $args = array(
252
  'meta_query' => array(
253
- array('key' => $mysubscribe2->get_usermeta_keyname('s2_authors'), 'compare' => 'NOT EXISTS')
254
- )
 
 
 
255
  );
256
 
257
  $user_query = new WP_User_Query( $args );
258
  $users = $user_query->get_results();
259
- if ( !empty($users) ) {
260
- foreach ($users as $user) {
261
- update_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_authors'), '');
262
  }
263
  }
264
  }
@@ -268,10 +368,10 @@ class s2class_upgrade {
268
  global $mysubscribe2, $wpdb;
269
 
270
  // include upgrade-functions for maybe_add_column;
271
- if ( !function_exists('maybe_add_column') ) {
272
- require_once(ABSPATH . 'wp-admin/install-helper.php');
273
  }
274
- maybe_add_column($mysubscribe2->public, 'time', "ALTER TABLE $mysubscribe2->public ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date");
275
 
276
  // update postmeta field to a protected name, from version 8.5
277
  $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_s2mail' WHERE meta_key = 's2mail'" );
@@ -281,25 +381,25 @@ class s2class_upgrade {
281
  global $mysubscribe2, $wpdb;
282
 
283
  // include upgrade-functions for maybe_add_column;
284
- if ( !function_exists('maybe_add_column') ) {
285
- require_once(ABSPATH . 'wp-admin/install-helper.php');
286
  }
287
- maybe_add_column($mysubscribe2->public, 'conf_date', "ALTER TABLE $mysubscribe2->public ADD conf_date DATE AFTER ip");
288
- maybe_add_column($mysubscribe2->public, 'conf_time', "ALTER TABLE $mysubscribe2->public ADD conf_time TIME AFTER conf_date");
289
- maybe_add_column($mysubscribe2->public, 'conf_ip', "ALTER TABLE $mysubscribe2->public ADD conf_ip char(64) AFTER conf_time");
290
 
291
  // remove unnecessary table data
292
  $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 's2_cat'" );
293
 
294
- $sql = "SELECT ID FROM $wpdb->users INNER JOIN $wpdb->usermeta ON ( $wpdb->users.ID = $wpdb->usermeta.user_id) WHERE ( $wpdb->usermeta.meta_key = '" . $mysubscribe2->get_usermeta_keyname('s2_subscribed') . "' AND $wpdb->usermeta.meta_value LIKE ',%' )";
295
- $users = $wpdb->get_results($sql);
296
  foreach ( $users as $user ) {
297
  // make sure we remove leading ',' from this setting
298
- $subscribed = get_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true);
299
- $old_cats = explode(',', $subscribed);
300
- unset($old_cats[0]);
301
- $cats = implode(',', $old_cats);
302
- update_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), $cats);
303
  }
304
  } // end upgrade86()
305
 
@@ -307,46 +407,66 @@ class s2class_upgrade {
307
  // to ensure compulsory category collects all users we need there to be s2_subscribed meta-keys for all users
308
  global $mysubscribe2;
309
 
310
- if ( version_compare($mysubscribe2->wp_release, '3.5', '<') ) {
311
- $all_registered = $mysubscribe2->get_all_registered('ID');
312
- if ( !empty($all_registered) ) {
313
  foreach ( $all_registered as $user_ID ) {
314
- $check_subscribed = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true);
315
- if ( empty($check_subscribed) ) {
316
- update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), '');
317
  }
318
  }
319
  }
320
  } else {
321
  $args = array(
322
  'meta_query' => array(
323
- array('key' => $mysubscribe2->get_usermeta_keyname('s2_subscribed'), 'compare' => 'NOT EXISTS')
324
- )
 
 
 
325
  );
326
 
327
  $user_query = new WP_User_Query( $args );
328
  $users = $user_query->get_results();
329
- if ( !empty($users) ) {
330
- foreach ($users as $user) {
331
- update_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), '');
332
  }
333
  }
334
  }
335
 
336
  // check the time column again as the upgrade86() function contained a bug
337
  // include upgrade-functions for maybe_add_column;
338
- if ( !function_exists('maybe_add_column') ) {
339
- require_once(ABSPATH . 'wp-admin/install-helper.php');
340
  }
341
- maybe_add_column($mysubscribe2->public, 'time', "ALTER TABLE $mysubscribe2->public ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date");
342
  } // end upgrade88()
343
 
344
  function upgrade95() {
345
  global $mysubscribe2;
346
- if ( $mysubscribe2->subscribe2_options['email_freq'] != 'never' ) {
347
  $mysubscribe2->subscribe2_options['last_s2cron'] = '';
348
- unset($mysubscribe2->subscribe2_options['previous_s2cron']);
349
  }
350
  } // end upgrade95()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  }
352
  ?>
1
  <?php
2
+ class S2_Upgrade {
3
+ /**
4
+ Core upgrade function for the database and settings
5
+ */
6
+ function upgrade() {
7
+ global $mysubscribe2;
8
+ // load our translations and strings
9
+ $mysubscribe2->load_translations();
10
+
11
+ // ensure that the options are in the database
12
+ require( S2PATH . 'include/options.php' );
13
+ // catch older versions that didn't use serialised options
14
+ if ( ! isset( $mysubscribe2->subscribe2_options['version'] ) ) {
15
+ $mysubscribe2->subscribe2_options['version'] = '2.0';
16
+ }
17
+
18
+ // let's take the time to ensure that database entries exist for all registered users
19
+ $this->upgrade_core();
20
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '2.3', '<' ) ) {
21
+ $this->upgrade23();
22
+ $mysubscribe2->subscribe2_options['version'] = '2.3';
23
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
24
+ }
25
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '5.1', '<' ) ) {
26
+ $this->upgrade51();
27
+ $mysubscribe2->subscribe2_options['version'] = '5.1';
28
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
29
+ }
30
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '5.6', '<' ) ) {
31
+ $this->upgrade56();
32
+ $mysubscribe2->subscribe2_options['version'] = '5.6';
33
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
34
+ }
35
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '5.9', '<' ) ) {
36
+ $this->upgrade59();
37
+ $mysubscribe2->subscribe2_options['version'] = '5.9';
38
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
39
+ }
40
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '6.4', '<' ) ) {
41
+ $this->upgrade64();
42
+ $mysubscribe2->subscribe2_options['version'] = '6.4';
43
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
44
+ }
45
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '7.0', '<' ) ) {
46
+ $this->upgrade70();
47
+ $mysubscribe2->subscribe2_options['version'] = '7.0';
48
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
49
+ }
50
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '8.5', '<' ) ) {
51
+ $this->upgrade85();
52
+ $mysubscribe2->subscribe2_options['version'] = '8.5';
53
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
54
+ }
55
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '8.6', '<' ) ) {
56
+ $this->upgrade86();
57
+ $mysubscribe2->subscribe2_options['version'] = '8.6';
58
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
59
+ }
60
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '8.8', '<' ) ) {
61
+ $this->upgrade88();
62
+ $mysubscribe2->subscribe2_options['version'] = '8.8';
63
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
64
+ }
65
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '9.5', '<' ) ) {
66
+ $this->upgrade95();
67
+ $mysubscribe2->subscribe2_options['version'] = '9.5';
68
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
69
+ }
70
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '10.14', '<' ) ) {
71
+ $this->upgrade1014();
72
+ $mysubscribe2->subscribe2_options['version'] = '10.14';
73
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
74
+ }
75
+ if ( version_compare( $mysubscribe2->subscribe2_options['version'], '10.15', '<' ) ) {
76
+ $this->upgrade1015();
77
+ $mysubscribe2->subscribe2_options['version'] = '10.15';
78
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
79
+ }
80
+
81
+ $mysubscribe2->subscribe2_options['version'] = S2VERSION;
82
+ update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
83
+
84
+ return;
85
+ } // end upgrade()
86
+
87
  function upgrade_core() {
88
  // let's take the time to double check data for registered users
89
  global $mysubscribe2;
90
+ if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
91
  global $wpdb;
92
+ $users = $wpdb->get_col( $wpdb->prepare( "SELECT ID from $wpdb->users WHERE ID NOT IN (SELECT user_id FROM $wpdb->usermeta WHERE meta_key=%s)", $mysubscribe2->get_usermeta_keyname( 's2_format' ) ) );
93
+ if ( ! empty( $users ) ) {
94
+ foreach ( $users as $user_ID ) {
95
+ $mysubscribe2->register( $user_ID );
96
  }
97
  }
98
  } else {
99
  $args = array(
100
  'meta_query' => array(
101
+ array(
102
+ 'key' => $mysubscribe2->get_usermeta_keyname( 's2_format' ),
103
+ 'compare' => 'NOT EXISTS',
104
+ ),
105
+ ),
106
  );
107
 
108
  $user_query = new WP_User_Query( $args );
109
  $users = $user_query->get_results();
110
+ if ( ! empty( $users ) ) {
111
+ foreach ( $users as $user ) {
112
+ $mysubscribe2->register( $user->ID );
113
  }
114
  }
115
  }
121
  global $mysubscribe2, $wpdb;
122
 
123
  // include upgrade-functions for maybe_add_column;
124
+ if ( ! function_exists( 'maybe_add_column' ) ) {
125
+ require_once( ABSPATH . 'wp-admin/install-helper.php' );
126
  }
127
+ $date = date( 'Y-m-d' );
128
+ maybe_add_column( $mysubscribe2->public, 'date', "ALTER TABLE $mysubscribe2->public ADD date DATE DEFAULT '$date' NOT NULL AFTER active" );
129
 
130
  // update the options table to serialized format
131
+ $old_options = $wpdb->get_col( "SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name !== 's2_future_posts'" );
132
 
133
+ if ( ! empty( $old_options ) ) {
134
  foreach ( $old_options as $option ) {
135
+ $value = get_option( $option );
136
+ $option_array = substr( $option, 3 );
137
+ $mysubscribe2->subscribe2_options[ $option_array ] = $value;
138
+ delete_option( $option );
139
  }
140
  }
141
  } // end upgrade23()
144
  global $mysubscribe2;
145
 
146
  // include upgrade-functions for maybe_add_column;
147
+ if ( ! function_exists( 'maybe_add_column' ) ) {
148
+ require_once( ABSPATH . 'wp-admin/install-helper.php' );
149
  }
150
+ maybe_add_column( $mysubscribe2->public, 'ip', "ALTER TABLE $mysubscribe2->public ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date" );
151
  } // end upgrade51()
152
 
153
+ function upgrade56() {
154
  global $mysubscribe2;
155
  // correct autoformat to upgrade from pre 5.6
156
+ if ( 'text' === $mysubscribe2->subscribe2_options['autoformat'] ) {
157
  $mysubscribe2->subscribe2_options['autoformat'] = 'excerpt';
158
  }
159
+ if ( 'full' === $mysubscribe2->subscribe2_options['autoformat'] ) {
160
  $mysubscribe2->subscribe2_options['autoformat'] = 'post';
161
  }
162
  } // end upgrade56()
165
  global $mysubscribe2, $wpdb;
166
  // ensure existing public subscriber emails are all sanitized
167
  $confirmed = $mysubscribe2->get_public();
168
+ $unconfirmed = $mysubscribe2->get_public( 0 );
169
+ $public_subscribers = array_merge( (array) $confirmed, (array) $unconfirmed );
170
 
171
  foreach ( $public_subscribers as $email ) {
172
+ $new_email = $mysubscribe2->sanitize_email( $email );
173
  if ( $email !== $new_email ) {
174
+ $wpdb->get_results( $wpdb->prepare( "UPDATE $mysubscribe2->public SET email=%s WHERE CAST(email as binary)=%s", $new_email, $email ) );
175
  }
176
  }
177
  } // end upgrade59()
179
  function upgrade64() {
180
  global $mysubscribe2;
181
  // change old CAPITALISED keywords to those in {PARENTHESES}; since version 6.4
182
+ $keywords = array( 'BLOGNAME', 'BLOGLINK', 'TITLE', 'POST', 'POSTTIME', 'TABLE', 'TABLELINKS', 'PERMALINK', 'TINYLINK', 'DATE', 'TIME', 'MYNAME', 'EMAIL', 'AUTHORNAME', 'LINK', 'CATS', 'TAGS', 'COUNT', 'ACTION' );
183
+ $keyword = implode( '|', $keywords );
184
+ $regex = '/(?<!\{)\b(' . $keyword . ')\b(?!\{)/xm';
185
  $replace = '{\1}';
186
+ $mysubscribe2->subscribe2_options['mailtext'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['mailtext'] );
187
+ $mysubscribe2->subscribe2_options['notification_subject'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['notification_subject'] );
188
+ $mysubscribe2->subscribe2_options['confirm_email'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['confirm_email'] );
189
+ $mysubscribe2->subscribe2_options['confirm_subject'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['confirm_subject'] );
190
+ $mysubscribe2->subscribe2_options['remind_email'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['remind_email'] );
191
+ $mysubscribe2->subscribe2_options['remind_subject'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['remind_subject'] );
192
+
193
+ if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
194
+ $users = $mysubscribe2->get_all_registered( 'ID' );
195
  foreach ( $users as $user_ID ) {
196
+ $check_format = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true );
197
  // if user is already registered update format remove 's2_excerpt' field and update 's2_format'
198
+ if ( 'html' === $check_format ) {
199
+ delete_user_meta( $user_ID, 's2_excerpt' );
200
+ } elseif ( 'text' === $check_format ) {
201
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), get_user_meta( $user_ID, 's2_excerpt' ) );
202
+ delete_user_meta( $user_ID, 's2_excerpt' );
203
  }
204
+ $subscribed = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
205
+ if ( strstr( $subscribed, '-1' ) ) {
206
  // make sure we remove '-1' from any settings
207
+ $old_cats = explode( ',', $subscribed );
208
+ $pos = array_search( '-1', $old_cats );
209
+ unset( $old_cats[ $pos ] );
210
+ $cats = implode( ',', $old_cats );
211
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
212
  }
213
  }
214
  } else {
215
  $args = array(
216
  'relation' => 'AND',
217
  'meta_query' => array(
218
+ array(
219
+ 'key' => $mysubscribe2->get_usermeta_keyname( 's2_format' ),
220
+ 'value' => 'html',
221
+ ),
222
  ),
223
  'meta_query' => array(
224
+ array(
225
+ 'key' => 's2_excerpt',
226
+ 'compare' => 'EXISTS',
227
+ ),
228
+ ),
229
  );
230
 
231
  $user_query = new WP_User_Query( $args );
232
  $users = $user_query->get_results();
233
+ if ( ! empty( $users ) ) {
234
+ foreach ( $users as $user ) {
235
+ delete_user_meta( $user->ID, 's2_excerpt' );
236
  }
237
  }
238
 
239
  $args = array(
240
  'relation' => 'AND',
241
  'meta_query' => array(
242
+ array(
243
+ 'key' => $mysubscribe2->get_usermeta_keyname( 's2_format' ),
244
+ 'value' => 'text',
245
+ ),
246
  ),
247
  'meta_query' => array(
248
+ array(
249
+ 'key' => 's2_excerpt',
250
+ 'compare' => 'EXISTS',
251
+ ),
252
+ ),
253
  );
254
 
255
  $user_query = new WP_User_Query( $args );
256
  $users = $user_query->get_results();
257
+ if ( ! empty( $users ) ) {
258
+ foreach ( $users as $user ) {
259
+ update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), get_user_meta( $user->ID, 's2_excerpt' ) );
260
+ delete_user_meta( $user->ID, 's2_excerpt' );
261
  }
262
  }
263
 
264
  $args = array(
265
  'meta_query' => array(
266
+ array(
267
+ 'key' => $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ),
268
+ 'value' => '-1',
269
+ 'compare' => 'LIKE',
270
+ ),
271
+ ),
272
  );
273
 
274
  $user_query = new WP_User_Query( $args );
275
  $users = $user_query->get_results();
276
+ if ( ! empty( $users ) ) {
277
+ foreach ( $users as $user ) {
278
+ $subscribed = get_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
279
+ $old_cats = explode( ',', $subscribed );
280
+ $pos = array_search( '-1', $old_cats );
281
+ unset( $old_cats[ $pos ] );
282
+ $cats = implode( ',', $old_cats );
283
+ update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
284
  }
285
  }
286
  }
287
 
288
  // upgrade old wpmu user meta data to new
289
+ if ( true === $mysubscribe2->s2_mu ) {
290
  global $s2class_multisite, $wpdb;
291
  $s2class_multisite->namechange_subscribe2_widget();
292
  // loop through all users
293
  foreach ( $users as $user_ID ) {
294
  // get categories which the user is subscribed to (old ones)
295
+ $categories = get_user_meta( $user_ID, 's2_subscribed', true );
296
+ $categories = explode( ',', $categories );
297
+ $format = get_user_meta( $user_ID, 's2_format', true );
298
+ $autosub = get_user_meta( $user_ID, 's2_autosub', true );
299
 
300
  // load blogs of user (only if we need them)
301
  $blogs = array();
302
+ if ( count( $categories ) > 0 && ! in_array( '-1', $categories ) ) {
303
+ $blogs = get_blogs_of_user( $user_ID, true );
304
  }
305
 
306
  foreach ( $blogs as $blog ) {
307
+ switch_to_blog( $blog->userblog_id );
308
 
309
+ $blog_categories = (array) $wpdb->get_col( "SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category'" );
310
+ $subscribed_categories = array_intersect( $categories, $blog_categories );
311
+ if ( ! empty( $subscribed_categories ) ) {
312
  foreach ( $subscribed_categories as $subscribed_category ) {
313
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $subscribed_category, $subscribed_category );
314
  }
315
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $subscribed_categories ) );
316
  }
317
+ if ( ! empty( $format ) ) {
318
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), $format );
319
  }
320
+ if ( ! empty( $autosub ) ) {
321
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), $autosub );
322
  }
323
  restore_current_blog();
324
  }
325
 
326
  // delete old user meta keys
327
+ delete_user_meta( $user_ID, 's2_subscribed' );
328
+ delete_user_meta( $user_ID, 's2_format' );
329
+ delete_user_meta( $user_ID, 's2_autosub' );
330
  foreach ( $categories as $cat ) {
331
+ delete_user_meta( $user_ID, 's2_cat' . $cat );
332
  }
333
  }
334
  }
336
 
337
  function upgrade70() {
338
  global $mysubscribe2, $wpdb;
339
+ if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
340
+ $users = $wpdb->get_col( $wpdb->prepare( "SELECT ID from $wpdb->users WHERE ID NOT IN (SELECT user_id from $wpdb->usermeta WHERE meta_key=%s", $mysubscribe2->get_usermeta_keyname( 's2_authors' ) ) );
341
  foreach ( $users as $user_ID ) {
342
+ $check_authors = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), true );
343
+ if ( empty( $check_authors ) ) {
344
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), '' );
345
  }
346
  }
347
  } else {
348
  $args = array(
349
  'meta_query' => array(
350
+ array(
351
+ 'key' => $mysubscribe2->get_usermeta_keyname( 's2_authors' ),
352
+ 'compare' => 'NOT EXISTS',
353
+ ),
354
+ ),
355
  );
356
 
357
  $user_query = new WP_User_Query( $args );
358
  $users = $user_query->get_results();
359
+ if ( ! empty( $users ) ) {
360
+ foreach ( $users as $user ) {
361
+ update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), '' );
362
  }
363
  }
364
  }
368
  global $mysubscribe2, $wpdb;
369
 
370
  // include upgrade-functions for maybe_add_column;
371
+ if ( ! function_exists( 'maybe_add_column' ) ) {
372
+ require_once( ABSPATH . 'wp-admin/install-helper.php' );
373
  }
374
+ maybe_add_column( $mysubscribe2->public, 'time', "ALTER TABLE $mysubscribe2->public ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date" );
375
 
376
  // update postmeta field to a protected name, from version 8.5
377
  $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_s2mail' WHERE meta_key = 's2mail'" );
381
  global $mysubscribe2, $wpdb;
382
 
383
  // include upgrade-functions for maybe_add_column;
384
+ if ( ! function_exists( 'maybe_add_column' ) ) {
385
+ require_once( ABSPATH . 'wp-admin/install-helper.php' );
386
  }
387
+ maybe_add_column( $mysubscribe2->public, 'conf_date', "ALTER TABLE $mysubscribe2->public ADD conf_date DATE AFTER ip" );
388
+ maybe_add_column( $mysubscribe2->public, 'conf_time', "ALTER TABLE $mysubscribe2->public ADD conf_time TIME AFTER conf_date" );
389
+ maybe_add_column( $mysubscribe2->public, 'conf_ip', "ALTER TABLE $mysubscribe2->public ADD conf_ip char(64) AFTER conf_time" );
390
 
391
  // remove unnecessary table data
392
  $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 's2_cat'" );
393
 
394
+ $sql = "SELECT ID FROM $wpdb->users INNER JOIN $wpdb->usermeta ON ( $wpdb->users.ID = $wpdb->usermeta.user_id) WHERE ( $wpdb->usermeta.meta_key = '" . $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ) . "' AND $wpdb->usermeta.meta_value LIKE ',%' )";
395
+ $users = $wpdb->get_results( $sql );
396
  foreach ( $users as $user ) {
397
  // make sure we remove leading ',' from this setting
398
+ $subscribed = get_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
399
+ $old_cats = explode( ',', $subscribed );
400
+ unset( $old_cats[0] );
401
+ $cats = implode( ',', $old_cats );
402
+ update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
403
  }
404
  } // end upgrade86()
405
 
407
  // to ensure compulsory category collects all users we need there to be s2_subscribed meta-keys for all users
408
  global $mysubscribe2;
409
 
410
+ if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
411
+ $all_registered = $mysubscribe2->get_all_registered( 'ID' );
412
+ if ( ! empty( $all_registered ) ) {
413
  foreach ( $all_registered as $user_ID ) {
414
+ $check_subscribed = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
415
+ if ( empty( $check_subscribed ) ) {
416
+ update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), '' );
417
  }
418
  }
419
  }
420
  } else {
421
  $args = array(
422
  'meta_query' => array(
423
+ array(
424
+ 'key' => $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ),
425
+ 'compare' => 'NOT EXISTS',
426
+ ),
427
+ ),
428
  );
429
 
430
  $user_query = new WP_User_Query( $args );
431
  $users = $user_query->get_results();
432
+ if ( ! empty( $users ) ) {
433
+ foreach ( $users as $user ) {
434
+ update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), '' );
435
  }
436
  }
437
  }
438
 
439
  // check the time column again as the upgrade86() function contained a bug
440
  // include upgrade-functions for maybe_add_column;
441
+ if ( ! function_exists( 'maybe_add_column' ) ) {
442
+ require_once( ABSPATH . 'wp-admin/install-helper.php' );
443
  }
444
+ maybe_add_column( $mysubscribe2->public, 'time', "ALTER TABLE $mysubscribe2->public ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date" );
445
  } // end upgrade88()
446
 
447
  function upgrade95() {
448
  global $mysubscribe2;
449
+ if ( 'never' !== $mysubscribe2->subscribe2_options['email_freq'] ) {
450
  $mysubscribe2->subscribe2_options['last_s2cron'] = '';
451
+ unset( $mysubscribe2->subscribe2_options['previous_s2cron'] );
452
  }
453
  } // end upgrade95()
454
+
455
+ function upgrade1014() {
456
+ global $mysubscribe2;
457
+ if ( ! isset( $mysubscribe2->subscribe2_options['frontend_form'] ) ) {
458
+ $mysubscribe2->subscribe2_options['frontend_form'] = '0';
459
+ }
460
+ if ( ! isset( $mysubscribe2->subscribe2_options['dismiss_sender_warning'] ) ) {
461
+ $mysubscribe2->subscribe2_options['dismiss_sender_warning'] = '0';
462
+ }
463
+ } // end upgrade1014()
464
+
465
+ function upgrade1015() {
466
+ global $mysubscribe2;
467
+ if ( ! isset( $mysubscribe2->subscribe2_options['js_ip_updater'] ) ) {
468
+ $mysubscribe2->subscribe2_options['js_ip_updater'] = '0';
469
+ }
470
+ } // end upgrade1015()
471
  }
472
  ?>
include/Sign-Alert-icon.png DELETED
Binary file
include/{email_edit.png → email-edit.png} RENAMED
File without changes
include/options.php CHANGED
@@ -2,159 +2,173 @@
2
  // include.php - Handles options for subscribe2
3
  // DO NOT EDIT THIS FILE AS IT IS SET BY THE OPTIONS PAGE
4
 
5
- if (!isset($this->subscribe2_options['autosub'])) {
6
- $this->subscribe2_options['autosub'] = "no";
 
 
7
  } // option to autosubscribe registered users to new categories
8
 
9
- if (!isset($this->subscribe2_options['newreg_override'])) {
10
- $this->subscribe2_options['newreg_override'] = "no";
11
  } // option to autosubscribe registered users to new categories
12
 
13
- if (!isset($this->subscribe2_options['wpregdef'])) {
14
- $this->subscribe2_options['wpregdef'] = "no";
15
  } // option to check registration form box by default
16
 
17
- if (!isset($this->subscribe2_options['autoformat'])) {
18
- $this->subscribe2_options['autoformat'] = "post";
19
  } // option for default auto-subscription email format
20
 
21
- if (!isset($this->subscribe2_options['show_autosub'])) {
22
- $this->subscribe2_options['show_autosub'] = "yes";
23
  } // option to display auto-subscription option to registered users
24
 
25
- if (!isset($this->subscribe2_options['autosub_def'])) {
26
- $this->subscribe2_options['autosub_def'] = "yes";
27
  } // option for user default auto-subscription to new categories
28
 
29
- if (!isset($this->subscribe2_options['comment_subs'])) {
30
- $this->subscribe2_options['comment_subs'] = "no";
31
  } // option for commenters to subscribe as public subscribers
32
 
33
- if (!isset($this->subscribe2_options['comment_def'])) {
34
- $this->subscribe2_options['comment_def'] = "no";
35
  } // option for comments box to be checked by default
36
 
37
- if (!isset($this->subscribe2_options['one_click_profile'])) {
38
- $this->subscribe2_options['one_click_profile'] = "no";
39
  } // option for displaying 'one-click' option on profile page
40
 
41
- if (!isset($this->subscribe2_options['bcclimit'])) {
42
- $this->subscribe2_options['bcclimit'] = 1;
43
  } // option for default bcc limit on email notifications
44
 
45
- if (!isset($this->subscribe2_options['admin_email'])) {
46
- $this->subscribe2_options['admin_email'] = "subs";
47
  } // option for sending new subscriber notifications to admins
48
 
49
- if (!isset($this->subscribe2_options['tracking'])) {
50
- $this->subscribe2_options['tracking'] = "";
51
  } // option for tracking
52
 
53
- if (!isset($this->subscribe2_options['s2page'])) {
54
- $this->subscribe2_options['s2page'] = 0;
55
  } // option for default WordPress page for Subscribe2 to use
56
 
57
- if (!isset($this->subscribe2_options['stylesheet'])) {
58
- $this->subscribe2_options['stylesheet'] = "yes";
59
  } // option to include link to theme stylesheet from HTML notifications
60
 
61
- if (!isset($this->subscribe2_options['pages'])) {
62
- $this->subscribe2_options['pages'] = "no";
 
 
 
 
63
  } // option for sending notifications for WordPress pages
64
 
65
- if (!isset($this->subscribe2_options['password'])) {
66
- $this->subscribe2_options['password'] = "no";
67
  } // option for sending notifications for posts that are password protected
68
 
69
- if (!isset($this->subscribe2_options['stickies'])) {
70
- $this->subscribe2_options['stickies'] = "no";
71
  } // option for including sticky posts in digest notifications
72
 
73
- if (!isset($this->subscribe2_options['private'])) {
74
- $this->subscribe2_options['private'] = "no";
75
  } // option for sending notifications for posts that are private
76
 
77
- if (!isset($this->subscribe2_options['email_freq'])) {
78
- $this->subscribe2_options['email_freq'] = "never";
79
  } // option for sending emails per-post or as a digest email on a cron schedule
80
 
81
- if (!isset($this->subscribe2_options['cron_order'])) {
82
- $this->subscribe2_options['cron_order'] = "desc";
83
  } // option for ordering of posts in digest email
84
 
85
- if (!isset($this->subscribe2_options['compulsory'])) {
86
- $this->subscribe2_options['compulsory'] = "";
87
  } // option for compulsory categories
88
 
89
- if (!isset($this->subscribe2_options['exclude'])) {
90
- $this->subscribe2_options['exclude'] = "";
91
  } // option for excluded categories
92
 
93
- if (!isset($this->subscribe2_options['sender'])) {
94
- $this->subscribe2_options['sender'] = "blogname";
95
  } // option for email notification sender
96
 
97
- if (!isset($this->subscribe2_options['reg_override'])) {
98
- $this->subscribe2_options['reg_override'] = "1";
99
  } // option for excluded categories to be overriden for registered users
100
 
101
- if (!isset($this->subscribe2_options['show_meta'])) {
102
- $this->subscribe2_options['show_meta'] = "0";
103
  } // option to display link to subscribe2 page from 'meta'
104
 
105
- if (!isset($this->subscribe2_options['show_button'])) {
106
- $this->subscribe2_options['show_button'] = "1";
107
  } // option to show Subscribe2 button on Write page
108
 
109
- if (!isset($this->subscribe2_options['ajax'])) {
110
- $this->subscribe2_options['ajax'] = "0";
111
  } // option to enable an AJAX style form
112
 
113
- if (!isset($this->subscribe2_options['widget'])) {
114
- $this->subscribe2_options['widget'] = "1";
115
  } // option to enable Subscribe2 Widget
116
 
117
- if (!isset($this->subscribe2_options['counterwidget'])) {
118
- $this->subscribe2_options['counterwidget'] = "0";
119
  } // option to enable Subscribe2 Counter Widget
120
 
121
- if (!isset($this->subscribe2_options['s2meta_default'])) {
122
- $this->subscribe2_options['s2meta_default'] = "0";
123
  } // option for Subscribe2 over ride postmeta to be checked by default
124
 
125
- if (!isset($this->subscribe2_options['entries'])) {
126
- $this->subscribe2_options['entries'] = 25;
127
  } // option for the number of subscribers displayed on each page
128
 
129
- if (!isset($this->subscribe2_options['barred'])) {
130
- $this->subscribe2_options['barred'] = "";
131
  } // option containing domains barred from public registration
132
 
133
- if (!isset($this->subscribe2_options['exclude_formats'])) {
134
- $this->subscribe2_options['exclude_formats'] = "";
135
  } // option for excluding post formats as supported by the current theme
136
 
137
- if (!isset($this->subscribe2_options['mailtext'])) {
138
- $this->subscribe2_options['mailtext'] = __("{BLOGNAME} has posted a new item, '{TITLE}'\n\n{POST}\n\nYou may view the latest post at\n{PERMALINK}\n\nYou received this e-mail because you asked to be notified when new updates are posted.\nBest regards,\n{MYNAME}\n{EMAIL}", "subscribe2");
139
  } // Default notification email text
140
 
141
- if (!isset($this->subscribe2_options['notification_subject'])) {
142
- $this->subscribe2_options['notification_subject'] = "[{BLOGNAME}] {TITLE}";
143
  } // Default notification email subject
144
 
145
- if (!isset($this->subscribe2_options['confirm_email'])) {
146
- $this->subscribe2_options['confirm_email'] = __("{BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:\n\n{LINK}\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\n{MYNAME}.", "subscribe2");
147
  } // Default confirmation email text
148
 
149
- if (!isset($this->subscribe2_options['confirm_subject'])) {
150
- $this->subscribe2_options['confirm_subject'] = "[{BLOGNAME}] " . __('Please confirm your request', 'subscribe2');
151
  } // Default confirmation email subject
152
 
153
- if (!isset($this->subscribe2_options['remind_email'])) {
154
- $this->subscribe2_options['remind_email'] = __("This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.\n\nIf you wish to complete your subscription please click on the link below:\n\n{LINK}\n\nIf you do not wish to complete your subscription please ignore this email and your address will be removed from our database.\n\nRegards,\n{MYNAME}", "subscribe2");
155
  } // Default reminder email text
156
 
157
- if (!isset($this->subscribe2_options['remind_subject'])) {
158
- $this->subscribe2_options['remind_subject'] = "[{BLOGNAME}] " . __('Subscription Reminder', 'subscribe2');;
159
  } // Default reminder email subject
 
 
 
 
 
 
 
 
160
  ?>
2
  // include.php - Handles options for subscribe2
3
  // DO NOT EDIT THIS FILE AS IT IS SET BY THE OPTIONS PAGE
4
 
5
+ global $mysubscribe2;
6
+
7
+ if ( ! isset( $mysubscribe2->subscribe2_options['autosub'] ) ) {
8
+ $mysubscribe2->subscribe2_options['autosub'] = 'no';
9
  } // option to autosubscribe registered users to new categories
10
 
11
+ if ( ! isset( $mysubscribe2->subscribe2_options['newreg_override'] ) ) {
12
+ $mysubscribe2->subscribe2_options['newreg_override'] = 'no';
13
  } // option to autosubscribe registered users to new categories
14
 
15
+ if ( ! isset( $mysubscribe2->subscribe2_options['wpregdef'] ) ) {
16
+ $mysubscribe2->subscribe2_options['wpregdef'] = 'no';
17
  } // option to check registration form box by default
18
 
19
+ if ( ! isset( $mysubscribe2->subscribe2_options['autoformat'] ) ) {
20
+ $mysubscribe2->subscribe2_options['autoformat'] = 'post';
21
  } // option for default auto-subscription email format
22
 
23
+ if ( ! isset( $mysubscribe2->subscribe2_options['show_autosub'] ) ) {
24
+ $mysubscribe2->subscribe2_options['show_autosub'] = 'yes';
25
  } // option to display auto-subscription option to registered users
26
 
27
+ if ( ! isset( $mysubscribe2->subscribe2_options['autosub_def'] ) ) {
28
+ $mysubscribe2->subscribe2_options['autosub_def'] = 'yes';
29
  } // option for user default auto-subscription to new categories
30
 
31
+ if ( ! isset( $mysubscribe2->subscribe2_options['comment_subs'] ) ) {
32
+ $mysubscribe2->subscribe2_options['comment_subs'] = 'no';
33
  } // option for commenters to subscribe as public subscribers
34
 
35
+ if ( ! isset( $mysubscribe2->subscribe2_options['comment_def'] ) ) {
36
+ $mysubscribe2->subscribe2_options['comment_def'] = 'no';
37
  } // option for comments box to be checked by default
38
 
39
+ if ( ! isset( $mysubscribe2->subscribe2_options['one_click_profile'] ) ) {
40
+ $mysubscribe2->subscribe2_options['one_click_profile'] = 'no';
41
  } // option for displaying 'one-click' option on profile page
42
 
43
+ if ( ! isset( $mysubscribe2->subscribe2_options['bcclimit'] ) ) {
44
+ $mysubscribe2->subscribe2_options['bcclimit'] = 1;
45
  } // option for default bcc limit on email notifications
46
 
47
+ if ( ! isset( $mysubscribe2->subscribe2_options['admin_email'] ) ) {
48
+ $mysubscribe2->subscribe2_options['admin_email'] = 'subs';
49
  } // option for sending new subscriber notifications to admins
50
 
51
+ if ( ! isset( $mysubscribe2->subscribe2_options['tracking'] ) ) {
52
+ $mysubscribe2->subscribe2_options['tracking'] = '';
53
  } // option for tracking
54
 
55
+ if ( ! isset( $mysubscribe2->subscribe2_options['s2page'] ) ) {
56
+ $mysubscribe2->subscribe2_options['s2page'] = 0;
57
  } // option for default WordPress page for Subscribe2 to use
58
 
59
+ if ( ! isset( $mysubscribe2->subscribe2_options['stylesheet'] ) ) {
60
+ $mysubscribe2->subscribe2_options['stylesheet'] = 'yes';
61
  } // option to include link to theme stylesheet from HTML notifications
62
 
63
+ if ( ! isset( $mysubscribe2->subscribe2_options['embed'] ) ) {
64
+ $mysubscribe2->subscribe2_options['embed'] = 'no';
65
+ } // option to embed stylesheet and images into HTML emails
66
+
67
+ if ( ! isset( $mysubscribe2->subscribe2_options['pages'] ) ) {
68
+ $mysubscribe2->subscribe2_options['pages'] = 'no';
69
  } // option for sending notifications for WordPress pages
70
 
71
+ if ( ! isset( $mysubscribe2->subscribe2_options['password'] ) ) {
72
+ $mysubscribe2->subscribe2_options['password'] = 'no';
73
  } // option for sending notifications for posts that are password protected
74
 
75
+ if ( ! isset( $mysubscribe2->subscribe2_options['stickies'] ) ) {
76
+ $mysubscribe2->subscribe2_options['stickies'] = 'no';
77
  } // option for including sticky posts in digest notifications
78
 
79
+ if ( ! isset( $mysubscribe2->subscribe2_options['private'] ) ) {
80
+ $mysubscribe2->subscribe2_options['private'] = 'no';
81
  } // option for sending notifications for posts that are private
82
 
83
+ if ( ! isset( $mysubscribe2->subscribe2_options['email_freq'] ) ) {
84
+ $mysubscribe2->subscribe2_options['email_freq'] = 'never';
85
  } // option for sending emails per-post or as a digest email on a cron schedule
86
 
87
+ if ( ! isset( $mysubscribe2->subscribe2_options['cron_order'] ) ) {
88
+ $mysubscribe2->subscribe2_options['cron_order'] = 'desc';
89
  } // option for ordering of posts in digest email
90
 
91
+ if ( ! isset( $mysubscribe2->subscribe2_options['compulsory'] ) ) {
92
+ $mysubscribe2->subscribe2_options['compulsory'] = '';
93
  } // option for compulsory categories
94
 
95
+ if ( ! isset( $mysubscribe2->subscribe2_options['exclude'] ) ) {
96
+ $mysubscribe2->subscribe2_options['exclude'] = '';
97
  } // option for excluded categories
98
 
99
+ if ( ! isset( $mysubscribe2->subscribe2_options['sender'] ) ) {
100
+ $mysubscribe2->subscribe2_options['sender'] = 'blogname';
101
  } // option for email notification sender
102
 
103
+ if ( ! isset( $mysubscribe2->subscribe2_options['reg_override'] ) ) {
104
+ $mysubscribe2->subscribe2_options['reg_override'] = '1';
105
  } // option for excluded categories to be overriden for registered users
106
 
107
+ if ( ! isset( $mysubscribe2->subscribe2_options['show_meta'] ) ) {
108
+ $mysubscribe2->subscribe2_options['show_meta'] = '0';
109
  } // option to display link to subscribe2 page from 'meta'
110
 
111
+ if ( ! isset( $mysubscribe2->subscribe2_options['show_button'] ) ) {
112
+ $mysubscribe2->subscribe2_options['show_button'] = '1';
113
  } // option to show Subscribe2 button on Write page
114
 
115
+ if ( ! isset( $mysubscribe2->subscribe2_options['ajax'] ) ) {
116
+ $mysubscribe2->subscribe2_options['ajax'] = '0';
117
  } // option to enable an AJAX style form
118
 
119
+ if ( ! isset( $mysubscribe2->subscribe2_options['widget'] ) ) {
120
+ $mysubscribe2->subscribe2_options['widget'] = '1';
121
  } // option to enable Subscribe2 Widget
122
 
123
+ if ( ! isset( $mysubscribe2->subscribe2_options['counterwidget'] ) ) {
124
+ $mysubscribe2->subscribe2_options['counterwidget'] = '0';
125
  } // option to enable Subscribe2 Counter Widget
126
 
127
+ if ( ! isset( $mysubscribe2->subscribe2_options['s2meta_default'] ) ) {
128
+ $mysubscribe2->subscribe2_options['s2meta_default'] = '0';
129
  } // option for Subscribe2 over ride postmeta to be checked by default
130
 
131
+ if ( ! isset( $mysubscribe2->subscribe2_options['entries'] ) ) {
132
+ $mysubscribe2->subscribe2_options['entries'] = 25;
133
  } // option for the number of subscribers displayed on each page
134
 
135
+ if ( ! isset( $mysubscribe2->subscribe2_options['barred'] ) ) {
136
+ $mysubscribe2->subscribe2_options['barred'] = '';
137
  } // option containing domains barred from public registration
138
 
139
+ if ( ! isset( $mysubscribe2->subscribe2_options['exclude_formats'] ) ) {
140
+ $mysubscribe2->subscribe2_options['exclude_formats'] = '';
141
  } // option for excluding post formats as supported by the current theme
142
 
143
+ if ( ! isset( $mysubscribe2->subscribe2_options['mailtext'] ) ) {
144
+ $mysubscribe2->subscribe2_options['mailtext'] = __( "{BLOGNAME} has posted a new item, '{TITLE}'\n\n{POST}\n\nYou may view the latest post at\n{PERMALINK}\n\nYou received this e-mail because you asked to be notified when new updates are posted.\nBest regards,\n{MYNAME}\n{EMAIL}", 'subscribe2' );
145
  } // Default notification email text
146
 
147
+ if ( ! isset( $mysubscribe2->subscribe2_options['notification_subject'] ) ) {
148
+ $mysubscribe2->subscribe2_options['notification_subject'] = '[{BLOGNAME}] {TITLE}';
149
  } // Default notification email subject
150
 
151
+ if ( ! isset( $mysubscribe2->subscribe2_options['confirm_email'] ) ) {
152
+ $mysubscribe2->subscribe2_options['confirm_email'] = __( '{BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:\n\n{LINK}\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\n{MYNAME}.', 'subscribe2' );
153
  } // Default confirmation email text
154
 
155
+ if ( ! isset( $mysubscribe2->subscribe2_options['confirm_subject'] ) ) {
156
+ $mysubscribe2->subscribe2_options['confirm_subject'] = '[{BLOGNAME}] ' . __( 'Please confirm your request', 'subscribe2' );
157
  } // Default confirmation email subject
158
 
159
+ if ( ! isset( $mysubscribe2->subscribe2_options['remind_email'] ) ) {
160
+ $mysubscribe2->subscribe2_options['remind_email'] = __( 'This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.\n\nIf you wish to complete your subscription please click on the link below:\n\n{LINK}\n\nIf you do not wish to complete your subscription please ignore this email and your address will be removed from our database.\n\nRegards,\n{MYNAME}', 'subscribe2' );
161
  } // Default reminder email text
162
 
163
+ if ( ! isset( $mysubscribe2->subscribe2_options['remind_subject'] ) ) {
164
+ $mysubscribe2->subscribe2_options['remind_subject'] = '[{BLOGNAME}] ' . __( 'Subscription Reminder', 'subscribe2' );
165
  } // Default reminder email subject
166
+
167
+ if ( ! isset( $mysubscribe2->subscribe2_options['ajax'] ) ) {
168
+ $mysubscribe2->subscribe2_options['ajax'] = '0';
169
+ } // Default frontend form setting
170
+
171
+ if ( ! isset( $mysubscribe2->subscribe2_options['js_ip_updater'] ) ) {
172
+ $mysubscribe2->subscribe2_options['js_ip_updater'] = '0';
173
+ } // Default setting for using javascript to update form ip address
174
  ?>
include/{s2_ajax.js → s2-ajax.js} RENAMED
@@ -1,12 +1,14 @@
1
- /* global s2_script_strings */
2
  // Version 1.0 - original version
3
- // Copyright Matthew Robinson 2015
 
4
 
5
  var s2jQuery = jQuery.noConflict();
6
  s2jQuery( document ).ready( function() {
7
  var dialog = s2jQuery( '<div></div>' );
8
- var ajaxurl = s2_script_strings.ajaxurl;
9
- s2jQuery( 'a.s2popup' ).click( function(){
 
10
  var data = {
11
  'action': 'subscribe2_form',
12
  'data': s2jQuery( 'a.s2popup' ).attr( 'id' )
@@ -14,7 +16,13 @@ s2jQuery( document ).ready( function() {
14
  jQuery.post( ajaxurl, data, function( response ) {
15
  dialog.html( response );
16
  });
17
- dialog.dialog( { modal: true, zIndex: 10000, title: s2_script_strings.title } );
 
 
 
 
 
 
18
  dialog.dialog( 'open' );
19
  });
20
  s2jQuery( document ).on( 'submit', '#s2ajaxform', function( event ) {
@@ -37,13 +45,14 @@ s2jQuery( document ).ready( function() {
37
  if ( btn.length && s2jQuery( '#s2ajaxform' ).has( btn ) ) {
38
  var data = {
39
  'action': 'subscribe2_submit',
 
40
  'data': {
41
- email: email,
42
- ip: ip,
43
- firstname: firstname,
44
- lastname: lastname,
45
- uri: uri,
46
- button: btn.attr( 'name' )
47
  }
48
  };
49
  jQuery.post( ajaxurl, data, function( response ) {
@@ -58,12 +67,6 @@ s2jQuery( document ).ready( function() {
58
  });
59
  // when form is closed return to default
60
  s2jQuery( document ).on( 'dialogclose', function() {
61
- var data = {
62
- 'action': 'subscribe2_form',
63
- 'data': s2jQuery( 'a.s2popup' ).attr( 'id' )
64
- };
65
- jQuery.post( ajaxurl, data, function( response ) {
66
- dialog.html( response );
67
- });
68
  });
69
  });
1
+ /* global s2_ajax_script_strings */
2
  // Version 1.0 - original version
3
+ // Version 1.1 - added position and minimum width and height attributes to .dialog
4
+ // Version 1.2 - added nonce use for form submission
5
 
6
  var s2jQuery = jQuery.noConflict();
7
  s2jQuery( document ).ready( function() {
8
  var dialog = s2jQuery( '<div></div>' );
9
+ var ajaxurl = s2_ajax_script_strings.ajaxurl;
10
+ s2jQuery( 'a.s2popup' ).click( function( event ){
11
+ event.preventDefault();
12
  var data = {
13
  'action': 'subscribe2_form',
14
  'data': s2jQuery( 'a.s2popup' ).attr( 'id' )
16
  jQuery.post( ajaxurl, data, function( response ) {
17
  dialog.html( response );
18
  });
19
+ dialog.dialog( {
20
+ modal: true,
21
+ zIndex: 10000,
22
+ minWidth: 350,
23
+ minHeight: 300,
24
+ title: s2_ajax_script_strings.title
25
+ });
26
  dialog.dialog( 'open' );
27
  });
28
  s2jQuery( document ).on( 'submit', '#s2ajaxform', function( event ) {
45
  if ( btn.length && s2jQuery( '#s2ajaxform' ).has( btn ) ) {
46
  var data = {
47
  'action': 'subscribe2_submit',
48
+ 'nonce': s2_ajax_script_strings.nonce,
49
  'data': {
50
+ 'email': email,
51
+ 'ip': ip,
52
+ 'firstname': firstname,
53
+ 'lastname': lastname,
54
+ 'uri': uri,
55
+ 'button': btn.attr( 'name' ),
56
  }
57
  };
58
  jQuery.post( ajaxurl, data, function( response ) {
67
  });
68
  // when form is closed return to default
69
  s2jQuery( document ).on( 'dialogclose', function() {
70
+ dialog.html( dialog );
 
 
 
 
 
 
71
  });
72
  });
include/s2-ajax.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var s2jQuery=jQuery.noConflict();s2jQuery(document).ready(function(){var dialog=s2jQuery('<div></div>');var ajaxurl=s2_ajax_script_strings.ajaxurl;s2jQuery('a.s2popup').click(function(event){event.preventDefault();var data={'action':'subscribe2_form','data':s2jQuery('a.s2popup').attr('id')};jQuery.post(ajaxurl,data,function(response){dialog.html(response)});dialog.dialog({modal:true,zIndex:10000,minWidth:350,minHeight:300,title:s2_ajax_script_strings.title});dialog.dialog('open')});s2jQuery(document).on('submit','#s2ajaxform',function(event){event.preventDefault();var email=s2jQuery('#s2ajaxform input[name=email]').val();var ip=s2jQuery('#s2ajaxform input[name=ip]').val();var firstname=s2jQuery('#s2ajaxform input[name=firstname]').val();if(typeof firstname==='undefined'){firstname=''}var lastname=s2jQuery('#s2ajaxform input[name=lastname]').val();if(typeof lastname==='undefined'){lastname=''}var uri=s2jQuery('#s2ajaxform input[name=uri]').val();if(typeof uri==='undefined'){uri='http://'}var btn=s2jQuery(this).find('input[type=submit][clicked=true]');if(btn.length&&s2jQuery('#s2ajaxform').has(btn)){var data={'action':'subscribe2_submit','nonce':s2_ajax_script_strings.nonce,'data':{'email':email,'ip':ip,'firstname':firstname,'lastname':lastname,'uri':uri,'button':btn.attr('name'),}};jQuery.post(ajaxurl,data,function(response){dialog.html(response)})}});s2jQuery(document).on('click','#s2ajaxform input[type=submit]',function(){s2jQuery('#s2ajaxform input[type=submit]').removeAttr('clicked');s2jQuery(this).attr('clicked','true')});s2jQuery(document).on('dialogclose',function(){dialog.html(dialog)})});
include/{s2_button.js → s2-button.js} RENAMED
File without changes
include/s2-button.min.js ADDED
@@ -0,0 +1 @@
 
1
+ QTags.addButton("Subscribe2","Subscribe2","[subscribe2]");
include/{s2_button.png → s2-button.png} RENAMED
File without changes
include/{s2_checkbox.js → s2-checkbox.js} RENAMED
File without changes
include/s2-checkbox.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(){jQuery('input[name="checkall"]').click(function(){var a=this.checked;jQuery('input[class="'+this.value+'"]').each(function(){!1===jQuery(this).prop("disabled")&&(this.checked=a)})}),jQuery('input[class^="checkall"]').click(function(){var a=!0;jQuery('input[class="'+this.className+'"]').each(function(){a=!0===this.checked&&!0===a?!0:!1,jQuery('input[value="'+this.className+'"]').prop("checked",a)})});var a=!0;jQuery('input[class^="checkall"]').each(function(){a=!0===this.checked&&!0===a?!0:!1,jQuery('input[value="'+this.className+'"]').prop("checked",a)})});
include/{s2_colorpicker.js → s2-colorpicker.js} RENAMED
File without changes
include/s2-colorpicker.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(){jQuery(document).on("focus",".colorpickerField",function(){if(!jQuery(this).is(".s2_initialised")&&-1===this.id.search("__i__")){jQuery(this).addClass("s2_initialised");var a,b=this.id.substr(0,20);jQuery(".s2_colorpicker").each(function(){return-1!==this.id.search(b)?(a=this.id,!1):void 0}),jQuery(this).on("focusin",function(){jQuery(".s2_colorpicker").slideUp(),jQuery.farbtastic("#"+a).linkTo(this),jQuery("#"+a).slideDown()}),jQuery(this).on("focusout",function(){jQuery("#"+a).slideUp()}),jQuery(this).trigger("focus")}}),jQuery(".colorpickerField").each(function(){jQuery.farbtastic("#"+this.id).linkTo(this)})});
include/s2-date-time.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ // Version 1.0 - original version
2
+ jQuery( document ).ready(function() {
3
+ jQuery( '#s2datepicker' ).datepicker({
4
+ dateFormat : 'MM d, yy'
5
+ });
6
+ });
include/s2-date-time.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(){jQuery("#s2datepicker").datepicker({dateFormat:"MM d, yy"})});
include/s2-dismiss.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global s2_dismiss_script_strings */
2
+ // Version 1.0 - original version
3
+
4
+ jQuery( document ).on( 'click', '#sender_message .notice-dismiss', function() {
5
+ var ajaxurl = s2_dismiss_script_strings.ajaxurl;
6
+ var data = {
7
+ 'action': 's2_dismiss_notice',
8
+ 'nonce': s2_dismiss_script_strings.nonce
9
+
10
+ };
11
+ jQuery.post( ajaxurl, data );
12
+ });
include/s2-dismiss.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).on('click','#sender_message .notice-dismiss',function(){var ajaxurl=s2_dismiss_script_strings.ajaxurl;var data={'action':'s2_dismiss_notice','nonce':s2_dismiss_script_strings.nonce};jQuery.post(ajaxurl,data)});
include/{s2_edit.js → s2-edit.js} RENAMED
@@ -51,8 +51,8 @@ function s2_cron_revert( id ) {
51
  jQuery( 'input[name="' + id + 'date"]' ).val( date );
52
  jQuery( '#s2' + id + 'date' ).html( date );
53
  time = jQuery( '#js' + id + 'time' ).val();
54
- jQuery( '[name='+ id + 'time] option' ).filter(function() {
55
- return ( this.text == time );
56
  }).prop( 'selected', true ).parent().focus();
57
  jQuery( '#s2' + id + 'time' ).html( time );
58
  s2_hide( id );
51
  jQuery( 'input[name="' + id + 'date"]' ).val( date );
52
  jQuery( '#s2' + id + 'date' ).html( date );
53
  time = jQuery( '#js' + id + 'time' ).val();
54
+ jQuery( '[name=' + id + 'time] option' ).filter(function() {
55
+ return ( this.text === time );
56
  }).prop( 'selected', true ).parent().focus();
57
  jQuery( '#s2' + id + 'time' ).html( time );
58
  s2_hide( id );
include/s2-edit.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function s2_show(a){return jQuery("#s2"+a+"_2").show(),jQuery("#s2"+a+"_1").hide(),!1}function s2_hide(a){return jQuery("#s2"+a+"_1").show(),jQuery("#s2"+a+"_2").hide(),!1}function s2_update(a){var b=jQuery('input[name="'+a+'"]').val();jQuery("#s2"+a).html(b),s2_hide(a)}function s2_revert(a){var b=jQuery("#js"+a).val();jQuery('input[name="'+a+'"]').val(b),jQuery("#s2"+a).html(b),s2_hide(a)}function s2_cron_update(a){var b,c;b=jQuery('input[name="'+a+'date"]').val(),jQuery("#s2"+a+"date").html(b),c=jQuery('select[name="'+a+'time"] option:selected').html(),jQuery("#s2"+a+"time").html(c),s2_hide(a)}function s2_cron_revert(a){var b,c;b=jQuery("#js"+a+"date").val(),jQuery('input[name="'+a+'date"]').val(b),jQuery("#s2"+a+"date").html(b),c=jQuery("#js"+a+"time").val(),jQuery("[name="+a+"time] option").filter(function(){return this.text===c}).prop("selected",!0).parent().focus(),jQuery("#s2"+a+"time").html(c),s2_hide(a)}jQuery(document).ready(function(){jQuery("#s2bcclimit_2").hide(),jQuery("#s2entries_2").hide(),jQuery("#s2cron_2").hide()});
include/s2-ip-updater.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Version 1.0 - original version
2
+
3
+ function getip( json ) {
4
+ if ( true === document.body.contains( document.forms['s2form'] ) ) {
5
+ var ip = document.getElementsByName( 'ip' );
6
+ for ( i = 0; i < ip.length; i++ ) {
7
+ if ( 's2form' === ip[i].parentElement.name ) {
8
+ ip[i].value = json.ip;
9
+ }
10
+ }
11
+ }
12
+ }
include/s2-ip-updater.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function getip(json){if(true===document.body.contains(document.forms['s2form'])){var ip=document.getElementsByName('ip');for(i=0;i<ip.length;i++){if('s2form'===ip[i].parentElement.name){ip[i].value=json.ip}}}}
include/{s2_marker.png → s2-marker.png} RENAMED
File without changes
include/s2-subscribers.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global s2_script_strings */
2
+ /* exported s2_delete_check, bu_cats, bu_format, bu_digest, s2_script_strings */
3
+ // Version 1.0 - original version
4
+ // Version 1.1 - context specific delete warnings for registered or public subscribers
5
+ // Version 1.2 - single and plural string confirmation messages
6
+
7
+ function s2_delete_check() {
8
+ document.getElementById( 'doaction' ).onclick = submitHandler;
9
+ document.getElementById( 'doaction2' ).onclick = submitHandler;
10
+ }
11
+ function submitHandler() {
12
+ var location, action1, action2, agree, selected;
13
+ location = document.getElementById( 's2_location' );
14
+ action1 = document.getElementById( 'bulk-action-selector-top' );
15
+ action2 = document.getElementById( 'bulk-action-selector-bottom' );
16
+ agree = false;
17
+ selected = document.querySelectorAll( 'input[name="subscriber[]"]:checked' ).length;
18
+ if ( 'delete' === action1.value || 'delete' === action2.value ) {
19
+ if ( 'registered' === location.value ) {
20
+ if ( selected > 1 ) {
21
+ agree = window.confirm( s2_script_strings.registered_confirm_plural );
22
+ } else {
23
+ agree = window.confirm( s2_script_strings.registered_confirm_single );
24
+ }
25
+ } else if ( 'public' === location.value ) {
26
+ if ( selected > 1 ) {
27
+ agree = window.confirm( s2_script_strings.public_confirm_plural );
28
+ } else {
29
+ agree = window.confirm( s2_script_strings.public_confirm_single );
30
+ }
31
+ }
32
+ }
33
+ return agree;
34
+ }
35
+ function bu_cats() {
36
+ var action, actions = document.getElementsByName( 'manage' );
37
+ for ( var i = 0; i < actions.length; i++ ) {
38
+ if ( actions[i].checked ) {
39
+ action = actions[i].value;
40
+ }
41
+ }
42
+ document.getElementById( 'bulk-action-selector-top' ).value = action;
43
+ document.getElementById( 'doaction' ).click();
44
+ }
45
+ function bu_format() {
46
+ document.getElementById( 'bulk-action-selector-top' ).value = 'format';
47
+ document.getElementById( 'doaction' ).click();
48
+ }
49
+ function bu_digest() {
50
+ document.getElementById( 'bulk-action-selector-top' ).value = 'digest';
51
+ document.getElementById( 'doaction' ).click();
52
+ }
53
+ window.onload = s2_delete_check;
include/s2-subscribers.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function s2_delete_check(){document.getElementById("doaction").onclick=submitHandler,document.getElementById("doaction2").onclick=submitHandler}function submitHandler(){var a,b,c,d,e;return a=document.getElementById("s2_location"),b=document.getElementById("bulk-action-selector-top"),c=document.getElementById("bulk-action-selector-bottom"),d=!1,e=document.querySelectorAll('input[name="subscriber[]"]:checked').length,"delete"!==b.value&&"delete"!==c.value||("registered"===a.value?d=e>1?window.confirm(s2_script_strings.registered_confirm_plural):window.confirm(s2_script_strings.registered_confirm_single):"public"===a.value&&(d=e>1?window.confirm(s2_script_strings.public_confirm_plural):window.confirm(s2_script_strings.public_confirm_single))),d}function bu_cats(){for(var a,b=document.getElementsByName("manage"),c=0;c<b.length;c++)b[c].checked&&(a=b[c].value);document.getElementById("bulk-action-selector-top").value=a,document.getElementById("doaction").click()}function bu_format(){document.getElementById("bulk-action-selector-top").value="format",document.getElementById("doaction").click()}function bu_digest(){document.getElementById("bulk-action-selector-top").value="digest",document.getElementById("doaction").click()}window.onload=s2_delete_check;
include/{s2_user_admin.css → s2-user-admin.css} RENAMED
File without changes
include/s2_ajax.min.js DELETED
@@ -1 +0,0 @@
1
- var s2jQuery=jQuery.noConflict();s2jQuery(document).ready(function(){var dialog=s2jQuery('<div></div>');var ajaxurl=s2_script_strings.ajaxurl;s2jQuery('a.s2popup').click(function(){var data={'action':'subscribe2_form','data':s2jQuery('a.s2popup').attr('id')};jQuery.post(ajaxurl,data,function(response){dialog.html(response)});dialog.dialog({modal:true,zIndex:10000,title:s2_script_strings.title});dialog.dialog('open')});s2jQuery(document).on('submit','#s2ajaxform',function(event){event.preventDefault();var email=s2jQuery('#s2ajaxform input[name=email]').val();var ip=s2jQuery('#s2ajaxform input[name=ip]').val();var firstname=s2jQuery('#s2ajaxform input[name=firstname]').val();if(typeof firstname==='undefined'){firstname=''}var lastname=s2jQuery('#s2ajaxform input[name=lastname]').val();if(typeof lastname==='undefined'){lastname=''}var uri=s2jQuery('#s2ajaxform input[name=uri]').val();if(typeof uri==='undefined'){uri='http://'}var btn=s2jQuery(this).find('input[type=submit][clicked=true]');if(btn.length&&s2jQuery('#s2ajaxform').has(btn)){var data={'action':'subscribe2_submit','data':{email:email,ip:ip,firstname:firstname,lastname:lastname,uri:uri,button:btn.attr('name')}};jQuery.post(ajaxurl,data,function(response){dialog.html(response)})}});s2jQuery(document).on('click','#s2ajaxform input[type=submit]',function(){s2jQuery('#s2ajaxform input[type=submit]').removeAttr('clicked');s2jQuery(this).attr('clicked','true')});s2jQuery(document).on('dialogclose',function(){var data={'action':'subscribe2_form','data':s2jQuery('a.s2popup').attr('id')};jQuery.post(ajaxurl,data,function(response){dialog.html(response)})})});
 
include/s2_button.min.js DELETED
@@ -1 +0,0 @@
1
- QTags.addButton('Subscribe2','Subscribe2','[subscribe2]');
 
include/s2_checkbox.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(document).ready(function(){jQuery('input[name="checkall"]').click(function(){var checked_status=this.checked;jQuery('input[class="'+this.value+'"]').each(function(){if(false===jQuery(this).prop('disabled')){this.checked=checked_status}})});jQuery('input[class^="checkall"]').click(function(){var checked_status=true;jQuery('input[class="'+this.className+'"]').each(function(){if((true===this.checked)&&(true===checked_status)){checked_status=true}else{checked_status=false}jQuery('input[value="'+this.className+'"]').prop('checked',checked_status)})});var checked_status=true;jQuery('input[class^="checkall"]').each(function(){if((true===this.checked)&&(true===checked_status)){checked_status=true}else{checked_status=false}jQuery('input[value="'+this.className+'"]').prop('checked',checked_status)})});
 
include/s2_colorpicker.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(document).ready(function(){jQuery(document).on('focus','.colorpickerField',function(){if(jQuery(this).is('.s2_initialised')||-1!==this.id.search('__i__')){return}jQuery(this).addClass('s2_initialised');var picker,field=this.id.substr(0,20);jQuery('.s2_colorpicker').each(function(){if(-1!==this.id.search(field)){picker=this.id;return false}});jQuery(this).on('focusin',function(){jQuery('.s2_colorpicker').slideUp();jQuery.farbtastic('#'+picker).linkTo(this);jQuery('#'+picker).slideDown()});jQuery(this).on('focusout',function(){jQuery('#'+picker).slideUp()});jQuery(this).trigger('focus')});jQuery('.colorpickerField').each(function(){jQuery.farbtastic('#'+this.id).linkTo(this)})});
 
include/s2_date_time.js DELETED
@@ -1,6 +0,0 @@
1
- // Version 1.0 - original version
2
- jQuery( document ).ready(function() {
3
- jQuery( '#s2datepicker' ).datepicker({
4
- dateFormat : 'MM d, yy'
5
- });
6
- });
 
 
 
 
 
 
include/s2_date_time.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(document).ready(function(){jQuery('#s2datepicker').datepicker({dateFormat:'MM d, yy'})});
 
include/s2_edit.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(document).ready(function(){jQuery('#s2bcclimit_2').hide();jQuery('#s2entries_2').hide();jQuery('#s2cron_2').hide()});function s2_show(id){jQuery('#s2'+id+'_2').show();jQuery('#s2'+id+'_1').hide();return false}function s2_hide(id){jQuery('#s2'+id+'_1').show();jQuery('#s2'+id+'_2').hide();return false}function s2_update(id){var input=jQuery('input[name="'+id+'"]').val();jQuery('#s2'+id).html(input);s2_hide(id)}function s2_revert(id){var option=jQuery('#js'+id).val();jQuery('input[name="'+id+'"]').val(option);jQuery('#s2'+id).html(option);s2_hide(id)}function s2_cron_update(id){var date,time;date=jQuery('input[name="'+id+'date"]').val();jQuery('#s2'+id+'date').html(date);time=jQuery('select[name="'+id+'time"] option:selected').html();jQuery('#s2'+id+'time').html(time);s2_hide(id)}function s2_cron_revert(id){var date,time;date=jQuery('#js'+id+'date').val();jQuery('input[name="'+id+'date"]').val(date);jQuery('#s2'+id+'date').html(date);time=jQuery('#js'+id+'time').val();jQuery('[name='+id+'time] option').filter(function(){return(this.text==time)}).prop('selected',true).parent().focus();jQuery('#s2'+id+'time').html(time);s2_hide(id)}
 
Licence.txt → license.txt RENAMED
File without changes
subscribe2.php CHANGED
@@ -1,13 +1,12 @@
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: 10.21
7
- Author: Matthew Robinson, Tanay Lakhani
8
- Author URI: http://subscribe2.wordpress.com
9
- Licence: GPL3
10
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904
11
  Text Domain: subscribe2
12
  */
13
 
@@ -32,57 +31,49 @@ You should have received a copy of the GNU General Public License
32
  along with Subscribe2. If not, see <http://www.gnu.org/licenses/>.
33
  */
34
 
35
- if ( version_compare($GLOBALS['wp_version'], '3.3', '<') || !function_exists( 'add_action' ) ) {
36
- if ( !function_exists( 'add_action' ) ) {
37
- $exit_msg = __("I'm just a plugin, please don't call me directly", 'subscribe2');
38
  } else {
39
  // Subscribe2 needs WordPress 3.3 or above, exit if not on a compatible version
40
- $exit_msg = sprintf(__('This version of Subscribe2 requires WordPress 3.3 or greater. Please update %1$s or use an older version of %2$s.', 'subscribe2'), '<a href="http://codex.wordpress.org/Updating_WordPress">Wordpress</a>', '<a href="http://wordpress.org/extend/plugins/subscribe2/download/">Subscribe2</a>');
41
  }
42
- exit($exit_msg);
43
  }
44
 
45
  // stop Subscribe2 being activated site wide on Multisite installs
46
- if ( !function_exists( 'is_plugin_active_for_network' ) ) {
47
  require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
48
  }
49
 
50
- if ( is_plugin_active_for_network(plugin_basename(__FILE__)) ) {
51
- deactivate_plugins( plugin_basename(__FILE__) );
52
- $exit_msg = __('Subscribe2 cannot be activated as a network plugin. Please activate it on a site level', 'subscribe2');
53
- exit($exit_msg);
54
  }
55
 
56
  // our version number. Don't touch this or any line below
57
  // unless you know exactly what you are doing
58
- define( 'S2VERSION', '10.21' );
59
- define( 'S2PATH', trailingslashit(dirname(__FILE__)) );
60
- define( 'S2DIR', trailingslashit(dirname(plugin_basename(__FILE__))) );
61
- define( 'S2URL', plugin_dir_url(dirname(__FILE__)) . S2DIR );
62
 
63
  // Set maximum execution time to 5 minutes - won't affect safe mode
64
- $safe_mode = array('On', 'ON', 'on', 1);
65
- if ( !in_array(ini_get('safe_mode'), $safe_mode) && ini_get('max_execution_time') < 300 ) {
66
- @ini_set('max_execution_time', 300);
67
  }
68
 
69
  require_once( S2PATH . 'classes/class-s2-core.php' );
70
  if ( is_admin() ) {
71
  require_once( S2PATH . 'classes/class-s2-admin.php' );
72
  global $mysubscribe2;
73
- $mysubscribe2 = new s2_admin;
74
- $mysubscribe2->s2init();
75
  } else {
76
  require_once( S2PATH . 'classes/class-s2-frontend.php' );
77
  global $mysubscribe2;
78
- $mysubscribe2 = new s2_frontend;
79
- $mysubscribe2->s2init();
80
  }
81
-
82
- function s2_install() {
83
- }
84
-
85
- register_activation_hook(__FILE__, 's2_install');
86
-
87
-
88
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Subscribe2
4
+ Plugin URI: https://subscribe2.wordpress.com/
5
  Description: Notifies an email list when new entries are posted.
6
+ Version: 10.22
7
+ Author: Matthew Robinson, Tanay Lakhani, Bryan Hadaway
8
+ Author URI: https://subscribe2.wordpress.com/
9
+ Licence: GPLv3
 
10
  Text Domain: subscribe2
11
  */
12
 
31
  along with Subscribe2. If not, see <http://www.gnu.org/licenses/>.
32
  */
33
 
34
+ if ( version_compare( $GLOBALS['wp_version'], '3.3', '<' ) || ! function_exists( 'add_action' ) ) {
35
+ if ( ! function_exists( 'add_action' ) ) {
36
+ $exit_msg = __( "I'm just a plugin, please don't call me directly", 'subscribe2' );
37
  } else {
38
  // Subscribe2 needs WordPress 3.3 or above, exit if not on a compatible version
39
+ $exit_msg = sprintf( __( 'This version of Subscribe2 requires WordPress 3.3 or greater. Please update %1$s or use an older version of %2$s.', 'subscribe2' ), '<a href="http://codex.wordpress.org/Updating_WordPress">Wordpress</a>', '<a href="http://wordpress.org/extend/plugins/subscribe2/download/">Subscribe2</a>' );
40
  }
41
+ exit( $exit_msg );
42
  }
43
 
44
  // stop Subscribe2 being activated site wide on Multisite installs
45
+ if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
46
  require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
47
  }
48
 
49
+ if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
50
+ deactivate_plugins( plugin_basename( __FILE__ ) );
51
+ $exit_msg = __( 'Subscribe2 cannot be activated as a network plugin. Please activate it on a site level', 'subscribe2' );
52
+ exit( $exit_msg );
53
  }
54
 
55
  // our version number. Don't touch this or any line below
56
  // unless you know exactly what you are doing
57
+ define( 'S2VERSION', '10.22' );
58
+ define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
59
+ define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
60
+ define( 'S2URL', plugin_dir_url( dirname( __FILE__ ) ) . S2DIR );
61
 
62
  // Set maximum execution time to 5 minutes - won't affect safe mode
63
+ $safe_mode = array( 'On', 'ON', 'on', 1 );
64
+ if ( ! in_array( ini_get( 'safe_mode' ), $safe_mode ) && ini_get( 'max_execution_time' ) < 300 ) {
65
+ @ini_set( 'max_execution_time', 300 );
66
  }
67
 
68
  require_once( S2PATH . 'classes/class-s2-core.php' );
69
  if ( is_admin() ) {
70
  require_once( S2PATH . 'classes/class-s2-admin.php' );
71
  global $mysubscribe2;
72
+ $mysubscribe2 = new S2_Admin;
 
73
  } else {
74
  require_once( S2PATH . 'classes/class-s2-frontend.php' );
75
  global $mysubscribe2;
76
+ $mysubscribe2 = new S2_Frontend;
 
77
  }
78
+ add_action( 'plugins_loaded', array( $mysubscribe2, 's2init' ) );
 
 
 
 
 
 
79
  ?>
subscribe2.pot DELETED
@@ -1,1638 +0,0 @@
1
- # Copyright (C) 2014 Subscribe2
2
- # This file is distributed under the same license as the Subscribe2 package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Subscribe2 10.3\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/subscribe2\n"
7
- "POT-Creation-Date: 2014-06-03 20:53:48+00:00\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
12
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
- "Language-Team: LANGUAGE <LL@li.org>\n"
14
-
15
- #: admin/app_page.php:15
16
- msgid "Final Step: Place the widget on your site to get started"
17
- msgstr ""
18
-
19
- #: admin/app_page.php:16
20
- msgid "Drag the widget to a prominent place to maximize signups"
21
- msgstr ""
22
-
23
- #: admin/app_page.php:17
24
- msgid "Place Widget Now"
25
- msgstr ""
26
-
27
- #: admin/app_page.php:18
28
- msgid "Tips"
29
- msgstr ""
30
-
31
- #: admin/app_page.php:20
32
- msgid ""
33
- "Already have the widget in place? Manage your ReadyGraph account <a href=\"%s"
34
- "\">here</a>"
35
- msgstr ""
36
-
37
- #: admin/app_page.php:21
38
- msgid ""
39
- "Need help? Email <a href=\"%1$s\">%2$s</a> or click <a href=\"%3$s\">here</a>"
40
- msgstr ""
41
-
42
- #: admin/app_page.php:24
43
- msgid "Unlink ReadyGraph Account"
44
- msgstr ""
45
-
46
- #: admin/app_page.php:31
47
- msgid "Subscribe2, Now with Readygraph"
48
- msgstr ""
49
-
50
- #: admin/app_page.php:32
51
- msgid "Activate Readygraph features to optimize Subscribe2 functionality"
52
- msgstr ""
53
-
54
- #: admin/app_page.php:36
55
- msgid "Free Signup"
56
- msgstr ""
57
-
58
- #: admin/app_page.php:38
59
- msgid "Site URL"
60
- msgstr ""
61
-
62
- #: admin/app_page.php:43
63
- msgid "Name"
64
- msgstr ""
65
-
66
- #: admin/app_page.php:48 admin/app_page.php:73
67
- msgid "Email"
68
- msgstr ""
69
-
70
- #: admin/app_page.php:53 admin/app_page.php:78
71
- msgid "Password"
72
- msgstr ""
73
-
74
- #: admin/app_page.php:58
75
- msgid "Confirm Password"
76
- msgstr ""
77
-
78
- #: admin/app_page.php:62 classes/class-s2-frontend.php:119
79
- msgid ""
80
- "By signing up, you agree to our <a href=\"%1$s\">Terms of Service</a> and <a "
81
- "href=\"%2$s\">Privacy Policy</a>"
82
- msgstr ""
83
-
84
- #: admin/app_page.php:64
85
- msgid "Continue to place widget"
86
- msgstr ""
87
-
88
- #: admin/app_page.php:71
89
- msgid "Already a member?"
90
- msgstr ""
91
-
92
- #: admin/app_page.php:83
93
- msgid "Sign In"
94
- msgstr ""
95
-
96
- #: admin/app_page.php:90
97
- msgid "Signup For These Benefits"
98
- msgstr ""
99
-
100
- #: admin/app_page.php:91
101
- msgid "Grow your subscribers faster"
102
- msgstr ""
103
-
104
- #: admin/app_page.php:92
105
- msgid "Engage users with automated email updates"
106
- msgstr ""
107
-
108
- #: admin/app_page.php:93
109
- msgid "Enhanced email deliverablility"
110
- msgstr ""
111
-
112
- #: admin/app_page.php:94
113
- msgid "Track performace with user-activity analytics"
114
- msgstr ""
115
-
116
- #: admin/send_email.php:71
117
- msgid "Your email was empty"
118
- msgstr ""
119
-
120
- #: admin/send_email.php:78
121
- msgid "Check your settings and check with your hosting provider"
122
- msgstr ""
123
-
124
- #: admin/send_email.php:83
125
- msgid "Preview message sent!"
126
- msgstr ""
127
-
128
- #: admin/send_email.php:85
129
- msgid "Message sent!"
130
- msgstr ""
131
-
132
- #: admin/send_email.php:89
133
- msgid "Message failed!"
134
- msgstr ""
135
-
136
- #: admin/send_email.php:99
137
- msgid "Send an email to subscribers"
138
- msgstr ""
139
-
140
- #: admin/send_email.php:107
141
- msgid "A message from"
142
- msgstr ""
143
-
144
- #: admin/send_email.php:112
145
- msgid "Subject"
146
- msgstr ""
147
-
148
- #: admin/send_email.php:115
149
- msgid "Add More Files"
150
- msgstr ""
151
-
152
- #: admin/send_email.php:117
153
- msgid "Recipients:"
154
- msgstr ""
155
-
156
- #: admin/send_email.php:120
157
- msgid "Preview"
158
- msgstr ""
159
-
160
- #: admin/send_email.php:120
161
- msgid "Send"
162
- msgstr ""
163
-
164
- #: admin/settings.php:13
165
- msgid "Options reset!"
166
- msgstr ""
167
-
168
- #: admin/settings.php:24
169
- msgid "Preview message(s) sent to logged in user"
170
- msgstr ""
171
-
172
- #: admin/settings.php:28
173
- msgid ""
174
- "The Digest Notification email contained no post information. No email was "
175
- "sent"
176
- msgstr ""
177
-
178
- #: admin/settings.php:30
179
- msgid "Attempt made to resend the Digest Notification email"
180
- msgstr ""
181
-
182
- #: admin/settings.php:111
183
- msgid "Options saved!"
184
- msgstr ""
185
-
186
- #: admin/settings.php:120
187
- msgid "You must create a WordPress page for this plugin to work correctly."
188
- msgstr ""
189
-
190
- #: admin/settings.php:135
191
- msgid ""
192
- "Your chosen email type (per-post or digest) does not support the following "
193
- "keywords:"
194
- msgstr ""
195
-
196
- #: admin/settings.php:136
197
- msgid "Modify your template"
198
- msgstr ""
199
-
200
- #: admin/settings.php:149
201
- msgid ""
202
- "You appear to be sending notifications from %1$s, which has a different "
203
- "domain name than your blog server %2$s. This may result in failed emails."
204
- msgstr ""
205
-
206
- #: admin/settings.php:160 classes/class-s2-admin.php:84
207
- msgid "Email Settings"
208
- msgstr ""
209
-
210
- #: admin/settings.php:161 classes/class-s2-admin.php:92
211
- msgid "Templates"
212
- msgstr ""
213
-
214
- #: admin/settings.php:162 classes/class-s2-admin.php:99
215
- msgid "Registered Users"
216
- msgstr ""
217
-
218
- #: admin/settings.php:163 classes/class-s2-admin.php:106
219
- msgid "Appearance"
220
- msgstr ""
221
-
222
- #: admin/settings.php:164 classes/class-s2-admin.php:113
223
- msgid "Miscellaneous"
224
- msgstr ""
225
-
226
- #: admin/settings.php:185
227
- msgid ""
228
- "Restrict the number of <strong>recipients per email</strong> to (0 for "
229
- "unlimited)"
230
- msgstr ""
231
-
232
- #: admin/settings.php:187 admin/settings.php:424
233
- #: classes/class-s2-admin.php:734 classes/class-s2-list-table.php:36
234
- msgid "Edit"
235
- msgstr ""
236
-
237
- #: admin/settings.php:190 admin/settings.php:427
238
- #: classes/class-s2-admin.php:748
239
- msgid "Update"
240
- msgstr ""
241
-
242
- #: admin/settings.php:191 admin/settings.php:428
243
- #: classes/class-s2-admin.php:749
244
- msgid "Revert"
245
- msgstr ""
246
-
247
- #: admin/settings.php:193
248
- msgid "Send Admins notifications for new"
249
- msgstr ""
250
-
251
- #: admin/settings.php:195
252
- msgid "Subscriptions"
253
- msgstr ""
254
-
255
- #: admin/settings.php:197
256
- msgid "Unsubscriptions"
257
- msgstr ""
258
-
259
- #: admin/settings.php:199
260
- msgid "Both"
261
- msgstr ""
262
-
263
- #: admin/settings.php:201
264
- msgid "Neither"
265
- msgstr ""
266
-
267
- #: admin/settings.php:203
268
- msgid "Include theme CSS stylesheet in HTML notifications"
269
- msgstr ""
270
-
271
- #: admin/settings.php:205 admin/settings.php:211 admin/settings.php:225
272
- #: admin/settings.php:230 admin/settings.php:235 admin/settings.php:356
273
- #: admin/settings.php:361 admin/settings.php:375 admin/settings.php:382
274
- #: admin/settings.php:396 admin/settings.php:402 admin/subscribers.php:297
275
- #: admin/your_subscriptions.php:123 admin/your_subscriptions.php:164
276
- msgid "Yes"
277
- msgstr ""
278
-
279
- #: admin/settings.php:207 admin/settings.php:213 admin/settings.php:227
280
- #: admin/settings.php:232 admin/settings.php:237 admin/settings.php:353
281
- #: admin/settings.php:358 admin/settings.php:363 admin/settings.php:377
282
- #: admin/settings.php:384 admin/settings.php:393 admin/settings.php:398
283
- #: admin/settings.php:404 admin/subscribers.php:299
284
- #: admin/your_subscriptions.php:125 admin/your_subscriptions.php:168
285
- msgid "No"
286
- msgstr ""
287
-
288
- #: admin/settings.php:209
289
- msgid "Send Emails for Pages"
290
- msgstr ""
291
-
292
- #: admin/settings.php:217
293
- msgid ""
294
- "Subscribe2 will send email notifications for the following custom post types"
295
- msgstr ""
296
-
297
- #: admin/settings.php:223
298
- msgid "Send Emails for Password Protected Posts"
299
- msgstr ""
300
-
301
- #: admin/settings.php:228
302
- msgid "Send Emails for Private Posts"
303
- msgstr ""
304
-
305
- #: admin/settings.php:233
306
- msgid "Include Sticky Posts at the top of all Digest Notifications"
307
- msgstr ""
308
-
309
- #: admin/settings.php:238
310
- msgid "Send Email From"
311
- msgstr ""
312
-
313
- #: admin/settings.php:243
314
- msgid "Send Emails"
315
- msgstr ""
316
-
317
- #: admin/settings.php:245
318
- msgid "For digest notifications, date order for posts is"
319
- msgstr ""
320
-
321
- #: admin/settings.php:247
322
- msgid "Descending"
323
- msgstr ""
324
-
325
- #: admin/settings.php:249
326
- msgid "Ascending"
327
- msgstr ""
328
-
329
- #: admin/settings.php:251
330
- msgid "Add Tracking Parameters to the Permalink"
331
- msgstr ""
332
-
333
- #: admin/settings.php:253
334
- msgid ""
335
- "eg. utm_source=subscribe2&amp;utm_medium=email&amp;"
336
- "utm_campaign=postnotify&amp;utm_id={ID}&amp;utm_title={TITLE}"
337
- msgstr ""
338
-
339
- #: admin/settings.php:264
340
- msgid "Notification email (must not be empty)"
341
- msgstr ""
342
-
343
- #: admin/settings.php:265 admin/settings.php:296 admin/settings.php:301
344
- msgid "Subject Line"
345
- msgstr ""
346
-
347
- #: admin/settings.php:270
348
- msgid "Send Email Preview"
349
- msgstr ""
350
-
351
- #: admin/settings.php:271
352
- msgid "Message substitutions"
353
- msgstr ""
354
-
355
- #: admin/settings.php:273
356
- msgid ""
357
- "IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED"
358
- msgstr ""
359
-
360
- #: admin/settings.php:276
361
- msgid "the post's title<br />(<i>for per-post emails only</i>)"
362
- msgstr ""
363
-
364
- #: admin/settings.php:277
365
- msgid ""
366
- "the excerpt or the entire post<br />(<i>based on the subscriber's "
367
- "preferences</i>)"
368
- msgstr ""
369
-
370
- #: admin/settings.php:278
371
- msgid ""
372
- "the excerpt of the post and the time it was posted<br />(<i>for digest "
373
- "emails only</i>)"
374
- msgstr ""
375
-
376
- #: admin/settings.php:279
377
- msgid "a list of post titles<br />(<i>for digest emails only</i>)"
378
- msgstr ""
379
-
380
- #: admin/settings.php:280
381
- msgid ""
382
- "a list of post titles followed by links to the articles<br />(<i>for digest "
383
- "emails only</i>)"
384
- msgstr ""
385
-
386
- #: admin/settings.php:281
387
- msgid ""
388
- "a reference style list of links at the end of the email with corresponding "
389
- "numbers in the content<br />(<i>for the full content plain text per-post "
390
- "email only</i>)"
391
- msgstr ""
392
-
393
- #: admin/settings.php:282
394
- msgid "the post's permalink<br />(<i>for per-post emails only</i>)"
395
- msgstr ""
396
-
397
- #: admin/settings.php:283
398
- msgid "the post's permalink after conversion by TinyURL"
399
- msgstr ""
400
-
401
- #: admin/settings.php:284
402
- msgid "the date the post was made<br />(<i>for per-post emails only</i>)"
403
- msgstr ""
404
-
405
- #: admin/settings.php:285
406
- msgid "the time the post was made<br />(<i>for per-post emails only</i>)"
407
- msgstr ""
408
-
409
- #: admin/settings.php:286
410
- msgid "the admin or post author's name"
411
- msgstr ""
412
-
413
- #: admin/settings.php:287
414
- msgid "the admin or post author's email"
415
- msgstr ""
416
-
417
- #: admin/settings.php:288
418
- msgid "the post author's name"
419
- msgstr ""
420
-
421
- #: admin/settings.php:289
422
- msgid ""
423
- "the generated link to confirm a request<br />(<i>only used in the "
424
- "confirmation email template</i>)"
425
- msgstr ""
426
-
427
- #: admin/settings.php:290
428
- msgid ""
429
- "Action performed by LINK in confirmation email<br />(<i>only used in the "
430
- "confirmation email template</i>)"
431
- msgstr ""
432
-
433
- #: admin/settings.php:291
434
- msgid "the post's assigned categories"
435
- msgstr ""
436
-
437
- #: admin/settings.php:292
438
- msgid "the post's assigned Tags"
439
- msgstr ""
440
-
441
- #: admin/settings.php:293
442
- msgid ""
443
- "the number of posts included in the digest email<br />(<i>for digest emails "
444
- "only</i>)"
445
- msgstr ""
446
-
447
- #: admin/settings.php:295
448
- msgid "Subscribe / Unsubscribe confirmation email"
449
- msgstr ""
450
-
451
- #: admin/settings.php:300
452
- msgid "Reminder email to Unconfirmed Subscribers"
453
- msgstr ""
454
-
455
- #: admin/settings.php:312
456
- msgid "Compulsory Categories"
457
- msgstr ""
458
-
459
- #: admin/settings.php:314
460
- msgid ""
461
- "Compulsory categories will be checked by default for Registered Subscribers"
462
- msgstr ""
463
-
464
- #: admin/settings.php:321
465
- msgid "Excluded Categories"
466
- msgstr ""
467
-
468
- #: admin/settings.php:323
469
- msgid ""
470
- "Posts assigned to any Excluded Category do not generate notifications and "
471
- "are not included in digest notifications"
472
- msgstr ""
473
-
474
- #: admin/settings.php:327
475
- msgid "Allow registered users to subscribe to excluded categories?"
476
- msgstr ""
477
-
478
- #: admin/settings.php:335
479
- msgid "Excluded Formats"
480
- msgstr ""
481
-
482
- #: admin/settings.php:337
483
- msgid ""
484
- "Posts assigned to any Excluded Format do not generate notifications and are "
485
- "not included in digest notifications"
486
- msgstr ""
487
-
488
- #: admin/settings.php:345
489
- msgid "Auto-Subscribe"
490
- msgstr ""
491
-
492
- #: admin/settings.php:347
493
- msgid "Subscribe new users registering with your blog"
494
- msgstr ""
495
-
496
- #: admin/settings.php:349
497
- msgid "Automatically"
498
- msgstr ""
499
-
500
- #: admin/settings.php:351
501
- msgid "Display option on Registration Form"
502
- msgstr ""
503
-
504
- #: admin/settings.php:354
505
- msgid "Auto-subscribe includes any excluded categories"
506
- msgstr ""
507
-
508
- #: admin/settings.php:359
509
- msgid "Registration Form option is checked by default"
510
- msgstr ""
511
-
512
- #: admin/settings.php:364
513
- msgid "Auto-subscribe users to receive email as"
514
- msgstr ""
515
-
516
- #: admin/settings.php:366 admin/subscribers.php:283
517
- #: admin/your_subscriptions.php:112
518
- msgid "HTML - Full"
519
- msgstr ""
520
-
521
- #: admin/settings.php:368 admin/subscribers.php:284
522
- #: admin/your_subscriptions.php:114
523
- msgid "HTML - Excerpt"
524
- msgstr ""
525
-
526
- #: admin/settings.php:370 admin/subscribers.php:285
527
- #: admin/your_subscriptions.php:116
528
- msgid "Plain Text - Full"
529
- msgstr ""
530
-
531
- #: admin/settings.php:372 admin/subscribers.php:286
532
- #: admin/your_subscriptions.php:118
533
- msgid "Plain Text - Excerpt"
534
- msgstr ""
535
-
536
- #: admin/settings.php:373
537
- msgid "Registered Users have the option to auto-subscribe to new categories"
538
- msgstr ""
539
-
540
- #: admin/settings.php:379
541
- msgid "New categories are immediately excluded"
542
- msgstr ""
543
-
544
- #: admin/settings.php:380
545
- msgid ""
546
- "Option for Registered Users to auto-subscribe to new categories is checked "
547
- "by default"
548
- msgstr ""
549
-
550
- #: admin/settings.php:387
551
- msgid "Display checkbox to allow subscriptions from the comment form"
552
- msgstr ""
553
-
554
- #: admin/settings.php:389
555
- msgid "Before the Comment Submit button"
556
- msgstr ""
557
-
558
- #: admin/settings.php:391
559
- msgid "After the Comment Submit button"
560
- msgstr ""
561
-
562
- #: admin/settings.php:394
563
- msgid "Comment form checkbox is checked by default"
564
- msgstr ""
565
-
566
- #: admin/settings.php:400
567
- msgid "Show one-click subscription on profile page"
568
- msgstr ""
569
-
570
- #: admin/settings.php:415
571
- msgid "Set default Subscribe2 page as"
572
- msgstr ""
573
-
574
- #: admin/settings.php:417
575
- msgid "Select a page"
576
- msgstr ""
577
-
578
- #: admin/settings.php:422
579
- msgid "Set the number of Subscribers displayed per page"
580
- msgstr ""
581
-
582
- #: admin/settings.php:432
583
- msgid "Show a link to your subscription page in \"meta\"?"
584
- msgstr ""
585
-
586
- #: admin/settings.php:436
587
- msgid "Show the Subscribe2 button on the Write toolbar?"
588
- msgstr ""
589
-
590
- #: admin/settings.php:440
591
- msgid "Enable AJAX style subscription form?"
592
- msgstr ""
593
-
594
- #: admin/settings.php:444
595
- msgid "Enable Subscribe2 Widget?"
596
- msgstr ""
597
-
598
- #: admin/settings.php:448
599
- msgid "Enable Subscribe2 Counter Widget?"
600
- msgstr ""
601
-
602
- #: admin/settings.php:452
603
- msgid "Disable email notifications is checked by default on authoring pages?"
604
- msgstr ""
605
-
606
- #: admin/settings.php:460
607
- msgid "Barred Domains"
608
- msgstr ""
609
-
610
- #: admin/settings.php:462
611
- msgid ""
612
- "Enter domains to bar from public subscriptions: <br /> (Use a new line for "
613
- "each entry and omit the \"@\" symbol, for example email.com)"
614
- msgstr ""
615
-
616
- #: admin/settings.php:465
617
- msgid "Links"
618
- msgstr ""
619
-
620
- #: admin/settings.php:466
621
- msgid "Plugin Site"
622
- msgstr ""
623
-
624
- #: admin/settings.php:467 classes/class-s2-admin.php:180
625
- msgid "Translation Files"
626
- msgstr ""
627
-
628
- #: admin/settings.php:468
629
- msgid "Plugin Forum"
630
- msgstr ""
631
-
632
- #: admin/settings.php:469
633
- msgid "Plugin Blog"
634
- msgstr ""
635
-
636
- #: admin/settings.php:470
637
- msgid "Make a donation via PayPal"
638
- msgstr ""
639
-
640
- #: admin/settings.php:476
641
- msgid "Submit"
642
- msgstr ""
643
-
644
- #: admin/settings.php:480
645
- msgid "Reset to Default Settings"
646
- msgstr ""
647
-
648
- #: admin/settings.php:481
649
- msgid ""
650
- "Use this to reset all options to their defaults. This <strong><em>will not</"
651
- "em></strong> modify your list of subscribers."
652
- msgstr ""
653
-
654
- #: admin/settings.php:483
655
- msgid "RESET"
656
- msgstr ""
657
-
658
- #: admin/subscribers.php:31
659
- msgid "Address(es) subscribed!"
660
- msgstr ""
661
-
662
- #: admin/subscribers.php:38
663
- msgid "Address(es) unsubscribed!"
664
- msgstr ""
665
-
666
- #: admin/subscribers.php:42
667
- msgid ""
668
- "Some emails were not processed, the following are already Registered "
669
- "Subscribers"
670
- msgstr ""
671
-
672
- #: admin/subscribers.php:45
673
- msgid ""
674
- "Some emails were not processed, the following are already Public Subscribers"
675
- msgstr ""
676
-
677
- #: admin/subscribers.php:48
678
- msgid "Some emails were not processed, the following were not in the database"
679
- msgstr ""
680
-
681
- #: admin/subscribers.php:59
682
- msgid "Address(es) deleted!"
683
- msgstr ""
684
-
685
- #: admin/subscribers.php:67
686
- msgid "Delete failed! You cannot delete some or all of these users"
687
- msgstr ""
688
-
689
- #: admin/subscribers.php:70
690
- msgid "User(s) deleted! Any posts made by these users were assigned to you"
691
- msgstr ""
692
-
693
- #: admin/subscribers.php:82
694
- msgid "Status changed!"
695
- msgstr ""
696
-
697
- #: admin/subscribers.php:85
698
- msgid "Reminder Email(s) Sent!"
699
- msgstr ""
700
-
701
- #: admin/subscribers.php:88
702
- msgid "Registered Users Subscribed!"
703
- msgstr ""
704
-
705
- #: admin/subscribers.php:91
706
- msgid "Registered Users Unsubscribed!"
707
- msgstr ""
708
-
709
- #: admin/subscribers.php:94
710
- msgid "Format updated for Selected Registered Users!"
711
- msgstr ""
712
-
713
- #: admin/subscribers.php:97
714
- msgid "Digest Subscription updated for Selected Registered Users!"
715
- msgstr ""
716
-
717
- #: admin/subscribers.php:186 classes/class-s2-admin.php:63
718
- #: classes/class-s2-admin.php:580
719
- msgid "Public Subscribers"
720
- msgstr ""
721
-
722
- #: admin/subscribers.php:186 classes/class-s2-admin.php:68
723
- #: classes/class-s2-admin.php:584
724
- msgid "Registered Subscribers"
725
- msgstr ""
726
-
727
- #: admin/subscribers.php:198 admin/subscribers.php:220
728
- msgid "Add/Remove Subscribers"
729
- msgstr ""
730
-
731
- #: admin/subscribers.php:199
732
- msgid "Enter addresses, one per line or comma-separated"
733
- msgstr ""
734
-
735
- #: admin/subscribers.php:202 admin/subscribers.php:274
736
- #: admin/your_subscriptions.php:263 classes/class-s2-frontend.php:67
737
- msgid "Subscribe"
738
- msgstr ""
739
-
740
- #: admin/subscribers.php:203 admin/subscribers.php:275
741
- #: admin/your_subscriptions.php:242 classes/class-s2-frontend.php:66
742
- msgid "Unsubscribe"
743
- msgstr ""
744
-
745
- #: admin/subscribers.php:208 admin/subscribers.php:227
746
- msgid "Current Subscribers"
747
- msgstr ""
748
-
749
- #: admin/subscribers.php:221
750
- msgid "Add Registered User"
751
- msgstr ""
752
-
753
- #: admin/subscribers.php:236
754
- msgid "Filter"
755
- msgstr ""
756
-
757
- #: admin/subscribers.php:240
758
- msgid "Send Reminder Email"
759
- msgstr ""
760
-
761
- #: admin/subscribers.php:247
762
- msgid "Save Emails to CSV File"
763
- msgstr ""
764
-
765
- #: admin/subscribers.php:254
766
- msgid "Search"
767
- msgstr ""
768
-
769
- #: admin/subscribers.php:261
770
- msgid "Bulk Management"
771
- msgstr ""
772
-
773
- #: admin/subscribers.php:271 admin/subscribers.php:293
774
- msgid ""
775
- "Preferences for Registered Users selected in the filter above can be changed "
776
- "using this section."
777
- msgstr ""
778
-
779
- #: admin/subscribers.php:272 admin/subscribers.php:294
780
- msgid "Consider User Privacy as changes cannot be undone"
781
- msgstr ""
782
-
783
- #: admin/subscribers.php:273
784
- msgid "Action to perform"
785
- msgstr ""
786
-
787
- #: admin/subscribers.php:281
788
- msgid "Bulk Update Categories"
789
- msgstr ""
790
-
791
- #: admin/subscribers.php:282
792
- msgid "Send email as"
793
- msgstr ""
794
-
795
- #: admin/subscribers.php:287
796
- msgid "Bulk Update Format"
797
- msgstr ""
798
-
799
- #: admin/subscribers.php:295
800
- msgid "Subscribe Selected Users to receive a periodic digest notification"
801
- msgstr ""
802
-
803
- #: admin/subscribers.php:300
804
- msgid "Bulk Update Digest Subscription"
805
- msgstr ""
806
-
807
- #: admin/subscribers.php:314
808
- msgid "You are about to delete user account(s). Are you sure?"
809
- msgstr ""
810
-
811
- #: admin/your_subscriptions.php:90
812
- msgid "Subscription preferences updated."
813
- msgstr ""
814
-
815
- #: admin/your_subscriptions.php:98
816
- msgid "Notification Settings"
817
- msgstr ""
818
-
819
- #: admin/your_subscriptions.php:101
820
- msgid "Editing Subscribe2 preferences for user"
821
- msgstr ""
822
-
823
- #: admin/your_subscriptions.php:110
824
- msgid "Receive email as"
825
- msgstr ""
826
-
827
- #: admin/your_subscriptions.php:121
828
- msgid "Automatically subscribe me to newly created categories"
829
- msgstr ""
830
-
831
- #: admin/your_subscriptions.php:131
832
- msgid "One Click Subscription / Unsubscription"
833
- msgstr ""
834
-
835
- #: admin/your_subscriptions.php:132
836
- msgid "Subscribe to All"
837
- msgstr ""
838
-
839
- #: admin/your_subscriptions.php:133
840
- msgid "Unsubscribe from All"
841
- msgstr ""
842
-
843
- #: admin/your_subscriptions.php:143
844
- msgid "Unsubscribe me from this blog"
845
- msgstr ""
846
-
847
- #: admin/your_subscriptions.php:147
848
- msgid "Subscribe to all categories"
849
- msgstr ""
850
-
851
- #: admin/your_subscriptions.php:149
852
- msgid "Subscribed Categories on"
853
- msgstr ""
854
-
855
- #: admin/your_subscriptions.php:151
856
- msgid "Subscribed Categories"
857
- msgstr ""
858
-
859
- #: admin/your_subscriptions.php:158
860
- msgid "Receive periodic summaries of new posts?"
861
- msgstr ""
862
-
863
- #: admin/your_subscriptions.php:174
864
- msgid "Do not send notifications for post made by these authors"
865
- msgstr ""
866
-
867
- #: admin/your_subscriptions.php:180
868
- msgid "Update Preferences"
869
- msgstr ""
870
-
871
- #: admin/your_subscriptions.php:231
872
- msgid "Subscribed Blogs"
873
- msgstr ""
874
-
875
- #: admin/your_subscriptions.php:236 admin/your_subscriptions.php:257
876
- msgid "Viewing Settings Now"
877
- msgstr ""
878
-
879
- #: admin/your_subscriptions.php:240 admin/your_subscriptions.php:261
880
- msgid "View Settings"
881
- msgstr ""
882
-
883
- #: admin/your_subscriptions.php:252
884
- msgid "Subscribe to new blogs"
885
- msgstr ""
886
-
887
- #. #-#-#-#-# subscribe2.pot (Subscribe2 10.3) #-#-#-#-#
888
- #. Plugin Name of the plugin/theme
889
- #: classes/class-s2-admin.php:8 include/widget.php:16
890
- msgid "Subscribe2"
891
- msgstr ""
892
-
893
- #: classes/class-s2-admin.php:10
894
- msgid "Your Subscriptions"
895
- msgstr ""
896
-
897
- #: classes/class-s2-admin.php:15
898
- msgid "Readygraph App"
899
- msgstr ""
900
-
901
- #: classes/class-s2-admin.php:18
902
- msgid "Subscribers"
903
- msgstr ""
904
-
905
- #: classes/class-s2-admin.php:22 classes/class-s2-admin.php:179
906
- msgid "Settings"
907
- msgstr ""
908
-
909
- #: classes/class-s2-admin.php:28
910
- msgid "Send Email"
911
- msgstr ""
912
-
913
- #: classes/class-s2-admin.php:42 classes/class-s2-admin.php:48
914
- #: classes/class-s2-admin.php:58 classes/class-s2-admin.php:79
915
- #: classes/class-s2-admin.php:124
916
- msgid "Overview"
917
- msgstr ""
918
-
919
- #: classes/class-s2-admin.php:43
920
- msgid ""
921
- "From this page you can opt in or out of receiving a periodical digest style "
922
- "email of blog posts."
923
- msgstr ""
924
-
925
- #: classes/class-s2-admin.php:49
926
- msgid ""
927
- "From this page you can control your subscription preferences. Choose the "
928
- "email format you wish to receive, which categories you would like to receive "
929
- "notification for and depending on the site settings which authors you would "
930
- "like to read."
931
- msgstr ""
932
-
933
- #: classes/class-s2-admin.php:59
934
- msgid "From this page you can manage your subscribers."
935
- msgstr ""
936
-
937
- #: classes/class-s2-admin.php:64
938
- msgid ""
939
- "Public Subscribers are subscribers who have used the plugin form and only "
940
- "provided their email address."
941
- msgstr ""
942
-
943
- #: classes/class-s2-admin.php:64
944
- msgid ""
945
- "On this page public subscribers can be viewed, searched, deleted and also "
946
- "toggled between Confirmed and Unconfirmed status."
947
- msgstr ""
948
-
949
- #: classes/class-s2-admin.php:69
950
- msgid ""
951
- "Registered Subscribers are subscribers who have registered in WordPress and "
952
- "have a username and password."
953
- msgstr ""
954
-
955
- #: classes/class-s2-admin.php:70
956
- msgid ""
957
- "Registered Subscribers have greater personal control over their "
958
- "subscription. They can change the format of the email and also select which "
959
- "categories and authors they want to receive notifications about."
960
- msgstr ""
961
-
962
- #: classes/class-s2-admin.php:71
963
- msgid ""
964
- "On this page registered subscribers can be viewed and searched. User "
965
- "accounts can be deleted from here with any posts created by those users "
966
- "being assigned to the currently logged in user. Bulk changes can be applied "
967
- "to all user settings changing their subscription email format and categories."
968
- msgstr ""
969
-
970
- #: classes/class-s2-admin.php:80
971
- msgid "From this page you can adjust the Settings for Subscribe2."
972
- msgstr ""
973
-
974
- #: classes/class-s2-admin.php:85
975
- msgid ""
976
- "This section allows you to specify settings that apply to the emails "
977
- "generated by the site."
978
- msgstr ""
979
-
980
- #: classes/class-s2-admin.php:86
981
- msgid ""
982
- "Emails can be sent to individual subscribers by setting the number of "
983
- "recipients per email to 1. A setting greater than one will group recipients "
984
- "together and make use of the BCC emails header. A setting of 0 sends a "
985
- "single email with all subscribers in one large BCC group. A setting of 1 "
986
- "looks less like spam email to filters but takes longer to process."
987
- msgstr ""
988
-
989
- #: classes/class-s2-admin.php:87
990
- msgid ""
991
- "This section is also where the sender of the email on this page is chosen. "
992
- "You can choose Post Author or your Blogname but it is recommended to create "
993
- "a user account with an email address that really exists and shares the same "
994
- "domain name as your site (the bit after the @ should be the same as your "
995
- "sites web address) and then use this account."
996
- msgstr ""
997
-
998
- #: classes/class-s2-admin.php:88
999
- msgid ""
1000
- "This page also configures the frequency of emails. This can be at the time "
1001
- "new posts are made (per post) or periodically with an excerpt of each post "
1002
- "made (digest). Additionally the post types (pages, private, password "
1003
- "protected) can also be configured here."
1004
- msgstr ""
1005
-
1006
- #: classes/class-s2-admin.php:93
1007
- msgid ""
1008
- "This section allows you to customise the content of your notification emails."
1009
- msgstr ""
1010
-
1011
- #: classes/class-s2-admin.php:94
1012
- msgid ""
1013
- "There are special {KEYWORDS} that are used by Subscribe2 to place content "
1014
- "into the final email. The template also accepts regular text and HTML as "
1015
- "desired in the final emails."
1016
- msgstr ""
1017
-
1018
- #: classes/class-s2-admin.php:95
1019
- msgid ""
1020
- "The {KEYWORDS} are listed on the right of the templates, note that some are "
1021
- "for per post emails only and some are for digest emails only. Make sure the "
1022
- "correct keywords are used based upon the Email Settings."
1023
- msgstr ""
1024
-
1025
- #: classes/class-s2-admin.php:100
1026
- msgid ""
1027
- "This section allows settings that apply to Registered Subscribers to be "
1028
- "configured."
1029
- msgstr ""
1030
-
1031
- #: classes/class-s2-admin.php:101
1032
- msgid ""
1033
- "Categories can be made compulsory so emails are always sent for posts in "
1034
- "these categories. They can also be excludes so that emails are not "
1035
- "generated. Excluded categories take precedence over Compulsory categories."
1036
- msgstr ""
1037
-
1038
- #: classes/class-s2-admin.php:102
1039
- msgid ""
1040
- "A set of default settings for new users can also be specified using the Auto "
1041
- "Subscribe section. Settings specified here will be applied to any newly "
1042
- "created user accounts while Subscribe2 is activated."
1043
- msgstr ""
1044
-
1045
- #: classes/class-s2-admin.php:107
1046
- msgid ""
1047
- "This section allows you to enable several aspect of the plugin such as "
1048
- "Widgets and editor buttons."
1049
- msgstr ""
1050
-
1051
- #: classes/class-s2-admin.php:108
1052
- msgid ""
1053
- "AJAX mode can be enabled that is intended to work with the shortcode link "
1054
- "parameter so that a dialog opens in the centre of the browser rather then "
1055
- "using the regular form."
1056
- msgstr ""
1057
-
1058
- #: classes/class-s2-admin.php:109
1059
- msgid ""
1060
- "The email over ride check box can be set to be automatically checked for "
1061
- "every new post and page from here to, this may be useful if you will only "
1062
- "want to send very occasional notifications for specific posts. You can then "
1063
- "uncheck this box just before you publish your content."
1064
- msgstr ""
1065
-
1066
- #: classes/class-s2-admin.php:114
1067
- msgid ""
1068
- "This section contains a place to bar specified domains from becoming Public "
1069
- "Subscribers and links to help and support pages."
1070
- msgstr ""
1071
-
1072
- #: classes/class-s2-admin.php:115
1073
- msgid ""
1074
- "In the paid Subscribe2 HTML version there is also a place here to enter a "
1075
- "license code so that updates can be accessed automatically."
1076
- msgstr ""
1077
-
1078
- #: classes/class-s2-admin.php:125
1079
- msgid ""
1080
- "From this page you can send emails to the recipients in the group selected "
1081
- "in the drop down."
1082
- msgstr ""
1083
-
1084
- #: classes/class-s2-admin.php:126
1085
- msgid ""
1086
- "<strong>Preview</strong> will send a preview of the email to the currently "
1087
- "logged in user. <strong>Send</strong> will send the email to the recipient "
1088
- "list."
1089
- msgstr ""
1090
-
1091
- #: classes/class-s2-admin.php:167
1092
- msgid "Email is empty!"
1093
- msgstr ""
1094
-
1095
- #: classes/class-s2-admin.php:168
1096
- msgid "Password is empty!"
1097
- msgstr ""
1098
-
1099
- #: classes/class-s2-admin.php:169
1100
- msgid "Site URL is empty!"
1101
- msgstr ""
1102
-
1103
- #: classes/class-s2-admin.php:170
1104
- msgid "Password is not matching!"
1105
- msgstr ""
1106
-
1107
- #: classes/class-s2-admin.php:181
1108
- msgid "Donate"
1109
- msgstr ""
1110
-
1111
- #: classes/class-s2-admin.php:289 classes/class-s2-admin.php:290
1112
- msgid "Subscribe2 Notification Override"
1113
- msgstr ""
1114
-
1115
- #: classes/class-s2-admin.php:300
1116
- msgid ""
1117
- "Check here to disable sending of an email notification for this post/page"
1118
- msgstr ""
1119
-
1120
- #: classes/class-s2-admin.php:372
1121
- msgctxt "Comma Separated Column Header names for CSV Export"
1122
- msgid "User Email,User Type,User Name,Confirm Date,IP"
1123
- msgstr ""
1124
-
1125
- #: classes/class-s2-admin.php:397
1126
- msgid "Registered User"
1127
- msgstr ""
1128
-
1129
- #: classes/class-s2-admin.php:402
1130
- msgid "Confirmed Public Subscriber"
1131
- msgstr ""
1132
-
1133
- #: classes/class-s2-admin.php:404
1134
- msgid "Unconfirmed Public Subscriber"
1135
- msgstr ""
1136
-
1137
- #: classes/class-s2-admin.php:430 classes/class-s2-admin.php:487
1138
- #: classes/class-s2-admin.php:527
1139
- msgid "Select / Unselect All"
1140
- msgstr ""
1141
-
1142
- #: classes/class-s2-admin.php:579
1143
- msgid "All Users and Subscribers"
1144
- msgstr ""
1145
-
1146
- #: classes/class-s2-admin.php:581
1147
- msgid "Confirmed"
1148
- msgstr ""
1149
-
1150
- #: classes/class-s2-admin.php:582
1151
- msgid "Unconfirmed"
1152
- msgstr ""
1153
-
1154
- #: classes/class-s2-admin.php:583
1155
- msgid "All Registered Users"
1156
- msgstr ""
1157
-
1158
- #: classes/class-s2-admin.php:679
1159
- msgid "Post Author"
1160
- msgstr ""
1161
-
1162
- #: classes/class-s2-admin.php:703
1163
- msgid ""
1164
- "The WordPress cron functions may be disabled on this server. Digest "
1165
- "notifications may not work."
1166
- msgstr ""
1167
-
1168
- #: classes/class-s2-admin.php:708
1169
- msgid "For each Post"
1170
- msgstr ""
1171
-
1172
- #: classes/class-s2-admin.php:725
1173
- msgid "Current UTC time is"
1174
- msgstr ""
1175
-
1176
- #: classes/class-s2-admin.php:727
1177
- msgid "Current blog time is"
1178
- msgstr ""
1179
-
1180
- #: classes/class-s2-admin.php:729
1181
- msgid "Next email notification will be sent when your blog time is after"
1182
- msgstr ""
1183
-
1184
- #: classes/class-s2-admin.php:751
1185
- msgid "Attempt to resend the last Digest Notification email"
1186
- msgstr ""
1187
-
1188
- #: classes/class-s2-admin.php:752
1189
- msgid "Resend Digest"
1190
- msgstr ""
1191
-
1192
- #: classes/class-s2-admin.php:991
1193
- msgid "Email subscription"
1194
- msgstr ""
1195
-
1196
- #: classes/class-s2-admin.php:993
1197
- msgid "Subscribe / Unsubscribe"
1198
- msgstr ""
1199
-
1200
- #: classes/class-s2-admin.php:994
1201
- msgid "Receive notifications"
1202
- msgstr ""
1203
-
1204
- #: classes/class-s2-admin.php:995
1205
- msgid ""
1206
- "Check if you want to receive email notification when new posts are published"
1207
- msgstr ""
1208
-
1209
- #: classes/class-s2-core.php:597
1210
- msgid "Plain Text Excerpt Preview"
1211
- msgstr ""
1212
-
1213
- #: classes/class-s2-core.php:599
1214
- msgid "Plain Text Full Preview"
1215
- msgstr ""
1216
-
1217
- #: classes/class-s2-core.php:601
1218
- msgid "HTML Excerpt Preview"
1219
- msgstr ""
1220
-
1221
- #: classes/class-s2-core.php:603
1222
- msgid "HTML Full Preview"
1223
- msgstr ""
1224
-
1225
- #: classes/class-s2-core.php:639
1226
- msgid "Like"
1227
- msgstr ""
1228
-
1229
- #: classes/class-s2-core.php:642
1230
- msgid "Tweet"
1231
- msgstr ""
1232
-
1233
- #: classes/class-s2-core.php:645
1234
- msgid "Google+"
1235
- msgstr ""
1236
-
1237
- #: classes/class-s2-core.php:1167
1238
- msgid "Check here to Subscribe to email notifications for new posts"
1239
- msgstr ""
1240
-
1241
- #: classes/class-s2-core.php:1173
1242
- msgid ""
1243
- "By registering with this blog you are also agreeing to receive email "
1244
- "notifications for new posts but you can unsubscribe at anytime"
1245
- msgstr ""
1246
-
1247
- #: classes/class-s2-core.php:1199
1248
- msgid "Check here to Subscribe to notifications for new posts"
1249
- msgstr ""
1250
-
1251
- #: classes/class-s2-core.php:1298
1252
- msgid "Weekly"
1253
- msgstr ""
1254
-
1255
- #: classes/class-s2-core.php:1451 classes/class-s2-core.php:1452
1256
- msgid "Author"
1257
- msgstr ""
1258
-
1259
- #: classes/class-s2-core.php:1458
1260
- msgid "Posted on"
1261
- msgstr ""
1262
-
1263
- #: classes/class-s2-core.php:1476 classes/class-s2-core.php:1477
1264
- msgid "Posted in"
1265
- msgstr ""
1266
-
1267
- #: classes/class-s2-core.php:1482 classes/class-s2-core.php:1483
1268
- msgid "Tagged as"
1269
- msgstr ""
1270
-
1271
- #: classes/class-s2-core.php:1556
1272
- msgid "Digest Email"
1273
- msgstr ""
1274
-
1275
- #: classes/class-s2-core.php:1569
1276
- msgid "Digest Preview"
1277
- msgstr ""
1278
-
1279
- #: classes/class-s2-frontend.php:7
1280
- msgid "To manage your subscription options please <a href=\"%1$s\">login.</a>"
1281
- msgstr ""
1282
-
1283
- #: classes/class-s2-frontend.php:9
1284
- msgid ""
1285
- "You may manage your subscription options from your <a href=\"%1$s\">profile</"
1286
- "a>"
1287
- msgstr ""
1288
-
1289
- #: classes/class-s2-frontend.php:15
1290
- msgid ""
1291
- "<a href=\"%1$s\">Subscribe</a> to email notifications when this blog posts "
1292
- "new content."
1293
- msgstr ""
1294
-
1295
- #: classes/class-s2-frontend.php:19
1296
- msgid "A confirmation message is on its way!"
1297
- msgstr ""
1298
-
1299
- #: classes/class-s2-frontend.php:21
1300
- msgid "That email address is already subscribed."
1301
- msgstr ""
1302
-
1303
- #: classes/class-s2-frontend.php:23
1304
- msgid "That email address is not subscribed."
1305
- msgstr ""
1306
-
1307
- #: classes/class-s2-frontend.php:25
1308
- msgid "Sorry, but that does not look like an email address to me."
1309
- msgstr ""
1310
-
1311
- #: classes/class-s2-frontend.php:27
1312
- msgid ""
1313
- "Sorry, email addresses at that domain are currently barred due to spam, "
1314
- "please use an alternative email address."
1315
- msgstr ""
1316
-
1317
- #: classes/class-s2-frontend.php:29
1318
- msgid ""
1319
- "Sorry, there seems to be an error on the server. Please try again later."
1320
- msgstr ""
1321
-
1322
- #: classes/class-s2-frontend.php:32
1323
- msgid "No such email address is registered."
1324
- msgstr ""
1325
-
1326
- #: classes/class-s2-frontend.php:34
1327
- msgid "You have successfully subscribed!"
1328
- msgstr ""
1329
-
1330
- #: classes/class-s2-frontend.php:36
1331
- msgid "You have successfully unsubscribed."
1332
- msgstr ""
1333
-
1334
- #: classes/class-s2-frontend.php:38
1335
- msgid "subscribe"
1336
- msgstr ""
1337
-
1338
- #: classes/class-s2-frontend.php:40
1339
- msgid "unsubscribe"
1340
- msgstr ""
1341
-
1342
- #: classes/class-s2-frontend.php:97
1343
- msgid "Enter email address..."
1344
- msgstr ""
1345
-
1346
- #: classes/class-s2-frontend.php:124 classes/class-s2-frontend.php:126
1347
- msgid "Your email:"
1348
- msgstr ""
1349
-
1350
- #: classes/class-s2-frontend.php:174
1351
- msgid "Slow down, you move too fast."
1352
- msgstr ""
1353
-
1354
- #: classes/class-s2-frontend.php:273
1355
- msgid "Subscription Confirmation"
1356
- msgstr ""
1357
-
1358
- #: classes/class-s2-frontend.php:275
1359
- msgid "Unsubscription Confirmation"
1360
- msgstr ""
1361
-
1362
- #: classes/class-s2-frontend.php:314
1363
- msgid "New Subscription"
1364
- msgstr ""
1365
-
1366
- #: classes/class-s2-frontend.php:316
1367
- msgid "subscribed to email notifications!"
1368
- msgstr ""
1369
-
1370
- #: classes/class-s2-frontend.php:338
1371
- msgid "New Unsubscription"
1372
- msgstr ""
1373
-
1374
- #: classes/class-s2-frontend.php:340
1375
- msgid "unsubscribed from email notifications!"
1376
- msgstr ""
1377
-
1378
- #: classes/class-s2-frontend.php:367
1379
- msgid "[Un]Subscribe to Posts"
1380
- msgstr ""
1381
-
1382
- #: classes/class-s2-frontend.php:402 classes/class-s2-frontend.php:404
1383
- msgid "Subscribe to this blog"
1384
- msgstr ""
1385
-
1386
- #: classes/class-s2-list-table.php:57 classes/class-s2-list-table.php:62
1387
- #: classes/class-s2-list-table.php:68
1388
- msgctxt "column name"
1389
- msgid "Email"
1390
- msgstr ""
1391
-
1392
- #: classes/class-s2-list-table.php:69
1393
- msgctxt "column name"
1394
- msgid "Date"
1395
- msgstr ""
1396
-
1397
- #: classes/class-s2-list-table.php:95 classes/class-s2-list-table.php:100
1398
- msgid "Delete"
1399
- msgstr ""
1400
-
1401
- #: classes/class-s2-list-table.php:101
1402
- msgid "Toggle"
1403
- msgstr ""
1404
-
1405
- #: classes/class-s2-list-table.php:119
1406
- msgid "1 item"
1407
- msgid_plural "%s items"
1408
- msgstr[0] ""
1409
- msgstr[1] ""
1410
-
1411
- #: classes/class-s2-list-table.php:157
1412
- msgid "Go to the first page"
1413
- msgstr ""
1414
-
1415
- #: classes/class-s2-list-table.php:164
1416
- msgid "Go to the previous page"
1417
- msgstr ""
1418
-
1419
- #: classes/class-s2-list-table.php:173
1420
- msgid "Current page"
1421
- msgstr ""
1422
-
1423
- #: classes/class-s2-list-table.php:180
1424
- msgctxt "paging"
1425
- msgid "%1$s of %2$s"
1426
- msgstr ""
1427
-
1428
- #: classes/class-s2-list-table.php:184
1429
- msgid "Go to the next page"
1430
- msgstr ""
1431
-
1432
- #: classes/class-s2-list-table.php:191
1433
- msgid "Go to the last page"
1434
- msgstr ""
1435
-
1436
- #: include/counterwidget.php:7
1437
- msgid "Subscriber Counter widget for Subscribe2"
1438
- msgstr ""
1439
-
1440
- #: include/counterwidget.php:9
1441
- msgid "Subscribe2 Counter"
1442
- msgstr ""
1443
-
1444
- #: include/counterwidget.php:73
1445
- msgid "Widget Title"
1446
- msgstr ""
1447
-
1448
- #: include/counterwidget.php:78
1449
- msgid "Color Scheme"
1450
- msgstr ""
1451
-
1452
- #: include/counterwidget.php:80
1453
- msgid "Body"
1454
- msgstr ""
1455
-
1456
- #: include/counterwidget.php:82
1457
- msgid "Text"
1458
- msgstr ""
1459
-
1460
- #: include/counterwidget.php:87
1461
- msgid "Width, Height and Font Size"
1462
- msgstr ""
1463
-
1464
- #: include/counterwidget.php:89
1465
- msgid "Width"
1466
- msgstr ""
1467
-
1468
- #: include/counterwidget.php:91
1469
- msgid "Height"
1470
- msgstr ""
1471
-
1472
- #: include/counterwidget.php:93
1473
- msgid "Font"
1474
- msgstr ""
1475
-
1476
- #: include/options.php:138
1477
- msgid ""
1478
- "{BLOGNAME} has posted a new item, '{TITLE}'\n"
1479
- "\n"
1480
- "{POST}\n"
1481
- "\n"
1482
- "You may view the latest post at\n"
1483
- "{PERMALINK}\n"
1484
- "\n"
1485
- "You received this e-mail because you asked to be notified when new updates "
1486
- "are posted.\n"
1487
- "Best regards,\n"
1488
- "{MYNAME}\n"
1489
- "{EMAIL}"
1490
- msgstr ""
1491
-
1492
- #: include/options.php:146
1493
- msgid ""
1494
- "{BLOGNAME} has received a request to {ACTION} for this email address. To "
1495
- "complete your request please click on the link below:\n"
1496
- "\n"
1497
- "{LINK}\n"
1498
- "\n"
1499
- "If you did not request this, please feel free to disregard this notice!\n"
1500
- "\n"
1501
- "Thank you,\n"
1502
- "{MYNAME}."
1503
- msgstr ""
1504
-
1505
- #: include/options.php:150
1506
- msgid "Please confirm your request"
1507
- msgstr ""
1508
-
1509
- #: include/options.php:154
1510
- msgid ""
1511
- "This email address was subscribed for notifications at {BLOGNAME} "
1512
- "({BLOGLINK}) but the subscription remains incomplete.\n"
1513
- "\n"
1514
- "If you wish to complete your subscription please click on the link below:\n"
1515
- "\n"
1516
- "{LINK}\n"
1517
- "\n"
1518
- "If you do not wish to complete your subscription please ignore this email "
1519
- "and your address will be removed from our database.\n"
1520
- "\n"
1521
- "Regards,\n"
1522
- "{MYNAME}"
1523
- msgstr ""
1524
-
1525
- #: include/options.php:158
1526
- msgid "Subscription Reminder"
1527
- msgstr ""
1528
-
1529
- #: include/widget.php:7
1530
- msgid "Sidebar Widget for Subscribe2"
1531
- msgstr ""
1532
-
1533
- #: include/widget.php:9
1534
- msgid "Subscribe2 Widget"
1535
- msgstr ""
1536
-
1537
- #: include/widget.php:30
1538
- msgid "(Un)Subscribe to Posts"
1539
- msgstr ""
1540
-
1541
- #: include/widget.php:114
1542
- msgid "Title"
1543
- msgstr ""
1544
-
1545
- #: include/widget.php:116
1546
- msgid "Div class name"
1547
- msgstr ""
1548
-
1549
- #: include/widget.php:118
1550
- msgid "Pre-Content"
1551
- msgstr ""
1552
-
1553
- #: include/widget.php:120
1554
- msgid "Post-Content"
1555
- msgstr ""
1556
-
1557
- #: include/widget.php:122
1558
- msgid "Text Box Size"
1559
- msgstr ""
1560
-
1561
- #: include/widget.php:124
1562
- msgid "Display options"
1563
- msgstr ""
1564
-
1565
- #: include/widget.php:125
1566
- msgid "Show complete form"
1567
- msgstr ""
1568
-
1569
- #: include/widget.php:126
1570
- msgid "Hide Subscribe button"
1571
- msgstr ""
1572
-
1573
- #: include/widget.php:127
1574
- msgid "Hide Unsubscribe button"
1575
- msgstr ""
1576
-
1577
- #: include/widget.php:129
1578
- msgid "Show as link"
1579
- msgstr ""
1580
-
1581
- #: include/widget.php:132
1582
- msgid "Post form content to page"
1583
- msgstr ""
1584
-
1585
- #: include/widget.php:134
1586
- msgid "Use Subscribe2 Default"
1587
- msgstr ""
1588
-
1589
- #: include/widget.php:137
1590
- msgid "Use Home Page"
1591
- msgstr ""
1592
-
1593
- #: include/widget.php:140
1594
- msgid "Use Referring Page"
1595
- msgstr ""
1596
-
1597
- #: include/widget.php:143
1598
- msgid "Disable JavaScript"
1599
- msgstr ""
1600
-
1601
- #: include/widget.php:146
1602
- msgid "Disable Anti-spam measures"
1603
- msgstr ""
1604
-
1605
- #: include/widget.php:149
1606
- msgid "Disable wrapping of form buttons"
1607
- msgstr ""
1608
-
1609
- #: subscribe2.php:37
1610
- msgid "I'm just a plugin, please don't call me directly"
1611
- msgstr ""
1612
-
1613
- #: subscribe2.php:40
1614
- msgid ""
1615
- "This version of Subscribe2 requires WordPress 3.3 or greater. Please update "
1616
- "%1$s or use an older version of %2$s."
1617
- msgstr ""
1618
-
1619
- #: subscribe2.php:52
1620
- msgid ""
1621
- "Subscribe2 cannot be activated as a network plugin. Please activate it on a "
1622
- "site level"
1623
- msgstr ""
1624
-
1625
- #. #-#-#-#-# subscribe2.pot (Subscribe2 10.3) #-#-#-#-#
1626
- #. Plugin URI of the plugin/theme
1627
- #. #-#-#-#-# subscribe2.pot (Subscribe2 10.3) #-#-#-#-#
1628
- #. Author URI of the plugin/theme
1629
- msgid "http://subscribe2.wordpress.com"
1630
- msgstr ""
1631
-
1632
- #. Description of the plugin/theme
1633
- msgid "Notifies an email list when new entries are posted."
1634
- msgstr ""
1635
-
1636
- #. Author of the plugin/theme
1637
- msgid "Matthew Robinson"
1638
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tinymce/css/content.css CHANGED
@@ -1 +1,9 @@
1
- .mceSubscribe2 {display:block;border:0;width:100%;height:12px;border-top:1px;margin-top:15px;background:#fff url(../../include/s2_marker.png) no-repeat center top;}
 
 
 
 
 
 
 
 
1
+ .mceSubscribe2 {
2
+ display:block;
3
+ width:100%;
4
+ height:12px;
5
+ margin-top:15px;
6
+ border:0;
7
+ border-top:1px;
8
+ background:url(../../include/s2-marker.png) center top no-repeat #fff;
9
+ }
tinymce/css/content.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .mceSubscribe2{display:block;width:100%;height:12px;margin-top:15px;border:0;border-top:1px;background:url(../../include/s2-marker.png) center top no-repeat #fff;}
tinymce/{editor_plugin3.js → editor-plugin3.js} RENAMED
@@ -7,7 +7,7 @@
7
  cls = 'mceSubscribe2',
8
  shortcode = '[subscribe2]',
9
  pbreplaced = [],
10
- pbRE = new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),
11
  replacer = function ( str ) {
12
  if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
13
  str = pbreplaced[i];
@@ -23,14 +23,13 @@
23
  // Register buttons
24
  ed.addButton( 'subscribe2', {
25
  title : 'Insert Subscribe2 Token',
26
- image : url + '/../include/s2_button.png',
27
  cmd : cls
28
  });
29
 
30
  // load the CSS and enable it on the right class
31
  ed.onInit.add(function () {
32
- ed.dom.loadCSS( url + '/css/content.css' );
33
-
34
  if ( ed.theme.onResolveName ) {
35
  ed.theme.onResolveName.add(function ( th, o ) {
36
  if ( o.node.nodeName === 'IMG' && ed.dom.hasClass( o.node, cls ) ) {
@@ -43,7 +42,6 @@
43
  // allow selection of the image placeholder
44
  ed.onClick.add(function ( ed, e ) {
45
  e = e.target;
46
-
47
  if ( e.nodeName === 'IMG' && ed.dom.hasClass( e, cls ) ) {
48
  ed.selection.select( e );
49
  }
@@ -67,7 +65,7 @@
67
  if ( o.get ) {
68
  if ( null !== pbreplaced ) {
69
  for ( i = 0; i < pbreplaced.length; i++ ) {
70
- o.content = o.content.replace(/<img[^>]+>/, replacer );
71
  }
72
  }
73
  o.content = o.content.replace( /<img[^>]+>/g, function ( im ) {
7
  cls = 'mceSubscribe2',
8
  shortcode = '[subscribe2]',
9
  pbreplaced = [],
10
+ pbRE = new RegExp( /(\[|<!--)subscribe2.*?(\]|-->)/g ),
11
  replacer = function ( str ) {
12
  if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
13
  str = pbreplaced[i];
23
  // Register buttons
24
  ed.addButton( 'subscribe2', {
25
  title : 'Insert Subscribe2 Token',
26
+ image : url + '/../include/s2-button.png',
27
  cmd : cls
28
  });
29
 
30
  // load the CSS and enable it on the right class
31
  ed.onInit.add(function () {
32
+ ed.dom.loadCSS( url + '/css/content.min.css' );
 
33
  if ( ed.theme.onResolveName ) {
34
  ed.theme.onResolveName.add(function ( th, o ) {
35
  if ( o.node.nodeName === 'IMG' && ed.dom.hasClass( o.node, cls ) ) {
42
  // allow selection of the image placeholder
43
  ed.onClick.add(function ( ed, e ) {
44
  e = e.target;
 
45
  if ( e.nodeName === 'IMG' && ed.dom.hasClass( e, cls ) ) {
46
  ed.selection.select( e );
47
  }
65
  if ( o.get ) {
66
  if ( null !== pbreplaced ) {
67
  for ( i = 0; i < pbreplaced.length; i++ ) {
68
+ o.content = o.content.replace( /<img[^>]+>/, replacer );
69
  }
70
  }
71
  o.content = o.content.replace( /<img[^>]+>/g, function ( im ) {
tinymce/editor-plugin3.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(){tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(a,b){var c=0,d='<img src="'+b+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" />',e="mceSubscribe2",f="[subscribe2]",g=[],h=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),i=function(a){return-1!==a.indexOf('class="mceSubscribe2')&&(a=g[c]),a};a.addCommand("mceSubscribe2",function(){a.execCommand("mceInsertContent",0,d)}),a.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:b+"/../include/s2-button.png",cmd:e}),a.onInit.add(function(){a.dom.loadCSS(b+"/css/content.min.css"),a.theme.onResolveName&&a.theme.onResolveName.add(function(b,c){"IMG"===c.node.nodeName&&a.dom.hasClass(c.node,e)&&(c.name="subscribe2")})}),a.onClick.add(function(a,b){b=b.target,"IMG"===b.nodeName&&a.dom.hasClass(b,e)&&a.selection.select(b)}),a.onNodeChange.add(function(a,b,c){b.setActive("subscribe2","IMG"===c.nodeName&&a.dom.hasClass(c,e))}),a.onBeforeSetContent.add(function(a,b){g=b.content.match(h),b.content=b.content.replace(h,d)}),a.onPostProcess.add(function(a,b){if(b.get){if(null!==g)for(c=0;c<g.length;c++)b.content=b.content.replace(/<img[^>]+>/,i);b.content=b.content.replace(/<img[^>]+>/g,function(a){return-1!==a.indexOf('class="mceSubscribe2')&&(a=f),a})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin)}();
tinymce/{editor_plugin4.js → editor-plugin4.js} RENAMED
@@ -7,7 +7,7 @@
7
  cls = 'mceSubscribe2',
8
  shortcode = '[subscribe2]',
9
  pbreplaced = [],
10
- pbRE = new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),
11
  replacer = function ( str ) {
12
  if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
13
  str = pbreplaced[i];
@@ -23,13 +23,13 @@
23
  // Register buttons
24
  ed.addButton( 'subscribe2', {
25
  title : 'Insert Subscribe2 Token',
26
- image : url + '/../include/s2_button.png',
27
  cmd : cls
28
  });
29
 
30
  // load the CSS and enable it on the right class
31
  ed.on('init', function () {
32
- ed.dom.loadCSS( url + '/css/content.css' );
33
 
34
  if ( ed.theme.onResolveName ) {
35
  ed.theme.onResolveName.add(function ( th, o ) {
@@ -53,7 +53,7 @@
53
  if ( ed.get ) {
54
  if ( null !== pbreplaced ) {
55
  for ( i = 0; i < pbreplaced.length; i++ ) {
56
- ed.content = ed.content.replace(/<img[^>]+>/, replacer );
57
  }
58
  }
59
  ed.content = ed.content.replace( /<img[^>]+>/g, function ( im ) {
7
  cls = 'mceSubscribe2',
8
  shortcode = '[subscribe2]',
9
  pbreplaced = [],
10
+ pbRE = new RegExp( /(\[|<!--)subscribe2.*?(\]|-->)/g ),
11
  replacer = function ( str ) {
12
  if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
13
  str = pbreplaced[i];
23
  // Register buttons
24
  ed.addButton( 'subscribe2', {
25
  title : 'Insert Subscribe2 Token',
26
+ image : url + '/../include/s2-button.png',
27
  cmd : cls
28
  });
29
 
30
  // load the CSS and enable it on the right class
31
  ed.on('init', function () {
32
+ ed.dom.loadCSS( url + '/css/content.min.css' );
33
 
34
  if ( ed.theme.onResolveName ) {
35
  ed.theme.onResolveName.add(function ( th, o ) {
53
  if ( ed.get ) {
54
  if ( null !== pbreplaced ) {
55
  for ( i = 0; i < pbreplaced.length; i++ ) {
56
+ ed.content = ed.content.replace( /<img[^>]+>/, replacer );
57
  }
58
  }
59
  ed.content = ed.content.replace( /<img[^>]+>/g, function ( im ) {
tinymce/editor-plugin4.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(){tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(a,b){var c=0,d='<p><img src="'+b+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',e="mceSubscribe2",f="[subscribe2]",g=[],h=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),i=function(a){return-1!==a.indexOf('class="mceSubscribe2')&&(a=g[c]),a};a.addCommand("mceSubscribe2",function(){a.execCommand("mceInsertContent",0,d)}),a.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:b+"/../include/s2-button.png",cmd:e}),a.on("init",function(){a.dom.loadCSS(b+"/css/content.min.css"),a.theme.onResolveName&&a.theme.onResolveName.add(function(b,c){"IMG"===c.node.nodeName&&a.dom.hasClass(c.node,e)&&(c.name="subscribe2")})}),a.on("BeforeSetContent",function(a){g=a.content.match(h),a.content=a.content.replace(h,d)}),a.on("PostProcess",function(a){if(a.get){if(null!==g)for(c=0;c<g.length;c++)a.content=a.content.replace(/<img[^>]+>/,i);a.content=a.content.replace(/<img[^>]+>/g,function(a){return-1!==a.indexOf('class="mceSubscribe2')&&(a=f),a})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin)}();
tinymce/editor_plugin3.min.js DELETED
@@ -1 +0,0 @@
1
- (function(){tinymce.create('tinymce.plugins.Subscribe2Plugin',{init:function(ed,url){var i=0,pb='<img src="'+url+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" />',cls='mceSubscribe2',shortcode='[subscribe2]',pbreplaced=[],pbRE=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),replacer=function(str){if(-1!==str.indexOf('class="mceSubscribe2')){str=pbreplaced[i]}return str};ed.addCommand('mceSubscribe2',function(){ed.execCommand('mceInsertContent',0,pb)});ed.addButton('subscribe2',{title:'Insert Subscribe2 Token',image:url+'/../include/s2_button.png',cmd:cls});ed.onInit.add(function(){ed.dom.loadCSS(url+'/css/content.css');if(ed.theme.onResolveName){ed.theme.onResolveName.add(function(th,o){if(o.node.nodeName==='IMG'&&ed.dom.hasClass(o.node,cls)){o.name='subscribe2'}})}});ed.onClick.add(function(ed,e){e=e.target;if(e.nodeName==='IMG'&&ed.dom.hasClass(e,cls)){ed.selection.select(e)}});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('subscribe2',n.nodeName==='IMG'&&ed.dom.hasClass(n,cls))});ed.onBeforeSetContent.add(function(ed,o){pbreplaced=o.content.match(pbRE);o.content=o.content.replace(pbRE,pb)});ed.onPostProcess.add(function(ed,o){if(o.get){if(null!==pbreplaced){for(i=0;i<pbreplaced.length;i++){o.content=o.content.replace(/<img[^>]+>/,replacer)}}o.content=o.content.replace(/<img[^>]+>/g,function(im){if(-1!==im.indexOf('class="mceSubscribe2')){im=shortcode}return im})}})},getInfo:function(){return{longname:'Insert Subscribe2 Token',author:'Matthew Robinson',authorurl:'http://subscribe2.wordpress.com',infourl:'http://subscribe2.wordpress.com',version:tinymce.majorVersion+'.'+tinymce.minorVersion}}});tinymce.PluginManager.add('subscribe2',tinymce.plugins.Subscribe2Plugin)})();
 
tinymce/editor_plugin4.min.js DELETED
@@ -1 +0,0 @@
1
- (function(){tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(ed,url){var i=0,pb='<p><img src="'+url+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',cls="mceSubscribe2",shortcode="[subscribe2]",pbreplaced=[],pbRE=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),replacer=function(str){if(-1!==str.indexOf('class="mceSubscribe2')){str=pbreplaced[i]}return str};ed.addCommand("mceSubscribe2",function(){ed.execCommand("mceInsertContent",0,pb)});ed.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:url+"/../include/s2_button.png",cmd:cls});ed.on("init",function(){ed.dom.loadCSS(url+"/css/content.css");if(ed.theme.onResolveName){ed.theme.onResolveName.add(function(th,o){if(o.node.nodeName==="IMG"&&ed.dom.hasClass(o.node,cls)){o.name="subscribe2"}})}});ed.on("BeforeSetContent",function(ed){pbreplaced=ed.content.match(pbRE);ed.content=ed.content.replace(pbRE,pb)});ed.on("PostProcess",function(ed){if(ed.get){if(null!==pbreplaced){for(i=0;i<pbreplaced.length;i++){ed.content=ed.content.replace(/<img[^>]+>/,replacer)}}ed.content=ed.content.replace(/<img[^>]+>/g,function(im){if(-1!==im.indexOf('class="mceSubscribe2')){im=shortcode}return im})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin)})();
 
uninstall.php CHANGED
@@ -1,26 +1,26 @@
1
  <?php
2
- if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) {
3
  // Make sure not to call this file directly
4
  exit();
5
  } else {
6
- // Is Subscribe2 free active
7
- if ( is_plugin_active( 'subscribe2_html/subscribe2.php' ) ) {
8
- return;
9
- }
10
 
11
  // Is this WordPressMU or not?
12
- if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
13
  $s2_mu = true;
14
  }
15
- if ( function_exists('is_multisite') && is_multisite() ) {
16
  $s2_mu = true;
17
  }
18
 
19
  if ( $s2_mu ) {
20
  global $wpdb;
21
- $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
22
  foreach ( $blogs as $blog ) {
23
- switch_to_blog($blog);
24
  s2_uninstall();
25
  restore_current_blog();
26
  }
@@ -31,25 +31,24 @@ if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) {
31
  function s2_uninstall() {
32
  global $wpdb;
33
  // get name of subscribe2 table
34
- $public = $wpdb->prefix . "subscribe2";
35
  // delete entry from wp_options table
36
- delete_option('subscribe2_options');
37
  // delete legacy entry from wp-options table
38
- delete_option('s2_future_posts');
39
  // remove and scheduled events
40
- wp_clear_scheduled_hook('s2_digest_cron');
41
  // delete usermeta data for registered users
42
  // use LIKE and % wildcard as meta_key names are prepended on WPMU
43
  // and s2_cat is appended with category ID integer
44
- $wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_cat%'");
45
- $wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_subscribed'");
46
- $wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_format'");
47
- $wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_autosub'");
48
  // delete any postmeta data that supressed notifications
49
- $wpdb->query("DELETE from $wpdb->postmeta WHERE meta_key = 's2mail'");
50
 
51
  // drop the subscribe2 table
52
- $sql = "DROP TABLE IF EXISTS `" . $public . "`";
53
- $wpdb->query($sql);
54
  } // end s2_uninstall()
55
  ?>
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3
  // Make sure not to call this file directly
4
  exit();
5
  } else {
6
+ // Is Subscribe2 HTML active
7
+ if ( is_plugin_active( 'subscribe2_html/subscribe2.php' ) ) {
8
+ return;
9
+ }
10
 
11
  // Is this WordPressMU or not?
12
+ if ( isset( $wpmu_version ) || strpos( $wp_version, 'wordpress-mu' ) ) {
13
  $s2_mu = true;
14
  }
15
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
16
  $s2_mu = true;
17
  }
18
 
19
  if ( $s2_mu ) {
20
  global $wpdb;
21
+ $blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
22
  foreach ( $blogs as $blog ) {
23
+ switch_to_blog( $blog );
24
  s2_uninstall();
25
  restore_current_blog();
26
  }
31
  function s2_uninstall() {
32
  global $wpdb;
33
  // get name of subscribe2 table
34
+ $public = $wpdb->prefix . 'subscribe2';
35
  // delete entry from wp_options table
36
+ delete_option( 'subscribe2_options' );
37
  // delete legacy entry from wp-options table
38
+ delete_option( 's2_future_posts' );
39
  // remove and scheduled events
40
+ wp_clear_scheduled_hook( 's2_digest_cron' );
41
  // delete usermeta data for registered users
42
  // use LIKE and % wildcard as meta_key names are prepended on WPMU
43
  // and s2_cat is appended with category ID integer
44
+ $wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_cat%'" );
45
+ $wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_subscribed'" );
46
+ $wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_format'" );
47
+ $wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_autosub'" );
48
  // delete any postmeta data that supressed notifications
49
+ $wpdb->query( "DELETE from $wpdb->postmeta WHERE meta_key = 's2mail'" );
50
 
51
  // drop the subscribe2 table
52
+ $wpdb->query( "DROP TABLE IF EXISTS $public" );
 
53
  } // end s2_uninstall()
54
  ?>