Subscribe to Comments - Version 2.3

Version Description

Download this release

Release Info

Developer markjaquith
Plugin Icon wp plugin Subscribe to Comments
Version 2.3
Comparing to
See all releases

Code changes from version 2.1.2 to 2.3

extras/readme.html DELETED
@@ -1,109 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Subscribe to Comments 2 for WordPress README</title>
4
- </head>
5
- <body>
6
- <h1>Subscribe to Comments 2</h1>
7
-
8
- <h2>Description</h2>
9
- <p>Subscribe to Comments 2 is a WordPress plugin that allows commenters on an entry to subscribe to e-mail notifications for subsequent comments. It does <em>NOT</em> e-mail you new blog posts. For that functionality, use Skippy's <a href="http://www.skippy.net/blog/2005/02/17/subscribe2/">Subscribe2 plugin</a>.</p>
10
-
11
- <h2>Links</h2>
12
- <p>Here are some of the crucial Subscribe to Comments 2 links</p>
13
- <ul>
14
- <li><a href="http://txfx.net/code/wordpress/subscribe-to-comments/">Plugin's home</a></li>
15
- <li><a href="http://dev.wp-plugins.org/newticket">Report Bugs or Suggest Features</a></li>
16
- <li><a href="http://downloads.wordpress.org/plugin/subscribe-to-comments.zip">Latest Stable Version</a></li>
17
- </ul>
18
-
19
- <h2>Installation</h2>
20
- <ol>
21
- <li>Put <code>subscribe-to-comments.php</code> into <code>[wordpress_dir]/wp-content/plugins/</code></li>
22
- <li><strong>If you are upgrading from a 2.0.x version of this plugin only,</strong> put <code>wp-subscription-manager.php</code> into your blog's root WordPress directory (the directory where <code>wp-config.php</code> resides)</li>
23
- <li>Go into the WordPress admin interface and activate the plugin</li>
24
- <li>Optional: if your WordPress theme doesn't have the <code>comment_form</code> hook, or if you would like to manually determine where in your comments form the subscribe checkbox appears, enter this where you would like it: <code>&lt;?php show_subscription_checkbox(); ?&gt;</code></li>
25
- <li>Optional: If you would like to enable users to subscribe to comments without having to leave a comment, place this somewhere in your template, but make sure it is <strong>outside the comments form</strong>. A good place would be right after the ending <code>&lt;/form&gt;</code> tag for the comments form: <code>&lt;?php show_manual_subscription_form(); ?></code></li>
26
- </ol>
27
-
28
- <h2>Notes</h2>
29
- <ul>
30
- <li>The <code>subscribe-to-comments.pot</code> file is for translators... normal users should disregard it</li>
31
- <li>The only file that <em>must</em> be uploaded is the <code>subscribe-to-comments.php</code> file. The <code>wp-subscription-manager.php</code> file is for backwards compatability only. If you are installing the plugin for the first time, you don't need it. None of the other files in the <code>/readme-etc/</code> directory need to be uploaded</li>
32
- <li>The function &gt;?php comment_subscription_status(); ?&gt; can be used within the comments loop to determine if a comment's author is subscribed or not. e.g.
33
- <pre><code>&lt;?php if (comment_subscription_status()) { ?&gt;
34
- Subscribed
35
- &lt;?php } ?&gt;</code></pre></li>
36
- <li>You need to be a logged-in WordPress user with the "manage_options" capability in order to search for subscriptions on random e-mail addresses or to remove a "do not mail" block.</li>
37
- <li>The author of the post is always determined to be subscribed, and thus will never see the "subscribe" checkbox for his entries, but instead will see the "entry author" message.</li>
38
- <li>Users are never e-mailed notifications for their own comments. (important that you know that for testing out the plugin)</li>
39
- <li>The text shown next to the checkbox for unsubscribed users, the "you are subscribed" text, and the "you are the author of this entry" text can all be customized in the options (Options -&gt; Subscribe to Comments).</li>
40
- <li>By default, the "subscribe" checkbox is unchecked, but you can change that in the options (i.e. so that it is checked by default).</li>
41
- <li>The following CSS can be used with the WordPress default "Kubrick" theme if you want to use a custom style for the Subscription Manager and should be added to your <code>style.css</code> file:<br /><br />
42
- <pre>
43
- /* SUBSCRIPTION MANAGER STYLE */
44
- .subscription-manager {
45
- padding: 10px 0 20px 0;
46
- margin: 5px 0 0 55px;
47
- width: 650px;
48
- }
49
-
50
- div.wrap {
51
- background: #fafafa;
52
- padding: 5px 10px;
53
- margin: 20px 0;
54
- border: 1px solid #ccc;
55
- }
56
-
57
- div.wrap h2 {
58
- margin: .5em 0 1em 0;
59
- border-bottom: 2px solid #589bd2;
60
- }
61
-
62
- div.wrap fieldset {
63
- border: 1px solid #555;
64
- margin: 1em 0;
65
- padding: 5px 10px;
66
- }
67
-
68
- div.wrap fieldset legend {
69
- font-weight: bold;
70
- font-size: small;
71
- }
72
-
73
- div.wrap p.submit {
74
- text-align: right;
75
- }
76
-
77
-
78
- .updated {
79
- background: #B9D6EF;
80
- border: 1px solid #589bd2;
81
- margin: 1em 5% 10px;
82
- padding: 0 1em;
83
- }
84
-
85
- .updated-error {
86
- background-color: #FFA3A3;
87
- border: 1px solid #FF5D5D;
88
- }
89
-
90
- div.wrap form {
91
- margin: 0;
92
- padding: 0;
93
- }
94
-
95
- div.warp li {
96
- margin-bottom: 6px;
97
- line-height: 130%;
98
- }
99
- /* END SUBSCRIPTION MANAGER STYLE */
100
-
101
- </pre></li>
102
-
103
-
104
-
105
-
106
- </ul>
107
-
108
- </body>
109
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
extras/subscribe-to-comments.pot DELETED
@@ -1,445 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Subscribe to Comments 2.0\n"
4
- "POT-Creation-Date: 2007-01-23 07:01-0500\n"
5
- "Last-Translator: Mark Jaquith <mark.i18n@txfx.net>\n"
6
- "Language-Team: Mark Jaquith <mark.wordpress@txfx.net>\n"
7
- "MIME-Version: 1.0\n"
8
- "Content-Type: text/plain; charset=utf-8\n"
9
- "Content-Transfer-Encoding: 8bit\n"
10
-
11
- #: subscribe-to-comments.php:68
12
- msgid "<strong>Error: </strong>"
13
- msgstr ""
14
-
15
- #: subscribe-to-comments.php:83
16
- msgid "Subscribe without commenting"
17
- msgstr ""
18
-
19
- #: subscribe-to-comments.php:85
20
- msgid "E-Mail:"
21
- msgstr ""
22
-
23
- #: subscribe-to-comments.php:87
24
- msgid "Subscribe"
25
- msgstr ""
26
-
27
- #: subscribe-to-comments.php:141
28
- msgid "\"From\" name for notifications:"
29
- msgstr ""
30
-
31
- #: subscribe-to-comments.php:142
32
- msgid "\"From\" e-mail addresss for notifications:"
33
- msgstr ""
34
-
35
- #: subscribe-to-comments.php:143
36
- msgid "\"Subscribe\" box should be checked by default"
37
- msgstr ""
38
-
39
- #: subscribe-to-comments.php:144
40
- msgid ""
41
- "Do a CSS \"clear\" on the subscription checkbox/message (uncheck this if the "
42
- "checkbox/message appears in a strange location in your theme)"
43
- msgstr ""
44
-
45
- #: subscribe-to-comments.php:147
46
- msgid "Comment Form Text"
47
- msgstr ""
48
-
49
- #: subscribe-to-comments.php:149
50
- msgid ""
51
- "Customize the messages shown to different people. Use <code>[manager_link]</"
52
- "code> to insert the URI to the Subscription Manager."
53
- msgstr ""
54
-
55
- #: subscribe-to-comments.php:153
56
- msgid "Not subscribed"
57
- msgstr ""
58
-
59
- #: subscribe-to-comments.php:155
60
- msgid "Subscribed"
61
- msgstr ""
62
-
63
- #: subscribe-to-comments.php:157
64
- msgid "Entry Author"
65
- msgstr ""
66
-
67
- #: subscribe-to-comments.php:163
68
- msgid "Use custom style for Subscription Manager"
69
- msgstr ""
70
-
71
- #: subscribe-to-comments.php:165
72
- msgid ""
73
- "These settings only matter if you are using a custom style. <code>"
74
- "[theme_path]</code> will be replaced with the path to your current theme."
75
- msgstr ""
76
-
77
- #: subscribe-to-comments.php:168
78
- msgid "Path to header:"
79
- msgstr ""
80
-
81
- #: subscribe-to-comments.php:169
82
- msgid "Path to sidebar:"
83
- msgstr ""
84
-
85
- #: subscribe-to-comments.php:170
86
- msgid "Path to footer:"
87
- msgstr ""
88
-
89
- #: subscribe-to-comments.php:173
90
- msgid "HTML for before the subscription manager:"
91
- msgstr ""
92
-
93
- #: subscribe-to-comments.php:174
94
- msgid "HTML for after the subscription manager:"
95
- msgstr ""
96
-
97
- #: subscribe-to-comments.php:199
98
- msgid "Options saved."
99
- msgstr ""
100
-
101
- #: subscribe-to-comments.php:206
102
- msgid "Update Options &raquo;"
103
- msgstr ""
104
-
105
- #: subscribe-to-comments.php:377
106
- msgid "Please provide a valid e-mail address."
107
- msgstr ""
108
-
109
- #: subscribe-to-comments.php:381
110
- msgid "This e-mail address may not be subscribed"
111
- msgstr ""
112
-
113
- #: subscribe-to-comments.php:387 subscribe-to-comments.php:403
114
- msgid "You appear to be already subscribed to this entry."
115
- msgstr ""
116
-
117
- #: subscribe-to-comments.php:393
118
- msgid "Comments are not allowed on this entry."
119
- msgstr ""
120
-
121
- #: subscribe-to-comments.php:597
122
- #, php-format
123
- msgid "There is a new comment on the post \"%s\""
124
- msgstr ""
125
-
126
- #: subscribe-to-comments.php:598
127
- #, php-format
128
- msgid "Author: %s\n"
129
- msgstr ""
130
-
131
- #: subscribe-to-comments.php:599
132
- msgid "Comment:\n"
133
- msgstr ""
134
-
135
- #: subscribe-to-comments.php:600
136
- msgid "See all comments on this post here:\n"
137
- msgstr ""
138
-
139
- #: subscribe-to-comments.php:603
140
- msgid ""
141
- "To manage your subscriptions or to block all notifications from this site, "
142
- "click the link below:\n"
143
- msgstr ""
144
-
145
- #: subscribe-to-comments.php:606
146
- #, php-format
147
- msgid "New Comment On: %s"
148
- msgstr ""
149
-
150
- #: subscribe-to-comments.php:625
151
- msgid "E-mail change confirmation"
152
- msgstr ""
153
-
154
- #: subscribe-to-comments.php:626
155
- #, php-format
156
- msgid ""
157
- "You are receiving this message to confirm a change of e-mail address for "
158
- "your subscriptions at \"%s\"\n"
159
- "\n"
160
- msgstr ""
161
-
162
- #: subscribe-to-comments.php:627
163
- #, php-format
164
- msgid ""
165
- "To change your e-mail address to %s, click this link:\n"
166
- "\n"
167
- msgstr ""
168
-
169
- #: subscribe-to-comments.php:629 subscribe-to-comments.php:641
170
- msgid "If you did not request this action, please disregard this message."
171
- msgstr ""
172
-
173
- #: subscribe-to-comments.php:637
174
- msgid "E-mail block confirmation"
175
- msgstr ""
176
-
177
- #: subscribe-to-comments.php:638
178
- #, php-format
179
- msgid ""
180
- "You are receiving this message to confirm that you no longer wish to receive "
181
- "e-mail comment notifications from \"%s\"\n"
182
- "\n"
183
- msgstr ""
184
-
185
- #: subscribe-to-comments.php:639
186
- msgid ""
187
- "To cancel all future notifications for this address, click this link:\n"
188
- "\n"
189
- msgstr ""
190
-
191
- #: subscribe-to-comments.php:679
192
- msgid "click here"
193
- msgstr ""
194
-
195
- #: subscribe-to-comments.php:701
196
- msgid "Notify me of followup comments via e-mail"
197
- msgstr ""
198
-
199
- #: subscribe-to-comments.php:701
200
- msgid ""
201
- "You are subscribed to this entry. <a href=\"[manager_link]\">Manage your "
202
- "subscriptions</a>."
203
- msgstr ""
204
-
205
- #: subscribe-to-comments.php:701
206
- msgid ""
207
- "You are the author of this entry. <a href=\"[manager_link]\">Manage "
208
- "subscriptions</a>."
209
- msgstr ""
210
-
211
- #: subscribe-to-comments.php:780 subscribe-to-comments.php:946
212
- msgid "Comment Subscription Manager"
213
- msgstr ""
214
-
215
- #: subscribe-to-comments.php:780 subscribe-to-comments.php:1124
216
- msgid "Subscriptions"
217
- msgstr ""
218
-
219
- #: subscribe-to-comments.php:785
220
- msgid "Subscribe to Comments"
221
- msgstr ""
222
-
223
- #: subscribe-to-comments.php:854
224
- msgid "You may not access this page without a valid key."
225
- msgstr ""
226
-
227
- #: subscribe-to-comments.php:862
228
- #, php-format
229
- msgid ""
230
- "All notifications that were formerly sent to <strong>%s</strong> will now be "
231
- "sent to <strong>%s</strong>!"
232
- msgstr ""
233
-
234
- #: subscribe-to-comments.php:874
235
- #, php-format
236
- msgid "<strong>%s</strong> %s removed successfully."
237
- msgstr ""
238
-
239
- #: subscribe-to-comments.php:874
240
- msgid "subscriptions"
241
- msgstr ""
242
-
243
- #: subscribe-to-comments.php:874
244
- msgid "subscription"
245
- msgstr ""
246
-
247
- #: subscribe-to-comments.php:879
248
- #, php-format
249
- msgid "The block on <strong>%s</strong> has been successfully removed."
250
- msgstr ""
251
-
252
- #: subscribe-to-comments.php:881
253
- #, php-format
254
- msgid "<strong>%s</strong> isn't blocked!"
255
- msgstr ""
256
-
257
- #: subscribe-to-comments.php:886
258
- #, php-format
259
- msgid ""
260
- "<strong>%s</strong> has been blocked from receiving notifications. You will "
261
- "have to have the administrator remove the block before you will be able to "
262
- "change your notification address."
263
- msgstr ""
264
-
265
- #: subscribe-to-comments.php:889
266
- #, php-format
267
- msgid ""
268
- "Your change of e-mail request was successfully received. Please check your "
269
- "old account (<strong>%s</strong>) in order to confirm the change."
270
- msgstr ""
271
-
272
- #: subscribe-to-comments.php:894
273
- #, php-format
274
- msgid ""
275
- "Your request to block <strong>%s</strong> from receiving any further "
276
- "notifications has been received. In order for you to complete the block, "
277
- "please check your e-mail and click on the link in the message that has been "
278
- "sent to you."
279
- msgstr ""
280
-
281
- #: subscribe-to-comments.php:898
282
- #, php-format
283
- msgid "<strong>%s</strong> has been successfully subscribed to %s"
284
- msgstr ""
285
-
286
- #: subscribe-to-comments.php:903
287
- #, php-format
288
- msgid ""
289
- "<strong>%s</strong> has been added to the \"do not mail\" list. You will no "
290
- "longer receive any notifications from this site. If this was done in error, "
291
- "please contact the <a href=\"mailto:%s\">site administrator</a> to remove "
292
- "this block."
293
- msgstr ""
294
-
295
- #: subscribe-to-comments.php:905
296
- #, php-format
297
- msgid "<strong>%s</strong> has already been blocked!"
298
- msgstr ""
299
-
300
- #: subscribe-to-comments.php:921
301
- #, php-format
302
- msgid "%s Comment Subscription Manager"
303
- msgstr ""
304
-
305
- #: subscribe-to-comments.php:949
306
- #, php-format
307
- msgid "Return to the page you were viewing: %s"
308
- msgstr ""
309
-
310
- #: subscribe-to-comments.php:960
311
- msgid "Remove Block"
312
- msgstr ""
313
-
314
- #: subscribe-to-comments.php:963
315
- #, php-format
316
- msgid ""
317
- "Click the button below to remove the block on <strong>%s</strong>. This "
318
- "should only be done if the user has specifically requested it."
319
- msgstr ""
320
-
321
- #: subscribe-to-comments.php:971
322
- msgid "Remove Block &raquo;"
323
- msgstr ""
324
-
325
- #: subscribe-to-comments.php:979
326
- msgid "Blocked"
327
- msgstr ""
328
-
329
- #: subscribe-to-comments.php:982
330
- #, php-format
331
- msgid ""
332
- "You have indicated that you do not wish to receive any notifications at "
333
- "<strong>%s</strong> from this site. If this is incorrect, or if you wish to "
334
- "have the block removed, please contact the <a href=\"mailto:%s\">site "
335
- "administrator</a>."
336
- msgstr ""
337
-
338
- #: subscribe-to-comments.php:997
339
- #, php-format
340
- msgid "<strong>%s</strong> is not subscribed to any posts on this site."
341
- msgstr ""
342
-
343
- #: subscribe-to-comments.php:999
344
- #, php-format
345
- msgid "<strong>%s</strong> is not a valid e-mail address."
346
- msgstr ""
347
-
348
- #: subscribe-to-comments.php:1012
349
- msgid "&laquo; Back"
350
- msgstr ""
351
-
352
- #: subscribe-to-comments.php:1015
353
- msgid "Find Subscriptions"
354
- msgstr ""
355
-
356
- #: subscribe-to-comments.php:1018
357
- msgid "Enter an e-mail address to view its subscriptions or undo a block."
358
- msgstr ""
359
-
360
- #: subscribe-to-comments.php:1026
361
- msgid "Search &raquo;"
362
- msgstr ""
363
-
364
- #: subscribe-to-comments.php:1034
365
- msgid "Top Subscriber List"
366
- msgstr ""
367
-
368
- #: subscribe-to-comments.php:1036
369
- msgid "Subscriber List"
370
- msgstr ""
371
-
372
- #: subscribe-to-comments.php:1055
373
- msgid "Show all subscribers"
374
- msgstr ""
375
-
376
- #: subscribe-to-comments.php:1057
377
- msgid ""
378
- "Show list of subscribers in <code>CC:</code>-field format (for bulk e-"
379
- "mailing)"
380
- msgstr ""
381
-
382
- #: subscribe-to-comments.php:1059
383
- msgid "&laquo; Back to regular view"
384
- msgstr ""
385
-
386
- #: subscribe-to-comments.php:1074
387
- msgid "Top Subscribed Posts"
388
- msgstr ""
389
-
390
- #: subscribe-to-comments.php:1127
391
- #, php-format
392
- msgid ""
393
- "<strong>%s</strong> is subscribed to the posts listed below. To unsubscribe "
394
- "to one or more posts, click the checkbox next to the title, then click "
395
- "\"Remove Selected Subscription(s)\" at the bottom of the list."
396
- msgstr ""
397
-
398
- #: subscribe-to-comments.php:1141
399
- msgid "Invert Checkbox Selection"
400
- msgstr ""
401
-
402
- #: subscribe-to-comments.php:1145
403
- msgid "Remove Selected Subscription(s) &raquo;"
404
- msgstr ""
405
-
406
- #: subscribe-to-comments.php:1152
407
- msgid "Advanced Options"
408
- msgstr ""
409
-
410
- #: subscribe-to-comments.php:1155
411
- msgid "Block All Notifications"
412
- msgstr ""
413
-
414
- #: subscribe-to-comments.php:1162
415
- #, php-format
416
- msgid ""
417
- "If you would like <strong>%s</strong> to be blocked from receiving any "
418
- "notifications from this site, click the button below. This should be "
419
- "reserved for cases where someone is signing you up for notifications without "
420
- "your consent."
421
- msgstr ""
422
-
423
- #: subscribe-to-comments.php:1166
424
- msgid "Block Notifications &raquo;"
425
- msgstr ""
426
-
427
- #: subscribe-to-comments.php:1172
428
- msgid "Change E-mail Address"
429
- msgstr ""
430
-
431
- #: subscribe-to-comments.php:1179
432
- #, php-format
433
- msgid ""
434
- "If you would like to change the e-mail address for your subscriptions, enter "
435
- "the new address below. You will be required to verify this request by "
436
- "clicking a special link sent to your current address (<strong>%s</strong>)."
437
- msgstr ""
438
-
439
- #: subscribe-to-comments.php:1183
440
- msgid "New E-mail Address:"
441
- msgstr ""
442
-
443
- #: subscribe-to-comments.php:1188
444
- msgid "Change E-mail Address &raquo;"
445
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Subscribe to Comments ===
2
  Tags: comments, subscription, email
