Version Description
Download this release
Release Info
| Developer | markjaquith |
| Plugin | |
| Version | 2.1.2 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.1 to 2.1.2
- readme.txt +3 -3
- subscribe-to-comments.php +74 -57
readme.txt
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
=== Subscribe to Comments ===
|
| 2 |
Tags: comments, subscription, email
|
| 3 |
Contributors: markjaquith
|
| 4 |
-
Requires at least:
|
| 5 |
-
Tested up to: 2.
|
| 6 |
Stable tag: trunk
|
| 7 |
|
| 8 |
Subscribe to Comments allows commenters on an entry to subscribe to e-mail notifications for subsequent comments.
|
|
@@ -29,7 +29,7 @@ Subscribe to Comments is a robust plugin that enables commenters to sign up for
|
|
| 29 |
|
| 30 |
= I'd like the subscription checkbox to be checked by default. Can I do that? =
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
= My subscription checkbox shows up in a strange place. How do I fix it? =
|
| 35 |
|
| 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.
|
| 29 |
|
| 30 |
= I'd like the subscription checkbox to be checked by default. Can I do that? =
|
| 31 |
|
| 32 |
+
Not anymore. But the checkbox status will be remembered on a per-user basis.
|
| 33 |
|
| 34 |
= My subscription checkbox shows up in a strange place. How do I fix it? =
|
| 35 |
|
subscribe-to-comments.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Subscribe To Comments
|
| 4 |
-
Version: 2.1.
|
| 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
|
|
@@ -15,8 +15,7 @@ function show_subscription_checkbox ($id='0') {
|
|
| 15 |
|
| 16 |
if ( $sg_subscribe->checkbox_shown ) return $id;
|
| 17 |
if ( !$email = $sg_subscribe->current_viewer_subscription_status() ) :
|
| 18 |
-
|
| 19 |
-
$checked_status = ( 'checked' == $_COOKIE['subscribe_checkbox_'.COOKIEHASH] ) ? true : false;
|
| 20 |
?>
|
| 21 |
|
| 22 |
<?php /* ------------------------------------------------------------------- */ ?>
|
|
@@ -24,7 +23,7 @@ function show_subscription_checkbox ($id='0') {
|
|
| 24 |
<?php /* ------------------------------------------------------------------- */ ?>
|
| 25 |
|
| 26 |
<p <?php if ($sg_subscribe->clear_both) echo 'style="clear: both;" '; ?>class="subscribe-to-comments">
|
| 27 |
-
<input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" <?php if (
|
| 28 |
<label for="subscribe"><?php echo $sg_subscribe->not_subscribed_text; ?></label>
|
| 29 |
</p>
|
| 30 |
|
|
@@ -130,10 +129,12 @@ return false;
|
|
| 130 |
|
| 131 |
class sg_subscribe_settings {
|
| 132 |
function options_page_contents() {
|
| 133 |
-
|
|
|
|
| 134 |
if ( isset($_POST['sg_subscribe_settings_submit']) ) {
|
| 135 |
check_admin_referer('subscribe-to-comments-update_options');
|
| 136 |
-
|
|
|
|
| 137 |
}
|
| 138 |
|
| 139 |
|
|
@@ -142,7 +143,6 @@ class sg_subscribe_settings {
|
|
| 142 |
|
| 143 |
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>';
|
| 144 |
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>';
|
| 145 |
-
echo '<li><label for="default_subscribed"><input type="checkbox" id="default_subscribed" name="sg_subscribe_settings[default_subscribed]" value="default_subscribed"' . sg_subscribe_settings::checkflag('default_subscribed') . ' /> ' . __('"Subscribe" box should be checked by default', 'subscribe-to-comments') . '</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 |
|
|
@@ -187,12 +187,12 @@ class sg_subscribe_settings {
|
|
| 187 |
|
| 188 |
function form_setting($optname) {
|
| 189 |
$options = get_settings('sg_subscribe_settings');
|
| 190 |
-
return
|
| 191 |
}
|
| 192 |
|
| 193 |
function textarea_setting($optname) {
|
| 194 |
$options = get_settings('sg_subscribe_settings');
|
| 195 |
-
return
|
| 196 |
}
|
| 197 |
|
| 198 |
function options_page() {
|
|
@@ -252,7 +252,7 @@ class sg_subscribe {
|
|
| 252 |
var $author_text;
|
| 253 |
var $salt;
|
| 254 |
var $settings;
|
| 255 |
-
|
| 256 |
|
| 257 |
function sg_subscribe() {
|
| 258 |
global $wpdb;
|
|
@@ -262,16 +262,16 @@ class sg_subscribe {
|
|
| 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']) ) ?
|
| 266 |
$this->default_subscribed = ($this->settings['default_subscribed']) ? true : false;
|
| 267 |
|
| 268 |
-
$this->not_subscribed_text =
|
| 269 |
-
$this->subscribed_text =
|
| 270 |
-
$this->author_text =
|
| 271 |
$this->clear_both = $this->settings['clear_both'];
|
| 272 |
|
| 273 |
$this->errors = '';
|
| 274 |
-
$this->post_subscriptions =
|
| 275 |
$this->email_subscriptions = '';
|
| 276 |
}
|
| 277 |
|
|
@@ -280,18 +280,13 @@ class sg_subscribe {
|
|
| 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(),
|
| 284 |
-
$this->sidebar = str_replace('[theme_path]', get_template_directory(),
|
| 285 |
-
$this->footer = str_replace('[theme_path]', get_template_directory(),
|
| 286 |
-
$this->before_manager =
|
| 287 |
-
$this->after_manager =
|
| 288 |
}
|
| 289 |
|
| 290 |
-
// version 2.0.8 -- allow plugin file to be renamed or placed in a subdirectory
|
| 291 |
-
if ( 'edit.php?page=subscribe-to-comments.php' == $this->form_action )
|
| 292 |
-
$this->form_action = 'edit.php?page=' . STC_PLUGIN_BASENAME;
|
| 293 |
-
|
| 294 |
-
|
| 295 |
foreach ( array('email', 'key', 'ref', 'new_email') as $var )
|
| 296 |
if ( isset($_REQUEST[$var]) && !empty($_REQUEST[$var]) )
|
| 297 |
$this->{$var} = attribute_escape(trim(stripslashes($_REQUEST[$var])));
|
|
@@ -333,15 +328,15 @@ class sg_subscribe {
|
|
| 333 |
|
| 334 |
|
| 335 |
function subscriptions_from_post($postid) {
|
| 336 |
-
if ( is_array($this->post_subscriptions) )
|
| 337 |
-
return $this->post_subscriptions;
|
| 338 |
global $wpdb;
|
| 339 |
$postid = (int) $postid;
|
| 340 |
-
$this->post_subscriptions = $wpdb->
|
| 341 |
-
$subscribed_without_comment = get_post_meta($postid, '_sg_subscribe-to-comments');
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
return $this->post_subscriptions;
|
| 345 |
}
|
| 346 |
|
| 347 |
|
|
@@ -385,7 +380,7 @@ class sg_subscribe {
|
|
| 385 |
if ( is_array($this->subscriptions_from_email($email)) )
|
| 386 |
if (in_array($postid, (array) $this->subscriptions_from_email($email))) {
|
| 387 |
// already subscribed
|
| 388 |
-
setcookie('comment_author_email_' . COOKIEHASH,
|
| 389 |
$this->add_error(__('You appear to be already subscribed to this entry.', 'subscribe-to-comments'),'solo_subscribe');
|
| 390 |
}
|
| 391 |
$email = $wpdb->escape($email);
|
|
@@ -401,13 +396,13 @@ class sg_subscribe {
|
|
| 401 |
|
| 402 |
$post_author = $cache_userdata[$post->post_author];
|
| 403 |
|
| 404 |
-
if ( strtolower($post_author->user_email) ==
|
| 405 |
$this->add_error(__('You appear to be already subscribed to this entry.', 'subscribe-to-comments'),'solo_subscribe');
|
| 406 |
|
| 407 |
if ( !is_array($this->errors['solo_subscribe']) ) {
|
| 408 |
-
add_post_meta($postid, '_sg_subscribe-to-comments',
|
| 409 |
-
setcookie('comment_author_email_' . COOKIEHASH,
|
| 410 |
-
$location = $this->manage_link(
|
| 411 |
header("Location: $location");
|
| 412 |
exit();
|
| 413 |
}
|
|
@@ -416,15 +411,17 @@ class sg_subscribe {
|
|
| 416 |
|
| 417 |
function add_subscriber($cid) {
|
| 418 |
global $wpdb;
|
|
|
|
| 419 |
$id = (int) $id;
|
| 420 |
-
$email =
|
|
|
|
| 421 |
$postid = $wpdb->get_var("SELECT comment_post_ID from $wpdb->comments WHERE comment_ID = '$cid'");
|
| 422 |
|
| 423 |
-
$previously_subscribed = ( $wpdb->get_var("SELECT comment_subscribe from $wpdb->comments WHERE comment_post_ID = '$postid' AND LCASE(comment_author_email) = '$
|
| 424 |
|
| 425 |
// If user wants to be notified or has previously subscribed, set the flag on this current comment
|
| 426 |
if (($_POST['subscribe'] == 'subscribe' && is_email($email)) || $previously_subscribed) {
|
| 427 |
-
delete_post_meta($postid, '_sg_subscribe-to-comments',
|
| 428 |
$wpdb->query("UPDATE $wpdb->comments SET comment_subscribe = 'Y' where comment_post_ID = '$postid' AND LCASE(comment_author_email) = '$email'");
|
| 429 |
}
|
| 430 |
return $cid;
|
|
@@ -567,9 +564,10 @@ class sg_subscribe {
|
|
| 567 |
function remove_subscriber($email, $postid) {
|
| 568 |
global $wpdb;
|
| 569 |
$postid = (int) $postid;
|
| 570 |
-
$email =
|
|
|
|
| 571 |
|
| 572 |
-
if ( delete_post_meta($postid, '_sg_subscribe-to-comments',
|
| 573 |
return true;
|
| 574 |
else
|
| 575 |
return false;
|
|
@@ -596,23 +594,23 @@ class sg_subscribe {
|
|
| 596 |
if ( $comment->comment_approved == '1' && $comment->comment_type == '' ) {
|
| 597 |
// Comment has been approved and isn't a trackback or a pingback, so we should send out notifications
|
| 598 |
|
| 599 |
-
$message = sprintf(__("There is a new comment on the post \"%s\"", 'subscribe-to-comments') . ". \n%s\n\n",
|
| 600 |
$message .= sprintf(__("Author: %s\n", 'subscribe-to-comments'), $comment->comment_author);
|
| 601 |
-
$message .= __("Comment:\n", 'subscribe-to-comments') .
|
| 602 |
$message .= __("See all comments on this post here:\n", 'subscribe-to-comments');
|
| 603 |
$message .= get_permalink($comment->comment_post_ID) . "#comments\n\n";
|
| 604 |
//add link to manage comment notifications
|
| 605 |
$message .= __("To manage your subscriptions or to block all notifications from this site, click the link below:\n", 'subscribe-to-comments');
|
| 606 |
$message .= get_settings('home') . '/?wp-subscription-manager=1&email=[email]&key=[key]';
|
| 607 |
|
| 608 |
-
$subject = sprintf(__('New Comment On: %s', 'subscribe-to-comments'),
|
| 609 |
|
| 610 |
$subscriptions = $this->subscriptions_from_post($comment->comment_post_ID);
|
| 611 |
foreach ( (array) $subscriptions as $email ) {
|
| 612 |
-
if ( !$this->is_blocked($email
|
| 613 |
-
$message_final = str_replace('[email]', urlencode($email
|
| 614 |
-
$message_final = str_replace('[key]', $this->generate_key($email
|
| 615 |
-
$this->send_mail($email
|
| 616 |
}
|
| 617 |
} // foreach subscription
|
| 618 |
} // end if comment approved
|
|
@@ -700,9 +698,13 @@ class sg_subscribe {
|
|
| 700 |
global $wpdb;
|
| 701 |
|
| 702 |
// add the options
|
| 703 |
-
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>', '
|
| 704 |
|
| 705 |
$settings = get_option('sg_subscribe_settings');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 706 |
|
| 707 |
if ( !$settings['salt'] ) {
|
| 708 |
$settings['salt'] = md5(md5(uniqid(rand() . rand() . rand() . rand() . rand(), true))); // random MD5 hash
|
|
@@ -714,8 +716,19 @@ class sg_subscribe {
|
|
| 714 |
$update = true;
|
| 715 |
}
|
| 716 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
if ( $update )
|
| 718 |
-
|
| 719 |
|
| 720 |
$column_name = 'comment_subscribe';
|
| 721 |
foreach ( (array) $wpdb->get_col("DESC $wpdb->comments", 0) as $column )
|
|
@@ -727,6 +740,12 @@ class sg_subscribe {
|
|
| 727 |
}
|
| 728 |
|
| 729 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 730 |
function current_viewer_subscription_status(){
|
| 731 |
global $wpdb, $post, $user_email;
|
| 732 |
|
|
@@ -779,9 +798,9 @@ class sg_subscribe {
|
|
| 779 |
|
| 780 |
|
| 781 |
function add_admin_menu() {
|
| 782 |
-
add_management_page(__('Comment Subscription Manager', 'subscribe-to-comments'), __('Subscriptions', 'subscribe-to-comments'), 8,
|
| 783 |
|
| 784 |
-
add_options_page(__('Subscribe to Comments', 'subscribe-to-comments'), __('Subscribe to Comments', 'subscribe-to-comments'), 5,
|
| 785 |
}
|
| 786 |
|
| 787 |
|
|
@@ -829,12 +848,10 @@ add_filter('preprocess_comment', 'stc_checkbox_state', 1);
|
|
| 829 |
// detect "subscribe without commenting" attempts
|
| 830 |
add_action('init', create_function('$a','global $sg_subscribe; if ( $_POST[\'solo-comment-subscribe\'] == \'solo-comment-subscribe\' && is_numeric($_POST[\'postid\']) ) {
|
| 831 |
sg_subscribe_start();
|
| 832 |
-
$sg_subscribe->solo_subscribe($_POST[\'email\'], $_POST[\'postid\']);
|
| 833 |
}')
|
| 834 |
);
|
| 835 |
|
| 836 |
-
define('STC_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
| 837 |
-
|
| 838 |
if ( isset($_REQUEST['wp-subscription-manager']) )
|
| 839 |
add_action('template_redirect', 'sg_subscribe_admin_standalone');
|
| 840 |
|
|
@@ -852,7 +869,7 @@ function sg_subscribe_admin($standalone = false) {
|
|
| 852 |
$sg_subscribe->standalone = true;
|
| 853 |
ob_start(create_function('$a', 'return str_replace("<title>", "<title> " . __("Subscription Manager", "subscribe-to-comments") . " » ", $a);'));
|
| 854 |
} else {
|
| 855 |
-
$sg_subscribe->form_action = 'edit.php?page=
|
| 856 |
$sg_subscribe->standalone = false;
|
| 857 |
}
|
| 858 |
|
| 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
|
| 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 /* ------------------------------------------------------------------- */ ?>
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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() {
|
| 252 |
var $author_text;
|
| 253 |
var $salt;
|
| 254 |
var $settings;
|
| 255 |
+
var $version = '2.1.2';
|
| 256 |
|
| 257 |
function sg_subscribe() {
|
| 258 |
global $wpdb;
|
| 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 |
|
| 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])));
|
| 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 |
|
| 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);
|
| 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 |
}
|
| 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;
|
| 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;
|
| 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
|
| 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
|
| 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 )
|
| 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 |
|
| 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 |
|
| 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 |
|
| 869 |
$sg_subscribe->standalone = true;
|
| 870 |
ob_start(create_function('$a', 'return str_replace("<title>", "<title> " . __("Subscription Manager", "subscribe-to-comments") . " » ", $a);'));
|
| 871 |
} else {
|
| 872 |
+
$sg_subscribe->form_action = 'edit.php?page=stc-management';
|
| 873 |
$sg_subscribe->standalone = false;
|
| 874 |
}
|
| 875 |
|