3
- Contributors: markjaquith
4
- Requires at least: 3.0
5
- Tested up to: 2.3.1
6
- Stable tag: trunk
7
 
8
  Subscribe to Comments allows commenters on an entry to subscribe to e-mail notifications for subsequent comments.
9
 
1
  === Subscribe to Comments ===
2
  Tags: comments, subscription, email
3
+ Contributors: markjaquith, joen
4
+ Requires at least: 2.9
5
+ Tested up to: 4.3
6
+ Stable tag: 2.1.2
7
 
8
  Subscribe to Comments allows commenters on an entry to subscribe to e-mail notifications for subsequent comments.
9
 
subscribe-to-comments.php CHANGED
@@ -1,1241 +1,1629 @@
1
- <?php
2
- /*
3
- Plugin Name: Subscribe To Comments
4
- Version: 2.1.2
5
- Plugin URI: http://txfx.net/code/wordpress/subscribe-to-comments/
6
- Description: Allows readers to receive notifications of new comments that are posted to an entry. Based on version 1 from <a href="http://scriptygoddess.com/">Scriptygoddess</a>
7
- Author: Mark Jaquith
8
- Author URI: http://txfx.net/
9
- */
10
-
11
- /* This is the code that is inserted into the comment form */
12
- function show_subscription_checkbox ($id='0') {
13
- global $sg_subscribe;
14
- sg_subscribe_start();
15
-
16
- if ( $sg_subscribe->checkbox_shown ) return $id;
17
- if ( !$email = $sg_subscribe->current_viewer_subscription_status() ) :
18
- $checked_status = ( !empty($_COOKIE['subscribe_checkbox_'.COOKIEHASH]) && 'checked' == $_COOKIE['subscribe_checkbox_'.COOKIEHASH] ) ? true : false;
19
- ?>
20
-
21
- <?php /* ------------------------------------------------------------------- */ ?>
22
- <?php /* This is the text that is displayed for users who are NOT subscribed */ ?>
23
- <?php /* ------------------------------------------------------------------- */ ?>
24
-
25
- <p <?php if ($sg_subscribe->clear_both) echo 'style="clear: both;" '; ?>class="subscribe-to-comments">
26
- <input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" <?php if ( $checked_status ) echo 'checked="checked" '; ?>/>
27
- <label for="subscribe"><?php echo $sg_subscribe->not_subscribed_text; ?></label>
28
- </p>
29
-
30
- <?php /* ------------------------------------------------------------------- */ ?>
31
-
32
- <?php elseif ( $email == 'admin' && current_user_can('manage_options') ) : ?>
33
-
34
- <?php /* ------------------------------------------------------------- */ ?>
35
- <?php /* This is the text that is displayed for the author of the post */ ?>
36
- <?php /* ------------------------------------------------------------- */ ?>
37
-
38
- <p <?php if ($sg_subscribe->clear_both) echo 'style="clear: both;" '; ?>class="subscribe-to-comments">
39
- <?php echo str_replace('[manager_link]', $sg_subscribe->manage_link($email, true, false), $sg_subscribe->author_text); ?>
40
- </p>
41
-
42
- <?php else : ?>
43
-
44
- <?php /* --------------------------------------------------------------- */ ?>
45
- <?php /* This is the text that is displayed for users who ARE subscribed */ ?>
46
- <?php /* --------------------------------------------------------------- */ ?>
47
-
48
- <p <?php if ($sg_subscribe->clear_both) echo 'style="clear: both;" '; ?>class="subscribe-to-comments">
49
- <?php echo str_replace('[manager_link]', $sg_subscribe->manage_link($email, true, false), $sg_subscribe->subscribed_text); ?>
50
- </p>
51
-
52
- <?php /* --------------------------------------------------------------- */ ?>
53
-
54
- <?php endif;
55
-
56
- $sg_subscribe->checkbox_shown = true;
57
- return $id;
58
- }
59
-
60
-
61
-
62
- /* -------------------------------------------------------------------- */
63
- /* This function outputs a "subscribe without commenting" form. */
64
- /* Place this somewhere within "the loop", but NOT within another form */
65
- /* This is NOT inserted automaticallly... you must place it yourself */
66
- /* -------------------------------------------------------------------- */
67
- function show_manual_subscription_form() {
68
- global $id, $sg_subscribe, $user_email;
69
- sg_subscribe_start();
70
- $sg_subscribe->show_errors('solo_subscribe', '<div class="solo-subscribe-errors">', '</div>', __('<strong>Error: </strong>', 'subscribe-to-comments'), '<br />');
71
-
72
- if ( !$sg_subscribe->current_viewer_subscription_status() ) :
73
- get_currentuserinfo(); ?>
74
-
75
- <?php /* ------------------------------------------------------------------- */ ?>
76
- <?php /* This is the text that is displayed for users who are NOT subscribed */ ?>
77
- <?php /* ------------------------------------------------------------------- */ ?>
78
-
79
- <form action="" method="post">
80
- <input type="hidden" name="solo-comment-subscribe" value="solo-comment-subscribe" />
81
- <input type="hidden" name="postid" value="<?php echo (int) $id; ?>" />
82
- <input type="hidden" name="ref" value="<?php echo urlencode('http://' . $_SERVER['HTTP_HOST'] . attribute_escape($_SERVER['REQUEST_URI'])); ?>" />
83
-
84
- <p class="solo-subscribe-to-comments">
85
- <?php _e('Subscribe without commenting', 'subscribe-to-comments'); ?>
86
- <br />
87
- <label for="solo-subscribe-email"><?php _e('E-Mail:', 'subscribe-to-comments'); ?>
88
- <input type="text" name="email" id="solo-subscribe-email" size="22" value="<?php echo $user_email; ?>" /></label>
89
- <input type="submit" name="submit" value="<?php _e('Subscribe', 'subscribe-to-comments'); ?>" />
90
- </p>
91
- </form>
92
-
93
- <?php /* ------------------------------------------------------------------- */ ?>
94
-
95
- <?php endif;
96
- }
97
-
98
-
99
-
100
- /* -------------------------
101
- Use this function on your comments display - to show whether a user is subscribed to comments on the post or not.
102
- Note: this must be used within the comments loop! It will not work properly outside of it.
103
- ------------------------- */
104
- function comment_subscription_status() {
105
- global $comment;
106
- if ($comment->comment_subscribe == 'Y') {
107
- return true;
108
- } else {
109
- return false;
110
- }
111
- }
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
- /* ============================= */
127
- /* DO NOT MODIFY BELOW THIS LINE */
128
- /* ============================= */
129
-
130
- class sg_subscribe_settings {
131
- function options_page_contents() {
132
- global $sg_subscribe;
133
- sg_subscribe_start();
134
- if ( isset($_POST['sg_subscribe_settings_submit']) ) {
135
- check_admin_referer('subscribe-to-comments-update_options');
136
- $update_settings = stripslashes_deep($_POST['sg_subscribe_settings']);
137
- $sg_subscribe->update_settings($update_settings);
138
- }
139
-
140
-
141
- echo '<h2>'.__('Subscribe to Comments Options','subscribe-to-comments').'</h2>';
142
- echo '<ul>';
143
-
144
- echo '<li><label for="name">' . __('"From" name for notifications:', 'subscribe-to-comments') . ' <input type="text" size="40" id="name" name="sg_subscribe_settings[name]" value="' . sg_subscribe_settings::form_setting('name') . '" /></label></li>';
145
- echo '<li><label for="email">' . __('"From" e-mail addresss for notifications:', 'subscribe-to-comments') . ' <input type="text" size="40" id="email" name="sg_subscribe_settings[email]" value="' . sg_subscribe_settings::form_setting('email') . '" /></label></li>';
146
- echo '<li><label for="clear_both"><input type="checkbox" id="clear_both" name="sg_subscribe_settings[clear_both]" value="clear_both"' . sg_subscribe_settings::checkflag('clear_both') . ' /> ' . __('Do a CSS "clear" on the subscription checkbox/message (uncheck this if the checkbox/message appears in a strange location in your theme)', 'subscribe-to-comments') . '</label></li>';
147
- echo '</ul>';
148
-
149
- echo '<fieldset><legend>' . __('Comment Form Text', 'subscribe-to-comments') . '</legend>';
150
-
151
- echo '<p>' . __('Customize the messages shown to different people. Use <code>[manager_link]</code> to insert the URI to the Subscription Manager.', 'subscribe-to-comments') . '</p>';
152
-
153
- echo '<ul>';
154
-
155
- echo '<li><label for="not_subscribed_text">' . __('Not subscribed', 'subscribe-to-comments') . '</label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="not_subscribed_text" name="sg_subscribe_settings[not_subscribed_text]">' . sg_subscribe_settings::textarea_setting('not_subscribed_text') . '</textarea></li>';
156
-
157
- echo '<li><label for="subscribed_text">' . __('Subscribed', 'subscribe-to-comments') . '</label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="subscribed_text" name="sg_subscribe_settings[subscribed_text]">' . sg_subscribe_settings::textarea_setting('subscribed_text') . '</textarea></li>';
158
-
159
- echo '<li><label for="author_text">' . __('Entry Author', 'subscribe-to-comments') . '</label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="author_text" name="sg_subscribe_settings[author_text]">' . sg_subscribe_settings::textarea_setting('author_text') . '</textarea></li>';
160
-
161
- echo '</ul></fieldset>';
162
-
163
-
164
- echo '<fieldset>';
165
- echo '<legend><input type="checkbox" id="use_custom_style" name="sg_subscribe_settings[use_custom_style]" value="use_custom_style"' . sg_subscribe_settings::checkflag('use_custom_style') . ' /> <label for="use_custom_style">' . __('Use custom style for Subscription Manager', 'subscribe-to-comments') . '</label></legend>';
166
-
167
- echo '<p>' . __('These settings only matter if you are using a custom style. <code>[theme_path]</code> will be replaced with the path to your current theme.', 'subscribe-to-comments') . '</p>';
168
-
169
- echo '<ul>';
170
- echo '<li><label for="sg_sub_header">' . __('Path to header:', 'subscribe-to-comments') . ' <input type="text" size="40" id="sg_sub_header" name="sg_subscribe_settings[header]" value="' . sg_subscribe_settings::form_setting('header') . '" /></label></li>';
171
- echo '<li><label for="sg_sub_sidebar">' . __('Path to sidebar:', 'subscribe-to-comments') . ' <input type="text" size="40" id="sg_sub_sidebar" name="sg_subscribe_settings[sidebar]" value="' . sg_subscribe_settings::form_setting('sidebar') . '" /></label></li>';
172
- echo '<li><label for="sg_sub_footer">' . __('Path to footer:', 'subscribe-to-comments') . ' <input type="text" size="40" id="sg_sub_footer" name="sg_subscribe_settings[footer]" value="' . sg_subscribe_settings::form_setting('footer') . '" /></label></li>';
173
-
174
-
175
- echo '<li><label for="before_manager">' . __('HTML for before the subscription manager:', 'subscribe-to-comments') . ' </label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="before_manager" name="sg_subscribe_settings[before_manager]">' . sg_subscribe_settings::textarea_setting('before_manager') . '</textarea></li>';
176
- echo '<li><label for="after_manager">' . __('HTML for after the subscription manager:', 'subscribe-to-comments') . ' </label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="after_manager" name="sg_subscribe_settings[after_manager]">' . sg_subscribe_settings::textarea_setting('after_manager') . '</textarea></li>';
177
- echo '</ul>';
178
- echo '</fieldset>';
179
- }
180
-
181
- function checkflag($optname) {
182
- $options = get_settings('sg_subscribe_settings');
183
- if ( $options[$optname] != $optname )
184
- return;
185
- return ' checked="checked"';
186
- }
187
-
188
- function form_setting($optname) {
189
- $options = get_settings('sg_subscribe_settings');
190
- return attribute_escape($options[$optname]);
191
- }
192
-
193
- function textarea_setting($optname) {
194
- $options = get_settings('sg_subscribe_settings');
195
- return wp_specialchars($options[$optname]);
196
- }
197
-
198
- function options_page() {
199
- /** Display "saved" notification on post **/
200
- if ( isset($_POST['sg_subscribe_settings_submit']) )
201
- echo '<div class="updated"><p><strong>' . __('Options saved.', 'subscribe-to-comments') . '</strong></p></div>';
202
-
203
- echo '<form method="post"><div class="wrap">';
204
-
205
- sg_subscribe_settings::options_page_contents();
206
-
207
- echo '<p class="submit"><input type="submit" name="sg_subscribe_settings_submit" value="';
208
- _e('Update Options &raquo;', 'subscribe-to-comments');
209
- echo '" /></p></div>';
210
-
211
- if ( function_exists('wp_nonce_field') )
212
- wp_nonce_field('subscribe-to-comments-update_options');
213
-
214
- echo '</form>';
215
- }
216
-
217
- }
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
- class sg_subscribe {
226
- var $errors;
227
- var $messages;
228
- var $post_subscriptions;
229
- var $email_subscriptions;
230
- var $subscriber_email;
231
- var $site_email;
232
- var $site_name;
233
- var $standalone;
234
- var $form_action;
235
- var $checkbox_shown;
236
- var $use_wp_style;
237
- var $header;
238
- var $sidebar;
239
- var $footer;
240
- var $clear_both;
241
- var $before_manager;
242
- var $after_manager;
243
- var $email;
244
- var $new_email;
245
- var $ref;
246
- var $key;
247
- var $key_type;
248
- var $action;
249
- var $default_subscribed;
250
- var $not_subscribed_text;
251
- var $subscribed_text;
252
- var $author_text;
253
- var $salt;
254
- var $settings;
255
- var $version = '2.1.2';
256
-
257
- function sg_subscribe() {
258
- global $wpdb;
259
- $this->db_upgrade_check();
260
-
261
- $this->settings = get_settings('sg_subscribe_settings');
262
-
263
- $this->salt = $this->settings['salt'];
264
- $this->site_email = ( is_email($this->settings['email']) && $this->settings['email'] != 'email@example.com' ) ? $this->settings['email'] : get_bloginfo('admin_email');
265
- $this->site_name = ( $this->settings['name'] != 'YOUR NAME' && !empty($this->settings['name']) ) ? $this->settings['name'] : get_bloginfo('name');
266
- $this->default_subscribed = ($this->settings['default_subscribed']) ? true : false;
267
-
268
- $this->not_subscribed_text = $this->settings['not_subscribed_text'];
269
- $this->subscribed_text = $this->settings['subscribed_text'];
270
- $this->author_text = $this->settings['author_text'];
271
- $this->clear_both = $this->settings['clear_both'];
272
-
273
- $this->errors = '';
274
- $this->post_subscriptions = array();
275
- $this->email_subscriptions = '';
276
- }
277
-
278
-
279
- function manager_init() {
280
- $this->messages = '';
281
- $this->use_wp_style = ( $this->settings['use_custom_style'] == 'use_custom_style' ) ? false : true;
282
- if ( !$this->use_wp_style ) {
283
- $this->header = str_replace('[theme_path]', get_template_directory(), $this->settings['header']);
284
- $this->sidebar = str_replace('[theme_path]', get_template_directory(), $this->settings['sidebar']);
285
- $this->footer = str_replace('[theme_path]', get_template_directory(), $this->settings['footer']);
286
- $this->before_manager = $this->settings['before_manager'];
287
- $this->after_manager = $this->settings['after_manager'];
288
- }
289
-
290
- foreach ( array('email', 'key', 'ref', 'new_email') as $var )
291
- if ( isset($_REQUEST[$var]) && !empty($_REQUEST[$var]) )
292
- $this->{$var} = attribute_escape(trim(stripslashes($_REQUEST[$var])));
293
- if ( !$this->key )
294
- $this->key = 'unset';
295
- }
296
-
297
-
298
- function add_error($text='generic error', $type='manager') {
299
- $this->errors[$type][] = $text;
300
- }
301
-
302
-
303
- function show_errors($type='manager', $before_all='<div class="updated updated-error">', $after_all='</div>', $before_each='<p>', $after_each='</p>'){
304
- if ( is_array($this->errors[$type]) ) {
305
- echo $before_all;
306
- foreach ($this->errors[$type] as $error)
307
- echo $before_each . $error . $after_each;
308
- echo $after_all;
309
- }
310
- unset($this->errors);
311
- }
312
-
313
-
314
- function add_message($text) {
315
- $this->messages[] = $text;
316
- }
317
-
318
-
319
- function show_messages($before_all='', $after_all='', $before_each='<div class="updated"><p>', $after_each='</p></div>'){
320
- if ( is_array($this->messages) ) {
321
- echo $before_all;
322
- foreach ($this->messages as $message)
323
- echo $before_each . $message . $after_each;
324
- echo $after_all;
325
- }
326
- unset($this->messages);
327
- }
328
-
329
-
330
- function subscriptions_from_post($postid) {
331
- if ( is_array($this->post_subscriptions[$postid]) )
332
- return $this->post_subscriptions[$postid];
333
- global $wpdb;
334
- $postid = (int) $postid;
335
- $this->post_subscriptions[$postid] = $wpdb->get_col("SELECT comment_author_email FROM $wpdb->comments WHERE comment_post_ID = '$postid' AND comment_subscribe='Y' AND comment_author_email != '' AND comment_approved = '1' GROUP BY LCASE(comment_author_email)");
336
- $subscribed_without_comment = (array) get_post_meta($postid, '_sg_subscribe-to-comments');
337
- $this->post_subscriptions[$postid] = array_merge((array) $this->post_subscriptions[$postid], (array) $subscribed_without_comment);
338
- $this->post_subscriptions[$postid] = array_unique($this->post_subscriptions[$postid]);
339
- return $this->post_subscriptions[$postid];
340
- }
341
-
342
-
343
- function subscriptions_from_email($email='') {
344
- if ( is_array($this->email_subscriptions) )
345
- return $this->email_subscriptions;
346
- if ( !is_email($email) )
347
- $email = $this->email;
348
- global $wpdb;
349
- $email = $wpdb->escape(strtolower($email));
350
-
351
- $subscriptions = $wpdb->get_results("SELECT comment_post_ID FROM $wpdb->comments WHERE LCASE(comment_author_email) = '$email' AND comment_subscribe='Y' AND comment_approved = '1' GROUP BY comment_post_ID");
352
- foreach ( (array) $subscriptions as $subscription )
353
- $this->email_subscriptions[] = $subscription->comment_post_ID;
354
- $subscriptions = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' AND LCASE(meta_value) = '$email' GROUP BY post_id");
355
- foreach ( (array) $subscriptions as $subscription)
356
- $this->email_subscriptions[] = $subscription->post_id;
357
- if ( is_array($this->email_subscriptions) ) {
358
- sort($this->email_subscriptions, SORT_NUMERIC);
359
- return $this->email_subscriptions;
360
- }
361
- return false;
362
- }
363
-
364
-
365
- function solo_subscribe ($email, $postid) {
366
- global $wpdb, $cache_userdata, $user_email;
367
- $postid = (int) $postid;
368
- $email = strtolower($email);
369
- if ( !is_email($email) ) {
370
- get_currentuserinfo();
371
- if ( is_email($user_email) )
372
- $email = strtolower($user_email);
373
- else
374
- $this->add_error(__('Please provide a valid e-mail address.', 'subscribe-to-comments'),'solo_subscribe');
375
- }
376
-
377
- if ( ( $email == $this->site_email && is_email($this->site_email) ) || ( $email == get_settings('admin_email') && is_email(get_settings('admin_email')) ) )
378
- $this->add_error(__('This e-mail address may not be subscribed', 'subscribe-to-comments'),'solo_subscribe');
379
-
380
- if ( is_array($this->subscriptions_from_email($email)) )
381
- if (in_array($postid, (array) $this->subscriptions_from_email($email))) {
382
- // already subscribed
383
- setcookie('comment_author_email_' . COOKIEHASH, $email, time() + 30000000, COOKIEPATH);
384
- $this->add_error(__('You appear to be already subscribed to this entry.', 'subscribe-to-comments'),'solo_subscribe');
385
- }
386
- $email = $wpdb->escape($email);
387
- $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$postid' AND comment_status <> 'closed' AND ( post_status = 'static' OR post_status = 'publish') LIMIT 1");
388
-
389
- if ( !$post )
390
- $this->add_error(__('Comments are not allowed on this entry.', 'subscribe-to-comments'),'solo_subscribe');
391
-
392
- if ( empty($cache_userdata[$post->post_author]) && $post->post_author != 0) {
393
- $cache_userdata[$post->post_author] = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = $post->post_author");
394
- $cache_userdata[$cache_userdata[$post->post_author]->user_login] =& $cache_userdata[$post->post_author];
395
- }
396
-
397
- $post_author = $cache_userdata[$post->post_author];
398
-
399
- if ( strtolower($post_author->user_email) == ($email) )
400
- $this->add_error(__('You appear to be already subscribed to this entry.', 'subscribe-to-comments'),'solo_subscribe');
401
-
402
- if ( !is_array($this->errors['solo_subscribe']) ) {
403
- add_post_meta($postid, '_sg_subscribe-to-comments', $email);
404
- setcookie('comment_author_email_' . COOKIEHASH, $email, time() + 30000000, COOKIEPATH);
405
- $location = $this->manage_link($email, false, false) . '&subscribeid=' . $postid;
406
- header("Location: $location");
407
- exit();
408
- }
409
- }
410
-
411
-
412
- function add_subscriber($cid) {
413
- global $wpdb;
414
- $cid = (int) $cid;
415
- $id = (int) $id;
416
- $email = strtolower($wpdb->get_var("SELECT comment_author_email FROM $wpdb->comments WHERE comment_ID = '$cid'"));
417
- $email_sql = $wpdb->escape($email);
418
- $postid = $wpdb->get_var("SELECT comment_post_ID from $wpdb->comments WHERE comment_ID = '$cid'");
419
-
420
- $previously_subscribed = ( $wpdb->get_var("SELECT comment_subscribe from $wpdb->comments WHERE comment_post_ID = '$postid' AND LCASE(comment_author_email) = '$email_sql' AND comment_subscribe = 'Y' LIMIT 1") || in_array($email, (array) get_post_meta($postid, '_sg_subscribe-to-comments')) ) ? true : false;
421
-
422
- // If user wants to be notified or has previously subscribed, set the flag on this current comment
423
- if (($_POST['subscribe'] == 'subscribe' && is_email($email)) || $previously_subscribed) {
424
- delete_post_meta($postid, '_sg_subscribe-to-comments', $email);
425
- $wpdb->query("UPDATE $wpdb->comments SET comment_subscribe = 'Y' where comment_post_ID = '$postid' AND LCASE(comment_author_email) = '$email'");
426
- }
427
- return $cid;
428
- }
429
-
430
-
431
- function is_blocked($email='') {
432
- global $wpdb;
433
- if ( !is_email($email) )
434
- $email = $this->email;
435
- if ( empty($email) )
436
- return false;
437
- $email = strtolower($email);
438
- // add the option if it doesn't exist
439
- add_option('do_not_mail', '');
440
- $blocked = (array) explode (' ', get_settings('do_not_mail'));
441
- if ( in_array($email, $blocked) )
442
- return true;
443
- return false;
444
- }
445
-
446
-
447
- function add_block($email='') {
448
- if ( !is_email($email) )
449
- $email = $this->email;
450
- global $wpdb;
451
- $email = strtolower($email);
452
-
453
- // add the option if it doesn't exist
454
- add_option('do_not_mail', '');
455
-
456
- // check to make sure this email isn't already in there
457
- if ( !$this->is_blocked($email) ) {
458
- // email hasn't already been added - so add it
459
- $blocked = get_settings('do_not_mail') . ' ' . $email;
460
- update_option('do_not_mail', $blocked);
461
- return true;
462
- }
463
- return false;
464
- }
465
-
466
-
467
- function remove_block($email='') {
468
- if ( !is_email($email) )
469
- $email = $this->email;
470
- global $wpdb;
471
- $email = strtolower($email);
472
-
473
- if ( $this->is_blocked($email) ) {
474
- // e-mail is in the list - so remove it
475
- $blocked = str_replace (' ' . $email, '', explode (' ', get_settings('do_not_mail')));
476
- update_option('do_not_mail', $blocked);
477
- return true;
478
- }
479
- return false;
480
- }
481
-
482
-
483
- function has_subscribers() {
484
- if ( count($this->get_unique_subscribers()) > 0 )
485
- return true;
486
- return false;
487
- }
488
-
489
-
490
- function get_unique_subscribers() {
491
- global $comments, $comment, $sg_subscribers;
492
- if ( isset($sg_subscribers) )
493
- return $sg_subscribers;
494
-
495
- $sg_subscribers = array();
496
- $subscriber_emails = array();
497
-
498
- // We run the comment loop, and put each unique subscriber into a new array
499
- foreach ( (array) $comments as $comment ) {
500
- if ( comment_subscription_status() && !in_array($comment->comment_author_email, $subscriber_emails) ) {
501
- $sg_subscribers[] = $comment;
502
- $subscriber_emails[] = $comment->comment_author_email;
503
- }
504
- }
505
- return $sg_subscribers;
506
- }
507
-
508
-
509
- function hidden_form_fields() { ?>
510
- <input type="hidden" name="ref" value="<?php echo $this->ref; ?>" />
511
- <input type="hidden" name="key" value="<?php echo $this->key; ?>" />
512
- <input type="hidden" name="email" value="<?php echo $this->email; ?>" />
513
- <?php
514
- }
515
-
516
-
517
- function generate_key($data='') {
518
- if ( '' == $data )
519
- return false;
520
- if ( !$this->settings['salt'] )
521
- die('fatal error: corrupted salt');
522
- return md5(md5($this->settings['salt'] . $data));
523
- }
524
-
525
-
526
- function validate_key() {
527
- if ( $this->key == $this->generate_key($this->email) )
528
- $this->key_type = 'normal';
529
- elseif ( $this->key == $this->generate_key($this->email . $this->new_email) )
530
- $this->key_type = 'change_email';
531
- elseif ( $this->key == $this->generate_key($this->email . 'blockrequest') )
532
- $this->key_type = 'block';
533
- elseif ( current_user_can('manage_options') )
534
- $this->key_type = 'admin';
535
- else
536
- return false;
537
- return true;
538
- }
539
-
540
-
541
- function determine_action() {
542
- // rather than check it a bunch of times
543
- $is_email = is_email($this->email);
544
-
545
- if ( is_email($this->new_email) && $is_email && $this->key_type == 'change_email' )
546
- $this->action = 'change_email';
547
- elseif ( isset($_POST['removesubscrips']) && $is_email )
548
- $this->action = 'remove_subscriptions';
549
- elseif ( isset($_POST['removeBlock']) && $is_email && current_user_can('manage_options') )
550
- $this->action = 'remove_block';
551
- elseif ( isset($_POST['changeemailrequest']) && $is_email && is_email($this->new_email) )
552
- $this->action = 'email_change_request';
553
- elseif ( $is_email && isset($_POST['blockemail']) )
554
- $this->action = 'block_request';
555
- elseif ( isset($_GET['subscribeid']) )
556
- $this->action = 'solo_subscribe';
557
- elseif ( $is_email && isset($_GET['blockemailconfirm']) && $this->key == $this->generate_key($this->email . 'blockrequest') )
558
- $this->action = 'block';
559
- else
560
- $this->action = 'none';
561
- }
562
-
563
-
564
- function remove_subscriber($email, $postid) {
565
- global $wpdb;
566
- $postid = (int) $postid;
567
- $email = strtolower($email);
568
- $email_sql = $wpdb->escape($email);
569
-
570
- if ( delete_post_meta($postid, '_sg_subscribe-to-comments', $email) || $wpdb->query("UPDATE $wpdb->comments SET comment_subscribe = 'N' WHERE comment_post_ID = '$postid' AND LCASE(comment_author_email) ='$email_sql'") )
571
- return true;
572
- else
573
- return false;
574
- }
575
-
576
-
577
- function remove_subscriptions ($postids) {
578
- global $wpdb;
579
- $removed = 0;
580
- for ($i = 0; $i < count($postids); $i++) {
581
- if ( $this->remove_subscriber($this->email, $postids[$i]) )
582
- $removed++;
583
- }
584
- return $removed;
585
- }
586
-
587
-
588
- function send_notifications($cid) {
589
- global $wpdb;
590
- $cid = (int) $cid;
591
- $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$cid' LIMIT 1");
592
- $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
593
-
594
- if ( $comment->comment_approved == '1' && $comment->comment_type == '' ) {
595
- // Comment has been approved and isn't a trackback or a pingback, so we should send out notifications
596
-
597
- $message = sprintf(__("There is a new comment on the post \"%s\"", 'subscribe-to-comments') . ". \n%s\n\n", $post->post_title, get_permalink($comment->comment_post_ID));
598
- $message .= sprintf(__("Author: %s\n", 'subscribe-to-comments'), $comment->comment_author);
599
- $message .= __("Comment:\n", 'subscribe-to-comments') . $comment->comment_content . "\n\n";
600
- $message .= __("See all comments on this post here:\n", 'subscribe-to-comments');
601
- $message .= get_permalink($comment->comment_post_ID) . "#comments\n\n";
602
- //add link to manage comment notifications
603
- $message .= __("To manage your subscriptions or to block all notifications from this site, click the link below:\n", 'subscribe-to-comments');
604
- $message .= get_settings('home') . '/?wp-subscription-manager=1&email=[email]&key=[key]';
605
-
606
- $subject = sprintf(__('New Comment On: %s', 'subscribe-to-comments'), $post->post_title);
607
-
608
- $subscriptions = $this->subscriptions_from_post($comment->comment_post_ID);
609
- foreach ( (array) $subscriptions as $email ) {
610
- if ( !$this->is_blocked($email) && $email != $comment->comment_author_email && is_email($email) ) {
611
- $message_final = str_replace('[email]', urlencode($email), $message);
612
- $message_final = str_replace('[key]', $this->generate_key($email), $message_final);
613
- $this->send_mail($email, $subject, $message_final);
614
- }
615
- } // foreach subscription
616
- } // end if comment approved
617
- return $cid;
618
- }
619
-
620
-
621
- function change_email_request() {
622
- if ( $this->is_blocked() )
623
- return false;
624
-
625
- $subject = __('E-mail change confirmation', 'subscribe-to-comments');
626
- $message = sprintf(__("You are receiving this message to confirm a change of e-mail address for your subscriptions at \"%s\"\n\n", 'subscribe-to-comments'), get_bloginfo('blogname'));
627
- $message .= sprintf(__("To change your e-mail address to %s, click this link:\n\n", 'subscribe-to-comments'), $this->new_email);
628
- $message .= get_option('home') . "/?wp-subscription-manager=1&email=" . urlencode($this->email) . "&new_email=" . urlencode($this->new_email) . "&key=" . $this->generate_key($this->email . $this->new_email) . ".\n\n";
629
- $message .= __('If you did not request this action, please disregard this message.', 'subscribe-to-comments');
630
- return $this->send_mail($this->email, $subject, $message);
631
- }
632
-
633
-
634
- function block_email_request($email) {
635
- if ( $this->is_blocked($email) )
636
- return false;
637
- $subject = __('E-mail block confirmation', 'subscribe-to-comments');
638
- $message = sprintf(__("You are receiving this message to confirm that you no longer wish to receive e-mail comment notifications from \"%s\"\n\n", 'subscribe-to-comments'), get_bloginfo('name'));
639
- $message .= __("To cancel all future notifications for this address, click this link:\n\n", 'subscribe-to-comments');
640
- $message .= get_option('home') . "/?wp-subscription-manager=1&email=" . urlencode($email) . "&key=" . $this->generate_key($email . 'blockrequest') . "&blockemailconfirm=true" . ".\n\n";
641
- $message .= __("If you did not request this action, please disregard this message.", 'subscribe-to-comments');
642
- return $this->send_mail($email, $subject, $message);
643
- }
644
-
645
-
646
- function send_mail($to, $subject, $message) {
647
- $subject = '[' . get_bloginfo('name') . '] ' . $subject;
648
-
649
- // strip out some chars that might cause issues, and assemble vars
650
- $site_name = str_replace('"', "'", $this->site_name);
651
- $site_email = str_replace(array('<', '>'), array('', ''), $this->site_email);
652
- $charset = get_settings('blog_charset');
653
-
654
- $headers = "From: \"{$site_name}\" <{$site_email}>\n";
655
- $headers .= "MIME-Version: 1.0\n";
656
- $headers .= "Content-Type: text/plain; charset=\"{$charset}\"\n";
657
- return wp_mail($to, $subject, $message, $headers);
658
- }
659
-
660
-
661
- function change_email() {
662
- global $wpdb;
663
- $new_email = $wpdb->escape(strtolower($this->new_email));
664
- $email = $wpdb->escape(strtolower($this->email));
665
- if ( $wpdb->query("UPDATE $wpdb->comments SET comment_author_email = '$new_email' WHERE comment_author_email = '$email'") )
666
- $return = true;
667
- if ( $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$new_email' WHERE meta_value = '$email' AND meta_key = '_sg_subscribe-to-comments'") )
668
- $return = true;
669
- return $return;
670
- }
671
-
672
-
673
- function entry_link($postid, $uri='') {
674
- if ( empty($uri) )
675
- $uri = get_permalink($postid);
676
- $postid = (int) $postid;
677
- $title = get_the_title($postid);
678
- if ( empty($title) )
679
- $title = __('click here', 'subscribe-to-comments');
680
- $output = '<a href="'.$uri.'">'.$title.'</a>';
681
- return $output;
682
- }
683
-
684
-
685
- function sg_wp_head() { ?>
686
- <style type="text/css" media="screen">
687
- .updated-error {
688
- background-color: #FF8080;
689
- border: 1px solid #F00;
690
- }
691
- </style>
692
- <?php
693
- return true;
694
- }
695
-
696
-
697
- function db_upgrade_check () {
698
- global $wpdb;
699
-
700
- // add the options
701
- add_option('sg_subscribe_settings', array('use_custom_style' => '', 'email' => get_bloginfo('admin_email'), 'name' => get_bloginfo('name'), 'header' => '[theme_path]/header.php', 'sidebar' => '', 'footer' => '[theme_path]/footer.php', 'before_manager' => '<div id="content" class="widecolumn subscription-manager">', 'after_manager' => '</div>', 'not_subscribed_text' => __('Notify me of followup comments via e-mail', 'subscribe-to-comments'), 'subscribed_text' => __('You are subscribed to this entry. <a href="[manager_link]">Manage your subscriptions</a>.', 'subscribe-to-comments'), 'author_text' => __('You are the author of this entry. <a href="[manager_link]">Manage subscriptions</a>.', 'subscribe-to-comments'), 'version' => $this->version));
702
-
703
- $settings = get_option('sg_subscribe_settings');
704
- if ( !$settings ) { // work around WP 2.2/2.2.1 bug
705
- wp_redirect('http://' . $_SERVER['HTTP_HOST'] . add_query_arg('stcwpbug', '1'));
706
- exit;
707
- }
708
-
709
- if ( !$settings['salt'] ) {
710
- $settings['salt'] = md5(md5(uniqid(rand() . rand() . rand() . rand() . rand(), true))); // random MD5 hash
711
- $update = true;
712
- }
713
-
714
- if ( !$settings['clear_both'] ) {
715
- $settings['clear_both'] = 'clear_both';
716
- $update = true;
717
- }
718
-
719
- if ( !$settings['version'] ) {
720
- $settings = stripslashes_deep($settings);
721
- $update = true;
722
- }
723
-
724
- if ( $settings['not_subscribed_text'] == '' || $settings['subscribed_text'] == '' ) { // recover from WP 2.2/2.2.1 bug
725
- delete_option('sg_subscribe_settings');
726
- wp_redirect('http://' . $_SERVER['HTTP_HOST'] . add_query_arg('stcwpbug', '2'));
727
- exit;
728
- }
729
-
730
- if ( $update )
731
- $this->update_settings($settings);
732
-
733
- $column_name = 'comment_subscribe';
734
- foreach ( (array) $wpdb->get_col("DESC $wpdb->comments", 0) as $column )
735
- if ($column == $column_name)
736
- return true;
737
-
738
- // didn't find it... create it
739
- $wpdb->query("ALTER TABLE $wpdb->comments ADD COLUMN comment_subscribe enum('Y','N') NOT NULL default 'N'");
740
- }
741
-
742
-
743
- function update_settings($settings) {
744
- $settings['version'] = $this->version;
745
- update_option('sg_subscribe_settings', $settings);
746
- }
747
-
748
-
749
- function current_viewer_subscription_status(){
750
- global $wpdb, $post, $user_email;
751
-
752
- $comment_author_email = ( isset($_COOKIE['comment_author_email_'. COOKIEHASH]) ) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
753
- get_currentuserinfo();
754
-
755
- if ( is_email($user_email) ) {
756
- $email = strtolower($user_email);
757
- $loggedin = true;
758
- } elseif ( is_email($comment_author_email) ) {
759
- $email = strtolower($comment_author_email);
760
- } else {
761
- return false;
762
- }
763
-
764
- $post_author = get_userdata($post->post_author);
765
- if ( strtolower($post_author->user_email) == $email && $loggedin )
766
- return 'admin';
767
-
768
- if ( is_array($this->subscriptions_from_email($email)) )
769
- if ( in_array($post->ID, (array) $this->email_subscriptions) )
770
- return $email;
771
- return false;
772
- }
773
-
774
-
775
- function manage_link($email='', $html=true, $echo=true) {
776
- $link = get_option('home') . '/?wp-subscription-manager=1';
777
- if ( $email != 'admin' ) {
778
- $link = add_query_arg('email', urlencode($email), $link);
779
- $link = add_query_arg('key', $this->generate_key($email), $link);
780
- }
781
- $link = add_query_arg('ref', rawurlencode('http://' . $_SERVER['HTTP_HOST'] . attribute_escape($_SERVER['REQUEST_URI'])), $link);
782
- //$link = str_replace('+', '%2B', $link);
783
- if ( $html )
784
- $link = htmlentities($link);
785
- if ( !$echo )
786
- return $link;
787
- echo $link;
788
- }
789
-
790
-
791
- function on_edit($cid) {
792
- global $wpdb;
793
- $comment = &get_comment($cid);
794
- if ( !is_email($comment->comment_author_email) && $comment->comment_subscribe == 'Y' )
795
- $wpdb->query("UPDATE $wpdb->comments SET comment_subscribe = 'N' WHERE comment_ID = '$comment->comment_ID' LIMIT 1");
796
- return $cid;
797
- }
798
-
799
-
800
- function add_admin_menu() {
801
- add_management_page(__('Comment Subscription Manager', 'subscribe-to-comments'), __('Subscriptions', 'subscribe-to-comments'), 8, 'stc-management', 'sg_subscribe_admin');
802
-
803
- add_options_page(__('Subscribe to Comments', 'subscribe-to-comments'), __('Subscribe to Comments', 'subscribe-to-comments'), 5, 'stc-options', array('sg_subscribe_settings', 'options_page'));
804
- }
805
-
806
-
807
- } // class sg_subscribe
808
-
809
-
810
-
811
-
812
-
813
- function stc_checkbox_state($data) {
814
- if ( isset($_POST['subscribe']) )
815
- setcookie('subscribe_checkbox_'. COOKIEHASH, 'checked', time() + 30000000, COOKIEPATH);
816
- else
817
- setcookie('subscribe_checkbox_'. COOKIEHASH, 'unchecked', time() + 30000000, COOKIEPATH);
818
- return $data;
819
- }
820
-
821
-
822
- function sg_subscribe_start() {
823
- global $sg_subscribe;
824
-
825
- if ( !$sg_subscribe ) {
826
- load_plugin_textdomain('subscribe-to-comments');
827
- $sg_subscribe = new sg_subscribe();
828
- }
829
- }
830
-
831
- // This will be overridden if the user manually places the function
832
- // in the comments form before the comment_form do_action() call
833
- add_action('comment_form', 'show_subscription_checkbox');
834
-
835
- // priority is very low (50) because we want to let anti-spam plugins have their way first.
836
- add_action('comment_post', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); return $sg_subscribe->send_notifications($a);'), 50);
837
- add_action('comment_post', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); return $sg_subscribe->add_subscriber($a);'));
838
-
839
- add_action('wp_set_comment_status', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); return $sg_subscribe->send_notifications($a);'));
840
- add_action('admin_menu', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); $sg_subscribe->add_admin_menu();'));
841
- add_action('admin_head', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); $sg_subscribe->sg_wp_head();'));
842
- add_action('edit_comment', array('sg_subscribe', 'on_edit'));
843
-
844
- // save users' checkbox preference
845
- add_filter('preprocess_comment', 'stc_checkbox_state', 1);
846
-
847
-
848
- // detect "subscribe without commenting" attempts
849
- add_action('init', create_function('$a','global $sg_subscribe; if ( $_POST[\'solo-comment-subscribe\'] == \'solo-comment-subscribe\' && is_numeric($_POST[\'postid\']) ) {
850
- sg_subscribe_start();
851
- $sg_subscribe->solo_subscribe(stripslashes($_POST[\'email\']), (int) $_POST[\'postid\']);
852
- }')
853
- );
854
-
855
- if ( isset($_REQUEST['wp-subscription-manager']) )
856
- add_action('template_redirect', 'sg_subscribe_admin_standalone');
857
-
858
- function sg_subscribe_admin_standalone() {
859
- sg_subscribe_admin(true);
860
- }
861
-
862
- function sg_subscribe_admin($standalone = false) {
863
- global $wpdb, $sg_subscribe;
864
-
865
- sg_subscribe_start();
866
-
867
- if ( $standalone ) {
868
- $sg_subscribe->form_action = get_option('home') . '/?wp-subscription-manager=1';
869
- $sg_subscribe->standalone = true;
870
- ob_start(create_function('$a', 'return str_replace("<title>", "<title> " . __("Subscription Manager", "subscribe-to-comments") . " &raquo; ", $a);'));
871
- } else {
872
- $sg_subscribe->form_action = 'edit.php?page=stc-management';
873
- $sg_subscribe->standalone = false;
874
- }
875
-
876
- $sg_subscribe->manager_init();
877
-
878
- get_currentuserinfo();
879
-
880
- if ( !$sg_subscribe->validate_key() )
881
- die ( __('You may not access this page without a valid key.', 'subscribe-to-comments') );
882
-
883
- $sg_subscribe->determine_action();
884
-
885
- switch ($sg_subscribe->action) :
886
-
887
- case "change_email" :
888
- if ( $sg_subscribe->change_email() ) {
889
- $sg_subscribe->add_message(sprintf(__('All notifications that were formerly sent to <strong>%1$s</strong> will now be sent to <strong>%2$s</strong>!', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->new_email));
890
- // change info to the new email
891
- $sg_subscribe->email = $sg_subscribe->new_email;
892
- unset($sg_subscribe->new_email);
893
- $sg_subscribe->key = $sg_subscribe->generate_key($sg_subscribe->email);
894
- $sg_subscribe->validate_key();
895
- }
896
- break;
897
-
898
- case "remove_subscriptions" :
899
- $postsremoved = $sg_subscribe->remove_subscriptions($_POST['subscrips']);
900
- if ( $postsremoved > 0 )
901
- $sg_subscribe->add_message(sprintf(__('<strong>%1$s</strong> %2$s removed successfully.', 'subscribe-to-comments'), $postsremoved, ($postsremoved != 1) ? __('subscriptions', 'subscribe-to-comments') : __('subscription', 'subscribe-to-comments')));
902
- break;
903
-
904
- case "remove_block" :
905
- if ( $sg_subscribe->remove_block($sg_subscribe->email) )
906
- $sg_subscribe->add_message(sprintf(__('The block on <strong>%s</strong> has been successfully removed.', 'subscribe-to-comments'), $sg_subscribe->email));
907
- else
908
- $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> isn\'t blocked!', 'subscribe-to-comments'), $sg_subscribe->email), 'manager');
909
- break;
910
-
911
- case "email_change_request" :
912
- if ( $sg_subscribe->is_blocked($sg_subscribe->email) )
913
- $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> has been blocked from receiving notifications. You will have to have the administrator remove the block before you will be able to change your notification address.', 'subscribe-to-comments'), $sg_subscribe->email));
914
- else
915
- if ($sg_subscribe->change_email_request($sg_subscribe->email, $sg_subscribe->new_email))
916
- $sg_subscribe->add_message(sprintf(__('Your change of e-mail request was successfully received. Please check your old account (<strong>%s</strong>) in order to confirm the change.', 'subscribe-to-comments'), $sg_subscribe->email));
917
- break;
918
-
919
- case "block_request" :
920
- if ($sg_subscribe->block_email_request($sg_subscribe->email ))
921
- $sg_subscribe->add_message(sprintf(__('Your request to block <strong>%s</strong> from receiving any further notifications has been received. In order for you to complete the block, please check your e-mail and click on the link in the message that has been sent to you.', 'subscribe-to-comments'), $sg_subscribe->email));
922
- break;
923
-
924
- case "solo_subscribe" :
925
- $sg_subscribe->add_message(sprintf(__('<strong>%1$s</strong> has been successfully subscribed to %2$s', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->entry_link($_GET['subscribeid'])));
926
- break;
927
-
928
- case "block" :
929
- if ($sg_subscribe->add_block($sg_subscribe->email))
930
- $sg_subscribe->add_message(sprintf(__('<strong>%1$s</strong> has been added to the "do not mail" list. You will no longer receive any notifications from this site. If this was done in error, please contact the <a href="mailto:%2$s">site administrator</a> to remove this block.', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->site_email));
931
- else
932
- $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> has already been blocked!', 'subscribe-to-comments'), $sg_subscribe->email), 'manager');
933
- $sg_subscribe->key = $sg_subscribe->generate_key($sg_subscribe->email);
934
- $sg_subscribe->validate_key();
935
- break;
936
-
937
- endswitch;
938
-
939
-
940
-
941
- if ( $sg_subscribe->standalone ) {
942
- if ( !$sg_subscribe->use_wp_style && !empty($sg_subscribe->header) ) {
943
- @include($sg_subscribe->header);
944
- echo $sg_subscribe->before_manager;
945
- } else { ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
946
- <html>
947
- <head>
948
- <title><?php printf(__('%s Comment Subscription Manager', 'subscribe-to-comments'), bloginfo('name')); ?></title>
949
-
950
- <style type="text/css" media="screen">
951
- @import url( <?php echo get_settings('siteurl'); ?>/wp-admin/wp-admin.css );
952
- </style>
953
-
954
- <link rel="stylesheet" type="text/css" media="print" href="<?php echo get_settings('siteurl'); ?>/print.css" />
955
-
956
- <meta http-equiv="Content-Type" content="text/html;
957
- charset=<?php bloginfo('charset'); ?>" />
958
-
959
- <?php $sg_subscribe->sg_wp_head(); ?>
960
-
961
- </head>
962
- <body>
963
- <?php } ?>
964
- <?php } ?>
965
-
966
-
967
- <?php $sg_subscribe->show_messages(); ?>
968
-
969
- <?php $sg_subscribe->show_errors(); ?>
970
-
971
-
972
- <div class="wrap">
973
- <h2><?php printf(__('%s Comment Subscription Manager', 'subscribe-to-comments'), bloginfo('name')); ?></h2>
974
-
975
- <?php if (!empty($sg_subscribe->ref)) : ?>
976
- <?php $sg_subscribe->add_message(sprintf(__('Return to the page you were viewing: %s', 'subscribe-to-comments'), $sg_subscribe->entry_link(url_to_postid($sg_subscribe->ref), $sg_subscribe->ref))); ?>
977
- <?php $sg_subscribe->show_messages(); ?>
978
- <?php endif; ?>
979
-
980
-
981
-
982
- <?php if ( $sg_subscribe->is_blocked() ) { ?>
983
-
984
- <?php if ( current_user_can('manage_options') ) : ?>
985
-
986
- <fieldset class="options">
987
- <legend><?php _e('Remove Block', 'subscribe-to-comments'); ?></legend>
988
-
989
- <p>
990
- <?php printf(__('Click the button below to remove the block on <strong>%s</strong>. This should only be done if the user has specifically requested it.', 'subscribe-to-comments'), $sg_subscribe->email); ?>
991
- </p>
992
-
993
- <form name="removeBlock" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
994
- <input type="hidden" name="removeBlock" value="removeBlock /">
995
- <?php $sg_subscribe->hidden_form_fields(); ?>
996
-
997
- <p class="submit">
998
- <input type="submit" name="submit" value="<?php _e('Remove Block &raquo;', 'subscribe-to-comments'); ?>" />
999
- </p>
1000
- </form>
1001
- </fieldset>
1002
-
1003
- <?php else : ?>
1004
-
1005
- <fieldset class="options">
1006
- <legend><?php _e('Blocked', 'subscribe-to-comments'); ?></legend>
1007
-
1008
- <p>
1009
- <?php printf(__('You have indicated that you do not wish to receive any notifications at <strong>%1$s</strong> from this site. If this is incorrect, or if you wish to have the block removed, please contact the <a href="mailto:%2$s">site administrator</a>.', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->site_email); ?>
1010
- </p>
1011
- </fieldset>
1012
-
1013
- <?php endif; ?>
1014
-
1015
-
1016
- <?php } else { ?>
1017
-
1018
-
1019
- <?php $postlist = $sg_subscribe->subscriptions_from_email(); ?>
1020
-
1021
- <?php
1022
- if ( isset($sg_subscribe->email) && !is_array($postlist) && $sg_subscribe->email != $sg_subscribe->site_email && $sg_subscribe->email != get_bloginfo('admin_email') ) {
1023
- if ( is_email($sg_subscribe->email) )
1024
- $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> is not subscribed to any posts on this site.', 'subscribe-to-comments'), $sg_subscribe->email));
1025
- else
1026
- $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> is not a valid e-mail address.', 'subscribe-to-comments'), $sg_subscribe->email));
1027
- }
1028
- ?>
1029
-
1030
- <?php $sg_subscribe->show_errors(); ?>
1031
-
1032
-
1033
-
1034
-
1035
- <?php if ( current_user_can('manage_options') ) { ?>
1036
-
1037
- <fieldset class="options">
1038
- <?php if ( $_REQUEST['email'] ) : ?>
1039
- <p><a href="<?php echo $sg_subscribe->form_action; ?>"><?php _e('&laquo; Back'); ?></a></p>
1040
- <?php endif; ?>
1041
-
1042
- <legend><?php _e('Find Subscriptions', 'subscribe-to-comments'); ?></legend>
1043
-
1044
- <p>
1045
- <?php _e('Enter an e-mail address to view its subscriptions or undo a block.', 'subscribe-to-comments'); ?>
1046
- </p>
1047
-
1048
- <form name="getemail" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
1049
- <input type="hidden" name="ref" value="<?php echo $sg_subscribe->ref; ?>" />
1050
-
1051
- <p>
1052
- <input name="email" type="text" id="email" size="40" />
1053
- <input type="submit" value="<?php _e('Search &raquo;', 'subscribe-to-comments'); ?>" />
1054
- </p>
1055
- </form>
1056
- </fieldset>
1057
-
1058
- <?php if ( !$_REQUEST['email'] ) : ?>
1059
- <fieldset class="options">
1060
- <?php if ( !$_REQUEST['showallsubscribers'] ) : ?>
1061
- <legend><?php _e('Top Subscriber List', 'subscribe-to-comments'); ?></legend>
1062
- <?php else : ?>
1063
- <legend><?php _e('Subscriber List', 'subscribe-to-comments'); ?></legend>
1064
- <?php endif; ?>
1065
-
1066
- <?php
1067
- $stc_limit = ( !$_REQUEST['showallsubscribers'] ) ? 'LIMIT 25' : '';
1068
- $all_ct_subscriptions = $wpdb->get_results("SELECT distinct LCASE(comment_author_email) as email, count(distinct comment_post_ID) as ccount FROM $wpdb->comments WHERE comment_subscribe='Y' AND comment_approved = '1' GROUP BY email ORDER BY ccount DESC $stc_limit");
1069
- $all_pm_subscriptions = $wpdb->get_results("SELECT distinct LCASE(meta_value) as email, count(post_id) as ccount FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' GROUP BY email ORDER BY ccount DESC $stc_limit");
1070
- $all_subscriptions = array();
1071
-
1072
- foreach ( array('all_ct_subscriptions', 'all_pm_subscriptions') as $each ) {
1073
- foreach ( (array) $$each as $sub ) {
1074
- if ( !isset($all_subscriptions[$sub->email]) )
1075
- $all_subscriptions[$sub->email] = (int) $sub->ccount;
1076
- else
1077
- $all_subscriptions[$sub->email] += (int) $sub->ccount;
1078
- }
1079
- }
1080
-
1081
- if ( !$_REQUEST['showallsubscribers'] ) : ?>
1082
- <p><a href="<?php echo attribute_escape(add_query_arg('showallsubscribers', '1', $sg_subscribe->form_action)); ?>"><?php _e('Show all subscribers', 'subscribe-to-comments'); ?></a></p>
1083
- <?php elseif ( !$_REQUEST['showccfield'] ) : ?>
1084
- <p><a href="<?php echo add_query_arg('showccfield', '1'); ?>"><?php _e('Show list of subscribers in <code>CC:</code>-field format (for bulk e-mailing)', 'subscribe-to-comments'); ?></a></p>
1085
- <?php else : ?>
1086
- <p><a href="<?php echo attribute_escape($sg_subscribe->form_action); ?>"><?php _e('&laquo; Back to regular view'); ?></a></p>
1087
- <p><textarea cols="60" rows="10"><?php echo implode(', ', array_keys($all_subscriptions) ); ?></textarea></p>
1088
- <?php endif;
1089
-
1090
-
1091
- if ( $all_subscriptions ) {
1092
- if ( !$_REQUEST['showccfield'] ) {
1093
- echo "<ul>\n";
1094
- foreach ( (array) $all_subscriptions as $email => $ccount ) {
1095
- $enc_email = urlencode($email);
1096
- echo "<li>($ccount) <a href='" . attribute_escape($sg_subscribe->form_action . "&email=$enc_email") . "'>" . wp_specialchars($email) . "</a></li>\n";
1097
- }
1098
- echo "</ul>\n";
1099
- }
1100
- ?>
1101
- <legend><?php _e('Top Subscribed Posts', 'subscribe-to-comments'); ?></legend>
1102
- <?php
1103
- $top_subscribed_posts1 = $wpdb->get_results("SELECT distinct comment_post_ID as post_id, count(distinct comment_author_email) as ccount FROM $wpdb->comments WHERE comment_subscribe='Y' AND comment_approved = '1' GROUP BY post_id ORDER BY ccount DESC LIMIT 25");
1104
- $top_subscribed_posts2 = $wpdb->get_results("SELECT distinct post_id, count(distinct meta_value) as ccount FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' GROUP BY post_id ORDER BY ccount DESC LIMIT 25");
1105
- $all_top_posts = array();
1106
-
1107
- foreach ( array('top_subscribed_posts1', 'top_subscribed_posts2') as $each ) {
1108
- foreach ( (array) $$each as $pid ) {
1109
- if ( !isset($all_top_posts[$pid->post_id]) )
1110
- $all_top_posts[$pid->post_id] = (int) $pid->ccount;
1111
- else
1112
- $all_top_posts[$pid->post_id] += (int) $pid->ccount;
1113
- }
1114
- }
1115
- arsort($all_top_posts);
1116
-
1117
- echo "<ul>\n";
1118
- foreach ( $all_top_posts as $pid => $ccount ) {
1119
- echo "<li>($ccount) <a href='" . get_permalink($pid) . "'>" . get_the_title($pid) . "</a></li>\n";
1120
- }
1121
- echo "</ul>";
1122
- ?>
1123
-
1124
- <?php } ?>
1125
-
1126
- </fieldset>
1127
-
1128
- <?php endif; ?>
1129
-
1130
- <?php } ?>
1131
-
1132
- <?php if ( count($postlist) > 0 && is_array($postlist) ) { ?>
1133
-
1134
-
1135
- <script type="text/javascript">
1136
- <!--
1137
- function checkAll(form) {
1138
- for ( i = 0, n = form.elements.length; i < n; i++ ) {
1139
- if ( form.elements[i].type == "checkbox" ) {
1140
- if ( form.elements[i].checked == true )
1141
- form.elements[i].checked = false;
1142
- else
1143
- form.elements[i].checked = true;
1144
- }
1145
- }
1146
- }
1147
- //-->
1148
- </script>
1149
-
1150
- <fieldset class="options">
1151
- <legend><?php _e('Subscriptions', 'subscribe-to-comments'); ?></legend>
1152
-
1153
- <p>
1154
- <?php printf(__('<strong>%s</strong> is subscribed to the posts listed below. To unsubscribe to one or more posts, click the checkbox next to the title, then click "Remove Selected Subscription(s)" at the bottom of the list.', 'subscribe-to-comments'), $sg_subscribe->email); ?>
1155
- </p>
1156
-
1157
- <form name="removeSubscription" id="removeSubscription" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
1158
- <input type="hidden" name="removesubscrips" value="removesubscrips" />
1159
- <?php $sg_subscribe->hidden_form_fields(); ?>
1160
-
1161
- <ol>
1162
- <?php for ($i = 0; $i < count($postlist); $i++) { ?>
1163
- <li><label for="subscrip-<?php echo $i; ?>"><input id="subscrip-<?php echo $i; ?>" type="checkbox" name="subscrips[]" value="<?php echo $postlist[$i]; ?>" /> <?php echo $sg_subscribe->entry_link($postlist[$i]); ?></label></li>
1164
- <?php } ?>
1165
- </ol>
1166
-
1167
- <p>
1168
- <a href="javascript:;" onclick="checkAll(document.getElementById('removeSubscription')); return false; "><?php _e('Invert Checkbox Selection', 'subscribe-to-comments'); ?></a>
1169
- </p>
1170
-
1171
- <p class="submit">
1172
- <input type="submit" name="submit" value="<?php _e('Remove Selected Subscription(s) &raquo;', 'subscribe-to-comments'); ?>" />
1173
- </p>
1174
- </form>
1175
- </fieldset>
1176
- </div>
1177
-
1178
- <div class="wrap">
1179
- <h2><?php _e('Advanced Options', 'subscribe-to-comments'); ?></h2>
1180
-
1181
- <fieldset class="options">
1182
- <legend><?php _e('Block All Notifications', 'subscribe-to-comments'); ?></legend>
1183
-
1184
- <form name="blockemail" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
1185
- <input type="hidden" name="blockemail" value="blockemail" />
1186
- <?php $sg_subscribe->hidden_form_fields(); ?>
1187
-
1188
- <p>
1189
- <?php printf(__('If you would like <strong>%s</strong> to be blocked from receiving any notifications from this site, click the button below. This should be reserved for cases where someone is signing you up for notifications without your consent.', 'subscribe-to-comments'), $sg_subscribe->email); ?>
1190
- </p>
1191
-
1192
- <p class="submit">
1193
- <input type="submit" name="submit" value="<?php _e('Block Notifications &raquo;', 'subscribe-to-comments'); ?>" />
1194
- </p>
1195
- </form>
1196
- </fieldset>
1197
-
1198
- <fieldset class="options">
1199
- <legend><?php _e('Change E-mail Address', 'subscribe-to-comments'); ?></legend>
1200
-
1201
- <form name="changeemailrequest" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
1202
- <input type="hidden" name="changeemailrequest" value="changeemailrequest" />
1203
- <?php $sg_subscribe->hidden_form_fields(); ?>
1204
-
1205
- <p>
1206
- <?php printf(__('If you would like to change the e-mail address for your subscriptions, enter the new address below. You will be required to verify this request by clicking a special link sent to your current address (<strong>%s</strong>).', 'subscribe-to-comments'), $sg_subscribe->email); ?>
1207
- </p>
1208
-
1209
- <p>
1210
- <?php _e('New E-mail Address:', 'subscribe-to-comments'); ?>
1211
- <input name="new_email" type="text" id="new_email" size="40" />
1212
- </p>
1213
-
1214
- <p class="submit">
1215
- <input type="submit" name="submit" value="<?php _e('Change E-mail Address &raquo;', 'subscribe-to-comments'); ?>" />
1216
- </p>
1217
- </form>
1218
- </fieldset>
1219
-
1220
- <?php } ?>
1221
- <?php } //end if not in do not mail ?>
1222
- </div>
1223
-
1224
- <?php if ( $sg_subscribe->standalone ) : ?>
1225
- <?php if ( !$sg_subscribe->use_wp_style ) :
1226
- echo $sg_subscribe->after_manager;
1227
-
1228
- if ( !empty($sg_subscribe->sidebar) )
1229
- @include_once($sg_subscribe->sidebar);
1230
- if ( !empty($sg_subscribe->footer) )
1231
- @include_once($sg_subscribe->footer);
1232
- ?>
1233
- <?php else : ?>
1234
- </body>
1235
- </html>
1236
- <?php endif; ?>
1237
- <?php endif; ?>
1238
-
1239
-
1240
- <?php die(); // stop WP from loading ?>
1241
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Subscribe To Comments
4
+ Version: 2.3
5
+ Plugin URI: http://txfx.net/wordpress-plugins/subscribe-to-comments/
6
+ Description: Allows readers to choose to receive notifications of new comments that are posted to an entry.
7
+ Author: Mark Jaquith
8
+ Author URI: http://coveredwebservices.com/
9
+ */
10
+
11
+
12
+
13
+
14
+
15
+
16
+ /**
17
+ * Returns the CWS_STC singleton object
18
+ * @return CWS_STC the instantiated CWS_STC object
19
+ */
20
+ function _stc() {
21
+ global $_cws_stc, $sg_subscribe;
22
+ if ( !isset( $_cws_stc ) || !is_object( $_cws_stc ) ) {
23
+ /**
24
+ * @global CWS_STC $_cws_stc
25
+ */
26
+ $_cws_stc = new CWS_STC;
27
+ /**
28
+ * @global CWS_STC $sg_subscribe
29
+ * @deprecated
30
+ */
31
+ $sg_subscribe = &$_cws_stc; // Backwards compat
32
+ }
33
+ return $_cws_stc;
34
+ }
35
+
36
+ // Backwards Compat
37
+ function show_subscription_checkbox( $id=0 ) {
38
+ _stc()->echo_add_checkbox();
39
+ }
40
+
41
+ function show_manual_subscription_form() {
42
+ global $id, $sg_subscribe, $user_email;
43
+ _stc()->show_errors( 'solo_subscribe', '<div class="solo-subscribe-errors">', '</div>', __( '<strong>Error: </strong>', 'subscribe-to-comments' ), '<br />' );
44
+
45
+ if ( !_stc()->current_viewer_subscription_status() ) :
46
+ get_currentuserinfo(); ?>
47
+
48
+ <form action="" method="post">
49
+ <input type="hidden" name="solo-comment-subscribe" value="solo-comment-subscribe" />
50
+ <input type="hidden" name="postid" value="<?php echo absint( $id ); ?>" />
51
+ <input type="hidden" name="ref" value="<?php echo esc_url( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); ?>" />
52
+
53
+ <p class="solo-subscribe-to-comments">
54
+ <?php _e( 'Subscribe without commenting', 'subscribe-to-comments' ); ?>
55
+ <br />
56
+ <label for="solo-subscribe-email"><?php _e( 'E-Mail:', 'subscribe-to-comments' ); ?>
57
+ <input type="text" name="email" id="solo-subscribe-email" size="22" value="<?php echo esc_attr( $user_email ); ?>" /></label>
58
+ <input type="submit" name="submit" value="<?php _e( 'Subscribe', 'subscribe-to-comments' ); ?>" />
59
+ </p>
60
+ </form>
61
+
62
+ <?php endif;
63
+ }
64
+
65
+ /**
66
+ * Returns the subscription status of the current comment in the comments loop
67
+ * @return bool
68
+ */
69
+ function comment_subscription_status() {
70
+ global $comment;
71
+ return !!_stc()->is_subscribed( $comment->comment_ID );
72
+ }
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+ class CWS_STC {
93
+ var $errors;
94
+ var $messages;
95
+ var $bid_post_subscriptions;
96
+ var $email_subscriptions;
97
+ var $subscriber_email;
98
+ var $site_email;
99
+ var $site_name;
100
+ var $standalone;
101
+ var $form_action;
102
+ var $checkbox_shown;
103
+ var $use_wp_style;
104
+ var $header;
105
+ var $sidebar;
106
+ var $footer;
107
+ var $clear_both;
108
+ var $before_manager;
109
+ var $after_manager;
110
+ var $email;
111
+ var $new_email;
112
+ var $ref;
113
+ var $key;
114
+ var $key_type;
115
+ var $action;
116
+ var $default_subscribed;
117
+ var $not_subscribed_text;
118
+ var $subscribed_text;
119
+ var $author_text;
120
+ var $subscribed_format;
121
+ var $salt;
122
+ var $settings;
123
+ var $version = '2.3-bleeding';
124
+ var $is_multisite;
125
+ var $ms_table;
126
+
127
+ function __construct() {
128
+ global $wpdb;
129
+ // Multisite code is disabled. It exists so that adventurous blog networks can play with it they like.
130
+ // IT IS NOT SUPPORTED. IT MAY BURN YOUR HOUSE DOWN.
131
+ $this->is_multisite = defined( 'STC_MULTISITE' ) && STC_MULTISITE;
132
+ if ( $this->is_multisite() )
133
+ $this->ms_table = $wpdb->base_prefix . 'comment_subscriptions';
134
+ $this->db_upgrade_check();
135
+
136
+ $this->register_hooks();
137
+ register_uninstall_hook( __FILE__, 'cws_stc_uninstall_hook' );
138
+
139
+ $this->settings = $this->get_options();
140
+
141
+ $this->salt = $this->settings['salt'];
142
+ $this->site_email = ( is_email( $this->settings['email'] ) && $this->settings['email'] != 'email@example.com' ) ? $this->settings['email'] : get_bloginfo( 'admin_email' );
143
+ $this->site_name = ( $this->settings['name'] != 'YOUR NAME' && !empty( $this->settings['name'] ) ) ? $this->settings['name'] : get_bloginfo( 'name' );
144
+ $this->default_subscribed = ( isset($this->settings['default_subscribed']) ) ? true : false;
145
+
146
+ $this->not_subscribed_text = $this->settings['not_subscribed_text'];
147
+ $this->subscribed_text = $this->settings['subscribed_text'];
148
+ $this->author_text = $this->settings['author_text'];
149
+ $this->subscribed_format = $this->settings['subscribed_format'];
150
+ $this->clear_both = $this->settings['clear_both'];
151
+
152
+ $this->errors = '';
153
+ $this->bid_post_subscriptions = array();
154
+ $this->email_subscriptions = '';
155
+ }
156
+
157
+ /**
158
+ * Registers this plugin's WordPress hooks
159
+ */
160
+ function register_hooks() {
161
+ /*
162
+ This will be overridden if the user manually places the function
163
+ in the comments form before the comment_form do_action() call
164
+ or if the user has a theme that supports a hookable comments form
165
+ */
166
+ add_action( 'comment_form', array( $this, 'echo_add_checkbox' ));
167
+ // Hook in to themes that use comment_form()
168
+ add_filter( 'comment_form_defaults', array( $this, 'add_checkbox_to_default' ));
169
+
170
+ // priority is very low (50) because we want to let anti-spam plugins have their way first.
171
+ add_action( 'comment_post', array( $this, 'send_notifications' ));
172
+ add_action( 'comment_post', array( $this, 'maybe_add_subscriber' ));
173
+ add_action( 'wp_set_comment_status', array( $this, 'send_notifications' ));
174
+ add_action( 'admin_menu', array( $this, 'add_admin_menu' ));
175
+ add_action( 'admin_head', array( $this, 'admin_head' ));
176
+ add_action( 'edit_comment', array( $this, 'on_edit' ));
177
+ add_action( 'delete_comment', array( $this, 'on_delete' ));
178
+ add_filter( 'the_content', array( $this, 'manager' ));
179
+
180
+ add_filter( 'get_comment_author_link', 'stc_comment_author_filter' );
181
+
182
+ // save users' checkbox preference
183
+ add_filter( 'preprocess_comment', 'stc_checkbox_state', 1 );
184
+
185
+ // detect "subscribe without commenting" attempts
186
+ add_action( 'init', array( $this, 'maybe_solo_subscribe' ) );
187
+
188
+ if ( isset( $_REQUEST['wp-subscription-manager'] ) )
189
+ add_action( 'template_redirect', array( $this, 'single' ) );
190
+ }
191
+
192
+ function manager( $content ) {
193
+ global $post;
194
+ if ( $post->ID == $this->get_manage_id() ) {
195
+ $content = '';
196
+ ob_start();
197
+ sg_subscribe_admin( true );
198
+ $content = ob_get_clean();
199
+ }
200
+ return $content;
201
+ }
202
+
203
+ function get_manage_id() {
204
+ if ( !isset ($this->settings['manage_id']) || !get_post( $this->settings['manage_id'] ) ) {
205
+ $this->settings['manage_id'] = wp_insert_post( array(
206
+ 'post_title' => __( 'Comment Manager', 'subscribe-to-comments' ),
207
+ 'post_type' => 'stc',
208
+ 'post_status' => 'publish',
209
+ 'comment_status' => 'closed',
210
+ 'ping_status' => 'closed'
211
+ ) );
212
+ $this->update_settings( $this->settings );
213
+ }
214
+ // wp_delete_post( $this->settings['manage_id'] );
215
+ // die('deleted');
216
+ return $this->settings['manage_id'];
217
+ }
218
+
219
+ function wp_title( $title, $sep, $reverse ) {
220
+ if ( 'right' == $reverse )
221
+ return __( 'Comment Subscription Manager' ) . ' ' . $sep . ' ';
222
+ else
223
+ return ' ' . $sep . ' ' . __( 'Comment Subscription Manager' );
224
+ }
225
+
226
+ function standalone_css() {
227
+ if ( 'twentyten' == get_option( 'template' ) ) {
228
+ ?>
229
+ <style>
230
+ .entry-meta, .entry-utility { display: none; }
231
+ </style>
232
+ <?php
233
+ }
234
+ }
235
+
236
+ function single() {
237
+ query_posts( array(
238
+ 'post_type' => 'stc',
239
+ 'p' => $this->get_manage_id(),
240
+ 'post_status' => 'publish'
241
+ ) );
242
+ add_action( 'wp_title', array( $this, 'wp_title' ), 10, 5 );
243
+ add_action( 'wp_head', array( $this, 'standalone_css' ) );
244
+ if ( $template = get_single_template() ) {
245
+ include( $template );
246
+ exit();
247
+ }
248
+ }
249
+
250
+ function uninstall() {
251
+ delete_option( 'sg_subscribe_settings' );
252
+ }
253
+
254
+ function manager_init() {
255
+ $this->messages = '';
256
+ $this->use_wp_style = ( $this->settings['use_custom_style'] == 'use_custom_style' ) ? false : true;
257
+ if ( !$this->use_wp_style ) {
258
+ $this->header = str_replace( '[theme_path]', get_template_directory(), $this->settings['header'] );
259
+ $this->sidebar = str_replace( '[theme_path]', get_template_directory(), $this->settings['sidebar'] );
260
+ $this->footer = str_replace( '[theme_path]', get_template_directory(), $this->settings['footer'] );
261
+ $this->before_manager = $this->settings['before_manager'];
262
+ $this->after_manager = $this->settings['after_manager'];
263
+ }
264
+
265
+ foreach ( array( 'email', 'key', 'ref', 'new_email' ) as $var )
266
+ if ( isset( $_REQUEST[$var]) && !empty($_REQUEST[$var] ) )
267
+ $this->{$var} = esc_attr( trim( stripslashes( $_REQUEST[$var] ) ) );
268
+ if ( !$this->key )
269
+ $this->key = 'unset';
270
+ }
271
+
272
+ function is_multisite() {
273
+ return (bool) $this->is_multisite;
274
+ }
275
+
276
+ function add_error( $text='generic error', $type='manager' ) {
277
+ $this->errors[$type][] = $text;
278
+ }
279
+
280
+ function add_checkbox_to_default( $defaults ) {
281
+ $defaults['comment_notes_after'] .= $this->add_checkbox();
282
+ return $defaults;
283
+ }
284
+
285
+ function echo_add_checkbox() {
286
+ echo $this->add_checkbox();
287
+ }
288
+
289
+ function add_checkbox( $text = '' ) {
290
+ if ( _stc()->checkbox_shown )
291
+ return;
292
+ if ( !$email = _stc()->current_viewer_subscription_status() ) {
293
+ $checked_status = (bool) ( !empty( $_COOKIE['subscribe_checkbox_'.COOKIEHASH] ) && 'checked' == $_COOKIE['subscribe_checkbox_'.COOKIEHASH] );
294
+ $text .= "<p " . ( ( _stc()->clear_both ) ? 'style="clear: both;" ' : '' ) . 'class="subscribe-to-comments">
295
+ <input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" ' . ( ( $checked_status ) ? 'checked="checked" ' : '' ) . '/>
296
+ <label for="subscribe">' . _stc()->not_subscribed_text . '</label>
297
+ </p>';
298
+ } elseif ( $email == 'admin' && current_user_can( 'manage_options' ) ) {
299
+ $text .= '<p ' . ( ( _stc()->clear_both ) ? 'style="clear: both;" ' : '' ) . 'class="subscribe-to-comments">
300
+ ' . str_replace( '[manager_link]', _stc()->manage_link($email, true, false ), _stc()->author_text ) . '</p>';
301
+ } else {
302
+ $text .= '<p ' . ( ( _stc()->clear_both ) ? 'style="clear: both;" ' : '' ) . 'class="subscribe-to-comments">' .
303
+ str_replace( '[manager_link]', _stc()->manage_link( $email, true, false ), _stc()->subscribed_text ) . '</p>';
304
+ }
305
+ _stc()->checkbox_shown = true;
306
+ return $text;
307
+ }
308
+
309
+ function show_errors( $type='manager', $before_all='<div class="updated updated-error">', $after_all='</div>', $before_each='<p>', $after_each='</p>' ){
310
+ if ( isset( $this->errors[$type] ) && is_array( $this->errors[$type] ) ) {
311
+ echo $before_all;
312
+ foreach ( $this->errors[$type] as $error )
313
+ echo $before_each . $error . $after_each;
314
+ echo $after_all;
315
+ }
316
+ unset( $this->errors);
317
+ }
318
+
319
+
320
+ function add_message( $text ) {
321
+ $this->messages[] = $text;
322
+ }
323
+
324
+
325
+ function show_messages( $before_all='', $after_all='', $before_each='<div class="updated"><p>', $after_each='</p></div>' ){
326
+ if ( is_array( $this->messages ) ) {
327
+ echo $before_all;
328
+ foreach ( $this->messages as $message )
329
+ echo $before_each . $message . $after_each;
330
+ echo $after_all;
331
+ }
332
+ unset( $this->messages );
333
+ }
334
+
335
+
336
+ function is_subscribed_email_post_bid( $email, $post_id, $bid = NULL ) {
337
+ global $wpdb, $blog_id;
338
+ $bid = ( NULL == $bid ) ? $blog_id : $bid;
339
+ $email = strtolower( $email );
340
+ if ( $this->is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT email FROM $this->ms_table WHERE email = %s AND post_id = %s AND blog_id = %s", $email, $post_id, $bid ) ) )
341
+ return true;
342
+ elseif ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE LCASE( meta_value ) = %s AND meta_key = '_sg_subscribe-to-comments' AND post_id = %s", $email, $post_id ) ) )
343
+ return true;
344
+ return false;
345
+ }
346
+
347
+
348
+ function subscriptions_from_post( $postid, $bid=NULL ) {
349
+ global $wpdb, $blog_id;
350
+ if ( NULL == $bid )
351
+ $bid = $blog_id;
352
+ if ( isset( $this->bid_post_subscriptions[$bid][$postid] ) && is_array( $this->bid_post_subscriptions[$bid][$postid] ) )
353
+ return $this->bid_post_subscriptions[$bid][$postid];
354
+ $postid = (int) $postid;
355
+ if ( $this->is_multisite() ) {
356
+ $this->bid_post_subscriptions[$bid][$postid] = (array) $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT email FROM $this->ms_table WHERE blog_id = %d AND post_id = %d", $bid, $postid ) );
357
+ } else {
358
+ $this->bid_post_subscriptions[$bid][$postid] = (array) get_post_meta( $postid, '_sg_subscribe-to-comments' );
359
+ }
360
+
361
+ // Cleanup!
362
+ $duplicates = $this->array_duplicates( $this->bid_post_subscriptions[$bid][$postid] );
363
+ if ( $this->is_multisite() ) {
364
+ if ( $duplicates ) {
365
+ foreach ( (array) $duplicates as $duplicate ) {
366
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $this->ms_table WHERE blog_id = %d AND post_id = %d", $bid, $postid ) );
367
+ $this->add_subscriber_by_post_id_and_email( $postid, $duplicate, $bid );
368
+ }
369
+ }
370
+ } else {
371
+ if ( $duplicates ) {
372
+ foreach ( (array) $duplicates as $duplicate ) {
373
+ delete_post_meta( $postid, '_sg_subscribe-to-comments', $duplicate );
374
+ $this->add_subscriber_by_post_id_and_email( $postid, $duplicate, $bid );
375
+ }
376
+ }
377
+ }
378
+
379
+ $this->bid_post_subscriptions[$bid][$postid] = array_unique( $this->bid_post_subscriptions[$bid][$postid] );
380
+ return $this->bid_post_subscriptions[$bid][$postid];
381
+ }
382
+
383
+
384
+ function subscriptions_from_email( $email='' ) {
385
+ global $wpdb, $blog_id;
386
+ if ( is_array( $this->email_subscriptions ) )
387
+ return $this->email_subscriptions;
388
+ if ( !is_email( $email ) )
389
+ $email = $this->email;
390
+ $email = strtolower( $email );
391
+
392
+ if ( $this->is_multisite() ) {
393
+ $where = ( current_user_can( 'manage_options' ) ) ? $wpdb->prepare( " AND blog_id = %d ", $blog_id ) : '';
394
+ $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, post_id FROM $this->ms_table WHERE email = %s AND status='active' $where", $email ) );
395
+ } else {
396
+ $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' AND LCASE(meta_value) = %s GROUP BY post_id", $email ) );
397
+ }
398
+ foreach ( (array) $subscriptions as $subscription)
399
+ $this->email_subscriptions[] = array( ( isset( $subscription->blog_id ) ) ? $subscription->blog_id : $blog_id, $subscription->post_id );
400
+ if ( is_array( $this->email_subscriptions ) ) {
401
+ usort( $this->email_subscriptions, array( $this, 'email_sort' ) );
402
+ return $this->email_subscriptions;
403
+ }
404
+ return false;
405
+ }
406
+
407
+ function email_sort( $a, $b ) {
408
+ if ( $a[0] == $b[0] ) {
409
+ if ( $a[1] == $a[1] )
410
+ return 0;
411
+ return ( $a[1] < $b[1] ) ? -1 : 1;
412
+ } else {
413
+ return ( $a[0] < $b[0] ) ? -1 : 1;
414
+ }
415
+ }
416
+
417
+ function maybe_solo_subscribe() {
418
+ if ( isset( $_POST['solo-comment-subscribe'] ) && $_POST['solo-comment-subscribe'] == 'solo-comment-subscribe' && isset( $_POST['postid'] ) && is_numeric( $_POST['postid'] ) )
419
+ $this->solo_subscribe( stripslashes( $_POST['email'] ), (int) $_POST['postid'] );
420
+ }
421
+
422
+ function solo_subscribe ( $email, $postid ) {
423
+ global $wpdb, $blog_id, $cache_userdata, $user_email;
424
+ $postid = (int) $postid;
425
+ $email = strtolower( $email );
426
+ if ( !is_email( $email ) ) {
427
+ get_currentuserinfo();
428
+ if ( is_email( $user_email ) )
429
+ $email = strtolower( $user_email );
430
+ else
431
+ $this->add_error( __( 'Please provide a valid e-mail address.', 'subscribe-to-comments' ),'solo_subscribe' );
432
+ }
433
+
434
+ if ( ( $email == $this->site_email && is_email( $this->site_email ) ) || ( $email == get_option( 'admin_email' ) && is_email( get_option( 'admin_email' ) ) ) )
435
+ $this->add_error( __( 'This e-mail address may not be subscribed', 'subscribe-to-comments' ),'solo_subscribe' );
436
+
437
+ if ( $this->is_subscribed_email_post_bid( $email, $postid, $blog_id ) ) {
438
+ // already subscribed
439
+ setcookie( 'comment_author_email_' . COOKIEHASH, $email, time() + 30000000, COOKIEPATH );
440
+ $this->add_error( __( 'You appear to be already subscribed to this entry.', 'subscribe-to-comments' ),'solo_subscribe' );
441
+ }
442
+ $post = get_post( $postid );
443
+
444
+ if ( !$post )
445
+ $this->add_error( __( 'Comments are not allowed on this entry.', 'subscribe-to-comments' ),'solo_subscribe' );
446
+
447
+ if ( empty( $cache_userdata[$post->post_author] ) && $post->post_author != 0 ) {
448
+ $cache_userdata[$post->post_author] = $wpdb->get_row( "SELECT * FROM $wpdb->users WHERE ID = $post->post_author" );
449
+ $cache_userdata[$cache_userdata[$post->post_author]->user_login] =& $cache_userdata[$post->post_author];
450
+ }
451
+
452
+ $post_author = $cache_userdata[$post->post_author];
453
+
454
+ if ( strtolower( $post_author->user_email ) == ( $email ) )
455
+ $this->add_error( __( 'You appear to be already subscribed to this entry.', 'subscribe-to-comments' ),'solo_subscribe' );
456
+
457
+ if ( !is_array( $this->errors['solo_subscribe'] ) ) {
458
+ add_post_meta( $postid, '_sg_subscribe-to-comments', strtolower( $email ) );
459
+ setcookie( 'comment_author_email_' . COOKIEHASH, $email, time() + 30000000, COOKIEPATH );
460
+ $location = $this->manage_link( $email, false, false ) . '&subscribeid=' . $postid;
461
+ header( "Location: $location" );
462
+ exit();
463
+ }
464
+ }
465
+
466
+
467
+ // From: http://php.net/manual/en/function.array-unique.php#85109
468
+ function array_duplicates( $array ) {
469
+ if ( !is_array( $array ) )
470
+ return false;
471
+
472
+ $duplicates = array();
473
+ foreach ( $array as $key => $val ) {
474
+ end( $array );
475
+ $k = key( $array );
476
+ $v = current( $array );
477
+ while ( $k !== $key ) {
478
+ if ( $v === $val ) {
479
+ $duplicates[$key] = $v;
480
+ break;
481
+ }
482
+ $v = prev( $array );
483
+ $k = key( $array );
484
+ }
485
+ }
486
+ return $duplicates;
487
+ }
488
+
489
+
490
+ function maybe_add_subscriber( $cid ) {
491
+ global $wpdb;
492
+ if ( $this->settings['double_opt_in'] ) {
493
+ $comment = get_comment( $cid );
494
+ $email = strtolower( $comment->comment_author_email );
495
+ if ( $this->is_multisite() ) {
496
+ $proceed = !!$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $this->ms_table WHERE email = %s AND status = 'active'", $email ) );
497
+ } else {
498
+ $proceed = !!$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' AND LCASE(meta_value) = %s", $email ) );
499
+ }
500
+ } else {
501
+ $proceed = true;
502
+ }
503
+
504
+ if ( 'spam' != $comment->comment_approved && $_POST['subscribe'] == 'subscribe' ) {
505
+ if ( $proceed )
506
+ $this->add_subscriber( $cid );
507
+ else
508
+ $this->add_pending_subscriber( $cid );
509
+ }
510
+ return $cid;
511
+ }
512
+
513
+
514
+ function add_subscriber_by_post_id_and_email( $postid, $email, $bid = NULL ) {
515
+ global $wpdb, $blog_id;
516
+ $email = strtolower( $email );
517
+ if ( $this->is_multisite() ) {
518
+ $bid = ( NULL == $bid ) ? $blog_id : $bid;
519
+ $already_subscribed_to_this_post = !!$wpdb->get_var( $wpdb->prepare( "SELECT email FROM $this->ms_table WHERE email = %s AND blog_id = %d AND post_id = %d AND status = 'active'", $email, $bid, $postid ) );
520
+ if ( is_email( $email ) && !$already_subscribed_to_this_post )
521
+ $wpdb->insert( $this->ms_table, array( 'email' => $email, 'blog_id' => $bid, 'post_id' => $postid, 'status' => 'active' ) );
522
+ } else {
523
+ $already_subscribed_to_this_post = in_array( $email, (array) get_post_meta( $postid, '_sg_subscribe-to-comments' ) );
524
+ if ( is_email( $email ) && !$already_subscribed_to_this_post )
525
+ add_post_meta( $postid, '_sg_subscribe-to-comments', $email );
526
+ }
527
+ }
528
+
529
+
530
+ function add_subscriber( $cid ) {
531
+ global $blog_id;
532
+ $comment = get_comment( $cid );
533
+ $email = strtolower( $comment->comment_author_email );
534
+ $postid = $comment->comment_post_ID;
535
+ $this->add_subscriber_by_post_id_and_email( $postid, $email, $blog_id );
536
+ return $cid;
537
+ }
538
+
539
+
540
+ function add_pending_subscriber( $cid ) {
541
+ global $wpdb, $blog_id;
542
+ $comment = get_comment( $cid );
543
+ $email = strtolower( $comment->comment_author_email );
544
+ $postid = $comment->comment_post_ID;
545
+
546
+ if ( $this->is_multisite() ) {
547
+ $already_pending_on_this_post = !!$wpdb->get_var( $wpdb->prepare( "SELECT email FROM $this->ms_table WHERE email = %s AND blog_id = %d AND post_id = %d AND status = 'pending'", $email, $blog_id, $postid ) );
548
+ if ( is_email( $email ) && !$already_pending_on_this_post ) {
549
+ if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $this->ms_table WHERE email = %s AND status = 'pending-with-email' AND date_gmt > DATE_SUB( NOW(), INTERVAL 1 DAY)", $email ) ) ) {
550
+ $wpdb->insert( $this->ms_table, array( 'email' => $email, 'blog_id' => $blog_id, 'post_id' => $postid, 'status' => 'pending-with-email', 'date_gmt' => current_time( 'mysql', 1 ) ) );
551
+ $this->send_pending_nag( $cid );
552
+ } else {
553
+ $wpdb->insert( $this->ms_table, array( 'email' => $email, 'blog_id' => $blog_id, 'post_id' => $postid, 'status' => 'pending', 'date_gmt' => current_time( 'mysql', 1 ) ) );
554
+ }
555
+ }
556
+ } else {
557
+ $already_pending_on_this_post = in_array( $email, (array) get_post_meta( $postid, '_sg_subscribe-to-comments-pending' ) );
558
+ if ( is_email( $email ) && !$already_pending_on_this_post ) {
559
+ if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments, $wpdb->postmeta WHERE comment_post_ID = post_id AND LCASE( meta_value ) = %s AND meta_key = '_sg_subscribe-to-comments-pending-with-email' AND comment_date_gmt > DATE_SUB( NOW(), INTERVAL 1 DAY)", $email ) ) ) {
560
+ add_post_meta( $postid, '_sg_subscribe-to-comments-pending-with-email', strtolower( $email ) );
561
+ $this->send_pending_nag( $cid );
562
+ } else {
563
+ add_post_meta( $postid, '_sg_subscribe-to-comments-pending', strtolower( $email ) );
564
+ }
565
+ }
566
+ }
567
+ return $cid;
568
+ }
569
+
570
+
571
+ function confirm_pending_subscriber( $email ) {
572
+ global $wpdb, $blog_id;
573
+ $email = strtolower( $email );
574
+
575
+ if ( $this->is_multisite() ) {
576
+ $wpdb->update( $this->ms_table, array( 'status' => 'active' ), array( 'email' => $email ) );
577
+ } else {
578
+ $pending = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE LCASE(meta_value) = %s AND meta_key IN( '_sg_subscribe-to-comments-pending', '_sg_subscribe-to-comments-pending-with-email' )", $email ) );
579
+ foreach ( (array) $pending as $p ) {
580
+ $this->add_subscriber_by_post_id_and_email( $p->post_id, $email, $blog_id );
581
+ delete_post_meta( $p->post_id, $p->meta_key, $email );
582
+ }
583
+ }
584
+
585
+ return !!count( $pending );
586
+ }
587
+
588
+
589
+ function is_subscribed( $cid ) {
590
+ $comment = &get_comment( $cid );
591
+ $email = strtolower( $comment->comment_author_email );
592
+ $postid = $comment->comment_post_ID;
593
+ return in_array( $email, (array) $this->subscriptions_from_post( $postid ) );
594
+ }
595
+
596
+
597
+ function is_blocked( $email='' ) {
598
+ global $wpdb;
599
+ if ( !is_email( $email ) )
600
+ $email = $this->email;
601
+ if ( empty( $email ) )
602
+ return false;
603
+ $email = strtolower( $email );
604
+ // add the option if it doesn't exist
605
+ add_option( 'do_not_mail', '' );
606
+ $blocked = (array) explode ( ' ', get_option( 'do_not_mail' ) );
607
+ if ( in_array( $email, $blocked ) )
608
+ return true;
609
+ return false;
610
+ }
611
+
612
+
613
+ function add_block( $email='' ) {
614
+ global $wpdb;
615
+ if ( !is_email( $email ) )
616
+ $email = $this->email;
617
+ $email = strtolower( $email );
618
+
619
+ // add the option if it doesn't exist
620
+ add_option( 'do_not_mail', '' );
621
+
622
+ // check to make sure this email isn't already in there
623
+ if ( !$this->is_blocked( $email ) ) {
624
+ // email hasn't already been added - so add it
625
+ $blocked = get_option( 'do_not_mail' ) . ' ' . $email;
626
+ update_option( 'do_not_mail', $blocked );
627
+ return true;
628
+ }
629
+ return false;
630
+ }
631
+
632
+
633
+ function remove_block( $email='' ) {
634
+ global $wpdb;
635
+ if ( !is_email( $email ) )
636
+ $email = $this->email;
637
+ $email = strtolower( $email );
638
+
639
+ if ( $this->is_blocked( $email ) ) {
640
+ // e-mail is in the list - so remove it
641
+ $blocked = str_replace ( ' ' . $email, '', explode( ' ', get_option( 'do_not_mail' ) ) );
642
+ update_option( 'do_not_mail', $blocked );
643
+ return true;
644
+ }
645
+ return false;
646
+ }
647
+
648
+
649
+ function has_subscribers() {
650
+ if ( count( $this->get_unique_subscribers() ) > 0 )
651
+ return true;
652
+ return false;
653
+ }
654
+
655
+
656
+ function get_unique_subscribers() {
657
+ global $comments, $comment, $sg_subscribers;
658
+ if ( isset( $sg_subscribers ) )
659
+ return $sg_subscribers;
660
+
661
+ $sg_subscribers = array();
662
+ $subscriber_emails = array();
663
+
664
+ // We run the comment loop, and put each unique subscriber into a new array
665
+ foreach ( (array) $comments as $comment ) {
666
+ if ( comment_subscription_status() && !in_array( $comment->comment_author_email, $subscriber_emails ) ) {
667
+ $sg_subscribers[] = $comment;
668
+ $subscriber_emails[] = $comment->comment_author_email;
669
+ }
670
+ }
671
+ return $sg_subscribers;
672
+ }
673
+
674
+
675
+ function hidden_form_fields() { ?>
676
+ <input type="hidden" name="ref" value="<?php echo $this->ref; ?>" />
677
+ <input type="hidden" name="key" value="<?php echo $this->key; ?>" />
678
+ <input type="hidden" name="email" value="<?php echo $this->email; ?>" />
679
+ <?php
680
+ }
681
+
682
+
683
+ function generate_key( $data='' ) {
684
+ if ( '' == $data )
685
+ return false;
686
+ if ( !$this->settings['salt'] )
687
+ die( 'fatal error: corrupted salt' );
688
+ return md5( md5( $this->settings['salt'] . $data ) );
689
+ }
690
+
691
+
692
+ function validate_key() {
693
+ if ( $this->key == $this->generate_key( $this->email ) )
694
+ $this->key_type = 'normal';
695
+ elseif ( $this->key == $this->generate_key( $this->email . $this->new_email ) )
696
+ $this->key_type = 'change_email';
697
+ elseif ( $this->key == $this->generate_key( $this->email . 'blockrequest' ) )
698
+ $this->key_type = 'block';
699
+ elseif ( $this->key == $this->generate_key( 'opt_in:' . $this->email ) )
700
+ $this->key_type = 'opt_in';
701
+ elseif ( current_user_can( 'manage_options' ) )
702
+ $this->key_type = 'admin';
703
+ else
704
+ return false;
705
+ return true;
706
+ }
707
+
708
+
709
+ function determine_action() {
710
+ // rather than check it a bunch of times
711
+ $is_email = is_email( $this->email );
712
+
713
+ if ( is_email( $this->new_email) && $is_email && $this->key_type == 'change_email' )
714
+ $this->action = 'change_email';
715
+ elseif ( $this->key_type == 'opt_in' && $is_email )
716
+ $this->action = 'opt_in';
717
+ elseif ( isset( $_POST['removesubscrips'] ) && $is_email )
718
+ $this->action = 'remove_subscriptions';
719
+ elseif ( isset( $_POST['removeBlock'] ) && $is_email && current_user_can( 'manage_options' ) )
720
+ $this->action = 'remove_block';
721
+ elseif ( isset( $_POST['changeemailrequest'] ) && $is_email && is_email( $this->new_email ) )
722
+ $this->action = 'email_change_request';
723
+ elseif ( $is_email && isset( $_POST['blockemail'] ) )
724
+ $this->action = 'block_request';
725
+ elseif ( isset( $_GET['subscribeid'] ) )
726
+ $this->action = 'solo_subscribe';
727
+ elseif ( $is_email && isset( $_GET['blockemailconfirm'] ) && $this->key == $this->generate_key( $this->email . 'blockrequest' ) )
728
+ $this->action = 'block';
729
+ else
730
+ $this->action = 'none';
731
+ }
732
+
733
+
734
+ function remove_subscriber( $email, $postid, $bid = NULL ) {
735
+ global $wpdb, $blog_id;
736
+ $postid = (int) $postid;
737
+ $bid = absint( ( NULL == $bid ) ? $blog_id : $bid );
738
+ $email = strtolower( $email );
739
+
740
+ if ( $this->is_multisite() ) {
741
+ echo "REMOVING $bid : $postid : $email";
742
+ if ( $wpdb->query( $wpdb->prepare( "DELETE FROM $this->ms_table WHERE email = %s AND post_id = %d AND blog_id = %d", $email, $postid, $bid ) ) )
743
+ return true;
744
+ } else {
745
+ if ( delete_post_meta( $postid, '_sg_subscribe-to-comments', $email ) || delete_post_meta( $postid, '_sg_subscribe-to-comments-pending-with-email', $email ) || delete_post_meta( $postid, '_sg_subscribe-to-comments-pending', $email ) )
746
+ return true;
747
+ }
748
+ return false;
749
+ }
750
+
751
+
752
+ function remove_subscriptions ( $bid_post_ids ) {
753
+ global $wpdb;
754
+ $removed = 0;
755
+ foreach ( $bid_post_ids as $bp ) {
756
+ $bp = explode( '-', $bp );
757
+ // echo 'Removing BID: ' . $bp[0] . ' PID:' . $bp[1];
758
+ if ( $this->remove_subscriber( $this->email, $bp[1], $bp[0] ) )
759
+ $removed++;
760
+ }
761
+ return $removed;
762
+ }
763
+
764
+
765
+ function send_notifications( $cid ) {
766
+ global $wpdb;
767
+ $comment =& get_comment( $cid );
768
+ $post = get_post( $comment->comment_post_ID );
769
+
770
+ if ( $comment->comment_approved == '1' && $comment->comment_type == '' ) {
771
+ // Comment has been approved and isn't a trackback or a pingback, so we should send out notifications
772
+
773
+ $message = sprintf( __( "There is a new comment on the post \"%s\"", 'subscribe-to-comments' ) . ". \n%s\n\n", $post->post_title, get_permalink( $comment->comment_post_ID ) );
774
+ $message .= sprintf( __( "Author: %s\n", 'subscribe-to-comments' ), $comment->comment_author );
775
+ $message .= __( "Comment:\n", 'subscribe-to-comments' ) . $comment->comment_content . "\n\n";
776
+ $message .= __( "See all comments on this post here:\n", 'subscribe-to-comments' );
777
+ $message .= get_permalink( $comment->comment_post_ID ) . "#comments\n\n";
778
+ //add link to manage comment notifications
779
+ $message .= __( "To manage your subscriptions or to block all notifications from this site, click the link below:\n", 'subscribe-to-comments' );
780
+ $message .= get_option( 'home' ) . '/?wp-subscription-manager=1&email=[email]&key=[key]';
781
+
782
+ $subject = sprintf( __( 'New Comment On: %s', 'subscribe-to-comments' ), $post->post_title );
783
+
784
+ $subscriptions = $this->subscriptions_from_post( $comment->comment_post_ID );
785
+ foreach ( (array) $subscriptions as $email ) {
786
+ if ( !$this->is_blocked( $email ) && $email != $comment->comment_author_email && is_email( $email ) ) {
787
+ $message_final = str_replace( '[email]', urlencode( $email ), $message );
788
+ $message_final = str_replace( '[key]', $this->generate_key( $email ), $message_final );
789
+ $this->send_mail( $email, $subject, $message_final );
790
+ }
791
+ } // foreach subscription
792
+ } // end if comment approved
793
+ return $cid;
794
+ }
795
+
796
+
797
+ function send_pending_nag( $cid ) {
798
+ $comment = get_comment( $cid );
799
+ $email = strtolower( $comment->comment_author_email );
800
+ $subject = __( 'Subscription Confirmation', 'subscribe-to-comments' );
801
+ $message = sprintf( __( "You are receiving this message to confirm your comment subscription at \"%s\"\n\n", 'subscribe-to-comments' ), get_bloginfo( 'blogname' ) );
802
+ $message .= __( "To confirm your subscription, click this link:\n\n", 'subscribe-to-comments' );
803
+ $message .= get_option( 'home' ) . "/?wp-subscription-manager=1&email=" . urlencode( $email ) . "&key=" . $this->generate_key( 'opt_in:' . $email ) . "\n\n";
804
+ $message .= __( 'If you did not request this subscription, please disregard this message.', 'subscribe-to-comments' );
805
+ return $this->send_mail( $email, $subject, $message );
806
+ }
807
+
808
+
809
+ function change_email_request() {
810
+ if ( $this->is_blocked() )
811
+ return false;
812
+
813
+ $subject = __( 'E-mail change confirmation', 'subscribe-to-comments' );
814
+ $message = sprintf( __( "You are receiving this message to confirm a change of e-mail address for your subscriptions at \"%s\"\n\n", 'subscribe-to-comments' ), get_bloginfo( 'blogname' ) );
815
+ $message .= sprintf( __( "To change your e-mail address to %s, click this link:\n\n", 'subscribe-to-comments' ), $this->new_email );
816
+ $message .= get_option( 'home' ) . "/?wp-subscription-manager=1&email=" . urlencode( $this->email ) . "&new_email=" . urlencode( $this->new_email ) . "&key=" . $this->generate_key( $this->email . $this->new_email ) . ".\n\n";
817
+ $message .= __( 'If you did not request this action, please disregard this message.', 'subscribe-to-comments' );
818
+ return $this->send_mail( $this->email, $subject, $message );
819
+ }
820
+
821
+
822
+ function block_email_request( $email ) {
823
+ if ( $this->is_blocked( $email ) )
824
+ return false;
825
+ $subject = __( 'E-mail block confirmation', 'subscribe-to-comments' );
826
+ $message = sprintf( __( "You are receiving this message to confirm that you no longer wish to receive e-mail comment notifications from \"%s\"\n\n", 'subscribe-to-comments' ), get_bloginfo( 'name' ) );
827
+ $message .= __( "To cancel all future notifications for this address, click this link:\n\n", 'subscribe-to-comments' );
828
+ $message .= get_option( 'home' ) . "/?wp-subscription-manager=1&email=" . urlencode( $email ) . "&key=" . $this->generate_key( $email . 'blockrequest' ) . "&blockemailconfirm=true" . ".\n\n";
829
+ $message .= __( "If you did not request this action, please disregard this message.", 'subscribe-to-comments' );
830
+ return $this->send_mail( $email, $subject, $message );
831
+ }
832
+
833
+
834
+ function send_mail( $to, $subject, $message ) {
835
+ $subject = '[' . get_bloginfo( 'name' ) . '] ' . $subject;
836
+
837
+ // strip out some chars that might cause issues, and assemble vars
838
+ $site_name = str_replace( '"', "'", $this->site_name );
839
+ $site_email = str_replace( array( '<', '>' ), array( '', '' ), $this->site_email );
840
+ $charset = get_option( 'blog_charset' );
841
+
842
+ $headers = "From: \"{$site_name}\" <{$site_email}>\n";
843
+ $headers .= "MIME-Version: 1.0\n";
844
+ $headers .= "Content-Type: text/plain; charset=\"{$charset}\"\n";
845
+ return wp_mail( $to, $subject, $message, $headers );
846
+ }
847
+
848
+
849
+ function change_email() {
850
+ global $wpdb;
851
+ $new_email = strtolower( $this->new_email );
852
+ $email = strtolower( $this->email );
853
+ if ( $wpdb->update( $wpdb->comments, array( 'comment_author_email' => $new_email ), array( 'comment_author_email' => $email ) ) )
854
+ $return = true;
855
+ if ( $wpdb->update( $wpdb->postmeta, array( 'meta_value' => $new_email ), array( 'meta_value' => $email, 'meta_key' => '_sg_subscribe-to-comments' ) ) )
856
+ $return = true;
857
+ if ( $wpdb->update( $this->ms_table, array( 'email' => $new_email ), array( 'email' => $email ) ) )
858
+ $return = true;
859
+ return $return;
860
+ }
861
+
862
+
863
+ function entry_link( $bid, $postid, $uri='') {
864
+ global $blog_id;
865
+ $switched = false;
866
+ if ( $blog_id != $bid ) {
867
+ $switched = true;
868
+ switch_to_blog( $bid );
869
+ }
870
+ if ( empty( $uri ) )
871
+ $uri = esc_url( get_permalink( $postid ) );
872
+ $postid = (int) $postid;
873
+ $title = get_the_title( $postid );
874
+ if ( empty( $title ) )
875
+ $title = __( 'click here', 'subscribe-to-comments' );
876
+ $output = '<a href="'.$uri.'">'. esc_html( get_option( 'blogname' ) ) . ' &rarr; ' . $title.'</a>';
877
+ if ( $switched )
878
+ restore_current_blog();
879
+ return $output;
880
+ }
881
+
882
+
883
+ function admin_head() { ?>
884
+ <style type="text/css" media="screen">
885
+ .updated-error {
886
+ background-color: #FF8080;
887
+ border: 1px solid #F00;
888
+ }
889
+ </style>
890
+ <?php
891
+ return true;
892
+ }
893
+
894
+
895
+ function db_upgrade_check () {
896
+ global $wpdb, $blog_id;
897
+
898
+ $update = false;
899
+
900
+ // add the options
901
+ add_option( 'sg_subscribe_settings', array( 'use_custom_style' => '', 'email' => get_bloginfo( 'admin_email' ), 'name' => get_bloginfo( 'name' ), 'header' => '[theme_path]/header.php', 'sidebar' => '', 'footer' => '[theme_path]/footer.php', 'before_manager' => '<div id="content" class="widecolumn subscription-manager">', 'after_manager' => '</div>', 'not_subscribed_text' => __( 'Notify me of followup comments via e-mail', 'subscribe-to-comments' ), 'subscribed_text' => __( 'You are subscribed to this entry. <a href="[manager_link]">Manage your subscriptions</a>.', 'subscribe-to-comments' ), 'author_text' => __( 'You are the author of this entry. <a href="[manager_link]">Manage subscriptions</a>.', 'subscribe-to-comments' ), 'version' => 0, 'double_opt_in' => '', 'subscribed_format' => '%NAME%' ) );
902
+
903
+ $settings = $this->get_options();
904
+
905
+ if ( !isset( $settings['salt'] ) ) {
906
+ $settings['salt'] = md5( md5( uniqid( rand() . rand() . rand() . rand() . rand(), true ) ) ); // random MD5 hash
907
+ $update = true;
908
+ }
909
+
910
+ if ( !isset( $settings['clear_both'] ) ) {
911
+ $settings['clear_both'] = 'clear_both';
912
+ $update = true;
913
+ }
914
+
915
+ if ( !isset( $settings['version'] ) ) {
916
+ $settings = stripslashes_deep( $settings );
917
+ $update = true;
918
+ }
919
+
920
+ if ( !isset( $settings['double_opt_in'] ) ) {
921
+ $settings['double_opt_in'] = '';
922
+ $update = true;
923
+ }
924
+
925
+ if ( !isset( $settings['subscribed_format'] ) ) {
926
+ $settings['subscribed_format'] = '%NAME%';
927
+ $update = true;
928
+ }
929
+
930
+ if ( !$this->is_multisite() && version_compare( $settings['version'], '2.2', '<' ) ) { // Upgrade to postmeta-driven subscriptions
931
+ foreach ( (array) $wpdb->get_col( "DESC $wpdb->comments", 0 ) as $column ) {
932
+ if ( $column == 'comment_subscribe' ) {
933
+ $upgrade_comments = $wpdb->get_results( "SELECT comment_post_ID, comment_author_email FROM $wpdb->comments WHERE comment_subscribe = 'Y'" );
934
+ foreach ( (array) $upgrade_comments as $upgrade_comment )
935
+ $this->add_subscriber_by_post_id_and_email( $upgrade_comment->comment_post_ID, $upgrade_comment->comment_author_email, $blog_id );
936
+ // Done. Drop the column
937
+ $wpdb->query( "ALTER TABLE $wpdb->comments DROP COLUMN comment_subscribe" );
938
+ }
939
+ }
940
+ $udpate = true;
941
+ }
942
+
943
+ elseif ( $this->is_multisite() && ( version_compare( $settings['version'], '2.2', '<' ) || !isset( $settings['version'] ) ) ) {
944
+ // Create WPMU tables
945
+ if ( $wpdb->has_cap( 'collation' ) ) {
946
+ if ( ! empty( $wpdb->charset ) )
947
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
948
+ if ( ! empty( $wpdb->collate ) )
949
+ $charset_collate .= " COLLATE $wpdb->collate";
950
+ }
951
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
952
+ $queries = "CREATE TABLE IF NOT EXISTS $this->ms_table (
953
+ id int(11) NOT NULL auto_increment,
954
+ email varchar(100) NOT NULL,
955
+ blog_id int(11) NOT NULL default 0,
956
+ post_id int(11) NOT NULL default 0,
957
+ date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
958
+ status varchar(20) NOT NULL default '',
959
+ PRIMARY KEY (id),
960
+ KEY email_blog_post_status (email,blog_id,post_id,status),
961
+ KEY email_status (email,status)
962
+ ) $charset_collate";
963
+ dbDelta( $queries );
964
+ }
965
+
966
+ if ( $update || !isset( $settings['version'] ) )
967
+ $this->update_settings( $settings );
968
+ }
969
+
970
+
971
+ function update_settings( $settings ) {
972
+ $settings['version'] = $this->version;
973
+ $settings = $this->sanitize_settings( $settings );
974
+ update_option( 'sg_subscribe_settings', $settings );
975
+ }
976
+
977
+ function sanitize_settings( $settings ) {
978
+ if ( strpos( $settings['subscribed_format'], '%NAME%' ) === false ) {
979
+ $settings['subscribed_format'] = '%NAME%';
980
+ }
981
+ if ( ! empty( $settings['header'] ) ) {
982
+ $settings['header'] = '[theme_path]/header.php';
983
+ }
984
+ if ( ! empty( $settings['sidebar'] ) ) {
985
+ $settings['sidebar'] = '[theme_path]/sidebar.php';
986
+ }
987
+ if ( ! empty( $settings['footer'] ) ) {
988
+ $settings['footer'] = '[theme_path]/footer.php';
989
+ }
990
+ return $settings;
991
+ }
992
+
993
+
994
+ function current_viewer_subscription_status(){
995
+ global $wpdb, $blog_id, $post, $user_email;
996
+
997
+ $comment_author_email = ( isset( $_COOKIE['comment_author_email_'. COOKIEHASH] ) ) ? trim( $_COOKIE['comment_author_email_'. COOKIEHASH] ) : '';
998
+ get_currentuserinfo();
999
+
1000
+ if ( is_email( $user_email ) ) {
1001
+ $email = strtolower( $user_email );
1002
+ $loggedin = true;
1003
+ } elseif ( is_email( $comment_author_email ) ) {
1004
+ $email = strtolower( $comment_author_email );
1005
+ } else {
1006
+ return false;
1007
+ }
1008
+
1009
+ $post_author = get_userdata( $post->post_author );
1010
+ if ( strtolower( $post_author->user_email ) == $email && $loggedin )
1011
+ return 'admin';
1012
+
1013
+ if ( in_array( $email, (array) $this->subscriptions_from_post( $post->ID ) ) )
1014
+ return $email;
1015
+ return false;
1016
+ }
1017
+
1018
+ function manage_link( $email='', $html=true, $echo=true ) {
1019
+ $link = get_option( 'home' ) . '/?wp-subscription-manager=1';
1020
+ if ( $email != 'admin' ) {
1021
+ $link = add_query_arg( 'email', urlencode( $email ), $link );
1022
+ $link = add_query_arg( 'key', $this->generate_key( $email ), $link );
1023
+ }
1024
+ $link = add_query_arg( 'ref', rawurlencode( 'http://' . $_SERVER['HTTP_HOST'] . esc_attr( $_SERVER['REQUEST_URI'] ) ), $link);
1025
+ //$link = str_replace('+', '%2B', $link);
1026
+ if ( $html )
1027
+ $link = esc_url( $link );
1028
+ if ( !$echo )
1029
+ return $link;
1030
+ echo $link;
1031
+ }
1032
+
1033
+
1034
+ function on_edit( $cid ) {
1035
+ global $blog_id;
1036
+ $comment =& get_comment( $cid );
1037
+ $email = strtolower( $comment->comment_author_email );
1038
+ $postid = $comment->comment_post_ID;
1039
+ if ( !is_email( $email ) )
1040
+ _stc()->remove_subscriber( $email, $postid, $blog_id );
1041
+ return $cid;
1042
+ }
1043
+
1044
+
1045
+ function on_delete( $cid ) {
1046
+ global $blog_id;
1047
+ $comment = &get_comment( $cid );
1048
+ $email = strtolower( $comment->comment_author_email );
1049
+ $postid = $comment->comment_post_ID;
1050
+ _stc()->remove_subscriber( $email, $postid, $blog_id );
1051
+ return $cid;
1052
+ }
1053
+
1054
+ function get_comment_author_format() {
1055
+ if ( strpos( $this->subscribed_format, '%NAME%' ) === false )
1056
+ return '%NAME%';
1057
+ else
1058
+ return $this->subscribed_format;
1059
+ }
1060
+
1061
+ function comment_author_filter( $author ) {
1062
+ if ( comment_subscription_status() )
1063
+ $author = str_replace( '%NAME%', $author, $this->get_comment_author_format() );
1064
+ return $author;
1065
+ }
1066
+
1067
+ function add_admin_menu() {
1068
+ $manager_callback = add_submenu_page( 'edit-comments.php', __( 'Comment Subscription Manager', 'subscribe-to-comments' ), __( 'Subscriptions', 'subscribe-to-comments' ), 'manage_options', 'stc-management', 'sg_subscribe_admin' );
1069
+ $opt_callback = add_options_page( __( 'Subscribe to Comments', 'subscribe-to-comments' ), __( 'Subscribe to Comments', 'subscribe-to-comments' ), 'publish_posts', 'stc-options', array( _stc(), 'options_page' ) );
1070
+ add_action( "load-{$opt_callback}", array( _stc(), 'save_options' ) );
1071
+ }
1072
+
1073
+
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+ //////////////////// OPTIONS ////////////////////////
1084
+
1085
+
1086
+
1087
+ function tr( $option_slug, $option_title, $option_text, $description ='' ) {
1088
+ echo "<tr valign='top'>\n\t<th scope='row'><label for='" . $option_slug . "'>" . $option_title . "</label></th>\n\t<td>" . $option_text;
1089
+ if ( !empty( $description ) )
1090
+ echo '<span class="setting-description">' . $description . '</span>';
1091
+ echo "</td>\n</tr>\n";
1092
+ }
1093
+
1094
+ function save_options() {
1095
+ if ( isset( $_POST['sg_subscribe_settings_submit'] ) ) {
1096
+ check_admin_referer( 'subscribe-to-comments-update_options' );
1097
+ $update_settings = stripslashes_deep( $_POST['sg_subscribe_settings'] );
1098
+ _stc()->update_settings( $update_settings );
1099
+ wp_redirect( add_query_arg( 'updated', '1', menu_page_url( 'stc-options', false ) ) );
1100
+ add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' );
1101
+ set_transient( 'settings_errors', get_settings_errors(), 30 );
1102
+ exit();
1103
+ }
1104
+ }
1105
+
1106
+ function options_page_contents() {
1107
+ echo '<h2>' . __( 'Subscribe to Comments Settings', 'subscribe-to-comments' ) . '</h2>';
1108
+
1109
+
1110
+ echo '<h3>' . __( 'Notification e-mails', 'subscribe-to-comments' ) . '</h3>';
1111
+ echo '<table class="form-table">';
1112
+ $this->tr( 'name', __( '"From" name', 'subscribe-to-comments' ), '<input type="text" size="40" id="name" name="sg_subscribe_settings[name]" value="' . $this->form_setting( 'name' ) . '" />' );
1113
+ $this->tr( 'email', __( '"From" address', 'subscribe-to-comments' ), '<input type="text" size="40" id="email" name="sg_subscribe_settings[email]" value="' . $this->form_setting( 'email' ) . '" />', __( 'You may want this to be a special account that you set up for this purpose, as it will go out to everyone who subscribes', 'subscribe-to-comments' ) );
1114
+ $this->tr( 'double_opt_in', __( 'Double opt-in', 'subscribe-to-comments' ), '<input type="checkbox" id="double_opt_in" name="sg_subscribe_settings[double_opt_in]" value="double_opt_in"' . $this->checkflag( 'double_opt_in' ) . ' /> <label for="double_opt_in">' . __( 'Require verification of first-time subscription e-mails (this is known as "double opt-in" and is required by law in some countries)', 'subscribe-to-comments') . '</label>' );
1115
+ echo '</table>';
1116
+
1117
+ echo '<h3>' . __( 'Subscriber name formatting', 'subscribe_to_comments' ) . '</h3>';
1118
+ echo '<table class="form-table">';
1119
+ $this->tr( 'subscribed_format', __( 'Subscribed format', 'subscribe-to-comments' ), '<input type="text" size="40" id="subscribed_format" name="sg_subscribe_settings[subscribed_format]" value="' . $this->form_setting( 'subscribed_format' ) . '" />', __( 'e.g. <code>%NAME% (subscribed)</code> will display <code>John Smith (subscribed)</code>', 'subscribe-to-comments' ) );
1120
+ echo '</table>';
1121
+
1122
+
1123
+ echo '<h3>' . __( 'Comment form layout' ) . '</h3>';
1124
+ echo '<table class="form-table">';
1125
+ $this->tr( 'clear_both', 'CSS clearing', '<input type="checkbox" id="clear_both" name="sg_subscribe_settings[clear_both]" value="clear_both"' . $this->checkflag( 'clear_both' ) . ' /> <label for="clear_both">' . __( 'Do a CSS "clear" on the subscription checkbox/message (uncheck this if the checkbox/message appears in a strange location in your theme)', 'subscribe-to-comments' ) . '</label>' );
1126
+ echo '</table>';
1127
+
1128
+ echo '<h3>' . __( 'Comment form text', 'subscribe-to-comments' ) . '</h3>';
1129
+ echo '<p>' . __( 'Customize the messages shown to different people. Use <code>[manager_link]</code> to insert the URI to the Subscription Manager.', 'subscribe-to-comments' ) . '</p>';
1130
+ echo '<table class="form-table">';
1131
+ $this->tr( 'not_subscribed_text', __( 'Not subscribed text', 'subscribe-to-comments' ), '<textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="not_subscribed_text" name="sg_subscribe_settings[not_subscribed_text]">' . $this->textarea_setting( 'not_subscribed_text' ) . '</textarea>' );
1132
+ $this->tr( 'subscribed_text', __( 'Subscribed text', 'subscribe-to-comments' ), '<textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="subscribed_text" name="sg_subscribe_settings[subscribed_text]">' . $this->textarea_setting( 'subscribed_text' ) . '</textarea>' );
1133
+ $this->tr( 'author_text', __( 'Entry author text', 'subscribe-to-comments' ), '<textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="author_text" name="sg_subscribe_settings[author_text]">' . $this->textarea_setting( 'author_text' ) . '</textarea>' );
1134
+ echo '</table>';
1135
+
1136
+ echo '<h3>' . __( 'Subscription manager', 'subscribe-to-comments' ) . '</h3>';
1137
+ echo '<table class="form-table">';
1138
+ $this->tr( 'use_custom_style', __( 'Custom style', 'subscribe-to-comments' ), '<input type="checkbox" onchange="if(this.checked){document.getElementById(\'stc-custom-style-div\').style.display=\'block\';}else{document.getElementById(\'stc-custom-style-div\').style.display=\'none\';}" id="use_custom_style" name="sg_subscribe_settings[use_custom_style]" value="use_custom_style"' . $this->checkflag( 'use_custom_style' ) . ' /> <label for="use_custom_style">' . __( 'Use custom style for Subscription Manager', 'subscribe-to-comments' ) . '</label>' );
1139
+ echo '</table>';
1140
+
1141
+ echo '<div id="stc-custom-style-div" style="' . ( ( $this->form_setting( 'use_custom_style' ) != 'use_custom_style' ) ? 'display:none' : '' ) . '">';
1142
+ echo '<p>' . __( 'These settings only matter if you are using a custom style. <code>[theme_path]</code> will be replaced with the path to your current theme.', 'subscribe-to-comments' ) . '</p>';
1143
+ echo '<table class="form-table">';
1144
+ $this->tr( 'header', __( 'Path to header', 'subscribe-to-comments' ), '<input type="text" size="40" id="sg_sub_header" name="sg_subscribe_settings[header]" value="' . $this->form_setting( 'header' ) . '" />' );
1145
+ $this->tr( 'sidebar', __( 'Path to sidebar', 'subscribe-to-comments' ), '<input type="text" size="40" id="sg_sub_sidebar" name="sg_subscribe_settings[sidebar]" value="' . $this->form_setting( 'sidebar' ) . '" />' );
1146
+ $this->tr( 'footer', __( 'Path to footer', 'subscribe-to-comments' ), '<input type="text" size="40" id="sg_sub_footer" name="sg_subscribe_settings[footer]" value="' . $this->form_setting( 'footer' ) . '" />' );
1147
+ $this->tr( 'before_manager', __( 'HTML for before the subscription manager', 'subscribe-to-comments' ), '<textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="before_manager" name="sg_subscribe_settings[before_manager]">' . $this->textarea_setting( 'before_manager' ) . '</textarea>' );
1148
+ $this->tr( 'after_manager', __( 'HTML for after the subscription manager', 'subscribe-to-comments' ), '<textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="after_manager" name="sg_subscribe_settings[after_manager]">' . $this->textarea_setting( 'after_manager' ) . '</textarea>' );
1149
+ echo '</table>';
1150
+ echo '</div>';
1151
+ }
1152
+
1153
+ function get_options() {
1154
+ return $this->sanitize_settings( get_option( 'sg_subscribe_settings' ) );
1155
+ }
1156
+
1157
+ function checkflag( $optname ) {
1158
+ $options = $this->get_options();
1159
+ if ( !isset( $options[$optname] ) || $options[$optname] != $optname )
1160
+ return;
1161
+ return ' checked="checked"';
1162
+ }
1163
+
1164
+ /**
1165
+ * Returns an HTML attribute sanitized version of a setting
1166
+ * @param string $option_name The name of the STC option to fetch
1167
+ * @return string the sanitized setting
1168
+ */
1169
+ function form_setting( $option_name ) {
1170
+ $options = $this->get_options();
1171
+ if ( isset( $options[$option_name] ) )
1172
+ return esc_attr( $options[$option_name] );
1173
+ else
1174
+ return '';
1175
+ }
1176
+
1177
+ function textarea_setting( $optname ) {
1178
+ $options = $this->get_options();
1179
+ if ( isset( $options[$optname] ) )
1180
+ return esc_textarea( $options[$optname] );
1181
+ else
1182
+ return '';
1183
+ }
1184
+
1185
+ function options_page() {
1186
+ echo '<form method="post">';
1187
+ screen_icon();
1188
+ echo '<div class="wrap">';
1189
+
1190
+ $this->options_page_contents();
1191
+
1192
+ echo '<p class="submit"><input type="submit" name="sg_subscribe_settings_submit" value="';
1193
+ _e( 'Save Changes', 'subscribe-to-comments' );
1194
+ echo '" class="button-primary" /></p></div>';
1195
+
1196
+ wp_nonce_field( 'subscribe-to-comments-update_options' );
1197
+
1198
+ echo '</form>';
1199
+ }
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+
1225
+
1226
+
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+ } // class sg_subscribe
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+ function stc_checkbox_state( $data ) {
1247
+ if ( isset( $_POST['subscribe'] ) )
1248
+ setcookie( 'subscribe_checkbox_'. COOKIEHASH, 'checked', time() + 30000000, COOKIEPATH );
1249
+ else
1250
+ setcookie( 'subscribe_checkbox_'. COOKIEHASH, 'unchecked', time() + 30000000, COOKIEPATH );
1251
+ return $data;
1252
+ }
1253
+
1254
+
1255
+ function stc_comment_author_filter( $author ) {
1256
+ return _stc()->comment_author_filter( $author );
1257
+ }
1258
+
1259
+
1260
+ function sg_subscribe_start() {
1261
+ if ( !$sg_subscribe ) {
1262
+ load_plugin_textdomain( 'subscribe-to-comments', false, dirname( plugin_basename( __FILE__ ) ) );
1263
+ $sg_subscribe = new CWS_STC();
1264
+ }
1265
+ }
1266
+
1267
+
1268
+
1269
+ function sg_subscribe_admin_standalone() {
1270
+ sg_subscribe_admin( true );
1271
+ }
1272
+
1273
+ function sg_subscribe_admin( $standalone = false ) {
1274
+ global $wpdb, $sg_subscribe, $wp_version, $blog_id;
1275
+
1276
+
1277
+ if ( $standalone ) {
1278
+ _stc()->form_action = get_option( 'home' ) . '/?wp-subscription-manager=1';
1279
+ _stc()->standalone = true;
1280
+ } else {
1281
+ _stc()->form_action = 'edit-comments.php?page=stc-management';
1282
+ _stc()->standalone = false;
1283
+ }
1284
+
1285
+ _stc()->manager_init();
1286
+
1287
+ get_currentuserinfo();
1288
+
1289
+ if ( !_stc()->validate_key() )
1290
+ die ( __( 'You may not access this page without a valid key.', 'subscribe-to-comments' ) );
1291
+
1292
+ _stc()->determine_action();
1293
+
1294
+ switch ( _stc()->action ) :
1295
+
1296
+ case "opt_in" :
1297
+ if ( _stc()->confirm_pending_subscriber( _stc()->email ) ) {
1298
+ _stc()->add_message( sprintf( __( 'Thank you! <strong>%1$s</strong> has been confirmed, and is now subscribed to comments.', 'subscribe-to-comments' ), _stc()->email ) );
1299
+ }
1300
+ break;
1301
+
1302
+ case "change_email" :
1303
+ if ( _stc()->change_email() ) {
1304
+ _stc()->add_message( sprintf( __('All notifications that were formerly sent to <strong>%1$s</strong> will now be sent to <strong>%2$s</strong>!', 'subscribe-to-comments' ), _stc()->email, _stc()->new_email ) );
1305
+ // change info to the new email
1306
+ _stc()->email = _stc()->new_email;
1307
+ unset( _stc()->new_email );
1308
+ _stc()->key = _stc()->generate_key( _stc()->email );
1309
+ _stc()->validate_key();
1310
+ }
1311
+ break;
1312
+
1313
+ case "remove_subscriptions" :
1314
+ $postsremoved = _stc()->remove_subscriptions( $_POST['subscrips'] );
1315
+ if ( $postsremoved > 0 )
1316
+ _stc()->add_message( sprintf( __( '<strong>%1$s</strong> %2$s removed successfully.', 'subscribe-to-comments' ), $postsremoved, ( $postsremoved != 1 ) ? __( 'subscriptions', 'subscribe-to-comments' ) : __( 'subscription', 'subscribe-to-comments' ) ) );
1317
+ break;
1318
+
1319
+ case "remove_block" :
1320
+ if ( _stc()->remove_block( _stc()->email ) )
1321
+ _stc()->add_message( sprintf( __( 'The block on <strong>%s</strong> has been successfully removed.', 'subscribe-to-comments' ), _stc()->email ) );
1322
+ else
1323
+ _stc()->add_error( sprintf( __( '<strong>%s</strong> isn\'t blocked!', 'subscribe-to-comments' ), _stc()->email ), 'manager' );
1324
+ break;
1325
+
1326
+ case "email_change_request" :
1327
+ if ( _stc()->is_blocked( _stc()->email ) )
1328
+ _stc()->add_error( sprintf( __( '<strong>%s</strong> has been blocked from receiving notifications. You will have to have the administrator remove the block before you will be able to change your notification address.', 'subscribe-to-comments' ), _stc()->email ) );
1329
+ else
1330
+ if ( _stc()->change_email_request( _stc()->email, _stc()->new_email ) )
1331
+ _stc()->add_message( sprintf( __( 'Your change of e-mail request was successfully received. Please check your old account (<strong>%s</strong>) in order to confirm the change.', 'subscribe-to-comments' ), _stc()->email ) );
1332
+ break;
1333
+
1334
+ case "block_request" :
1335
+ if ( _stc()->block_email_request( _stc()->email ) )
1336
+ _stc()->add_message( sprintf( __( 'Your request to block <strong>%s</strong> from receiving any further notifications has been received. In order for you to complete the block, please check your e-mail and click on the link in the message that has been sent to you.', 'subscribe-to-comments' ), _stc()->email ) );
1337
+ break;
1338
+
1339
+ case "solo_subscribe" :
1340
+ _stc()->add_message( sprintf( __( '<strong>%1$s</strong> has been successfully subscribed to %2$s', 'subscribe-to-comments' ), _stc()->email, _stc()->entry_link( $blog_id, $_GET['subscribeid'] ) ) );
1341
+ break;
1342
+
1343
+ case "block" :
1344
+ if ( _stc()->add_block( _stc()->email ) )
1345
+ _stc()->add_message( sprintf( __( '<strong>%1$s</strong> has been added to the "do not mail" list. You will no longer receive any notifications from this site. If this was done in error, please contact the <a href="mailto:%2$s">site administrator</a> to remove this block.', 'subscribe-to-comments' ), _stc()->email, _stc()->site_email ) );
1346
+ else
1347
+ _stc()->add_error( sprintf( __( '<strong>%s</strong> has already been blocked!', 'subscribe-to-comments'), _stc()->email), 'manager');
1348
+ _stc()->key = _stc()->generate_key( _stc()->email );
1349
+ _stc()->validate_key();
1350
+ break;
1351
+
1352
+ endswitch;
1353
+
1354
+ ?>
1355
+
1356
+ <?php _stc()->show_messages(); ?>
1357
+
1358
+ <?php _stc()->show_errors(); ?>
1359
+
1360
+ <?php if ( function_exists( 'screen_icon' ) ) screen_icon(); ?>
1361
+ <div class="wrap">
1362
+ <?php if ( ! _stc()->standalone ) : ?>
1363
+ <h2><?php _e( 'Comment Subscription Manager', 'subscribe-to-comments' ); ?></h2>
1364
+ <?php endif; ?>
1365
+
1366
+ <?php if ( !empty( _stc()->ref ) ) : ?>
1367
+ <?php _stc()->add_message( sprintf( __( 'Return to the page you were viewing: %s', 'subscribe-to-comments' ), _stc()->entry_link( $blog_id, url_to_postid( _stc()->ref ), _stc()->ref ) ) ); ?>
1368
+ <?php _stc()->show_messages(); ?>
1369
+ <?php endif; ?>
1370
+
1371
+
1372
+
1373
+ <?php if ( _stc()->is_blocked() ) { ?>
1374
+
1375
+ <?php if ( current_user_can( 'manage_options' ) ) : ?>
1376
+
1377
+ <h3><?php _e( 'Remove Block', 'subscribe-to-comments' ); ?></h3
1378
+
1379
+ <p>
1380
+ <?php printf( __( 'Click the button below to remove the block on <strong>%s</strong>. This should only be done if the user has specifically requested it.', 'subscribe-to-comments' ), _stc()->email ); ?>
1381
+ </p>
1382
+
1383
+ <form name="removeBlock" method="post" action="<?php echo _stc()->form_action; ?>">
1384
+ <input type="hidden" name="removeBlock" value="removeBlock /">
1385
+ <?php _stc()->hidden_form_fields(); ?>
1386
+
1387
+ <p class="submit">
1388
+ <input type="submit" name="submit" value="<?php _e( 'Remove Block &raquo;', 'subscribe-to-comments' ); ?>" />
1389
+ </p>
1390
+ </form>
1391
+
1392
+ <?php else : ?>
1393
+
1394
+ <h3><?php _e( 'Blocked', 'subscribe-to-comments' ); ?></h3>
1395
+
1396
+ <p>
1397
+ <?php printf( __( 'You have indicated that you do not wish to receive any notifications at <strong>%1$s</strong> from this site. If this is incorrect, or if you wish to have the block removed, please contact the <a href="mailto:%2$s">site administrator</a>.', 'subscribe-to-comments' ), _stc()->email, _stc()->site_email ); ?>
1398
+ </p>
1399
+
1400
+ <?php endif; ?>
1401
+
1402
+
1403
+ <?php } else { ?>
1404
+
1405
+
1406
+ <?php $postlist = _stc()->subscriptions_from_email(); ?>
1407
+
1408
+ <?php
1409
+ if ( isset( _stc()->email ) && !is_array( $postlist ) && _stc()->email != _stc()->site_email && _stc()->email != get_bloginfo( 'admin_email' ) ) {
1410
+ if ( is_email( _stc()->email ) )
1411
+ _stc()->add_error( sprintf( __( '<strong>%s</strong> is not subscribed to any posts on this site.', 'subscribe-to-comments' ), _stc()->email ) );
1412
+ else
1413
+ _stc()->add_error( sprintf( __( '<strong>%s</strong> is not a valid e-mail address.', 'subscribe-to-comments' ), _stc()->email ) );
1414
+ }
1415
+ ?>
1416
+
1417
+ <?php _stc()->show_errors(); ?>
1418
+
1419
+
1420
+
1421
+
1422
+ <?php if ( current_user_can( 'manage_options' ) ) { ?>
1423
+
1424
+ <?php if ( isset( $_REQUEST['email'] ) && $_REQUEST['email'] ) : ?>
1425
+ <p><a href="<?php echo esc_url( _stc()->form_action ); ?>"><?php _e( '&laquo; Back' ); ?></a></p>
1426
+ <?php endif; ?>
1427
+
1428
+ <h3><?php _e( 'Find Subscriptions', 'subscribe-to-comments' ); ?></h3>
1429
+
1430
+ <p>
1431
+ <?php _e( 'Enter an e-mail address to view its subscriptions or undo a block.', 'subscribe-to-comments' ); ?>
1432
+ </p>
1433
+
1434
+ <form name="getemail" method="post" action="<?php echo esc_url( _stc()->form_action ); ?>">
1435
+ <input type="hidden" name="ref" value="<?php echo _stc()->ref; ?>" />
1436
+
1437
+ <p>
1438
+ <input name="email" type="text" id="email" size="40" />
1439
+ <input type="submit" class="button-secondary" value="<?php _e( 'Search &raquo;', 'subscribe-to-comments' ); ?>" />
1440
+ </p>
1441
+ </form>
1442
+
1443
+ <?php if ( !isset( $_REQUEST['email'] ) || !$_REQUEST['email'] ) : ?>
1444
+ <?php if ( !isset( $_REQUEST['showallsubscribers'] ) || !$_REQUEST['showallsubscribers'] ) : ?>
1445
+ <h3><?php _e( 'Top Subscriber List', 'subscribe-to-comments' ); ?></h3>
1446
+ <?php else : ?>
1447
+ <h3><?php _e( 'Subscriber List', 'subscribe-to-comments' ); ?></h3>
1448
+ <?php endif; ?>
1449
+
1450
+ <?php
1451
+ $stc_limit = ( !isset( $_REQUEST['showallsubscribers'] ) || !$_REQUEST['showallsubscribers'] ) ? 'LIMIT 25' : '';
1452
+ if ( _stc()->is_multisite() ) {
1453
+ $all_pm_subscriptions = $wpdb->get_results( "SELECT DISTINCT email, count(post_id) as ccount FROM _stc()->ms_table WHERE status = 'active' GROUP BY email ORDER BY ccount DESC $stc_limit" );
1454
+ } else {
1455
+ $all_pm_subscriptions = $wpdb->get_results( "SELECT DISTINCT LCASE(meta_value) as email, count(post_id) as ccount FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' GROUP BY email ORDER BY ccount DESC $stc_limit" );
1456
+ }
1457
+ $all_subscriptions = array();
1458
+
1459
+ foreach ( (array) $all_pm_subscriptions as $sub ) {
1460
+ if ( !isset( $all_subscriptions[$sub->email] ) )
1461
+ $all_subscriptions[$sub->email] = (int) $sub->ccount;
1462
+ else
1463
+ $all_subscriptions[$sub->email] += (int) $sub->ccount;
1464
+ }
1465
+
1466
+ if ( !isset( $_REQUEST['showallsubscribers'] ) || !$_REQUEST['showallsubscribers'] ) : ?>
1467
+ <p><a href="<?php echo esc_url( esc_attr( add_query_arg( 'showallsubscribers', '1', _stc()->form_action ) ) ); ?>"><?php _e( 'Show all subscribers',
1468
+ 'subscribe-to-comments' ); ?></a></p>
1469
+ <?php elseif ( !isset( $_REQUEST['showccfield'] ) || !$_REQUEST['showccfield'] ) : ?>
1470
+ <p><a href="<?php echo add_query_arg( 'showccfield', '1' ); ?>"><?php _e( 'Show list of subscribers in <code>CC:</code>-field format (for bulk e-mailing)', 'subscribe-to-comments' ); ?></a></p>
1471
+ <?php else : ?>
1472
+ <p><a href="<?php echo esc_url( _stc()->form_action ); ?>"><?php _e( '&laquo; Back to regular view' ); ?></a></p>
1473
+ <p><textarea cols="60" rows="10"><?php echo implode( ', ', array_keys( $all_subscriptions ) ); ?></textarea></p>
1474
+ <?php endif;
1475
+
1476
+
1477
+ if ( $all_subscriptions ) {
1478
+ if ( !$_REQUEST['showccfield'] ) {
1479
+ echo "<ul>\n";
1480
+ foreach ( (array) $all_subscriptions as $email => $ccount ) {
1481
+ $enc_email = urlencode( $email );
1482
+ echo "<li>($ccount) <a href='" . esc_url( _stc()->form_action . "&email=$enc_email" ) . "'>" . esc_html( $email ) .
1483
+ "</a></li>\n";
1484
+ }
1485
+ echo "</ul>\n";
1486
+ }
1487
+ ?>
1488
+ <h3><?php _e( 'Top Subscribed Posts', 'subscribe-to-comments' ); ?></h3>
1489
+ <?php
1490
+ if ( _stc()->is_multisite() ) {
1491
+ $top_subscribed_posts = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT post_id, count( distinct post_id ) as ccount FROM _stc()->ms_table WHERE status = 'active' AND blog_id = %s ORDER BY ccount DEST LIMIT 25", $blog_id ) );
1492
+ } else {
1493
+ $top_subscribed_posts = $wpdb->get_results( "SELECT DISTINCT post_id, count(distinct meta_value) as ccount FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' GROUP BY post_id ORDER BY ccount DESC LIMIT 25" );
1494
+ }
1495
+ $all_top_posts = array();
1496
+
1497
+ foreach ( (array) $top_subscribed_posts as $pid ) {
1498
+ if ( !isset( $all_top_posts[$pid->post_id] ) )
1499
+ $all_top_posts[$pid->post_id] = (int) $pid->ccount;
1500
+ else
1501
+ $all_top_posts[$pid->post_id] += (int) $pid->ccount;
1502
+ }
1503
+
1504
+ arsort( $all_top_posts );
1505
+
1506
+ echo "<ul>\n";
1507
+ foreach ( $all_top_posts as $pid => $ccount ) {
1508
+ echo "<li>($ccount) <a href='" . get_permalink( $pid ) . "'>" . get_the_title( $pid ) . "</a></li>\n";
1509
+ }
1510
+ echo "</ul>";
1511
+ ?>
1512
+
1513
+ <?php } ?>
1514
+
1515
+ <?php endif; ?>
1516
+
1517
+ <?php } ?>
1518
+
1519
+ <?php if ( count( $postlist ) > 0 && is_array( $postlist ) ) { ?>
1520
+
1521
+
1522
+ <script type="text/javascript">
1523
+ <!--
1524
+ function checkAll(form) {
1525
+ for ( i = 0, n = form.elements.length; i < n; i++ ) {
1526
+ if ( form.elements[i].type == "checkbox" ) {
1527
+ if ( form.elements[i].checked == true )
1528
+ form.elements[i].checked = false;
1529
+ else
1530
+ form.elements[i].checked = true;
1531
+ }
1532
+ }
1533
+ }
1534
+ //-->
1535
+ </script>
1536
+
1537
+ <h3><?php _e( 'Subscriptions', 'subscribe-to-comments' ); ?></h3>
1538
+
1539
+ <p>
1540
+ <?php printf( __( '<strong>%s</strong> is subscribed to the posts listed below. To unsubscribe to one or more posts, click the checkbox next to the title, then click "Remove Selected Subscription(s)" at the bottom of the list.', 'subscribe-to-comments' ), _stc()->email ); ?>
1541
+ </p>
1542
+
1543
+ <form name="removeSubscription" id="removeSubscription" method="post" action="<?php echo esc_url( _stc()->form_action ); ?>">
1544
+ <input type="hidden" name="removesubscrips" value="removesubscrips" />
1545
+ <?php _stc()->hidden_form_fields(); ?>
1546
+
1547
+ <ol>
1548
+ <?php $i = 0;
1549
+ foreach ( $postlist as $pl ) { $i++; ?>
1550
+ <li><label for="subscrip-<?php echo $i; ?>"><input id="subscrip-<?php echo $i; ?>" type="checkbox" name="subscrips[]" value="<?php echo $pl[0] .'-'. $pl[1]; ?>" /> <?php echo _stc()->entry_link( $pl[0], $pl[1] ); ?></label></li>
1551
+ <?php } ?>
1552
+ </ol>
1553
+
1554
+ <p>
1555
+ <a href="javascript:;" onclick="checkAll(document.getElementById('removeSubscription')); return false; "><?php _e( 'Invert Checkbox Selection', 'subscribe-to-comments' ); ?></a>
1556
+ </p>
1557
+
1558
+ <p class="submit">
1559
+ <input type="submit" name="submit" value="<?php _e( 'Remove Selected Subscription(s) &raquo;', 'subscribe-to-comments' ); ?>" />
1560
+ </p>
1561
+ </form>
1562
+
1563
+ </div>
1564
+
1565
+ <div class="wrap">
1566
+ <h2><?php _e( 'Advanced Options', 'subscribe-to-comments' ); ?></h2>
1567
+
1568
+ <h3><?php _e( 'Block All Notifications', 'subscribe-to-comments' ); ?></h3>
1569
+
1570
+ <form name="blockemail" method="post" action="<?php echo esc_url( _stc()->form_action ); ?>">
1571
+ <input type="hidden" name="blockemail" value="blockemail" />
1572
+ <?php _stc()->hidden_form_fields(); ?>
1573
+
1574
+ <p>
1575
+ <?php printf( __( 'If you would like <strong>%s</strong> to be blocked from receiving any notifications from this site, click the button below. This should be reserved for cases where someone is signing you up for notifications without your consent.', 'subscribe-to-comments' ), _stc()->email ); ?>
1576
+ </p>
1577
+
1578
+ <p class="submit">
1579
+ <input type="submit" name="submit" value="<?php _e( 'Block Notifications &raquo;', 'subscribe-to-comments' ); ?>" />
1580
+ </p>
1581
+ </form>
1582
+
1583
+
1584
+
1585
+ <h3><?php _e( 'Change E-mail Address', 'subscribe-to-comments' ); ?></h3>
1586
+
1587
+ <form name="changeemailrequest" method="post" action="<?php echo esc_url( _stc()->form_action ); ?>">
1588
+ <input type="hidden" name="changeemailrequest" value="changeemailrequest" />
1589
+ <?php _stc()->hidden_form_fields(); ?>
1590
+
1591
+ <p>
1592
+ <?php printf( __( 'If you would like to change the e-mail address for your subscriptions, enter the new address below. You will be required to verify this request by clicking a special link sent to your current address (<strong>%s</strong>).', 'subscribe-to-comments' ), _stc()->email ); ?>
1593
+ </p>
1594
+
1595
+ <p>
1596
+ <?php _e( 'New E-mail Address:', 'subscribe-to-comments' ); ?>
1597
+ <input name="new_email" type="text" id="new_email" size="40" />
1598
+ <input type="submit" name="submit" class="button-secondary" value="<?php _e( 'Change E-mail Address &raquo;', 'subscribe-to-comments' ); ?>" />
1599
+ </p>
1600
+ </form>
1601
+
1602
+
1603
+ <?php } ?>
1604
+ <?php } //end if not in do not mail ?>
1605
+ </div>
1606
+
1607
+ <?php if ( _stc()->standalone ) : ?>
1608
+ <?php if ( !_stc()->use_wp_style ) :
1609
+ echo _stc()->after_manager;
1610
+
1611
+ if ( !empty( _stc()->sidebar ) )
1612
+ @include_once( _stc()->sidebar );
1613
+ if ( !empty( _stc()->footer ) )
1614
+ @include_once( _stc()->footer );
1615
+ ?>
1616
+ <?php else : ?>
1617
+ </body>
1618
+ </html>
1619
+ <?php endif; ?>
1620
+ <?php endif; ?>
1621
+
1622
+ <?php }
1623
+
1624
+ function cws_stc_uninstall_hook() {
1625
+ _stc()->uninstall();
1626
+ }
1627
+
1628
+ // Bootstrap the whole thing
1629
+ _stc();