Version Description
Download this release
Release Info
Developer | wpkube |
Plugin | Subscribe To Comments Reloaded |
Version | 191009 |
Comparing to | |
See all releases |
Code changes from version 190529 to 191009
- langs/subscribe-to-comments-reloaded-de_DE.mo +0 -0
- langs/subscribe-to-comments-reloaded-de_DE.po +2 -3
- options/panel1-add-subscription.php +1 -1
- options/panel1-edit-subscription.php +2 -2
- options/stcr_comment_form.php +1 -1
- options/stcr_manage_subscriptions.php +4 -4
- options/stcr_management_page.php +3 -3
- options/stcr_notifications.php +6 -6
- options/stcr_options.php +5 -5
- options/stcr_system.php +1 -1
- readme.txt +10 -1
- subscribe-to-comments-reloaded.php +35 -15
- templates/confirm.php +16 -9
- templates/key_expired.php +2 -2
- templates/one-click-unsubscribe.php +1 -1
- templates/request-management-link.php +44 -35
- templates/subscribe.php +100 -88
- uninstall.php +34 -25
- utils/stcr_manage.php +4 -1
- utils/stcr_upgrade.php +70 -4
- utils/stcr_utils.php +917 -896
- wp_subscribe_reloaded.php +678 -338
langs/subscribe-to-comments-reloaded-de_DE.mo
CHANGED
Binary file
|
langs/subscribe-to-comments-reloaded-de_DE.po
CHANGED
@@ -3,7 +3,7 @@ msgstr ""
|
|
3 |
"Project-Id-Version: Subscribe to Comments Reloaded\n"
|
4 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/src\n"
|
5 |
"POT-Creation-Date: 2019-02-07 08:12:11+00:00\n"
|
6 |
-
"PO-Revision-Date:
|
7 |
"Last-Translator: Reedyseth <reedyseth@gmail.com>\n"
|
8 |
"Language-Team: \n"
|
9 |
"Language: de\n"
|
@@ -19,11 +19,10 @@ msgstr ""
|
|
19 |
"esc_html_x:1,2c;comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2\n"
|
20 |
"X-Poedit-Basepath: ..\n"
|
21 |
"X-Textdomain-Support: yes\n"
|
22 |
-
"X-Generator: Poedit 2.
|
23 |
"X-Loco-Target-Locale: de_DE\n"
|
24 |
"X-Poedit-SearchPath-0: .\n"
|
25 |
"X-Poedit-SearchPathExcluded-0: includes\n"
|
26 |
-
"X-Poedit-SearchPathExcluded-0: bower_components\n"
|
27 |
"X-Poedit-SearchPathExcluded-1: vendor\n"
|
28 |
|
29 |
#: classes/stcr_i18n.php:51 classes/stcr_i18n.php:56
|
3 |
"Project-Id-Version: Subscribe to Comments Reloaded\n"
|
4 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/src\n"
|
5 |
"POT-Creation-Date: 2019-02-07 08:12:11+00:00\n"
|
6 |
+
"PO-Revision-Date: 2019-08-01 17:37+0200\n"
|
7 |
"Last-Translator: Reedyseth <reedyseth@gmail.com>\n"
|
8 |
"Language-Team: \n"
|
9 |
"Language: de\n"
|
19 |
"esc_html_x:1,2c;comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2\n"
|
20 |
"X-Poedit-Basepath: ..\n"
|
21 |
"X-Textdomain-Support: yes\n"
|
22 |
+
"X-Generator: Poedit 2.2.3\n"
|
23 |
"X-Loco-Target-Locale: de_DE\n"
|
24 |
"X-Poedit-SearchPath-0: .\n"
|
25 |
"X-Poedit-SearchPathExcluded-0: includes\n"
|
|
|
26 |
"X-Poedit-SearchPathExcluded-1: vendor\n"
|
27 |
|
28 |
#: classes/stcr_i18n.php:51 classes/stcr_i18n.php:56
|
options/panel1-add-subscription.php
CHANGED
@@ -23,7 +23,7 @@ echo ' <strong>' . get_the_title( intval( $_GET['srp'] ) ) . " (" . intval( $_GE
|
|
23 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
24 |
<option value='YC'><?php _e( 'Ask user to confirm', 'subscribe-to-comments-reloaded' ) ?></option>
|
25 |
</select>
|
26 |
-
<input type='submit' class='subscribe-form-button' value='<?php
|
27 |
</p>
|
28 |
<input type='hidden' name='sra' value='add' />
|
29 |
<input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
|
23 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
24 |
<option value='YC'><?php _e( 'Ask user to confirm', 'subscribe-to-comments-reloaded' ) ?></option>
|
25 |
</select>
|
26 |
+
<input type='submit' class='subscribe-form-button' value='<?php esc_attr_e( 'Update', 'subscribe-to-comments-reloaded' ) ?>' />
|
27 |
</p>
|
28 |
<input type='hidden' name='sra' value='add' />
|
29 |
<input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
|
options/panel1-edit-subscription.php
CHANGED
@@ -18,7 +18,7 @@ echo ' <strong>' . get_the_title( intval( $_GET['srp'] ) ) . " (" . intval( $_GE
|
|
18 |
</p>
|
19 |
|
20 |
<p class="liquid"><label for='sre'><?php _e( 'To', 'subscribe-to-comments-reloaded' ) ?></label>
|
21 |
-
<input type='text' size='30' name='sre' id='sre' value='<?php
|
22 |
onfocus='if (this.value == "<?php _e( 'optional', 'subscribe-to-comments-reloaded' ) ?>") this.value="";this.style.color="#000"'
|
23 |
onblur='if (this.value == ""){this.value="<?php _e( 'optional', 'subscribe-to-comments-reloaded' ) ?>";this.style.color="#ccc"}' />
|
24 |
</p>
|
@@ -30,7 +30,7 @@ echo ' <strong>' . get_the_title( intval( $_GET['srp'] ) ) . " (" . intval( $_GE
|
|
30 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
31 |
<option value='C'><?php _e( 'Suspended', 'subscribe-to-comments-reloaded' ) ?></option>
|
32 |
</select>
|
33 |
-
<input type='submit' class='subscribe-form-button' value='<?php
|
34 |
</p>
|
35 |
<input type='hidden' name='sra' value='edit' />
|
36 |
<input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
|
18 |
</p>
|
19 |
|
20 |
<p class="liquid"><label for='sre'><?php _e( 'To', 'subscribe-to-comments-reloaded' ) ?></label>
|
21 |
+
<input type='text' size='30' name='sre' id='sre' value='<?php esc_attr_e( 'optional', 'subscribe-to-comments-reloaded' ) ?>' style="color:#ccc"
|
22 |
onfocus='if (this.value == "<?php _e( 'optional', 'subscribe-to-comments-reloaded' ) ?>") this.value="";this.style.color="#000"'
|
23 |
onblur='if (this.value == ""){this.value="<?php _e( 'optional', 'subscribe-to-comments-reloaded' ) ?>";this.style.color="#ccc"}' />
|
24 |
</p>
|
30 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
31 |
<option value='C'><?php _e( 'Suspended', 'subscribe-to-comments-reloaded' ) ?></option>
|
32 |
</select>
|
33 |
+
<input type='submit' class='subscribe-form-button' value='<?php esc_attr_e( 'Update', 'subscribe-to-comments-reloaded' ) ?>' />
|
34 |
</p>
|
35 |
<input type='hidden' name='sra' value='edit' />
|
36 |
<input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
|
options/stcr_comment_form.php
CHANGED
@@ -183,7 +183,7 @@ if ( isset( $_POST['options'] ) ) {
|
|
183 |
<div class="col-sm-7">
|
184 |
<input type="text" name="options[checkbox_inline_style]" id="checkbox_inline_style"
|
185 |
class="form-control form-control-input-8"
|
186 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checkbox_inline_style' ); ?>" size="20">
|
187 |
|
188 |
<div class="helpDescription subsOptDescriptions"
|
189 |
data-content="<?php _e( 'Custom inline CSS to add to the checkbox.', 'subscribe-to-comments-reloaded' ); ?>"
|
183 |
<div class="col-sm-7">
|
184 |
<input type="text" name="options[checkbox_inline_style]" id="checkbox_inline_style"
|
185 |
class="form-control form-control-input-8"
|
186 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checkbox_inline_style' ) ); ?>" size="20">
|
187 |
|
188 |
<div class="helpDescription subsOptDescriptions"
|
189 |
data-content="<?php _e( 'Custom inline CSS to add to the checkbox.', 'subscribe-to-comments-reloaded' ); ?>"
|
options/stcr_manage_subscriptions.php
CHANGED
@@ -56,12 +56,12 @@ if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/panel
|
|
56 |
<table>
|
57 |
<tr>
|
58 |
<td><label for='oldsre'><?php _e( 'From', 'subscribe-to-comments-reloaded' ) ?></label></td>
|
59 |
-
<td><input class="form-control form-controls-font" type='text' size='30' name='oldsre' id='oldsre' value='<?php
|
60 |
<td><span class="validate-error-text validate-error-text-oldsre stcr-hidden "></span></td>
|
61 |
</tr>
|
62 |
<tr>
|
63 |
<td><label for='sre'><?php _e( 'To', 'subscribe-to-comments-reloaded' ) ?></label></td>
|
64 |
-
<td><input class="form-control form-controls-font" type='text' size='30' name='sre' id='sre' value='<?php
|
65 |
>
|
66 |
</td>
|
67 |
<td><span class="validate-error-text validate-error-text-sre stcr-hidden "></span></td>
|
@@ -74,7 +74,7 @@ if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/panel
|
|
74 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
75 |
<option value='C'><?php _e( 'Suspended', 'subscribe-to-comments-reloaded' ) ?></option>
|
76 |
</select>
|
77 |
-
<input type='submit' style="font-size: 0.8rem;" class='subscribe-form-button btn btn-primary' value='<?php
|
78 |
</tr>
|
79 |
<tr>
|
80 |
<td colspan="2">
|
@@ -127,7 +127,7 @@ if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/panel
|
|
127 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
128 |
<option value='YC'><?php _e( 'Ask user to confirm', 'subscribe-to-comments-reloaded' ) ?></option>
|
129 |
</select>
|
130 |
-
<input type='submit' style="font-size: 0.8rem;" class='subscribe-form-button btn btn-primary' value='<?php
|
131 |
</td>
|
132 |
</tr>
|
133 |
<tr>
|
56 |
<table>
|
57 |
<tr>
|
58 |
<td><label for='oldsre'><?php _e( 'From', 'subscribe-to-comments-reloaded' ) ?></label></td>
|
59 |
+
<td><input class="form-control form-controls-font" type='text' size='30' name='oldsre' id='oldsre' value='<?php esc_attr_e( 'email address', 'subscribe-to-comments-reloaded' ) ?>' style="color:#ccc;"></td>
|
60 |
<td><span class="validate-error-text validate-error-text-oldsre stcr-hidden "></span></td>
|
61 |
</tr>
|
62 |
<tr>
|
63 |
<td><label for='sre'><?php _e( 'To', 'subscribe-to-comments-reloaded' ) ?></label></td>
|
64 |
+
<td><input class="form-control form-controls-font" type='text' size='30' name='sre' id='sre' value='<?php esc_attr_e( 'optional - new email address', 'subscribe-to-comments-reloaded' ) ?>' style="color:#ccc;"
|
65 |
>
|
66 |
</td>
|
67 |
<td><span class="validate-error-text validate-error-text-sre stcr-hidden "></span></td>
|
74 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
75 |
<option value='C'><?php _e( 'Suspended', 'subscribe-to-comments-reloaded' ) ?></option>
|
76 |
</select>
|
77 |
+
<input type='submit' style="font-size: 0.8rem;" class='subscribe-form-button btn btn-primary' value='<?php esc_attr_e( 'Update', 'subscribe-to-comments-reloaded' ) ?>' ></td>
|
78 |
</tr>
|
79 |
<tr>
|
80 |
<td colspan="2">
|
127 |
<option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
|
128 |
<option value='YC'><?php _e( 'Ask user to confirm', 'subscribe-to-comments-reloaded' ) ?></option>
|
129 |
</select>
|
130 |
+
<input type='submit' style="font-size: 0.8rem;" class='subscribe-form-button btn btn-primary' value='<?php esc_attr_e( 'Add', 'subscribe-to-comments-reloaded' ) ?>' >
|
131 |
</td>
|
132 |
</tr>
|
133 |
<tr>
|
options/stcr_management_page.php
CHANGED
@@ -99,7 +99,7 @@ wp_print_scripts( 'quicktags' );
|
|
99 |
<div class="col-sm-7">
|
100 |
<input type="text" name="options[manager_page_title]" id="manager_page_title"
|
101 |
class="form-control form-control-input-8"
|
102 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_title' ); ?>" size="20">
|
103 |
|
104 |
<div class="helpDescription subsOptDescriptions"
|
105 |
data-content="<?php _e( 'Title of the page your visitors will use to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -117,7 +117,7 @@ wp_print_scripts( 'quicktags' );
|
|
117 |
<code><?php echo get_bloginfo( 'url' ) ?></code>
|
118 |
<input type="text" name="options[manager_page]" id="manager_page"
|
119 |
class="form-control form-control-input-8"
|
120 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page' ); ?>" style=" width: 60% !important;">
|
121 |
|
122 |
<div class="helpDescription subsOptDescriptions"
|
123 |
data-content="<?php _e( "The permalink for your management page (something like <code>/manage-subscriptions</code> or <code>/?page_id=345</code>). This page <b>does not</b> actually exist in the system, but its link must follow your permalink structure.", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -142,7 +142,7 @@ wp_print_scripts( 'quicktags' );
|
|
142 |
<div class="col-sm-7">
|
143 |
<input type="text" name="options[custom_header_meta]" id="custom_header_meta"
|
144 |
class="form-control form-control-input-8"
|
145 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'custom_header_meta' ); ?>" size="20">
|
146 |
|
147 |
<div class="helpDescription subsOptDescriptions"
|
148 |
data-content="<?php _e( 'Specify your custom HTML code to be added to the HEAD section of the page. Use <strong>single</strong> quotes for values.', 'subscribe-to-comments-reloaded' ); ?>"
|
99 |
<div class="col-sm-7">
|
100 |
<input type="text" name="options[manager_page_title]" id="manager_page_title"
|
101 |
class="form-control form-control-input-8"
|
102 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_title' ) ); ?>" size="20">
|
103 |
|
104 |
<div class="helpDescription subsOptDescriptions"
|
105 |
data-content="<?php _e( 'Title of the page your visitors will use to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>"
|
117 |
<code><?php echo get_bloginfo( 'url' ) ?></code>
|
118 |
<input type="text" name="options[manager_page]" id="manager_page"
|
119 |
class="form-control form-control-input-8"
|
120 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page' ) ); ?>" style=" width: 60% !important;">
|
121 |
|
122 |
<div class="helpDescription subsOptDescriptions"
|
123 |
data-content="<?php _e( "The permalink for your management page (something like <code>/manage-subscriptions</code> or <code>/?page_id=345</code>). This page <b>does not</b> actually exist in the system, but its link must follow your permalink structure.", 'subscribe-to-comments-reloaded' ); ?>"
|
142 |
<div class="col-sm-7">
|
143 |
<input type="text" name="options[custom_header_meta]" id="custom_header_meta"
|
144 |
class="form-control form-control-input-8"
|
145 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'custom_header_meta' ) ); ?>" size="20">
|
146 |
|
147 |
<div class="helpDescription subsOptDescriptions"
|
148 |
data-content="<?php _e( 'Specify your custom HTML code to be added to the HEAD section of the page. Use <strong>single</strong> quotes for values.', 'subscribe-to-comments-reloaded' ); ?>"
|
options/stcr_notifications.php
CHANGED
@@ -76,7 +76,7 @@ wp_print_scripts( 'quicktags' );
|
|
76 |
<div class="col-sm-7">
|
77 |
<input type="text" name="options[from_name]" id="from_name"
|
78 |
class="form-control form-control-input-8"
|
79 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'from_name' ); ?>" size="20">
|
80 |
|
81 |
<div class="helpDescription subsOptDescriptions"
|
82 |
data-content="<?php _e( "Name to use for the 'from' field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -93,7 +93,7 @@ wp_print_scripts( 'quicktags' );
|
|
93 |
<div class="col-sm-7">
|
94 |
<input type="text" name="options[from_email]" id="from_email"
|
95 |
class="form-control form-control-input-8"
|
96 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'from_email' ); ?>" size="20">
|
97 |
|
98 |
<div class="helpDescription subsOptDescriptions"
|
99 |
data-content="<?php _e( "Email address to use for the \"from\" field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -110,7 +110,7 @@ wp_print_scripts( 'quicktags' );
|
|
110 |
<div class="col-sm-7">
|
111 |
<input type="text" name="options[reply_to]" id="reply_to"
|
112 |
class="form-control form-control-input-8"
|
113 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'reply_to' ); ?>" size="20">
|
114 |
|
115 |
<div class="helpDescription subsOptDescriptions"
|
116 |
data-content="<?php _e( "This will be use when the user click reply on their email agent. If not set it will be the same as the Sender email address.", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -129,7 +129,7 @@ wp_print_scripts( 'quicktags' );
|
|
129 |
<div class="col-sm-7">
|
130 |
<input type="text" name="options[notification_subject]" id="notification_subject"
|
131 |
class="form-control form-control-input-8"
|
132 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'notification_subject' ); ?>" size="20">
|
133 |
|
134 |
<div class="helpDescription subsOptDescriptions"
|
135 |
data-content="<?php _e( "Subject of the notification email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -177,7 +177,7 @@ wp_print_scripts( 'quicktags' );
|
|
177 |
<div class="col-sm-7">
|
178 |
<input type="text" name="options[double_check_subject]" id="double_check_subject"
|
179 |
class="form-control form-control-input-8"
|
180 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'double_check_subject' ); ?>" size="20">
|
181 |
|
182 |
<div class="helpDescription subsOptDescriptions"
|
183 |
data-content="<?php _e( "Subject of the confirmation email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -221,7 +221,7 @@ wp_print_scripts( 'quicktags' );
|
|
221 |
<div class="col-sm-7">
|
222 |
<input type="text" name="options[management_subject]" id="management_subject"
|
223 |
class="form-control form-control-input-8"
|
224 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'management_subject' ); ?>" size="20">
|
225 |
|
226 |
<div class="helpDescription subsOptDescriptions"
|
227 |
data-content="<?php _e( "Subject of the mail sent to those who request to access their management page. Allowed tag: [blog_name]", 'subscribe-to-comments-reloaded' ); ?>"
|
76 |
<div class="col-sm-7">
|
77 |
<input type="text" name="options[from_name]" id="from_name"
|
78 |
class="form-control form-control-input-8"
|
79 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'from_name' ) ); ?>" size="20">
|
80 |
|
81 |
<div class="helpDescription subsOptDescriptions"
|
82 |
data-content="<?php _e( "Name to use for the 'from' field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
|
93 |
<div class="col-sm-7">
|
94 |
<input type="text" name="options[from_email]" id="from_email"
|
95 |
class="form-control form-control-input-8"
|
96 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'from_email' ) ); ?>" size="20">
|
97 |
|
98 |
<div class="helpDescription subsOptDescriptions"
|
99 |
data-content="<?php _e( "Email address to use for the \"from\" field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
|
110 |
<div class="col-sm-7">
|
111 |
<input type="text" name="options[reply_to]" id="reply_to"
|
112 |
class="form-control form-control-input-8"
|
113 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'reply_to' ) ); ?>" size="20">
|
114 |
|
115 |
<div class="helpDescription subsOptDescriptions"
|
116 |
data-content="<?php _e( "This will be use when the user click reply on their email agent. If not set it will be the same as the Sender email address.", 'subscribe-to-comments-reloaded' ); ?>"
|
129 |
<div class="col-sm-7">
|
130 |
<input type="text" name="options[notification_subject]" id="notification_subject"
|
131 |
class="form-control form-control-input-8"
|
132 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'notification_subject' ) ); ?>" size="20">
|
133 |
|
134 |
<div class="helpDescription subsOptDescriptions"
|
135 |
data-content="<?php _e( "Subject of the notification email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
|
177 |
<div class="col-sm-7">
|
178 |
<input type="text" name="options[double_check_subject]" id="double_check_subject"
|
179 |
class="form-control form-control-input-8"
|
180 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'double_check_subject' ) ); ?>" size="20">
|
181 |
|
182 |
<div class="helpDescription subsOptDescriptions"
|
183 |
data-content="<?php _e( "Subject of the confirmation email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
|
221 |
<div class="col-sm-7">
|
222 |
<input type="text" name="options[management_subject]" id="management_subject"
|
223 |
class="form-control form-control-input-8"
|
224 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'management_subject' ) ); ?>" size="20">
|
225 |
|
226 |
<div class="helpDescription subsOptDescriptions"
|
227 |
data-content="<?php _e( "Subject of the mail sent to those who request to access their management page. Allowed tag: [blog_name]", 'subscribe-to-comments-reloaded' ); ?>"
|
options/stcr_options.php
CHANGED
@@ -135,7 +135,7 @@ wp_print_scripts( 'quicktags' );
|
|
135 |
<div class="col-sm-7">
|
136 |
<input type="number" name="options[purge_days]" id="purge_days"
|
137 |
class="form-control form-control-input-3"
|
138 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'purge_days' ); ?>" size="20">
|
139 |
|
140 |
<div class="helpDescription subsOptDescriptions"
|
141 |
data-content="<?php _e( "Delete pending subscriptions (not confirmed) after X days. Zero disables this feature.", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -152,7 +152,7 @@ wp_print_scripts( 'quicktags' );
|
|
152 |
<div class="col-sm-7">
|
153 |
<input type="text" name="options[date_format]" id="date_format"
|
154 |
class="form-control form-control-input-3"
|
155 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'date_format' ); ?>" size="20">
|
156 |
|
157 |
<div class="helpDescription subsOptDescriptions"
|
158 |
data-content="<?php _e( "Date format that will be display on the management page. Use <a href='https://secure.php.net/manual/en/function.date.php#refsect1-function.date-parameters' target='_blank'>PHP Date Format</a>", 'subscribe-to-comments-reloaded' ); ?>"
|
@@ -448,9 +448,9 @@ wp_print_scripts( 'quicktags' );
|
|
448 |
?>
|
449 |
<input type="text" name="options[unique_key]" id="unique_key"
|
450 |
class="form-control form-control-input-6"
|
451 |
-
value="<?php echo $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'unique_key' ); ?>" size="20">
|
452 |
|
453 |
-
<input type="submit" value="<?php
|
454 |
<?php } ?>
|
455 |
|
456 |
|
@@ -495,7 +495,7 @@ wp_print_scripts( 'quicktags' );
|
|
495 |
<span class="switch-selection"></span>
|
496 |
</div>
|
497 |
|
498 |
-
<input type="submit" value="<?php
|
499 |
|
500 |
</div>
|
501 |
</div>
|
135 |
<div class="col-sm-7">
|
136 |
<input type="number" name="options[purge_days]" id="purge_days"
|
137 |
class="form-control form-control-input-3"
|
138 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'purge_days' ) ); ?>" size="20">
|
139 |
|
140 |
<div class="helpDescription subsOptDescriptions"
|
141 |
data-content="<?php _e( "Delete pending subscriptions (not confirmed) after X days. Zero disables this feature.", 'subscribe-to-comments-reloaded' ); ?>"
|
152 |
<div class="col-sm-7">
|
153 |
<input type="text" name="options[date_format]" id="date_format"
|
154 |
class="form-control form-control-input-3"
|
155 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'date_format' ) ); ?>" size="20">
|
156 |
|
157 |
<div class="helpDescription subsOptDescriptions"
|
158 |
data-content="<?php _e( "Date format that will be display on the management page. Use <a href='https://secure.php.net/manual/en/function.date.php#refsect1-function.date-parameters' target='_blank'>PHP Date Format</a>", 'subscribe-to-comments-reloaded' ); ?>"
|
448 |
?>
|
449 |
<input type="text" name="options[unique_key]" id="unique_key"
|
450 |
class="form-control form-control-input-6"
|
451 |
+
value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'unique_key' ) ); ?>" size="20">
|
452 |
|
453 |
+
<input type="submit" value="<?php esc_attr_e( 'Generate New Key' ) ?>" class="btn btn-secondary subscribe-form-button" name="generate_key" >
|
454 |
<?php } ?>
|
455 |
|
456 |
|
495 |
<span class="switch-selection"></span>
|
496 |
</div>
|
497 |
|
498 |
+
<input type="submit" value="<?php esc_attr_e( 'Reset All Options' ) ?>" class="btn btn-danger subscribe-form-button reset_all_options" name="reset_all_options" >
|
499 |
|
500 |
</div>
|
501 |
</div>
|
options/stcr_system.php
CHANGED
@@ -207,7 +207,7 @@ else {
|
|
207 |
); ?>
|
208 |
</span>
|
209 |
|
210 |
-
<input type='submit' id="purge_log" value='<?php
|
211 |
</div>
|
212 |
</div>
|
213 |
|
207 |
); ?>
|
208 |
</span>
|
209 |
|
210 |
+
<input type='submit' id="purge_log" value='<?php esc_attr_e( 'Clean' ); ?>' class='btn btn-secondary subscribe-form-button' name='purge_log' >
|
211 |
</div>
|
212 |
</div>
|
213 |
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Requires at least: 4.0
|
|
7 |
Requires PHP: 5.6
|
8 |
Requires MySQL: 5.6
|
9 |
Tested up to: 5.2
|
10 |
-
Stable tag:
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -100,6 +100,15 @@ Just go to the Options Panel and click the generate button. By generating a new
|
|
100 |
|
101 |
== Changelog ==
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
= v190529 =
|
104 |
* **Fix** Issue with being unable to dismiss admin notices shown by StCR
|
105 |
* **Fix** Virtual management page was still being shown even when disabled
|
7 |
Requires PHP: 5.6
|
8 |
Requires MySQL: 5.6
|
9 |
Tested up to: 5.2
|
10 |
+
Stable tag: 191009
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
100 |
|
101 |
== Changelog ==
|
102 |
|
103 |
+
= v191009 =
|
104 |
+
* **Fix** Issue with post slug being displayed instead of the post title on unsubscribe
|
105 |
+
* **Fix** HTML validation error in subscribe template
|
106 |
+
* **Fix** Fix German translation "Nicht abonnieren"
|
107 |
+
* **Fix** Fix import data from Subscribe Reloaded by Mark Jaquith
|
108 |
+
* **Fix** Issue with using double quotes in options
|
109 |
+
* **Tweak** Show a message to the comment author to check his email to confirm subscription
|
110 |
+
* **Tweak** Performance improvement for error logging
|
111 |
+
|
112 |
= v190529 =
|
113 |
* **Fix** Issue with being unable to dismiss admin notices shown by StCR
|
114 |
* **Fix** Virtual management page was still being shown even when disabled
|
subscribe-to-comments-reloaded.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Subscribe to Comments Reloaded
|
4 |
* Description: Subscribe to Comments Reloaded is a robust plugin that enables commenters to sign up for e-mail notifications. It includes a full-featured subscription manager that your commenters can use to unsubscribe to certain posts or suspend all notifications.
|
5 |
-
* Version:
|
6 |
* Author: WPKube
|
7 |
* Author URI: http://wpkube.com/
|
8 |
* License: GPL-2.0+
|
@@ -12,27 +12,41 @@
|
|
12 |
*/
|
13 |
|
14 |
namespace stcr;
|
15 |
-
|
|
|
16 |
if ( ! function_exists( 'add_action' ) ) {
|
17 |
header( 'Location: /' );
|
18 |
exit;
|
19 |
}
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
class stcr_subscribe_reloaded {
|
24 |
-
|
25 |
-
const CLASSNAME = __CLASS__;
|
26 |
|
27 |
public $stcr = null;
|
28 |
|
|
|
|
|
|
|
|
|
|
|
29 |
function __construct() {
|
30 |
$this->stcr = new wp_subscribe_reloaded();
|
31 |
-
$this->stcr->
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
* This will trigger the activate function located on utils/stcr_manage.php
|
|
|
36 |
* @since 150720
|
37 |
*/
|
38 |
static function activate() {
|
@@ -40,8 +54,10 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_subscribe_reloaded'))
|
|
40 |
$_stcra = new stcr_manage();
|
41 |
$_stcra->activate();
|
42 |
}
|
|
|
43 |
/**
|
44 |
-
* This will trigger the
|
|
|
45 |
* @since 150720
|
46 |
*/
|
47 |
static function deactivate() {
|
@@ -49,14 +65,18 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_subscribe_reloaded'))
|
|
49 |
$_stcrd = new stcr_manage();
|
50 |
$_stcrd->deactivate();
|
51 |
}
|
|
|
52 |
}
|
53 |
-
|
54 |
-
//
|
55 |
register_activation_hook( __FILE__, array( \stcr\stcr_subscribe_reloaded::CLASSNAME , 'activate' ) );
|
|
|
|
|
56 |
register_deactivation_hook( __FILE__, array( \stcr\stcr_subscribe_reloaded::CLASSNAME , 'deactivate' ) );
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
$GLOBALS['wp_subscribe_reloaded'] = new stcr_subscribe_reloaded();
|
61 |
-
|
|
|
62 |
}
|
2 |
/**
|
3 |
* Plugin Name: Subscribe to Comments Reloaded
|
4 |
* Description: Subscribe to Comments Reloaded is a robust plugin that enables commenters to sign up for e-mail notifications. It includes a full-featured subscription manager that your commenters can use to unsubscribe to certain posts or suspend all notifications.
|
5 |
+
* Version: 191009
|
6 |
* Author: WPKube
|
7 |
* Author URI: http://wpkube.com/
|
8 |
* License: GPL-2.0+
|
12 |
*/
|
13 |
|
14 |
namespace stcr;
|
15 |
+
|
16 |
+
// avoid direct access to this piece of code
|
17 |
if ( ! function_exists( 'add_action' ) ) {
|
18 |
header( 'Location: /' );
|
19 |
exit;
|
20 |
}
|
21 |
+
|
22 |
+
require_once dirname(__FILE__) . '/wp_subscribe_reloaded.php';
|
23 |
+
|
24 |
+
if( ! class_exists( '\\'.__NAMESPACE__.'\\stcr_subscribe_reloaded' ) ) {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Main plugin class
|
28 |
+
*
|
29 |
+
* @since 150720
|
30 |
+
*/
|
31 |
class stcr_subscribe_reloaded {
|
32 |
+
|
33 |
+
const CLASSNAME = __CLASS__; // http://www.garfieldtech.com/blog/class-constants-php54
|
34 |
|
35 |
public $stcr = null;
|
36 |
|
37 |
+
/**
|
38 |
+
* Constructor
|
39 |
+
*
|
40 |
+
* @since 150720
|
41 |
+
*/
|
42 |
function __construct() {
|
43 |
$this->stcr = new wp_subscribe_reloaded();
|
44 |
+
$this->stcr->set_user_cookie();
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
* This will trigger the activate function located on utils/stcr_manage.php
|
49 |
+
*
|
50 |
* @since 150720
|
51 |
*/
|
52 |
static function activate() {
|
54 |
$_stcra = new stcr_manage();
|
55 |
$_stcra->activate();
|
56 |
}
|
57 |
+
|
58 |
/**
|
59 |
+
* This will trigger the deactivate function located on utils/stcr_manage.php
|
60 |
+
*
|
61 |
* @since 150720
|
62 |
*/
|
63 |
static function deactivate() {
|
65 |
$_stcrd = new stcr_manage();
|
66 |
$_stcrd->deactivate();
|
67 |
}
|
68 |
+
|
69 |
}
|
70 |
+
|
71 |
+
// plugin activation
|
72 |
register_activation_hook( __FILE__, array( \stcr\stcr_subscribe_reloaded::CLASSNAME , 'activate' ) );
|
73 |
+
|
74 |
+
// plugin deactivation
|
75 |
register_deactivation_hook( __FILE__, array( \stcr\stcr_subscribe_reloaded::CLASSNAME , 'deactivate' ) );
|
76 |
|
77 |
+
// instantiate stcr_subscribe_reloaded class
|
78 |
+
if ( ! isset( $GLOBALS['wp_subscribe_reloaded'] ) ) {
|
79 |
+
$GLOBALS['wp_subscribe_reloaded'] = new stcr_subscribe_reloaded();
|
80 |
+
}
|
81 |
+
|
82 |
}
|
templates/confirm.php
CHANGED
@@ -1,32 +1,39 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
if ( ! function_exists( 'add_action' ) ) {
|
4 |
header( 'Location: /' );
|
5 |
exit;
|
6 |
}
|
7 |
|
|
|
8 |
global $wp_subscribe_reloaded;
|
9 |
-
$post_permalink = null;
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
{
|
15 |
$post_permalink = $_GET['post_permalink'];
|
16 |
}
|
17 |
}
|
18 |
|
|
|
19 |
$wp_subscribe_reloaded->stcr->update_subscription_status( $post_ID, $email, '-C' );
|
|
|
|
|
20 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed' ) ), ENT_COMPAT, 'UTF-8' );
|
|
|
|
|
21 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
22 |
$message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
|
23 |
}
|
24 |
|
25 |
-
|
26 |
-
{
|
27 |
$message .= '<p id="subscribe-reloaded-update-p">
|
28 |
<a style="margin-right: 10px; text-decoration: none; box-shadow: unset;" href="'. esc_url( $post_permalink ) .'"><i class="fa fa-arrow-circle-left fa-2x" aria-hidden="true" style="vertical-align: middle;"></i> '. __('Return to Post','subscribe-to-comments-reloaded').'</a>
|
29 |
</p>';
|
30 |
}
|
31 |
|
32 |
-
|
|
1 |
<?php
|
2 |
+
|
3 |
+
// avoid direct access to this piece of code
|
4 |
if ( ! function_exists( 'add_action' ) ) {
|
5 |
header( 'Location: /' );
|
6 |
exit;
|
7 |
}
|
8 |
|
9 |
+
// get the instance of stcr_subscribe_reloaded class
|
10 |
global $wp_subscribe_reloaded;
|
|
|
11 |
|
12 |
+
// get post permalink
|
13 |
+
$post_permalink = null;
|
14 |
+
if (array_key_exists('post_permalink', $_GET)) {
|
15 |
+
if ( ! empty( $_GET['post_permalink'] ) ) {
|
16 |
$post_permalink = $_GET['post_permalink'];
|
17 |
}
|
18 |
}
|
19 |
|
20 |
+
// update status of subscription to confirmed
|
21 |
$wp_subscribe_reloaded->stcr->update_subscription_status( $post_ID, $email, '-C' );
|
22 |
+
|
23 |
+
// get confirmed message
|
24 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed' ) ), ENT_COMPAT, 'UTF-8' );
|
25 |
+
|
26 |
+
// qTranslate compatibility
|
27 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
28 |
$message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
|
29 |
}
|
30 |
|
31 |
+
// append post link to message
|
32 |
+
if ( isset( $post_permalink ) ) {
|
33 |
$message .= '<p id="subscribe-reloaded-update-p">
|
34 |
<a style="margin-right: 10px; text-decoration: none; box-shadow: unset;" href="'. esc_url( $post_permalink ) .'"><i class="fa fa-arrow-circle-left fa-2x" aria-hidden="true" style="vertical-align: middle;"></i> '. __('Return to Post','subscribe-to-comments-reloaded').'</a>
|
35 |
</p>';
|
36 |
}
|
37 |
|
38 |
+
// pass it back
|
39 |
+
return '<div>' . $message . '</div>';
|
templates/key_expired.php
CHANGED
@@ -70,8 +70,8 @@ else
|
|
70 |
?>" name="sub-form" method="post">
|
71 |
<fieldset style="border:0">
|
72 |
<p><label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
|
73 |
-
<input id='subscribe_reloaded_email' type="text" class="subscribe-form-field" name="sre" value="<?php echo isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ? $_COOKIE['comment_author_email_' . COOKIEHASH] : 'email'; ?>" size="22" onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue" />
|
74 |
-
<input name="submit" type="submit" class="subscribe-form-button" value="<?php
|
75 |
</p>
|
76 |
</fieldset>
|
77 |
</form>
|
70 |
?>" name="sub-form" method="post">
|
71 |
<fieldset style="border:0">
|
72 |
<p><label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
|
73 |
+
<input id='subscribe_reloaded_email' type="text" class="subscribe-form-field" name="sre" value="<?php echo isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ? esc_attr( $_COOKIE['comment_author_email_' . COOKIEHASH] ) : 'email'; ?>" size="22" onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue" />
|
74 |
+
<input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
|
75 |
</p>
|
76 |
</fieldset>
|
77 |
</form>
|
templates/one-click-unsubscribe.php
CHANGED
@@ -16,7 +16,7 @@ ob_start();
|
|
16 |
if ( is_object( $post ) ) {
|
17 |
|
18 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_oneclick_text' ) ), ENT_QUOTES, 'UTF-8' );
|
19 |
-
$message = str_replace( '[post_title]', $post
|
20 |
$message = str_replace( '[blog_name]' , get_bloginfo('name'), $message );
|
21 |
|
22 |
$rows_affected = $wp_subscribe_reloaded->stcr->delete_subscriptions( $post_ID, $email );
|
16 |
if ( is_object( $post ) ) {
|
17 |
|
18 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_oneclick_text' ) ), ENT_QUOTES, 'UTF-8' );
|
19 |
+
$message = str_replace( '[post_title]', get_the_title($post), $message );
|
20 |
$message = str_replace( '[blog_name]' , get_bloginfo('name'), $message );
|
21 |
|
22 |
$rows_affected = $wp_subscribe_reloaded->stcr->delete_subscriptions( $post_ID, $email );
|
templates/request-management-link.php
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
<?php
|
|
|
2 |
// Avoid direct access to this piece of code
|
3 |
if ( ! function_exists( 'add_action' ) ) {
|
4 |
header( 'Location: /' );
|
5 |
exit;
|
6 |
}
|
|
|
7 |
global $wp_subscribe_reloaded;
|
8 |
|
9 |
// The the page where the user is coming from
|
@@ -12,32 +14,32 @@ $current_user_email = null; // Comes from wp_subscribe-to-comments-reloaded\subs
|
|
12 |
$ID = $target_post;
|
13 |
$valid_email = true;
|
14 |
|
15 |
-
|
16 |
-
{
|
17 |
$current_user_email = $current_user->data->user_email;
|
18 |
}
|
19 |
|
20 |
-
|
21 |
-
{
|
22 |
-
if ( ! empty( $_GET['post_permalink'] ) )
|
23 |
-
{
|
24 |
$post_permalink = $_GET['post_permalink'];
|
25 |
}
|
26 |
}
|
27 |
|
28 |
-
|
29 |
ob_start();
|
30 |
|
|
|
31 |
if ( ! empty( $email ) ) {
|
32 |
|
33 |
$stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
|
34 |
|
35 |
-
if ( $stcr_post_email === false )
|
36 |
-
|
37 |
$valid_email = false;
|
38 |
-
|
39 |
-
else
|
40 |
-
|
41 |
// Send management link
|
42 |
$subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]' ) ), ENT_QUOTES, 'UTF-8' );
|
43 |
$page_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_content', '' ) ), ENT_QUOTES, 'UTF-8' );
|
@@ -59,10 +61,8 @@ if ( ! empty( $email ) ) {
|
|
59 |
. "&srk=$subscriber_salt" . "&sra=u;srsrc=e" . "&srp=";
|
60 |
|
61 |
// Replace tags with their actual values
|
62 |
-
$subject
|
63 |
-
|
64 |
-
$page_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $page_message );
|
65 |
-
// Setup the email message
|
66 |
$email_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $email_message );
|
67 |
$email_message = str_replace( '[manager_link]', $manager_link, $email_message );
|
68 |
$email_message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $email_message );
|
@@ -74,38 +74,40 @@ if ( ! empty( $email ) ) {
|
|
74 |
$page_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $page_message );
|
75 |
$email_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $email_message );
|
76 |
}
|
|
|
77 |
// Prepare email settings
|
78 |
$email_settings = array(
|
79 |
'subject' => $subject,
|
80 |
'message' => $email_message,
|
81 |
'toEmail' => $clean_email
|
82 |
);
|
|
|
83 |
$wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
|
84 |
|
85 |
echo wpautop( $page_message );
|
|
|
86 |
}
|
87 |
-
|
88 |
-
|
89 |
-
{
|
|
|
90 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
|
|
|
|
|
91 |
$email = '';
|
92 |
-
|
93 |
-
if ( isset($current_user_email) )
|
94 |
-
{
|
95 |
$email = $current_user_email;
|
96 |
-
}
|
97 |
-
else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ))
|
98 |
-
{
|
99 |
$email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
|
100 |
-
}
|
101 |
-
else
|
102 |
-
{
|
103 |
$email = 'email';
|
104 |
}
|
105 |
|
|
|
106 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
107 |
$message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
|
108 |
}
|
|
|
109 |
?>
|
110 |
<p><?php echo wpautop( $message ); ?></p>
|
111 |
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
|
@@ -119,24 +121,29 @@ else
|
|
119 |
</form>
|
120 |
<?php
|
121 |
|
122 |
-
if ( isset( $post_permalink ) )
|
123 |
-
{
|
124 |
echo '<p id="subscribe-reloaded-update-p">
|
125 |
<a style="margin-right: 10px; text-decoration: none; box-shadow: unset;" href="'. esc_url( $post_permalink ) .'"><i class="fa fa-arrow-circle-left fa-2x" aria-hidden="true" style="vertical-align: middle;"></i> '. __('Return to Post','subscribe-to-comments-reloaded').'</a>
|
126 |
</p>';
|
127 |
}
|
128 |
|
129 |
}
|
130 |
-
|
131 |
-
|
|
|
|
|
132 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
|
|
|
133 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
134 |
$message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
|
135 |
}
|
136 |
-
|
|
|
|
|
137 |
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
|
138 |
<fieldset style="border:0">
|
139 |
-
<p
|
|
|
140 |
<input id='subscribe_reloaded_email' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" />
|
141 |
<input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
|
142 |
</p>
|
@@ -145,6 +152,8 @@ if( ! $valid_email )
|
|
145 |
</form>
|
146 |
<?php
|
147 |
}
|
|
|
|
|
148 |
?>
|
149 |
<script type="text/javascript">
|
150 |
( function($){
|
@@ -189,8 +198,8 @@ if( ! $valid_email )
|
|
189 |
} )( jQuery );
|
190 |
</script>
|
191 |
<?php
|
|
|
192 |
$output = ob_get_contents();
|
193 |
ob_end_clean();
|
194 |
-
|
195 |
return $output;
|
196 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
// Avoid direct access to this piece of code
|
4 |
if ( ! function_exists( 'add_action' ) ) {
|
5 |
header( 'Location: /' );
|
6 |
exit;
|
7 |
}
|
8 |
+
|
9 |
global $wp_subscribe_reloaded;
|
10 |
|
11 |
// The the page where the user is coming from
|
14 |
$ID = $target_post;
|
15 |
$valid_email = true;
|
16 |
|
17 |
+
// get email if user known
|
18 |
+
if ( isset( $current_user ) && $current_user->ID > 0 ) {
|
19 |
$current_user_email = $current_user->data->user_email;
|
20 |
}
|
21 |
|
22 |
+
// post permalink supplied with $_GET
|
23 |
+
if ( array_key_exists('post_permalink', $_GET ) ) {
|
24 |
+
if ( ! empty( $_GET['post_permalink'] ) ) {
|
|
|
25 |
$post_permalink = $_GET['post_permalink'];
|
26 |
}
|
27 |
}
|
28 |
|
29 |
+
// start output buffering
|
30 |
ob_start();
|
31 |
|
32 |
+
// email address not supplied
|
33 |
if ( ! empty( $email ) ) {
|
34 |
|
35 |
$stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
|
36 |
|
37 |
+
if ( $stcr_post_email === false ) {
|
38 |
+
|
39 |
$valid_email = false;
|
40 |
+
|
41 |
+
} else {
|
42 |
+
|
43 |
// Send management link
|
44 |
$subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]' ) ), ENT_QUOTES, 'UTF-8' );
|
45 |
$page_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_content', '' ) ), ENT_QUOTES, 'UTF-8' );
|
61 |
. "&srk=$subscriber_salt" . "&sra=u;srsrc=e" . "&srp=";
|
62 |
|
63 |
// Replace tags with their actual values
|
64 |
+
$subject = str_replace( '[blog_name]', get_bloginfo( 'name' ), $subject );
|
65 |
+
$page_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $page_message );
|
|
|
|
|
66 |
$email_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $email_message );
|
67 |
$email_message = str_replace( '[manager_link]', $manager_link, $email_message );
|
68 |
$email_message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $email_message );
|
74 |
$page_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $page_message );
|
75 |
$email_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $email_message );
|
76 |
}
|
77 |
+
|
78 |
// Prepare email settings
|
79 |
$email_settings = array(
|
80 |
'subject' => $subject,
|
81 |
'message' => $email_message,
|
82 |
'toEmail' => $clean_email
|
83 |
);
|
84 |
+
|
85 |
$wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
|
86 |
|
87 |
echo wpautop( $page_message );
|
88 |
+
|
89 |
}
|
90 |
+
|
91 |
+
// email address supplied
|
92 |
+
} else {
|
93 |
+
|
94 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
|
95 |
+
|
96 |
+
// get email address
|
97 |
$email = '';
|
98 |
+
if ( isset($current_user_email) ) {
|
|
|
|
|
99 |
$email = $current_user_email;
|
100 |
+
} else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] )) {
|
|
|
|
|
101 |
$email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
|
102 |
+
} else {
|
|
|
|
|
103 |
$email = 'email';
|
104 |
}
|
105 |
|
106 |
+
// qTrans compatibility
|
107 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
108 |
$message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
|
109 |
}
|
110 |
+
|
111 |
?>
|
112 |
<p><?php echo wpautop( $message ); ?></p>
|
113 |
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
|
121 |
</form>
|
122 |
<?php
|
123 |
|
124 |
+
if ( isset( $post_permalink ) ) {
|
|
|
125 |
echo '<p id="subscribe-reloaded-update-p">
|
126 |
<a style="margin-right: 10px; text-decoration: none; box-shadow: unset;" href="'. esc_url( $post_permalink ) .'"><i class="fa fa-arrow-circle-left fa-2x" aria-hidden="true" style="vertical-align: middle;"></i> '. __('Return to Post','subscribe-to-comments-reloaded').'</a>
|
127 |
</p>';
|
128 |
}
|
129 |
|
130 |
}
|
131 |
+
|
132 |
+
// email invalid
|
133 |
+
if( ! $valid_email ) {
|
134 |
+
|
135 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
|
136 |
+
|
137 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
138 |
$message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
|
139 |
}
|
140 |
+
|
141 |
+
?>
|
142 |
+
<p><?php echo wpautop( $message ); ?></p>
|
143 |
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
|
144 |
<fieldset style="border:0">
|
145 |
+
<p>
|
146 |
+
<label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
|
147 |
<input id='subscribe_reloaded_email' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" />
|
148 |
<input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
|
149 |
</p>
|
152 |
</form>
|
153 |
<?php
|
154 |
}
|
155 |
+
|
156 |
+
// output script
|
157 |
?>
|
158 |
<script type="text/javascript">
|
159 |
( function($){
|
198 |
} )( jQuery );
|
199 |
</script>
|
200 |
<?php
|
201 |
+
// stop output buffer and pass it back
|
202 |
$output = ob_get_contents();
|
203 |
ob_end_clean();
|
|
|
204 |
return $output;
|
205 |
?>
|
templates/subscribe.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
// Avoid direct access to this piece of code
|
3 |
if ( ! function_exists( 'add_action' ) ) {
|
4 |
header( 'Location: /' );
|
@@ -10,25 +11,34 @@ global $wp_subscribe_reloaded;
|
|
10 |
$current_user_email = null; // Comes from wp_subscribe-to-comments-reloaded\subscribe_reloaded_manage()
|
11 |
$valid_email = true;
|
12 |
|
13 |
-
|
14 |
-
{
|
15 |
$current_user_email = $current_user->data->user_email;
|
16 |
}
|
17 |
|
18 |
-
|
19 |
$post_permalink = get_permalink( $post_ID );
|
20 |
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
$valid_email = false;
|
27 |
-
|
28 |
-
|
29 |
-
{
|
|
|
30 |
// Use Akismet, if available, to check this user is legit
|
31 |
if ( function_exists( 'akismet_http_post' ) ) {
|
|
|
32 |
global $akismet_api_host, $akismet_api_port;
|
33 |
|
34 |
$akismet_query_string = "user_ip={$_SERVER['REMOTE_ADDR']}";
|
@@ -44,41 +54,46 @@ if ( ! empty( $email ) ) {
|
|
44 |
// If this is considered SPAM, we stop here
|
45 |
if ( $akismet_response[1] == 'true' ) {
|
46 |
ob_end_clean();
|
47 |
-
|
48 |
return '';
|
49 |
}
|
|
|
50 |
}
|
51 |
|
|
|
52 |
$clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
|
53 |
|
54 |
-
//
|
55 |
-
if ( get_option( 'subscribe_reloaded_enable_admin_messages' ) == 'yes' )
|
56 |
-
|
57 |
$from_name = stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) );
|
58 |
$from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
|
59 |
|
60 |
$subject = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title";
|
61 |
$message = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title\n" . __( 'User:', 'subscribe-to-comments-reloaded' ) . " $clean_email";
|
62 |
-
|
63 |
$email_settings = array(
|
64 |
'subject' => $subject,
|
65 |
'message' => $message,
|
66 |
'toEmail' => get_bloginfo( 'admin_email' )
|
67 |
);
|
|
|
68 |
$wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
|
|
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
-
{
|
73 |
$wp_subscribe_reloaded->stcr->add_subscription( $post_ID, $clean_email, 'YC' );
|
74 |
$wp_subscribe_reloaded->stcr->confirmation_email( $post_ID, $clean_email );
|
75 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed_dci' ) ), ENT_QUOTES, 'UTF-8' );
|
76 |
-
|
77 |
-
|
|
|
78 |
$this->add_subscription( $post_ID, $clean_email, 'Y' );
|
79 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed' ) ), ENT_QUOTES, 'UTF-8' );
|
80 |
}
|
81 |
|
|
|
82 |
$message = str_replace( '[post_permalink]', $post_permalink, $message );
|
83 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
84 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
|
@@ -86,24 +101,24 @@ if ( ! empty( $email ) ) {
|
|
86 |
} else {
|
87 |
$message = str_replace( '[post_title]', $target_post->post_title, $message );
|
88 |
}
|
89 |
-
|
|
|
|
|
90 |
}
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
95 |
$email = $current_user_email;
|
96 |
-
}
|
97 |
-
else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ))
|
98 |
-
{
|
99 |
$email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
|
100 |
-
}
|
101 |
-
else
|
102 |
-
{
|
103 |
$email = 'email';
|
104 |
}
|
105 |
|
106 |
-
|
107 |
$message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
|
108 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
109 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
|
@@ -111,25 +126,28 @@ else {
|
|
111 |
} else {
|
112 |
$message = str_replace( '[post_title]', $target_post->post_title, $message );
|
113 |
}
|
114 |
-
echo $message;
|
115 |
-
|
|
|
116 |
?>
|
117 |
-
<form action="<?php
|
118 |
-
echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>"
|
119 |
-
method="post" name="sub-form">
|
120 |
<fieldset style="border:0">
|
121 |
-
<
|
|
|
122 |
<input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" />
|
123 |
-
<input name="submit" type="submit" class="subscribe-form-button" value="<?php
|
124 |
-
|
125 |
-
</
|
126 |
</fieldset>
|
127 |
</form>
|
128 |
<?php
|
|
|
129 |
}
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
133 |
$message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
|
134 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
135 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
|
@@ -137,66 +155,60 @@ if( ! $valid_email )
|
|
137 |
} else {
|
138 |
$message = str_replace( '[post_title]', esc_html( $target_post->post_title ), $message );
|
139 |
}
|
140 |
-
echo $message;
|
141 |
|
142 |
-
echo "</p>";
|
143 |
?>
|
144 |
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
|
145 |
<fieldset style="border:0">
|
146 |
<p><label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
|
147 |
<input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue" />
|
148 |
-
<input name="submit" type="submit" class="subscribe-form-button" value="<?php
|
149 |
</p>
|
150 |
<p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Email address is not valid", 'subscribe-to-comments-reloaded') ?></p>
|
151 |
</fieldset>
|
152 |
</form>
|
153 |
<?php
|
|
|
154 |
}
|
|
|
155 |
?>
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
}
|
187 |
-
});
|
188 |
-
|
189 |
-
email_input.blur(function(){
|
190 |
-
if( $(this).val() == "" )
|
191 |
-
{
|
192 |
-
$(this).val(<?php echo wp_json_encode( $email ); ?>);
|
193 |
-
}
|
194 |
-
});
|
195 |
});
|
196 |
-
}
|
197 |
-
|
|
|
198 |
|
199 |
<?php
|
|
|
200 |
$output = ob_get_contents();
|
201 |
ob_end_clean();
|
202 |
return $output;
|
1 |
<?php
|
2 |
+
|
3 |
// Avoid direct access to this piece of code
|
4 |
if ( ! function_exists( 'add_action' ) ) {
|
5 |
header( 'Location: /' );
|
11 |
$current_user_email = null; // Comes from wp_subscribe-to-comments-reloaded\subscribe_reloaded_manage()
|
12 |
$valid_email = true;
|
13 |
|
14 |
+
// get user email
|
15 |
+
if ( isset($current_user) && $current_user->ID > 0 ) {
|
16 |
$current_user_email = $current_user->data->user_email;
|
17 |
}
|
18 |
|
19 |
+
// get post permalink
|
20 |
$post_permalink = get_permalink( $post_ID );
|
21 |
|
22 |
+
// start output buffer
|
23 |
+
ob_start();
|
24 |
|
25 |
+
// email address supplied
|
26 |
+
if ( ! empty( $email ) ) {
|
27 |
+
|
28 |
+
// check email validity
|
29 |
+
$stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
|
30 |
+
|
31 |
+
// email is invalid
|
32 |
+
if ( $stcr_post_email === false ) {
|
33 |
+
|
34 |
$valid_email = false;
|
35 |
+
|
36 |
+
// email is valid
|
37 |
+
} else {
|
38 |
+
|
39 |
// Use Akismet, if available, to check this user is legit
|
40 |
if ( function_exists( 'akismet_http_post' ) ) {
|
41 |
+
|
42 |
global $akismet_api_host, $akismet_api_port;
|
43 |
|
44 |
$akismet_query_string = "user_ip={$_SERVER['REMOTE_ADDR']}";
|
54 |
// If this is considered SPAM, we stop here
|
55 |
if ( $akismet_response[1] == 'true' ) {
|
56 |
ob_end_clean();
|
|
|
57 |
return '';
|
58 |
}
|
59 |
+
|
60 |
}
|
61 |
|
62 |
+
// sanitize email address
|
63 |
$clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
|
64 |
|
65 |
+
// notify the administrator about the new subscription
|
66 |
+
if ( get_option( 'subscribe_reloaded_enable_admin_messages' ) == 'yes' ) {
|
67 |
+
|
68 |
$from_name = stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) );
|
69 |
$from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
|
70 |
|
71 |
$subject = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title";
|
72 |
$message = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title\n" . __( 'User:', 'subscribe-to-comments-reloaded' ) . " $clean_email";
|
73 |
+
|
74 |
$email_settings = array(
|
75 |
'subject' => $subject,
|
76 |
'message' => $message,
|
77 |
'toEmail' => get_bloginfo( 'admin_email' )
|
78 |
);
|
79 |
+
|
80 |
$wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
|
81 |
+
|
82 |
}
|
83 |
+
|
84 |
+
// double check, send confirmation email
|
85 |
+
if ( get_option( 'subscribe_reloaded_enable_double_check' ) == 'yes' && ! $wp_subscribe_reloaded->stcr->is_user_subscribed( $post_ID, $clean_email, 'C' ) ) {
|
86 |
$wp_subscribe_reloaded->stcr->add_subscription( $post_ID, $clean_email, 'YC' );
|
87 |
$wp_subscribe_reloaded->stcr->confirmation_email( $post_ID, $clean_email );
|
88 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed_dci' ) ), ENT_QUOTES, 'UTF-8' );
|
89 |
+
|
90 |
+
// not double check, add subscription
|
91 |
+
} else {
|
92 |
$this->add_subscription( $post_ID, $clean_email, 'Y' );
|
93 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed' ) ), ENT_QUOTES, 'UTF-8' );
|
94 |
}
|
95 |
|
96 |
+
// new subscription message
|
97 |
$message = str_replace( '[post_permalink]', $post_permalink, $message );
|
98 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
99 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
|
101 |
} else {
|
102 |
$message = str_replace( '[post_title]', $target_post->post_title, $message );
|
103 |
}
|
104 |
+
|
105 |
+
echo wpautop( $message );
|
106 |
+
|
107 |
}
|
108 |
+
|
109 |
+
// no email address supplied
|
110 |
+
} else {
|
111 |
+
|
112 |
+
// email value for input field
|
113 |
+
if ( isset( $current_user_email ) ) {
|
114 |
$email = $current_user_email;
|
115 |
+
} else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] )) {
|
|
|
|
|
116 |
$email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
|
117 |
+
} else {
|
|
|
|
|
118 |
$email = 'email';
|
119 |
}
|
120 |
|
121 |
+
// output message for subscribing without commenting
|
122 |
$message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
|
123 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
124 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
|
126 |
} else {
|
127 |
$message = str_replace( '[post_title]', $target_post->post_title, $message );
|
128 |
}
|
129 |
+
echo '<p>' . $message . '</p>';
|
130 |
+
|
131 |
+
// output the form
|
132 |
?>
|
133 |
+
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]); ?>" method="post" name="sub-form">
|
|
|
|
|
134 |
<fieldset style="border:0">
|
135 |
+
<div>
|
136 |
+
<label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
|
137 |
<input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" />
|
138 |
+
<input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
|
139 |
+
<p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
|
140 |
+
</div>
|
141 |
</fieldset>
|
142 |
</form>
|
143 |
<?php
|
144 |
+
|
145 |
}
|
146 |
+
|
147 |
+
// invalid email
|
148 |
+
if ( ! $valid_email ) {
|
149 |
+
|
150 |
+
// message for subscribing without commenting
|
151 |
$message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
|
152 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
153 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
|
155 |
} else {
|
156 |
$message = str_replace( '[post_title]', esc_html( $target_post->post_title ), $message );
|
157 |
}
|
158 |
+
echo '<p>' . $message . '</p>';
|
159 |
|
|
|
160 |
?>
|
161 |
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
|
162 |
<fieldset style="border:0">
|
163 |
<p><label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
|
164 |
<input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue" />
|
165 |
+
<input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
|
166 |
</p>
|
167 |
<p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Email address is not valid", 'subscribe-to-comments-reloaded') ?></p>
|
168 |
</fieldset>
|
169 |
</form>
|
170 |
<?php
|
171 |
+
|
172 |
}
|
173 |
+
|
174 |
?>
|
175 |
+
<script type="text/javascript">
|
176 |
+
( function($){
|
177 |
+
$(document).ready(function($){
|
178 |
+
|
179 |
+
var stcr_request_form = $('form[name="sub-form"]');
|
180 |
+
var email_input = $('form[name="sub-form"] input[name="sre"]');
|
181 |
+
|
182 |
+
stcr_request_form.on('submit',function (event) {
|
183 |
+
var emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
184 |
+
var email = $('input[name="sre"]');
|
185 |
+
|
186 |
+
if( email.val() !== "email" && email.val() === "" ) {
|
187 |
+
event.preventDefault();
|
188 |
+
$(".notice-email-error").html("<i class=\"fa fa-exclamation-triangle\"></i> <?php _e("Please enter your email", 'subscribe-to-comments-reloaded') ?>").show().delay(4000).fadeOut(1000);
|
189 |
+
} else if( emailRegex.test( email.val() ) === false ) {
|
190 |
+
event.preventDefault();
|
191 |
+
$(".notice-email-error").html("<i class=\"fa fa-exclamation-triangle\"></i> <?php _e("Email address is not valid", 'subscribe-to-comments-reloaded') ?>").show().delay(4000).fadeOut(1000);
|
192 |
+
}
|
193 |
+
});
|
194 |
+
|
195 |
+
email_input.focus(function(){
|
196 |
+
if( $(this).val() == <?php echo wp_json_encode( $email ); ?> ) {
|
197 |
+
$(this).val("");
|
198 |
+
}
|
199 |
+
});
|
200 |
+
|
201 |
+
email_input.blur(function(){
|
202 |
+
if( $(this).val() == "" ) {
|
203 |
+
$(this).val(<?php echo wp_json_encode( $email ); ?>);
|
204 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
});
|
206 |
+
});
|
207 |
+
} )( jQuery );
|
208 |
+
</script>
|
209 |
|
210 |
<?php
|
211 |
+
// stop output buffer and pass it back
|
212 |
$output = ob_get_contents();
|
213 |
ob_end_clean();
|
214 |
return $output;
|
uninstall.php
CHANGED
@@ -1,51 +1,60 @@
|
|
1 |
<?php
|
|
|
2 |
namespace stcr;
|
|
|
3 |
// Avoid misusage
|
4 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
5 |
exit;
|
6 |
}
|
7 |
|
|
|
8 |
global $wpdb;
|
9 |
-
|
10 |
-
$safeUnistall = get_option("subscribe_reloaded_safely_uninstall");
|
11 |
-
|
12 |
$stcr_options = stcr_get_settings($wpdb);
|
13 |
|
14 |
-
|
15 |
-
{
|
16 |
-
|
17 |
-
//
|
18 |
-
foreach($stcr_options as $option)
|
19 |
-
{
|
20 |
delete_option( $option->option_name );
|
21 |
}
|
22 |
-
|
23 |
-
|
24 |
-
{
|
25 |
-
|
|
|
26 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe_reloaded" ); // Compatibility with versions prior to 1.7
|
27 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe_reloaded_subscribers" ); // Compatibility with versions prior to 1.7
|
28 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
|
29 |
-
|
30 |
-
|
31 |
-
{
|
32 |
delete_option( $option->option_name );
|
33 |
}
|
|
|
34 |
}
|
35 |
|
36 |
-
//
|
37 |
wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
|
38 |
wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
);
|
47 |
|
|
|
48 |
return $stcr_options;
|
49 |
-
}
|
50 |
|
51 |
-
|
1 |
<?php
|
2 |
+
|
3 |
namespace stcr;
|
4 |
+
|
5 |
// Avoid misusage
|
6 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
+
// vars
|
11 |
global $wpdb;
|
12 |
+
$safeUnistall = get_option('subscribe_reloaded_safely_uninstall');
|
|
|
|
|
13 |
$stcr_options = stcr_get_settings($wpdb);
|
14 |
|
15 |
+
// only delete settings, keep the subscriptions
|
16 |
+
if ( $safeUnistall === 'yes' ) {
|
17 |
+
|
18 |
+
// delete settings
|
19 |
+
foreach( $stcr_options as $option ) {
|
|
|
20 |
delete_option( $option->option_name );
|
21 |
}
|
22 |
+
|
23 |
+
// delete settings and subscriptions
|
24 |
+
} else if ( $safeUnistall === 'no' ) {
|
25 |
+
|
26 |
+
// delete subscriptions
|
27 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe_reloaded" ); // Compatibility with versions prior to 1.7
|
28 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe_reloaded_subscribers" ); // Compatibility with versions prior to 1.7
|
29 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
|
30 |
+
|
31 |
+
// delete settings
|
32 |
+
foreach($stcr_options as $option) {
|
33 |
delete_option( $option->option_name );
|
34 |
}
|
35 |
+
|
36 |
}
|
37 |
|
38 |
+
// remove scheduled autopurge events
|
39 |
wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
|
40 |
wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
|
41 |
|
42 |
+
/**
|
43 |
+
* Function to get all the settings info
|
44 |
+
*
|
45 |
+
* @since 190705 cleanup
|
46 |
+
*/
|
47 |
+
function stcr_get_settings($_wpdb) {
|
48 |
+
|
49 |
+
// get the options
|
50 |
+
$stcr_options = $_wpdb->get_results(
|
51 |
+
"SELECT * FROM $_wpdb->options
|
52 |
+
WHERE option_name
|
53 |
+
LIKE 'subscribe_reloaded\_%'
|
54 |
+
ORDER BY option_name", OBJECT
|
55 |
);
|
56 |
|
57 |
+
// pass back the data
|
58 |
return $stcr_options;
|
|
|
59 |
|
60 |
+
}
|
utils/stcr_manage.php
CHANGED
@@ -254,7 +254,10 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_manage') )
|
|
254 |
$this->upgrade->_import_wpcs_data();
|
255 |
|
256 |
// Import data from Subscribe to Comments & Co., if needed
|
257 |
-
|
|
|
|
|
|
|
258 |
|
259 |
// Import data from Comment Reply Notification, if needed
|
260 |
// Function deprecated and not in use anymore.
|
254 |
$this->upgrade->_import_wpcs_data();
|
255 |
|
256 |
// Import data from Subscribe to Comments & Co., if needed
|
257 |
+
$this->upgrade->_import_stc_data();
|
258 |
+
|
259 |
+
// Import data from Subscribe to Comments by Mark Jaquith
|
260 |
+
$this->upgrade->_import_stc_mj_data();
|
261 |
|
262 |
// Import data from Comment Reply Notification, if needed
|
263 |
// Function deprecated and not in use anymore.
|
utils/stcr_upgrade.php
CHANGED
@@ -152,11 +152,11 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_upgrade') ) {
|
|
152 |
* Imports subscription data created with the Subscribe to Comments plugin
|
153 |
*/
|
154 |
public function _import_stc_data() {
|
155 |
-
|
156 |
|
157 |
// Import the information collected by Subscribe to Comments, if needed
|
158 |
-
|
159 |
-
|
160 |
// Perform the import only if the target table does not contain any subscriptions
|
161 |
$count_postmeta_rows = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
|
162 |
|
@@ -181,7 +181,73 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_upgrade') ) {
|
|
181 |
);
|
182 |
}
|
183 |
}
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
/**
|
186 |
* Imports subscription data created with the Comment Reply Notification plugin. This function is deprecated is not in use anymore.
|
187 |
*
|
152 |
* Imports subscription data created with the Subscribe to Comments plugin
|
153 |
*/
|
154 |
public function _import_stc_data() {
|
155 |
+
global $wpdb;
|
156 |
|
157 |
// Import the information collected by Subscribe to Comments, if needed
|
158 |
+
$result = $wpdb->get_row( "DESC $wpdb->comments comment_subscribe", ARRAY_A );
|
159 |
+
|
160 |
// Perform the import only if the target table does not contain any subscriptions
|
161 |
$count_postmeta_rows = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
|
162 |
|
181 |
);
|
182 |
}
|
183 |
}
|
184 |
+
// end _import_stc_data
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Imports subscriptions from Subscribe to Comments by Mark Jaquith
|
188 |
+
*
|
189 |
+
* @since 190708
|
190 |
+
*/
|
191 |
+
public function _import_stc_mj_data() {
|
192 |
+
|
193 |
+
global $wpdb;
|
194 |
+
|
195 |
+
// check if we currently have subscriptions
|
196 |
+
$current_subscriptions_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
|
197 |
+
|
198 |
+
// if subscriptions exists, do not proceed
|
199 |
+
if ( $current_subscriptions_count > 0 ) return;
|
200 |
+
|
201 |
+
// will hold subscriptions
|
202 |
+
$subscriptions = array();
|
203 |
+
|
204 |
+
// data from the other plugin
|
205 |
+
$result = $wpdb->get_results( "SELECT * FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments'", ARRAY_A );
|
206 |
+
|
207 |
+
// no results, go back
|
208 |
+
if ( empty( $result ) ) return;
|
209 |
+
|
210 |
+
// add the subscriptions to an array
|
211 |
+
foreach ( $result as $subscription ) {
|
212 |
+
$subscriptions[] = array(
|
213 |
+
'post_id' => $subscription['post_id'],
|
214 |
+
'email' => $this->clean_email( $subscription['meta_value'] ),
|
215 |
+
);
|
216 |
+
}
|
217 |
+
|
218 |
+
// no subscriptions, go back
|
219 |
+
if ( empty( $subscriptions ) ) return;
|
220 |
+
|
221 |
+
// add the subscriptions to the DB
|
222 |
+
$dt = date_i18n( 'Y-m-d H:i:s' );
|
223 |
+
$status = 'Y';
|
224 |
+
foreach ( $subscriptions as $subscription ) {
|
225 |
+
$post_id = $subscription['post_id'];
|
226 |
+
$meta_key = '_stcr@_' . $subscription['email'];
|
227 |
+
$meta_value = $dt . '|' . $status;
|
228 |
+
$wpdb->query(
|
229 |
+
$wpdb->prepare(
|
230 |
+
"INSERT IGNORE INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ( %s, %s, %s )",
|
231 |
+
$post_id, $meta_key, $meta_value
|
232 |
+
)
|
233 |
+
);
|
234 |
+
$this->add_user_subscriber_table( $subscription['email'] );
|
235 |
+
}
|
236 |
+
|
237 |
+
// notify the admin about the import
|
238 |
+
$this->stcr_create_admin_notice(
|
239 |
+
'notify_import_stc_mj_data',
|
240 |
+
'unread',
|
241 |
+
'<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> Comment subscription data from the <strong>Subscribe to Comments</strong> plugin by Mark Jaquith was detected and automatically imported into <strong>Subscribe to Comments Reloaded</strong>.', 'subscribe-to-comments-reloaded' ) . ( is_plugin_active( 'subscribe-to-comments/subscribe-to-comments.php' ) ? __( ' It is recommended that you now <strong>deactivate</strong> Subscribe to Comments to prevent confusion between the two plugins.', 'subscribe-to-comments-reloaded' ) : '' ) . '</p>' .
|
242 |
+
'<p>' . __( 'If you have subscription data from Subscribe to Comments Reloaded < v2.0 that you want to import, you\'ll need to import that data manually, as only one import routine will ever run to prevent data loss.', 'subscribe-to-comments-reloaded' ) . '</p>' .
|
243 |
+
'<p>' . __( 'Please visit <a href="options-general.php?page=subscribe-to-comments-reloaded/options/index.php">Settings -> Subscribe to Comments</a> to review your configuration.'
|
244 |
+
. '<a class="dismiss" href="#">Dismiss. </a>'
|
245 |
+
. '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">', 'subscribe-to-comments-reloaded' ) . '</p>',
|
246 |
+
'updated'
|
247 |
+
);
|
248 |
+
|
249 |
+
}
|
250 |
+
|
251 |
/**
|
252 |
* Imports subscription data created with the Comment Reply Notification plugin. This function is deprecated is not in use anymore.
|
253 |
*
|
utils/stcr_utils.php
CHANGED
@@ -1,896 +1,917 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class with utility functions. This functions are all over the plugin.
|
4 |
-
* @author reedyseth
|
5 |
-
* @since 15-Jul-2015
|
6 |
-
* @version 160831
|
7 |
-
*/
|
8 |
-
namespace stcr;
|
9 |
-
// Avoid direct access to this piece of code
|
10 |
-
if ( ! function_exists( 'add_action' ) ) {
|
11 |
-
header( 'Location: /' );
|
12 |
-
exit;
|
13 |
-
}
|
14 |
-
|
15 |
-
if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
|
16 |
-
{
|
17 |
-
class stcr_utils {
|
18 |
-
|
19 |
-
protected $menu_opts_cache = array();
|
20 |
-
|
21 |
-
public function __construct()
|
22 |
-
{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
*
|
37 |
-
*
|
38 |
-
* @
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
*
|
51 |
-
*
|
52 |
-
* @
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
*
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
$
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
*
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
"
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
$
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
"
|
176 |
-
"
|
177 |
-
"
|
178 |
-
"
|
179 |
-
"
|
180 |
-
"
|
181 |
-
"
|
182 |
-
"
|
183 |
-
"
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
"
|
191 |
-
"
|
192 |
-
"
|
193 |
-
"
|
194 |
-
"
|
195 |
-
"
|
196 |
-
"
|
197 |
-
"
|
198 |
-
"
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
*
|
240 |
-
*
|
241 |
-
*
|
242 |
-
*
|
243 |
-
*
|
244 |
-
* @
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
$_message =
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
"/
|
305 |
-
"/
|
306 |
-
"/
|
307 |
-
"/
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
add_option( '
|
329 |
-
add_option( '
|
330 |
-
add_option( '
|
331 |
-
add_option( '
|
332 |
-
add_option( '
|
333 |
-
add_option( '
|
334 |
-
add_option( '
|
335 |
-
add_option( '
|
336 |
-
add_option( '
|
337 |
-
add_option( '
|
338 |
-
add_option( '
|
339 |
-
add_option( '
|
340 |
-
add_option( '
|
341 |
-
add_option( '
|
342 |
-
add_option( '
|
343 |
-
add_option( '
|
344 |
-
|
345 |
-
add_option( '
|
346 |
-
add_option( '
|
347 |
-
|
348 |
-
add_option( '
|
349 |
-
add_option( '
|
350 |
-
add_option( '
|
351 |
-
add_option( '
|
352 |
-
add_option( '
|
353 |
-
add_option( '
|
354 |
-
add_option( '
|
355 |
-
add_option( '
|
356 |
-
|
357 |
-
add_option( '
|
358 |
-
add_option( '
|
359 |
-
|
360 |
-
add_option( '
|
361 |
-
add_option( '
|
362 |
-
add_option( '
|
363 |
-
add_option( '
|
364 |
-
add_option( '
|
365 |
-
add_option( '
|
366 |
-
|
367 |
-
add_option( '
|
368 |
-
add_option( '
|
369 |
-
|
370 |
-
add_option( '
|
371 |
-
add_option( '
|
372 |
-
add_option( '
|
373 |
-
add_option( '
|
374 |
-
add_option( '
|
375 |
-
add_option( '
|
376 |
-
add_option( '
|
377 |
-
add_option( '
|
378 |
-
add_option( '
|
379 |
-
add_option( '
|
380 |
-
add_option( '
|
381 |
-
add_option( '
|
382 |
-
add_option( '
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
* @
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
*
|
428 |
-
*
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
*
|
440 |
-
*
|
441 |
-
* @
|
442 |
-
* @
|
443 |
-
*
|
444 |
-
* @param $
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
$
|
452 |
-
|
453 |
-
|
454 |
-
$this->stcr_logger(" [ERROR][
|
455 |
-
$this->stcr_logger(" [ERROR][
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
*
|
464 |
-
*
|
465 |
-
* @
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
$
|
473 |
-
|
474 |
-
$
|
475 |
-
|
476 |
-
|
477 |
-
$
|
478 |
-
|
479 |
-
$
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
'
|
484 |
-
'
|
485 |
-
'
|
486 |
-
'
|
487 |
-
'
|
488 |
-
'
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
$
|
495 |
-
|
496 |
-
|
497 |
-
$headers .= "
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
$this->stcr_logger( "
|
507 |
-
$this->stcr_logger( "\n\
|
508 |
-
$this->stcr_logger( "\n\
|
509 |
-
$this->stcr_logger( "
|
510 |
-
|
511 |
-
$
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
*
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
*
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
//
|
559 |
-
|
560 |
-
|
561 |
-
//
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
// enqueue
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
*
|
587 |
-
*
|
588 |
-
* @
|
589 |
-
* @
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
*
|
633 |
-
*
|
634 |
-
*
|
635 |
-
* @
|
636 |
-
* @
|
637 |
-
*
|
638 |
-
* @param string $
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
*
|
655 |
-
*
|
656 |
-
* @
|
657 |
-
* @
|
658 |
-
*
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
$
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
*
|
684 |
-
*
|
685 |
-
* @
|
686 |
-
* @
|
687 |
-
*
|
688 |
-
* @param string $
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
"
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
*
|
709 |
-
*
|
710 |
-
* @
|
711 |
-
* @
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
"
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
*
|
738 |
-
*
|
739 |
-
* @
|
740 |
-
* @
|
741 |
-
*
|
742 |
-
* @
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
*
|
792 |
-
*
|
793 |
-
* @
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
*
|
809 |
-
*
|
810 |
-
* @
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
*
|
827 |
-
*
|
828 |
-
* @
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
*
|
845 |
-
*
|
846 |
-
* @
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
*
|
863 |
-
*
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class with utility functions. This functions are all over the plugin.
|
4 |
+
* @author reedyseth
|
5 |
+
* @since 15-Jul-2015
|
6 |
+
* @version 160831
|
7 |
+
*/
|
8 |
+
namespace stcr;
|
9 |
+
// Avoid direct access to this piece of code
|
10 |
+
if ( ! function_exists( 'add_action' ) ) {
|
11 |
+
header( 'Location: /' );
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
|
16 |
+
{
|
17 |
+
class stcr_utils {
|
18 |
+
|
19 |
+
protected $menu_opts_cache = array();
|
20 |
+
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
if ($this->stcr_get_log_path() !== null)
|
24 |
+
{
|
25 |
+
set_error_handler( array( $this, 'exceptions_error_handler' ) );
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
public function __destruct()
|
30 |
+
{
|
31 |
+
// house keeping
|
32 |
+
unset($this->menu_opts_cache);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Check a given email to be valid.
|
37 |
+
*
|
38 |
+
* @since 15-Feb-2018
|
39 |
+
* @author Reedyseth
|
40 |
+
* @param $email
|
41 |
+
* @return mixed
|
42 |
+
*/
|
43 |
+
public function check_valid_email( $email )
|
44 |
+
{
|
45 |
+
$email = trim( $email );
|
46 |
+
$email = sanitize_email( $email );
|
47 |
+
return filter_var( $email, FILTER_VALIDATE_EMAIL );
|
48 |
+
}
|
49 |
+
/**
|
50 |
+
* Check for a valid number.
|
51 |
+
*
|
52 |
+
* @since 15-Feb-2018
|
53 |
+
* @author Reedyseth
|
54 |
+
* @param $number String|Integer to be validated
|
55 |
+
* @return bool True if number false otherwise
|
56 |
+
*/
|
57 |
+
public function check_valid_number( $number )
|
58 |
+
{
|
59 |
+
$valid = true;
|
60 |
+
|
61 |
+
if ( ! is_numeric( $number ) )
|
62 |
+
{
|
63 |
+
$valid = false;
|
64 |
+
}
|
65 |
+
|
66 |
+
return $valid;
|
67 |
+
}
|
68 |
+
|
69 |
+
/*
|
70 |
+
* This will retrieve an user/email from the prefix_subscribe_reloaded_subscribers table.
|
71 |
+
* @param String $email email to be added.
|
72 |
+
* @return Mix false|unique_key false on failure, key un success
|
73 |
+
* */
|
74 |
+
public function get_subscriber_key( $email = null) {
|
75 |
+
global $wpdb;
|
76 |
+
$subscriber = null;
|
77 |
+
// Check if the user is register and the unique key
|
78 |
+
$retrieveEmail = "SELECT salt, subscriber_unique_id FROM ".$wpdb->prefix."subscribe_reloaded_subscribers WHERE subscriber_email = %s";
|
79 |
+
if( $email != null ) {
|
80 |
+
$subscriber = $wpdb->get_row($wpdb->prepare($retrieveEmail,$email), OBJECT);
|
81 |
+
if( ! empty( $subscriber ) ) {
|
82 |
+
return sanitize_key( $subscriber->subscriber_unique_id );
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
/*
|
88 |
+
* This will add an user/email to the prefix_subscribe_reloaded_subscribers table.
|
89 |
+
* @param String $email email to be added.
|
90 |
+
* @return Boolean true|false true on success, false on failure
|
91 |
+
* */
|
92 |
+
public function remove_user_subscriber_table($_email) {
|
93 |
+
global $wpdb;
|
94 |
+
|
95 |
+
$OK = $wpdb->query(
|
96 |
+
"DELETE FROM ".$wpdb->prefix."subscribe_reloaded_subscribers WHERE subscriber_email = '$_email'"
|
97 |
+
);
|
98 |
+
return $OK === false || $OK == 0 || empty( $OK ) ? false : $OK;
|
99 |
+
}
|
100 |
+
|
101 |
+
/*
|
102 |
+
* This will add an user/email to the prefix_subscribe_reloaded_subscribers table.
|
103 |
+
* @param String $email email to be added.
|
104 |
+
* @return Boolean true|false true on success, false on failure
|
105 |
+
* */
|
106 |
+
public function add_user_subscriber_table($_email) {
|
107 |
+
global $wpdb;
|
108 |
+
$OK = false;
|
109 |
+
$checkEmailSql = "SELECT COUNT(subscriber_email) FROM " . $wpdb->prefix . "subscribe_reloaded_subscribers WHERE subscriber_email = %s";
|
110 |
+
$numSubscribers = $wpdb->get_var( $wpdb->prepare($checkEmailSql, $_email) );
|
111 |
+
// If subscribers not found then add it to the subscribers table.
|
112 |
+
if ( (int)$numSubscribers == 0 ) {
|
113 |
+
$salt = time();
|
114 |
+
// Insert query
|
115 |
+
$OK = $wpdb->insert(
|
116 |
+
$wpdb->prefix . "subscribe_reloaded_subscribers",
|
117 |
+
array(
|
118 |
+
"subscriber_email" => $_email,
|
119 |
+
"salt" => $salt,
|
120 |
+
"subscriber_unique_id" => $this->generate_temp_key( $salt . $_email )
|
121 |
+
),
|
122 |
+
array(
|
123 |
+
"%s",
|
124 |
+
"%d",
|
125 |
+
"%s"
|
126 |
+
)
|
127 |
+
);
|
128 |
+
}
|
129 |
+
return $OK === false || $OK == 0 || empty( $OK ) ? false : $OK;
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* @param null|key $key the Unique Key of the email
|
133 |
+
*
|
134 |
+
* @return bool|String false if no key is found or the email if found.
|
135 |
+
*/
|
136 |
+
public function get_subscriber_email_by_key( $key = null) {
|
137 |
+
global $wpdb;
|
138 |
+
|
139 |
+
if( $key != null ) {
|
140 |
+
// Sanitize the key just for precaution.
|
141 |
+
$key = trim( sanitize_key($key) );
|
142 |
+
// Check if the user is register and the unique key
|
143 |
+
$retrieveEmail = "SELECT subscriber_email FROM "
|
144 |
+
.$wpdb->prefix."subscribe_reloaded_subscribers WHERE subscriber_unique_id = %s";
|
145 |
+
|
146 |
+
$subscriber = $wpdb->get_row($wpdb->prepare($retrieveEmail,$key), OBJECT);
|
147 |
+
|
148 |
+
if( ! empty( $subscriber->subscriber_email ) ) {
|
149 |
+
return $subscriber->subscriber_email;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
return false;
|
153 |
+
}
|
154 |
+
/**
|
155 |
+
* Generate a unique key to allow users to manage their subscriptions
|
156 |
+
*/
|
157 |
+
public function generate_key( $_email = "" ) {
|
158 |
+
$salt = time();
|
159 |
+
$dd_salt = md5( $salt );
|
160 |
+
$uniqueKey = md5( $dd_salt . $salt . sanitize_email( $_email ) );
|
161 |
+
|
162 |
+
return $uniqueKey;
|
163 |
+
}
|
164 |
+
|
165 |
+
public function generate_temp_key( $_email ) {
|
166 |
+
$uniqueKey = sanitize_key( get_option( "subscribe_reloaded_unique_key" ) );
|
167 |
+
$key = md5( $uniqueKey . $_email );
|
168 |
+
|
169 |
+
return $key;
|
170 |
+
}
|
171 |
+
// end generate_key
|
172 |
+
public function stcr_translate_month( $date_str )
|
173 |
+
{
|
174 |
+
$months_long = array (
|
175 |
+
"January" => __("January",'subscribe-to-comments-reloaded'),
|
176 |
+
"February" => __("February",'subscribe-to-comments-reloaded'),
|
177 |
+
"March" => __("March",'subscribe-to-comments-reloaded'),
|
178 |
+
"April" => __("April",'subscribe-to-comments-reloaded'),
|
179 |
+
"May" => __("May",'subscribe-to-comments-reloaded'),
|
180 |
+
"June" => __("June",'subscribe-to-comments-reloaded'),
|
181 |
+
"July" => __("July",'subscribe-to-comments-reloaded'),
|
182 |
+
"August" => __("August",'subscribe-to-comments-reloaded'),
|
183 |
+
"September" => __("September",'subscribe-to-comments-reloaded'),
|
184 |
+
"October" => __("October",'subscribe-to-comments-reloaded'),
|
185 |
+
"November" => __("November",'subscribe-to-comments-reloaded'),
|
186 |
+
"December" => __("December",'subscribe-to-comments-reloaded')
|
187 |
+
);
|
188 |
+
|
189 |
+
$months_short = array (
|
190 |
+
"Jan" => __("Jan",'subscribe-to-comments-reloaded'),
|
191 |
+
"Feb" => __("Feb",'subscribe-to-comments-reloaded'),
|
192 |
+
"Mar" => __("Mar",'subscribe-to-comments-reloaded'),
|
193 |
+
"Apr" => __("Apr",'subscribe-to-comments-reloaded'),
|
194 |
+
"May" => __("May",'subscribe-to-comments-reloaded'),
|
195 |
+
"Jun" => __("Jun",'subscribe-to-comments-reloaded'),
|
196 |
+
"Jul" => __("Jul",'subscribe-to-comments-reloaded'),
|
197 |
+
"Aug" => __("Aug",'subscribe-to-comments-reloaded'),
|
198 |
+
"Sep" => __("Sep",'subscribe-to-comments-reloaded'),
|
199 |
+
"Oct" => __("Oct",'subscribe-to-comments-reloaded'),
|
200 |
+
"Nov" => __("Nov",'subscribe-to-comments-reloaded'),
|
201 |
+
"Dec" => __("Dec",'subscribe-to-comments-reloaded')
|
202 |
+
);
|
203 |
+
|
204 |
+
// Replace String
|
205 |
+
foreach( $months_long as $key => $value)
|
206 |
+
{
|
207 |
+
$date_str = str_replace( $key, $value, $date_str);
|
208 |
+
}
|
209 |
+
// Find String
|
210 |
+
foreach( $months_short as $key => $value)
|
211 |
+
{
|
212 |
+
$date_str = str_replace( $key, $value, $date_str);
|
213 |
+
}
|
214 |
+
// Return string
|
215 |
+
return $date_str;
|
216 |
+
}
|
217 |
+
|
218 |
+
public function to_num_ini_notation( $size )
|
219 |
+
{
|
220 |
+
$l = substr( $size, - 1 );
|
221 |
+
$ret = substr( $size, 0, - 1 );
|
222 |
+
switch ( strtoupper( $l ) ) {
|
223 |
+
case 'P':
|
224 |
+
$ret *= 1024;
|
225 |
+
case 'T':
|
226 |
+
$ret *= 1024;
|
227 |
+
case 'G':
|
228 |
+
$ret *= 1024;
|
229 |
+
case 'M':
|
230 |
+
$ret *= 1024;
|
231 |
+
case 'K':
|
232 |
+
$ret *= 1024;
|
233 |
+
}
|
234 |
+
|
235 |
+
return $ret;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Get plugin info including status
|
240 |
+
*
|
241 |
+
* This is an enhanced version of get_plugins() that returns the status
|
242 |
+
* (`active` or `inactive`) of all plugins. Does not include MU plugins.
|
243 |
+
*
|
244 |
+
* @version 1.0.0
|
245 |
+
* @since 28-Nov-2018
|
246 |
+
*
|
247 |
+
* @return array Plugin info plus status
|
248 |
+
*/
|
249 |
+
function stcr_get_plugins() {
|
250 |
+
$plugins = get_plugins();
|
251 |
+
$active_plugin_paths = (array) get_option( 'active_plugins', array() );
|
252 |
+
|
253 |
+
if ( is_multisite() ) {
|
254 |
+
$network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
|
255 |
+
$active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
|
256 |
+
}
|
257 |
+
|
258 |
+
foreach ( $plugins as $plugin_path => $plugin_data ) {
|
259 |
+
// Is plugin active?
|
260 |
+
if ( in_array( $plugin_path, $active_plugin_paths ) ) {
|
261 |
+
$plugins[ $plugin_path ]['Status'] = 'active';
|
262 |
+
} else {
|
263 |
+
$plugins[ $plugin_path ]['Status'] = 'inactive';
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
return $plugins;
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Creates the HTML structure to properly handle HTML messages
|
272 |
+
*/
|
273 |
+
public function wrap_html_message( $_message = '', $_subject = '' ) {
|
274 |
+
global $wp_locale;
|
275 |
+
$_message = apply_filters( 'stcr_wrap_html_message', $_message );
|
276 |
+
// Add HTML paragraph tags to comment
|
277 |
+
// See wp-includes/formatting.php for details on the wpautop() function
|
278 |
+
$_message = wpautop( $_message );
|
279 |
+
|
280 |
+
if( $wp_locale->text_direction == "rtl")
|
281 |
+
{
|
282 |
+
$locale = get_locale();
|
283 |
+
$html = "<html xmlns='http://www.w3.org/1999/xhtml' dir='rtl' lang='$locale'>";
|
284 |
+
$head = "<head><title>$_subject</title></head>";
|
285 |
+
$body = "<body>$_message</body>";
|
286 |
+
return $html . $head . $body . "</html>";
|
287 |
+
}
|
288 |
+
else
|
289 |
+
{
|
290 |
+
$html = "<html>";
|
291 |
+
$head = "<head><title>$_subject</title></head>";
|
292 |
+
$body = "<body>$_message</body>";
|
293 |
+
return $html . $head . $body . "</html>";
|
294 |
+
}
|
295 |
+
|
296 |
+
}
|
297 |
+
// end _wrap_html_message
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Returns an email address where some possible 'offending' strings have been removed
|
301 |
+
*/
|
302 |
+
public function clean_email( $_email ) {
|
303 |
+
$offending_strings = array(
|
304 |
+
"/to\:/i",
|
305 |
+
"/from\:/i",
|
306 |
+
"/bcc\:/i",
|
307 |
+
"/cc\:/i",
|
308 |
+
"/content\-transfer\-encoding\:/i",
|
309 |
+
"/content\-type\:/i",
|
310 |
+
"/mime\-version\:/i"
|
311 |
+
);
|
312 |
+
|
313 |
+
return sanitize_email( stripslashes( strip_tags( preg_replace( $offending_strings, '', $_email ) ) ) );
|
314 |
+
}
|
315 |
+
// end clean_email
|
316 |
+
|
317 |
+
public function create_options()
|
318 |
+
{
|
319 |
+
// Messages related to the management page
|
320 |
+
global $wp_rewrite;
|
321 |
+
|
322 |
+
if ( empty( $wp_rewrite->permalink_structure ) ) {
|
323 |
+
add_option( 'subscribe_reloaded_manager_page', '/?page_id=99999', '', 'yes' );
|
324 |
+
} else {
|
325 |
+
add_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/', '', 'yes' );
|
326 |
+
}
|
327 |
+
|
328 |
+
add_option( 'subscribe_reloaded_unique_key', $this->generate_key(), '', 'yes' );
|
329 |
+
add_option( 'subscribe_reloaded_fresh_install', 'no', '', 'yes' );
|
330 |
+
add_option( 'subscribe_reloaded_safely_uninstall', 'yes', '', 'yes' );
|
331 |
+
add_option( 'subscribe_reloaded_stcr_position', 'no', '', 'yes' );
|
332 |
+
add_option( 'subscribe_reloaded_reply_to', '', '', 'yes' );
|
333 |
+
add_option( 'subscribe_reloaded_oneclick_text', "<p>Your are not longer subscribe to the post:</p>\r\n\r\n<h3>[post_title]</h3>\r\n<br>", '', 'yes' );
|
334 |
+
add_option( 'subscribe_reloaded_subscriber_table', 'no', '', 'yes' );
|
335 |
+
add_option( 'subscribe_reloaded_data_sanitized', 'yes', '', 'yes' );
|
336 |
+
add_option( 'subscribe_reloaded_show_subscription_box', 'yes', '', 'yes' );
|
337 |
+
add_option( 'subscribe_reloaded_checked_by_default', 'no', '', 'yes' );
|
338 |
+
add_option( 'subscribe_reloaded_enable_advanced_subscriptions', 'no', '', 'yes' );
|
339 |
+
add_option( 'subscribe_reloaded_default_subscription_type', '2', '', 'yes' );
|
340 |
+
add_option( 'subscribe_reloaded_checked_by_default_value', '0', '', 'yes' );
|
341 |
+
add_option( 'subscribe_reloaded_checkbox_inline_style', 'width:30px', '', 'yes' );
|
342 |
+
add_option( 'subscribe_reloaded_checkbox_html', "<p class='comment-form-subscriptions'><label for='subscribe-reloaded'>[checkbox_field] [checkbox_label]</label></p>", '', 'yes' );
|
343 |
+
add_option( 'subscribe_reloaded_checkbox_label', __( "Notify me of followup comments via e-mail. You can also <a href='[subscribe_link]'>subscribe</a> without commenting.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
344 |
+
add_option( 'subscribe_reloaded_subscribed_label', __( "You are subscribed to this post. <a href='[manager_link]'>Manage</a> your subscriptions.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
345 |
+
add_option( 'subscribe_reloaded_subscribed_waiting_label', __( "Your subscription to this post needs to be confirmed. <a href='[manager_link]'>Manage your subscriptions</a>.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
346 |
+
add_option( 'subscribe_reloaded_author_label', __( "You can <a href='[manager_link]'>manage the subscriptions</a> of this post.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
347 |
+
|
348 |
+
add_option( 'subscribe_reloaded_manager_page_enabled', 'yes', '', 'yes' );
|
349 |
+
add_option( 'subscribe_reloaded_virtual_manager_page_enabled', 'yes', '', 'yes' );
|
350 |
+
add_option( 'subscribe_reloaded_manager_page_title', __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
351 |
+
add_option( 'subscribe_reloaded_custom_header_meta', "<meta name='robots' content='noindex,nofollow'>", '', 'yes' );
|
352 |
+
add_option( 'subscribe_reloaded_request_mgmt_link', __( 'To manage your subscriptions, please enter your email address here below. We will send you a message containing the link to access your personal management page.', 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
353 |
+
add_option( 'subscribe_reloaded_request_mgmt_link_thankyou', __( 'Thank you for using our subscription service. Your request has been completed, and you should receive an email with the management link in a few minutes.', 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
354 |
+
add_option( 'subscribe_reloaded_subscribe_without_commenting', __( "You can follow the discussion on <strong>[post_title]</strong> without having to leave a comment. Cool, huh? Just enter your email address in the form here below and you're all set.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
355 |
+
add_option( 'subscribe_reloaded_subscription_confirmed', __( "Thank you for using our subscription service. Your request has been completed. You will receive a notification email every time a new comment to this article is approved and posted by the administrator.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
356 |
+
add_option( 'subscribe_reloaded_subscription_confirmed_dci', __( "Thank you for using our subscription service. In order to confirm your request, please check your email for the verification message and follow the instructions.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
357 |
+
add_option( 'subscribe_reloaded_author_text', __( "In order to cancel or suspend one or more notifications, select the corresponding checkbox(es) and click on the button at the end of the list.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
358 |
+
add_option( 'subscribe_reloaded_user_text', __( "In order to cancel or suspend one or more notifications, select the corresponding checkbox(es) and click on the button at the end of the list. You are currently subscribed to:", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
359 |
+
|
360 |
+
add_option( 'subscribe_reloaded_from_name', get_bloginfo( 'name' ), '', 'yes' );
|
361 |
+
add_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ), '', 'yes' );
|
362 |
+
add_option( 'subscribe_reloaded_notification_subject', __( 'There is a new comment to [post_title]', 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
363 |
+
add_option( 'subscribe_reloaded_notification_content', __( "<h1>There is a new comment on [post_title].</h1>\n\n<hr />\n<strong>Comment link:</strong> <a href=\"[comment_permalink]\">[comment_permalink]</a>\n<strong>Author:</strong> [comment_author]\n\n<strong>Comment:</strong>\n[comment_content]\n<div style=\"font-size: 0.8em;\"><strong>Permalink:</strong> <a href=\"[post_permalink]\">[post_permalink]</a>\n<a href=\"[manager_link]\">Manage your subscriptions</a> | <a href=\"[oneclick_link]\">One click unsubscribe</a></div>", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
364 |
+
add_option( 'subscribe_reloaded_double_check_subject', __( 'Please confirm your subscription to [post_title]', 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
365 |
+
add_option( 'subscribe_reloaded_double_check_content', __( "You have requested to be notified every time a new comment is added to:\n<a href='[post_permalink]'>[post_permalink]</a>\n\nPlease confirm your request by clicking on this link:\n<a href='[confirm_link]'>[confirm_link]</a>", 'subscribe-to-comments-reloaded' ), '', 'yes' );
|
366 |
+
add_option( 'subscribe_reloaded_management_subject', __( 'Manage your subscriptions on [blog_name]', 'subscribe-to-comments-reloaded' ) );
|
367 |
+
add_option( 'subscribe_reloaded_management_content', __( "You have requested to manage your subscriptions to the articles on [blog_name]. Please check the Subscriptions management link in your email", 'subscribe-to-comments-reloaded' ) );
|
368 |
+
add_option( 'subscribe_reloaded_management_email_content', __( "You have requested to manage your subscriptions to the articles on [blog_name]. Follow this link to access your personal page:\n<a href='[manager_link]'>[manager_link]</a>", 'subscribe-to-comments-reloaded' ) );
|
369 |
+
|
370 |
+
add_option( 'subscribe_reloaded_purge_days', '30', '', 'yes' );
|
371 |
+
add_option( 'subscribe_reloaded_enable_double_check', 'yes', '', 'yes' );
|
372 |
+
add_option( 'subscribe_reloaded_notify_authors', 'no', '', 'yes' );
|
373 |
+
add_option( 'subscribe_reloaded_enable_html_emails', 'yes', '', 'yes' );
|
374 |
+
add_option( 'subscribe_reloaded_htmlify_message_links', 'no', '', 'yes' );
|
375 |
+
add_option( 'subscribe_reloaded_process_trackbacks', 'no', '', 'yes' );
|
376 |
+
add_option( 'subscribe_reloaded_enable_admin_messages', 'no', '', 'yes' );
|
377 |
+
add_option( 'subscribe_reloaded_admin_subscribe', 'no', '', 'yes' );
|
378 |
+
add_option( 'subscribe_reloaded_admin_bcc', 'no', '', 'yes' );
|
379 |
+
add_option( 'subscribe_reloaded_enable_log_data', 'no', '', 'yes' );
|
380 |
+
add_option( 'subscribe_reloaded_auto_clean_log_data', 'yes', '', 'yes' );
|
381 |
+
add_option( 'subscribe_reloaded_auto_clean_log_frecuency', 'daily', '', 'yes' );
|
382 |
+
add_option( 'subscribe_reloaded_enable_font_awesome', 'yes', '', 'yes' );
|
383 |
+
add_option( 'subscribe_reloaded_delete_options_subscriptions', 'no', '', 'no' );
|
384 |
+
add_option( 'subscribe_reloaded_date_format', 'd M Y', '', 'no' );
|
385 |
+
add_option( 'subscribe_reloaded_only_for_posts', 'no', '', 'yes' );
|
386 |
+
|
387 |
+
}
|
388 |
+
/**
|
389 |
+
* @since 08-February-2018
|
390 |
+
* @author reedyseth
|
391 |
+
* @param $delete_subscriptions String Decide either to delete the subscriptions or not.
|
392 |
+
* @return true|false Boolean on success or failure.
|
393 |
+
*/
|
394 |
+
public function delete_all_settings( $delete_subscriptions = no )
|
395 |
+
{
|
396 |
+
global $wpdb;
|
397 |
+
$sql = "SELECT * FROM $wpdb->options WHERE option_name like 'subscribe_reloaded\_%'
|
398 |
+
ORDER BY option_name";
|
399 |
+
$stcr_options = $wpdb->get_results( $sql , OBJECT );
|
400 |
+
if( $stcr_options !== false && is_array( $stcr_options ) )
|
401 |
+
{
|
402 |
+
// Drop Only the Settings and not the subscriptions.
|
403 |
+
// Goodbye options...
|
404 |
+
foreach($stcr_options as $option)
|
405 |
+
{
|
406 |
+
delete_option( $option->option_name );
|
407 |
+
}
|
408 |
+
if ( $delete_subscriptions == "yes" )
|
409 |
+
{
|
410 |
+
// Delete the subscriptions in both tables.
|
411 |
+
$wpdb->query( "DELETE FROM {$wpdb->prefix}subscribe_reloaded_subscribers" );
|
412 |
+
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '\_stcr@\_%'" );
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
|
417 |
+
if ( $stcr_options === false )
|
418 |
+
{
|
419 |
+
return false;
|
420 |
+
}
|
421 |
+
else
|
422 |
+
{
|
423 |
+
return true;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
/**
|
427 |
+
* Enqueue a script that was previous registered,
|
428 |
+
*
|
429 |
+
* @since 28-Mar-2018
|
430 |
+
* @author reedyseth
|
431 |
+
* @param string $handle Script handle that will be enqueue
|
432 |
+
*/
|
433 |
+
public function enqueue_script_to_wp( $handle )
|
434 |
+
{
|
435 |
+
wp_enqueue_script( $handle );
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
*
|
440 |
+
*
|
441 |
+
* @since
|
442 |
+
* @author Israel Barragan (Reedyseth)
|
443 |
+
*
|
444 |
+
* @param $severity
|
445 |
+
* @param $message
|
446 |
+
* @param $filename
|
447 |
+
* @param $lineno
|
448 |
+
*/
|
449 |
+
function exceptions_error_handler($severity, $message, $filename, $lineno)
|
450 |
+
{
|
451 |
+
$date = date_i18n( 'Y-m-d H:i:s' );
|
452 |
+
// We don't want to break things out, so instead we add the error information to
|
453 |
+
// the log file, thus allowing us to help more on the debug / error / support of StCR.
|
454 |
+
$this->stcr_logger("\n [ERROR][$date] - An error occur, here is the detail information\n");
|
455 |
+
$this->stcr_logger(" [ERROR][SEVERITY] - $severity\n");
|
456 |
+
$this->stcr_logger(" [ERROR][MESSAGE] - $message\n");
|
457 |
+
$this->stcr_logger(" [ERROR][FILENAME] - $filename\n");
|
458 |
+
$this->stcr_logger(" [ERROR][LINE NUMBER] - $lineno\n\n");
|
459 |
+
|
460 |
+
// throw new \ErrorException($message, 0, $severity,$filename, $lineno);
|
461 |
+
}
|
462 |
+
/**
|
463 |
+
* Will send an email by adding the correct headers.
|
464 |
+
*
|
465 |
+
* @since 28-May-2016
|
466 |
+
* @author reedyseth
|
467 |
+
* @param $_emailSettings Array Associative array with settings.
|
468 |
+
* @return true|false Boolean On success or failure
|
469 |
+
*/
|
470 |
+
public function send_email( $_settings )
|
471 |
+
{ // Retrieve the options from the database
|
472 |
+
$from_name = html_entity_decode(
|
473 |
+
stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) ), ENT_QUOTES, 'UTF-8' );
|
474 |
+
$from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
|
475 |
+
$reply_to = get_option( "subscribe_reloaded_reply_to" ) == ''
|
476 |
+
? $from_email : get_option( "subscribe_reloaded_reply_to" );
|
477 |
+
$content_type = ( get_option( 'subscribe_reloaded_enable_html_emails' ) == 'yes' )
|
478 |
+
? 'text/html' : 'text/plain';
|
479 |
+
$headers = "Content-Type: $content_type; charset=" . get_bloginfo( 'charset' ) . "\n";
|
480 |
+
$date = date_i18n( 'Y-m-d H:i:s' );
|
481 |
+
|
482 |
+
$_emailSettings = array(
|
483 |
+
'fromEmail' => $from_email,
|
484 |
+
'fromName' => $from_name,
|
485 |
+
'toEmail' => '',
|
486 |
+
'subject' => __('StCR Notification' ,'subscribe-to-comments-reloaded'),
|
487 |
+
'message' => '',
|
488 |
+
'bcc' => '',
|
489 |
+
'reply_to' => $reply_to,
|
490 |
+
'XPostId' => '0',
|
491 |
+
'XCommentId' => '0'
|
492 |
+
);
|
493 |
+
|
494 |
+
$_emailSettings = array_merge( $_emailSettings, $_settings );
|
495 |
+
$_emailSettings[ 'message' ] = $this->wrap_html_message( $_emailSettings['message'], $_emailSettings['subject'] );
|
496 |
+
|
497 |
+
$headers .= "From: \"{$_emailSettings['fromName']}\" <{$_emailSettings['fromEmail']}>\n";
|
498 |
+
$headers .= "Reply-To: {$_emailSettings['reply_to']}\n";
|
499 |
+
$headers .= "X-Post-Id: {$_emailSettings['XPostId']}\n";
|
500 |
+
$headers .= "X-Comment-Id: {$_emailSettings['XCommentId']}\n";
|
501 |
+
|
502 |
+
if ( get_option( 'subscribe_reloaded_admin_bcc' ) == 'yes' ) {
|
503 |
+
$headers .= "Bcc: $from_name <$from_email>\n"; // The StCR email define or otherwise the blog admin.
|
504 |
+
}
|
505 |
+
|
506 |
+
$this->stcr_logger( "*********************************************************************************" );
|
507 |
+
$this->stcr_logger( "\n\nDate: " . $date );
|
508 |
+
$this->stcr_logger( "\n\nTo Email: " . $_emailSettings['toEmail'] );
|
509 |
+
$this->stcr_logger( "\n\nFrom Email: " . $_emailSettings['fromEmail'] );
|
510 |
+
$this->stcr_logger( "\n\nMessage: " . $_emailSettings['message'] );
|
511 |
+
$this->stcr_logger( "\n\nHeaders:\n\n" . $headers );
|
512 |
+
$this->stcr_logger( "*********************************************************************************" );
|
513 |
+
|
514 |
+
$sent_result = ( wp_mail( $_emailSettings['toEmail'], $_emailSettings['subject'], $_emailSettings['message'], $headers ) )
|
515 |
+
? true : false;
|
516 |
+
if( ! $sent_result )
|
517 |
+
{
|
518 |
+
$this->stcr_logger( "*********************************************************************************" );
|
519 |
+
$this->stcr_logger( "\nError sending email notification.\n" );
|
520 |
+
$this->stcr_logger( "*********************************************************************************" );
|
521 |
+
}
|
522 |
+
|
523 |
+
return $sent_result;
|
524 |
+
}// End send_email
|
525 |
+
/**
|
526 |
+
* Checks if a key is valid for a given email address
|
527 |
+
*/
|
528 |
+
public function _is_valid_key( $_key, $_email ) {
|
529 |
+
if ( $this->generate_temp_key( $_email ) === $_key ) {
|
530 |
+
return true;
|
531 |
+
} else {
|
532 |
+
return false;
|
533 |
+
}
|
534 |
+
}
|
535 |
+
// end _is_valid_key
|
536 |
+
/**
|
537 |
+
* Enqueue scripts to load the TinyMCE ritch editor. I could use the hook `after_wp_tiny_mce` but I will
|
538 |
+
* controll the tinyMCE version within my plugin instead of using the WordPress embedded one.
|
539 |
+
* @since 03-Agu-2015
|
540 |
+
* @author reedyseth
|
541 |
+
*/
|
542 |
+
public function add_ritch_editor_textarea() {
|
543 |
+
wp_enqueue_script('stcr-tinyMCE'); // TODO: Only enqueue it the first time.
|
544 |
+
wp_enqueue_script('stcr-tinyMCE-js');
|
545 |
+
}
|
546 |
+
/**
|
547 |
+
* Register scripts for admin pages. I could use the hook `after_wp_tiny_mce` but I will
|
548 |
+
* controll the tinyMCE version within my plugin instead of using the WordPress embedded one.
|
549 |
+
* @since 03-Agu-2015
|
550 |
+
* @author reedyseth
|
551 |
+
*/
|
552 |
+
public function register_admin_scripts( $hook ) {
|
553 |
+
|
554 |
+
// paths
|
555 |
+
$stcr_admin_js = ( is_ssl() ? str_replace( 'http://', 'https://', WP_PLUGIN_URL ) : WP_PLUGIN_URL ) . '/subscribe-to-comments-reloaded/includes/js/stcr-admin.js';
|
556 |
+
$stcr_admin_css = ( is_ssl() ? str_replace( 'http://', 'https://', WP_PLUGIN_URL ) : WP_PLUGIN_URL ) . '/subscribe-to-comments-reloaded/includes/css/stcr-admin-style.css';
|
557 |
+
|
558 |
+
// register scripts
|
559 |
+
wp_register_script('stcr-admin-js', $stcr_admin_js, array( 'jquery' ) );
|
560 |
+
|
561 |
+
// rergister styles
|
562 |
+
wp_register_style( 'stcr-admin-style', $stcr_admin_css );
|
563 |
+
|
564 |
+
// check if we're on our pages
|
565 |
+
if ( strpos( $hook, 'stcr' ) !== false ) {
|
566 |
+
|
567 |
+
// enqueue scripts
|
568 |
+
wp_enqueue_script('stcr-admin-js');
|
569 |
+
|
570 |
+
// enqueue styles
|
571 |
+
wp_enqueue_style('stcr-admin-style');
|
572 |
+
|
573 |
+
}
|
574 |
+
|
575 |
+
}
|
576 |
+
/**
|
577 |
+
* Hooking scripts for admin pages.
|
578 |
+
* @since 03-Agu-2015
|
579 |
+
* @author reedyseth
|
580 |
+
*/
|
581 |
+
public function hook_admin_scripts() {
|
582 |
+
// link the hooks
|
583 |
+
add_action('admin_enqueue_scripts',array( $this, 'register_admin_scripts') );
|
584 |
+
}
|
585 |
+
/**
|
586 |
+
* Registers a Javacsript file to the `wp_register_script` hook.
|
587 |
+
*
|
588 |
+
* @since 28-Mar-2018
|
589 |
+
* @author reedyseth
|
590 |
+
* @param string $handle Script handle the data will be attached to.
|
591 |
+
* @param string $script_name JS File name.
|
592 |
+
* @param string $path_add Sometimes the path is not in the root, therefore you can use this to complete the path.
|
593 |
+
*/
|
594 |
+
public function register_script_to_wp( $handle, $script_name, $path_add = "" )
|
595 |
+
{
|
596 |
+
$js_resource = ( is_ssl() ? str_replace( 'http://', 'https://', WP_PLUGIN_URL ) : WP_PLUGIN_URL ) . "/". SLUG ."/$path_add/$script_name";
|
597 |
+
wp_register_script( $handle, $js_resource );
|
598 |
+
}
|
599 |
+
/**includes/js/admin
|
600 |
+
* Hooking scripts for plugin pages.
|
601 |
+
* @since 22-Sep-2015
|
602 |
+
* @author reedyseth
|
603 |
+
*/
|
604 |
+
public function hook_plugin_scripts() {
|
605 |
+
// link the hooks
|
606 |
+
add_action('wp_enqueue_scripts',array( $this, 'register_plugin_scripts') );
|
607 |
+
}
|
608 |
+
/**
|
609 |
+
* Register scripts for plugin pages.
|
610 |
+
* @since 22-Sep-2015
|
611 |
+
* @author reedyseth
|
612 |
+
*/
|
613 |
+
public function register_plugin_scripts() {
|
614 |
+
$stcr_font_awesome_css = (is_ssl() ? str_replace('http://', 'https://', WP_PLUGIN_URL) : WP_PLUGIN_URL) . '/subscribe-to-comments-reloaded/includes/css/font-awesome.min.css';
|
615 |
+
// Font Awesome
|
616 |
+
if( get_option( 'subscribe_reloaded_enable_font_awesome' ) == "yes" )
|
617 |
+
{
|
618 |
+
wp_register_style( 'stcr-font-awesome', $stcr_font_awesome_css );
|
619 |
+
wp_enqueue_style('stcr-font-awesome');
|
620 |
+
}
|
621 |
+
}
|
622 |
+
/**
|
623 |
+
* Enqueue `style for plugin pages
|
624 |
+
* @since 22-Sep-2015
|
625 |
+
* @author reedyseth
|
626 |
+
*/
|
627 |
+
public function add_plugin_js_scripts() {
|
628 |
+
// Enqueue Scripts
|
629 |
+
//wp_enqueue_script('stcr-plugin-js');
|
630 |
+
}
|
631 |
+
/**
|
632 |
+
* Create a notice array with its settings and add it to the subscribe_reloaded_deferred_admin_notices
|
633 |
+
* option.
|
634 |
+
*
|
635 |
+
* @since 14-Agu-2015
|
636 |
+
* @author reedyseth
|
637 |
+
*
|
638 |
+
* @param string $_name Name of the notice.
|
639 |
+
* @param string $_status status read/unread. This will determine if the notice is display or not.
|
640 |
+
* @param string $_message Message that you want to show.
|
641 |
+
* @param string $_type What kind of notice you can use updated/error.
|
642 |
+
*/
|
643 |
+
public function stcr_create_admin_notice( $_name = '', $_status = 'unread', $_message = '', $_type = 'updated' ) {
|
644 |
+
$notices = get_option( 'subscribe_reloaded_deferred_admin_notices', array() );
|
645 |
+
$notices[ $_name ] = array(
|
646 |
+
"status" => $_status,
|
647 |
+
"message" => $_message,
|
648 |
+
"type" => $_type
|
649 |
+
);
|
650 |
+
update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
|
651 |
+
}
|
652 |
+
|
653 |
+
/**
|
654 |
+
* Method to avoid using all the StCR option variable name. Return the given option value.
|
655 |
+
*
|
656 |
+
* @since 08-Apr-2018
|
657 |
+
* @author Israel Barragan (Reedyseth)
|
658 |
+
*
|
659 |
+
* @param string $_option Option Name
|
660 |
+
* @param string $_default Default value in case is not defined.
|
661 |
+
* @return string The option value store in WP.
|
662 |
+
*/
|
663 |
+
public function stcr_get_menu_options($_option = '', $_default = '' )
|
664 |
+
{
|
665 |
+
$value = null;
|
666 |
+
|
667 |
+
if ( isset( $this->menu_opts_cache[$_option] ) )
|
668 |
+
{
|
669 |
+
return $this->menu_opts_cache[$_option];
|
670 |
+
}
|
671 |
+
else
|
672 |
+
{
|
673 |
+
$value = get_option( 'subscribe_reloaded_' . $_option, $_default );
|
674 |
+
$value = html_entity_decode( stripslashes( $value ), ENT_QUOTES, 'UTF-8' );
|
675 |
+
$value = stripslashes( $value );
|
676 |
+
// Set the cache value
|
677 |
+
$this->menu_opts_cache[$_option] = $value;
|
678 |
+
}
|
679 |
+
|
680 |
+
return $value;
|
681 |
+
}
|
682 |
+
/**
|
683 |
+
* Update a given notice with the given arguments.
|
684 |
+
*
|
685 |
+
* @since 14-Agu-2015
|
686 |
+
* @author reedyseth
|
687 |
+
*
|
688 |
+
* @param string $_name Name of the notice.
|
689 |
+
* @param string $_status status read/unread. This will determine if the notice is display or not.
|
690 |
+
* @param string $_message Message that you want to show.
|
691 |
+
* @param string $_type What kind of notice you can use updated/error.
|
692 |
+
*/
|
693 |
+
public function stcr_update_admin_notice( $_name = '', $_status = 'unread', $_message = '', $_type = 'updated', $_nonce = 'nonce-key' ) {
|
694 |
+
$notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
|
695 |
+
foreach ( $notices as $key => $notice ) {
|
696 |
+
if ( $key == $_name ) {
|
697 |
+
$notices[ $key ] = array(
|
698 |
+
"status" => $_status,
|
699 |
+
"message" => $_message,
|
700 |
+
"type" => $_type,
|
701 |
+
"nonce" => $_nonce
|
702 |
+
);
|
703 |
+
}
|
704 |
+
}
|
705 |
+
update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
|
706 |
+
}
|
707 |
+
/**
|
708 |
+
* Update a given notice status.
|
709 |
+
*
|
710 |
+
* @since 18-Agu-2015
|
711 |
+
* @author reedyseth
|
712 |
+
*
|
713 |
+
* @param string $_name Name of the notice.
|
714 |
+
* @param string $_status status read/unread. This will determine if the notice is display or not.
|
715 |
+
*/
|
716 |
+
public function stcr_update_admin_notice_status( $_name = '', $_status = 'unread', $_nonce = 0 ) {
|
717 |
+
$notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
|
718 |
+
foreach ( $notices as $key => $notice ) {
|
719 |
+
if ( $key == $_name ) {
|
720 |
+
if ( $_status == 'read' ) {
|
721 |
+
unset( $notices[$key] );
|
722 |
+
} else {
|
723 |
+
$notices[ $key ] = array(
|
724 |
+
"status" => $_status,
|
725 |
+
"message" => $notice['message'],
|
726 |
+
"type" => $notice['type'],
|
727 |
+
"nonce" => $_nonce
|
728 |
+
);
|
729 |
+
}
|
730 |
+
}
|
731 |
+
}
|
732 |
+
update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
|
733 |
+
}
|
734 |
+
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Method to avoid using all the StCR option variable name. It also verify the type of value to be store.
|
738 |
+
*
|
739 |
+
* @since 07-Apr-2018
|
740 |
+
* @author Israel Barragan (Reedyseth)
|
741 |
+
*
|
742 |
+
* @param string $_option Option Name.
|
743 |
+
* @param string $_value
|
744 |
+
* @param string $_type type to use for the correct sanitation yesno|integer|text|text-html|email|url
|
745 |
+
* @return bool false in case that the value is not defined.
|
746 |
+
*/
|
747 |
+
public function stcr_update_menu_options($_option = '', $_value = '', $_type = '' )
|
748 |
+
{
|
749 |
+
if ( ! isset( $_value ) ) {
|
750 |
+
return false;
|
751 |
+
}
|
752 |
+
|
753 |
+
// Prevent XSS/CSRF attacks
|
754 |
+
$_value = trim( stripslashes( $_value ) );
|
755 |
+
|
756 |
+
switch ( $_type ) {
|
757 |
+
case 'yesno':
|
758 |
+
if ( $_value == 'yes' || $_value == 'no' ) {
|
759 |
+
update_option( 'subscribe_reloaded_' . $_option, esc_attr( $_value ) );
|
760 |
+
}
|
761 |
+
break;
|
762 |
+
case 'integer':
|
763 |
+
update_option( 'subscribe_reloaded_' . $_option, abs( intval( esc_attr( $_value ) ) ) );
|
764 |
+
|
765 |
+
break;
|
766 |
+
case 'text':
|
767 |
+
update_option( 'subscribe_reloaded_' . $_option, sanitize_text_field( $_value ) );
|
768 |
+
|
769 |
+
break;
|
770 |
+
case 'text-html':
|
771 |
+
update_option( 'subscribe_reloaded_' . $_option, esc_html( $_value ) );
|
772 |
+
|
773 |
+
break;
|
774 |
+
case 'email':
|
775 |
+
update_option( 'subscribe_reloaded_' . $_option, sanitize_email( esc_attr( $_value ) ) );
|
776 |
+
|
777 |
+
break;
|
778 |
+
case 'url':
|
779 |
+
update_option( 'subscribe_reloaded_' . $_option, esc_url( $_value ) );
|
780 |
+
|
781 |
+
break;
|
782 |
+
default:
|
783 |
+
update_option( 'subscribe_reloaded_' . $_option, esc_attr( $_value ) );
|
784 |
+
|
785 |
+
break;
|
786 |
+
}
|
787 |
+
|
788 |
+
return true;
|
789 |
+
}
|
790 |
+
/**
|
791 |
+
* Delete a given notice with the given arguments.
|
792 |
+
*
|
793 |
+
* @since 14-Agu-2015
|
794 |
+
* @author reedyseth
|
795 |
+
*
|
796 |
+
* @param string $_name Name of the notice to be deleted.
|
797 |
+
*/
|
798 |
+
public function stcr_remove_admin_notice( $_name = '' ) {
|
799 |
+
$notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
|
800 |
+
foreach ( $notices as $key => $notice ) {
|
801 |
+
if ( $key == $_name ) {
|
802 |
+
unset( $notices[ $key ] );
|
803 |
+
}
|
804 |
+
}
|
805 |
+
update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
|
806 |
+
}
|
807 |
+
/**
|
808 |
+
* Bind the notices to the ajax hook.
|
809 |
+
*
|
810 |
+
* @since 14-Agu-2015
|
811 |
+
* @author reedyseth
|
812 |
+
*
|
813 |
+
* @param string $_notices The notifice to be binded.
|
814 |
+
*/
|
815 |
+
public function stcr_create_ajax_notices() {
|
816 |
+
$notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
|
817 |
+
|
818 |
+
if ( $notices ) {
|
819 |
+
foreach ( $notices as $key => $notice ) {
|
820 |
+
add_action( 'wp_ajax_' . $key, array( $this, 'stcr_ajax_update_notification') );
|
821 |
+
}
|
822 |
+
}
|
823 |
+
return;
|
824 |
+
}
|
825 |
+
/**
|
826 |
+
* Create a new Ajax Hook.
|
827 |
+
*
|
828 |
+
* @since 07-Dic-2018
|
829 |
+
* @author reedyseth
|
830 |
+
*
|
831 |
+
* @param array $_actions An array with the ajax hooks to bind. Each element of the array should be the name and the function to bind.
|
832 |
+
*/
|
833 |
+
public function stcr_create_ajax_hook( array $_actions )
|
834 |
+
{
|
835 |
+
foreach ($_actions as $hookName => $functionToBind )
|
836 |
+
{
|
837 |
+
add_action( 'wp_ajax_' . $hookName, array( $this, $functionToBind ) );
|
838 |
+
}
|
839 |
+
|
840 |
+
return;
|
841 |
+
}
|
842 |
+
|
843 |
+
/**
|
844 |
+
* Update a StCR notification status
|
845 |
+
*
|
846 |
+
* @since 14-Agu-2015
|
847 |
+
* @author reedyseth
|
848 |
+
*
|
849 |
+
* @param string $_notification The notification Name of the notice to be deleted.
|
850 |
+
*/
|
851 |
+
public function stcr_ajax_update_notification () {
|
852 |
+
$_notification = $_POST['action'];
|
853 |
+
// Check Nonce
|
854 |
+
check_ajax_referer( $_notification, 'security' );
|
855 |
+
// Update status
|
856 |
+
$this->stcr_update_admin_notice_status( sanitize_text_field( $_notification ), 'read' ) ;
|
857 |
+
// Send success message
|
858 |
+
wp_send_json_success( 'Notification status updated for "' . $_notification . '"' );
|
859 |
+
die();
|
860 |
+
}
|
861 |
+
/**
|
862 |
+
* Check if the current user is a WordPress Admin
|
863 |
+
*
|
864 |
+
* @since 10-Dic-2018
|
865 |
+
* @author reedyseth
|
866 |
+
*
|
867 |
+
*/
|
868 |
+
public function stcr_is_admin()
|
869 |
+
{
|
870 |
+
return is_admin();
|
871 |
+
}
|
872 |
+
|
873 |
+
/**
|
874 |
+
* Get path to log-path, or null if we can't write
|
875 |
+
*
|
876 |
+
* @since 01-Aug-2019
|
877 |
+
*
|
878 |
+
*/
|
879 |
+
public function stcr_get_log_path()
|
880 |
+
{
|
881 |
+
$loggin_info = get_option("subscribe_reloaded_enable_log_data", "no");
|
882 |
+
if ( $loggin_info != "yes" )
|
883 |
+
return null;
|
884 |
+
|
885 |
+
$file_path = plugin_dir_path( __FILE__ );
|
886 |
+
if ( !is_writable( $file_path ))
|
887 |
+
return null;
|
888 |
+
|
889 |
+
return $file_path .'/log.txt';
|
890 |
+
}
|
891 |
+
|
892 |
+
/**
|
893 |
+
* Function to log messages into a given file. The variable $file_path must have writing permissions.
|
894 |
+
*
|
895 |
+
* @param string $value The message to log
|
896 |
+
* @since 13-Mar-2016
|
897 |
+
* @author reedyseth
|
898 |
+
*/
|
899 |
+
public function stcr_logger( $value = '' )
|
900 |
+
{
|
901 |
+
$file_path = $this->stcr_get_log_path();
|
902 |
+
|
903 |
+
if (isset($file_path))
|
904 |
+
{
|
905 |
+
$file = fopen( $file_path, "a" );
|
906 |
+
|
907 |
+
fputs( $file , $value);
|
908 |
+
|
909 |
+
fclose($file);
|
910 |
+
}
|
911 |
+
// else
|
912 |
+
// {
|
913 |
+
// throw new \Exception("The path $file_path is not writable, please check the folder Permissions.", 1);
|
914 |
+
// }
|
915 |
+
}
|
916 |
+
}
|
917 |
+
}
|
wp_subscribe_reloaded.php
CHANGED
@@ -1,118 +1,162 @@
|
|
1 |
<?php
|
2 |
namespace stcr;
|
|
|
3 |
// Avoid direct access to this piece of code
|
4 |
if ( ! function_exists( 'add_action' ) ) {
|
5 |
header( 'Location: /' );
|
6 |
exit;
|
7 |
}
|
8 |
|
9 |
-
|
10 |
-
define( __NAMESPACE__.'\\
|
|
|
11 |
define( __NAMESPACE__.'\\SLUG', "subscribe-to-comments-reloaded" );
|
12 |
|
|
|
13 |
require_once dirname(__FILE__).'/utils/stcr_manage.php';
|
14 |
require_once dirname(__FILE__).'/classes/stcr_i18n.php';
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
class wp_subscribe_reloaded extends stcr_manage {
|
19 |
-
|
|
|
|
|
20 |
/**
|
21 |
-
* Constructor
|
22 |
*/
|
23 |
public function __construct() {
|
24 |
|
25 |
-
|
|
|
26 |
|
27 |
$this->salt = defined( 'NONCE_KEY' ) ? NONCE_KEY : 'please create a unique key in your wp-config.php';
|
28 |
|
29 |
-
//
|
30 |
-
if ( get_option( 'subscribe_reloaded_show_subscription_box' ) === 'yes' )
|
31 |
-
|
32 |
-
if( get_option('subscribe_reloaded_stcr_position') == 'yes' )
|
33 |
-
{
|
34 |
add_action( 'comment_form', array($this, 'subscribe_reloaded_show'), 5, 0 );
|
35 |
-
}
|
36 |
-
else
|
37 |
-
{
|
38 |
add_filter( 'comment_form_submit_field', array($this, 'subscribe_reloaded_show'), 5, 1 );
|
39 |
}
|
40 |
-
|
41 |
}
|
42 |
|
43 |
$this->maybe_update();
|
44 |
|
|
|
45 |
$this->define_wp_hooks();
|
46 |
|
47 |
-
|
|
|
48 |
|
49 |
-
|
50 |
-
{
|
51 |
-
|
52 |
-
//$this->add_manual_subs( 10000, 18,'Y', 'dev', 30);
|
53 |
}
|
54 |
|
|
|
55 |
add_shortcode( 'stcr_management_page', array( $this, 'management_page_sc' ) );
|
56 |
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
65 |
}
|
66 |
-
|
|
|
67 |
/**
|
68 |
-
* Define the WordPress Hooks that will be
|
69 |
*
|
70 |
-
* @since
|
71 |
-
* @author reedyseth
|
72 |
*/
|
73 |
-
public function define_wp_hooks()
|
74 |
-
|
75 |
-
//
|
76 |
-
|
77 |
-
|
|
|
78 |
add_action('_cron_subscribe_reloaded_purge', array($this, 'subscribe_reloaded_purge'), 10 );
|
79 |
add_action('_cron_log_file_purge', array($this, 'log_file_purge'), 10 );
|
80 |
|
81 |
-
//
|
82 |
add_action( 'plugins_loaded', array( $this, 'subscribe_reloaded_load_plugin_textdomain' ) );
|
83 |
|
84 |
-
//
|
85 |
if ( ! is_admin() ) {
|
86 |
|
87 |
-
//
|
88 |
$manager_page_permalink = get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
|
89 |
if ( function_exists( 'qtrans_convertURL' ) ) {
|
90 |
$manager_page_permalink = qtrans_convertURL( $manager_page_permalink );
|
91 |
}
|
|
|
|
|
92 |
if ( empty( $manager_page_permalink ) ) {
|
93 |
-
// Manager page can't be empty, set it to default.
|
94 |
$manager_page_permalink = '/comment-subscriptions/';
|
95 |
}
|
96 |
|
97 |
-
//
|
98 |
if ( ( strpos( $_SERVER["REQUEST_URI"], $manager_page_permalink ) !== false ) ) {
|
99 |
add_filter( 'the_posts', array( $this, 'subscribe_reloaded_manage' ), 10, 2 );
|
100 |
-
|
|
|
|
|
|
|
101 |
|
102 |
-
//
|
103 |
$this->utils->hook_plugin_scripts();
|
104 |
-
|
|
|
105 |
} else {
|
106 |
-
|
|
|
107 |
add_action( 'wpmu_new_blog', array( $this, 'new_blog' ), 10, 1 );
|
108 |
|
109 |
-
//
|
110 |
add_action( 'delete_post', array( $this, 'delete_subscriptions' ), 10, 2 );
|
111 |
|
112 |
-
//
|
113 |
add_action( 'deleted_comment', array( $this, 'comment_deleted' ) );
|
114 |
-
|
115 |
-
|
|
|
116 |
add_filter( 'manage_edit-comments_columns', array( $this, 'add_column_header' ) );
|
117 |
add_filter( 'manage_posts_columns', array( $this, 'add_column_header' ) );
|
118 |
add_action( 'manage_comments_custom_column', array( $this, 'add_comment_column' ) );
|
@@ -123,54 +167,66 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
123 |
add_action( 'admin_print_styles-edit-comments.php', array( $this, 'add_post_comments_stylesheet' ) );
|
124 |
add_action( 'admin_print_styles-edit.php', array( $this, 'add_post_comments_stylesheet' ) );
|
125 |
|
126 |
-
//
|
127 |
add_action( 'in_admin_header', array( $this, 'display_admin_header' ), 100 );
|
128 |
|
129 |
-
|
130 |
-
|
|
|
|
|
131 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
132 |
|
133 |
-
//
|
134 |
add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 );
|
135 |
|
136 |
-
//
|
137 |
add_shortcode( 'subscribe-url', array( $this, 'subscribe_url_shortcode' ) );
|
138 |
|
139 |
-
//
|
140 |
-
|
141 |
-
|
|
|
142 |
if ( get_option( 'subscribe_reloaded_notify_authors' ) === 'yes' ) {
|
143 |
add_action( 'publish_post', array( $this, 'subscribe_post_author' ) );
|
144 |
-
|
145 |
-
|
|
|
146 |
$this->utils->hook_admin_scripts();
|
147 |
|
148 |
-
//
|
149 |
$this->utils->stcr_create_ajax_notices();
|
150 |
|
|
|
151 |
add_action( 'admin_init', array( $this, 'sysinfo_download' ) );
|
152 |
|
153 |
-
|
|
|
154 |
}
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
$array_pages = array(
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
);
|
171 |
|
172 |
-
|
173 |
-
// Bail if we're not StCR plugin page.
|
174 |
if ( ! array_key_exists( $current_page, $array_pages) ) {
|
175 |
return;
|
176 |
}
|
@@ -178,112 +234,152 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
178 |
?>
|
179 |
|
180 |
<nav class="navbar navbar-expand-lg navbar-light bg-light <?php echo $wp_locale->text_direction ?>">
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
183 |
<ul class="navbar-nav">
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
223 |
|
224 |
/**
|
225 |
* Load localization files
|
|
|
|
|
226 |
*/
|
227 |
function subscribe_reloaded_load_plugin_textdomain() {
|
228 |
-
|
|
|
|
|
229 |
}
|
230 |
|
231 |
-
|
232 |
* Add Settings link to plugin on plugins page
|
|
|
|
|
233 |
*/
|
234 |
public function plugin_settings_link( $links, $file ) {
|
|
|
235 |
if ( $file == 'subscribe-to-comments-reloaded/subscribe-to-comments-reloaded.php' ) {
|
236 |
$links['settings'] = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
|
237 |
}
|
238 |
|
239 |
return $links;
|
|
|
240 |
}
|
241 |
|
242 |
/**
|
243 |
* Retrieves the comment information from the database
|
|
|
|
|
244 |
*/
|
245 |
public function _get_comment_object( $_comment_ID ) {
|
|
|
246 |
global $wpdb;
|
247 |
|
248 |
return $wpdb->get_row(
|
249 |
$wpdb->prepare(
|
250 |
-
"
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
), OBJECT
|
255 |
);
|
|
|
256 |
}
|
257 |
-
// end _get_comment_object
|
258 |
|
259 |
/**
|
260 |
* Takes the appropriate action, when a new comment is posted
|
|
|
|
|
261 |
*/
|
262 |
public function new_comment_posted( $_comment_ID = 0, $_comment_status = 0 ) {
|
263 |
-
|
|
|
264 |
$info = $this->_get_comment_object( $_comment_ID );
|
265 |
|
|
|
266 |
if ( empty( $info ) || $info->comment_approved == 'spam' ) {
|
267 |
return $_comment_ID;
|
268 |
}
|
269 |
|
270 |
-
//
|
271 |
$is_disabled = get_post_meta( $info->comment_post_ID, 'stcr_disable_subscriptions', true );
|
272 |
if ( ! empty( $is_disabled ) ) {
|
273 |
return $_comment_ID;
|
274 |
}
|
275 |
|
276 |
-
//
|
277 |
if ( ( get_option( 'subscribe_reloaded_process_trackbacks', 'no' ) == 'no' ) && ( $info->comment_type == 'trackback' || $info->comment_type == 'pingback' ) ) {
|
278 |
return $_comment_ID;
|
279 |
}
|
280 |
|
281 |
-
//
|
282 |
if ( ! empty( $_POST['subscribe-reloaded'] ) && ! empty( $info->comment_author_email ) ) {
|
283 |
-
|
284 |
-
|
285 |
if ( in_array( $_POST['subscribe-reloaded'], array( 'replies', 'digest', 'yes' ) ) ) {
|
286 |
|
|
|
287 |
switch ($_POST['subscribe-reloaded']) {
|
288 |
case 'replies':
|
289 |
$status = 'R';
|
@@ -296,47 +392,64 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
296 |
break;
|
297 |
}
|
298 |
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
301 |
$this->sendConfirmationEMail($info);
|
302 |
$status = "{$status}C";
|
303 |
-
|
304 |
|
|
|
305 |
$this->add_subscription($info->comment_post_ID, $info->comment_author_email, $status);
|
306 |
|
307 |
-
//
|
308 |
-
if ($info->comment_approved == 0) {
|
309 |
-
//don't send notification-emails to all subscribed users
|
310 |
return $_comment_ID;
|
311 |
-
|
312 |
-
|
313 |
-
|
|
|
|
|
|
|
314 |
}
|
315 |
|
316 |
-
//
|
317 |
if ( $info->comment_approved == 1 ) {
|
|
|
|
|
318 |
$subscriptions = $this->get_subscriptions(
|
319 |
array(
|
320 |
'post_id',
|
321 |
'status'
|
322 |
-
),
|
323 |
-
|
324 |
-
|
325 |
-
|
|
|
|
|
326 |
$info->comment_post_ID,
|
327 |
'Y'
|
328 |
)
|
329 |
);
|
330 |
-
|
|
|
331 |
if ( ! empty( $info->comment_parent ) ) {
|
|
|
|
|
332 |
$subscriptions = array_merge(
|
333 |
-
$subscriptions,
|
334 |
-
|
335 |
-
|
336 |
-
|
|
|
|
|
|
|
|
|
337 |
)
|
338 |
-
)
|
339 |
);
|
|
|
340 |
}
|
341 |
|
342 |
// post author info
|
@@ -363,7 +476,7 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
363 |
|
364 |
}
|
365 |
|
366 |
-
//
|
367 |
if ( ! $post_author_notified && get_option( 'subscribe_reloaded_notify_authors', 'no' ) == 'yes' ) {
|
368 |
|
369 |
// send email to author unless the author made the comment
|
@@ -375,151 +488,204 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
375 |
|
376 |
}
|
377 |
|
|
|
378 |
return $_comment_ID;
|
|
|
379 |
}
|
380 |
|
381 |
-
|
382 |
-
|
|
|
|
|
|
|
|
|
383 |
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
385 |
|
386 |
$approved_subscriptions = $this->get_subscriptions(
|
387 |
array(
|
388 |
'status',
|
389 |
'email'
|
|
|
|
|
|
|
|
|
390 |
), array(
|
391 |
-
'equals',
|
392 |
-
'equals'
|
393 |
-
), array(
|
394 |
'Y',
|
395 |
$info->comment_author_email
|
396 |
)
|
397 |
);
|
398 |
|
399 |
-
//
|
400 |
-
foreach ( $approved_subscriptions as $subscription )
|
401 |
-
|
402 |
-
if ( $info->comment_post_ID == $subscription->post_id )
|
403 |
-
{
|
404 |
$is_subscribe_to_post = true;
|
405 |
}
|
406 |
}
|
407 |
|
408 |
-
|
|
|
409 |
return true;
|
410 |
} else {
|
411 |
return false;
|
412 |
}
|
413 |
-
}
|
414 |
-
|
415 |
|
|
|
416 |
|
417 |
/**
|
418 |
-
*
|
|
|
|
|
419 |
*/
|
420 |
public function comment_status_changed( $_comment_ID = 0, $_comment_status = 0 ) {
|
421 |
-
|
|
|
422 |
$info = $this->_get_comment_object( $_comment_ID );
|
|
|
|
|
423 |
if ( empty( $info ) ) {
|
424 |
return $_comment_ID;
|
425 |
}
|
426 |
|
|
|
427 |
switch ( $info->comment_approved ) {
|
428 |
-
|
|
|
|
|
|
|
429 |
$this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, 'C' );
|
430 |
break;
|
431 |
|
432 |
-
|
|
|
|
|
433 |
$this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, '-C' );
|
|
|
|
|
434 |
$subscriptions = $this->get_subscriptions(
|
435 |
array(
|
436 |
'post_id',
|
437 |
'status'
|
438 |
), array(
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
$info->comment_post_ID,
|
443 |
'Y'
|
444 |
)
|
445 |
);
|
|
|
446 |
if ( ! empty( $info->comment_parent ) ) {
|
|
|
447 |
$subscriptions = array_merge(
|
448 |
$subscriptions, $this->get_subscriptions(
|
449 |
-
|
450 |
-
|
451 |
-
|
|
|
|
|
|
|
452 |
)
|
453 |
-
)
|
454 |
);
|
|
|
455 |
}
|
456 |
|
|
|
457 |
foreach ( $subscriptions as $a_subscription ) {
|
458 |
-
|
459 |
-
|
|
|
460 |
$this->notify_user( $info->comment_post_ID, $a_subscription->email, $_comment_ID );
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
break;
|
464 |
|
465 |
case 'trash':
|
|
|
466 |
case 'spam':
|
|
|
|
|
467 |
$this->comment_deleted( $_comment_ID );
|
468 |
break;
|
469 |
|
470 |
default:
|
471 |
break;
|
|
|
472 |
}
|
473 |
|
|
|
474 |
return $_comment_ID;
|
|
|
475 |
}
|
476 |
-
// end comment_status
|
477 |
|
478 |
/**
|
479 |
-
*
|
|
|
|
|
480 |
*/
|
481 |
public function comment_deleted( $_comment_ID ) {
|
|
|
482 |
global $wpdb;
|
483 |
|
|
|
484 |
$info = $this->_get_comment_object( $_comment_ID );
|
|
|
|
|
485 |
if ( empty( $info ) ) {
|
486 |
return $_comment_ID;
|
487 |
}
|
488 |
|
489 |
-
//
|
490 |
$count_approved_comments = $wpdb->get_var(
|
491 |
-
"
|
492 |
-
|
493 |
-
|
494 |
-
|
|
|
495 |
);
|
|
|
|
|
496 |
if ( intval( $count_approved_comments ) == 0 ) {
|
497 |
$this->delete_subscriptions( $info->comment_post_ID, $info->comment_author_email );
|
498 |
}
|
499 |
|
|
|
500 |
return $_comment_ID;
|
501 |
}
|
502 |
-
// end comment_deleted
|
503 |
|
504 |
/**
|
505 |
-
*
|
|
|
|
|
506 |
*/
|
507 |
public function subscribe_post_author( $_post_ID ) {
|
|
|
508 |
$new_post = get_post( $_post_ID );
|
509 |
$author_email = get_the_author_meta( 'user_email', $new_post->post_author );
|
|
|
510 |
if ( ! empty( $author_email ) ) {
|
511 |
$this->add_subscription( $_post_ID, $author_email, 'Y' );
|
512 |
}
|
513 |
-
|
514 |
-
|
515 |
|
516 |
/**
|
517 |
* Displays the appropriate management page
|
|
|
|
|
518 |
*/
|
519 |
public function subscribe_reloaded_manage( $_posts = '', $_query = '' ) {
|
520 |
|
|
|
521 |
global $current_user;
|
522 |
-
$stcr_unique_key = get_option(
|
523 |
$date = date_i18n( 'Y-m-d H:i:s' );
|
524 |
$error_exits = false;
|
525 |
$email = '';
|
@@ -532,41 +698,51 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
532 |
|
533 |
try {
|
534 |
|
|
|
535 |
$post_ID = !empty($_POST['srp']) ? intval($_POST['srp']) : (!empty($_GET['srp']) ? intval($_GET['srp']) : 0);
|
536 |
|
537 |
-
//
|
538 |
$target_post = get_post($post_ID);
|
539 |
-
if (($post_ID > 0) && !is_object($target_post)) {
|
540 |
return $_posts;
|
541 |
}
|
542 |
|
|
|
543 |
$action = !empty($_POST['sra']) ? $_POST['sra'] : (!empty($_GET['sra']) ? $_GET['sra'] : 0);
|
544 |
$key = !empty($_POST['srk']) ? $_POST['srk'] : (!empty($_GET['srk']) ? $_GET['srk'] : 0);
|
545 |
$sre = !empty($_POST['sre']) ? $_POST['sre'] : (!empty($_GET['sre']) ? $_GET['sre'] : '');
|
546 |
$srek = !empty($_POST['srek']) ? $_POST['srek'] : (!empty($_GET['srek']) ? $_GET['srek'] : '');
|
547 |
$link_source = !empty($_POST['srsrc']) ? $_POST['srsrc'] : (!empty($_GET['srsrc']) ? $_GET['srsrc'] : '');
|
548 |
$key_expired = !empty($_POST['key_expired']) ? $_POST['key_expired'] : (!empty($_GET['key_expired']) ? $_GET['key_expired'] : '0');
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
|
|
|
|
|
|
553 |
$this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find an email with the SRE key: ( $srek )\n");
|
554 |
-
|
|
|
|
|
555 |
} else {
|
556 |
-
|
|
|
557 |
$email = '';
|
558 |
-
} else if ($email_by_key && !empty($email_by_key)) {
|
559 |
$email = $email_by_key;
|
560 |
-
} else if (!empty($sre)) {
|
561 |
$email = $this->utils->check_valid_email( $sre );
|
562 |
} else {
|
563 |
$email = '';
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
|
|
|
|
570 |
// or is wrong, in that case display the request management page template
|
571 |
if ($email !== "" && $key !== 0 && $stcr_unique_key !== $key || $key_expired == "1") {
|
572 |
if ($key_expired == "1") {
|
@@ -575,9 +751,11 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
575 |
$this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
|
576 |
$error_exits = true;
|
577 |
}
|
578 |
-
|
579 |
-
|
580 |
-
|
|
|
|
|
581 |
if ($email !== "" && $key !== 0 && !$this->utils->_is_valid_key($key, $email) || $key_expired == "1") {
|
582 |
if ($key_expired == "1") {
|
583 |
$error_exits = true;
|
@@ -585,26 +763,38 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
585 |
$this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
|
586 |
$error_exits = true;
|
587 |
}
|
588 |
-
|
|
|
589 |
}
|
590 |
|
|
|
591 |
if ($error_exits) {
|
592 |
-
|
|
|
|
|
593 |
} else {
|
594 |
-
|
595 |
-
|
|
|
|
|
596 |
($action == 's') &&
|
597 |
($post_ID > 0) &&
|
598 |
$key_expired != "1"
|
599 |
) {
|
600 |
-
|
601 |
-
|
602 |
-
|
|
|
|
|
|
|
603 |
$this->is_author($target_post->post_author)
|
604 |
) {
|
605 |
-
|
606 |
-
|
607 |
-
|
|
|
|
|
|
|
608 |
!empty($email) &&
|
609 |
!empty($key) &&
|
610 |
!empty($action) &&
|
@@ -613,8 +803,12 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
613 |
($action == 'c') &&
|
614 |
$key_expired != "1"
|
615 |
) {
|
616 |
-
|
617 |
-
|
|
|
|
|
|
|
|
|
618 |
!empty($email) &&
|
619 |
!empty($key) &&
|
620 |
!empty($action) &&
|
@@ -622,25 +816,37 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
622 |
($action == 'u') &&
|
623 |
$key_expired != "1"
|
624 |
) {
|
625 |
-
|
626 |
-
|
627 |
-
|
|
|
|
|
|
|
628 |
($key !== 0 && $this->utils->_is_valid_key($key, $email) || (!empty($current_user->data->user_email) && ($current_user->data->user_email === $email && current_user_can('read'))))
|
629 |
) {
|
630 |
-
|
631 |
-
|
|
|
|
|
|
|
|
|
632 |
($key === 0 && (!empty($current_user->data->user_email) && ($current_user->data->user_email !== $email)))
|
633 |
) {
|
634 |
-
|
|
|
|
|
635 |
}
|
636 |
|
|
|
637 |
if (empty($include_post_content)) {
|
638 |
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/request-management-link.php';
|
639 |
-
|
|
|
640 |
}
|
641 |
|
642 |
global $wp_query;
|
643 |
|
|
|
644 |
$manager_page_title = html_entity_decode(get_option('subscribe_reloaded_manager_page_title', 'Manage subscriptions'), ENT_QUOTES, 'UTF-8');
|
645 |
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
|
646 |
$manager_page_title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($manager_page_title);
|
@@ -648,6 +854,7 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
648 |
$manager_page_title = $manager_page_title;
|
649 |
}
|
650 |
|
|
|
651 |
$posts[] =
|
652 |
(object)array(
|
653 |
'ID' => '9999999',
|
@@ -690,124 +897,153 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
690 |
$wp_query->is_404 = false;
|
691 |
|
692 |
// Seems like WP adds its own HTML formatting code to the content, we don't need that here
|
693 |
-
|
|
|
694 |
// Look like the plugin is call twice and therefor subscribe to the "the_posts" filter again so we need to
|
695 |
// tell to WordPress to not register again.
|
696 |
remove_filter("the_posts", array($this, "subscribe_reloaded_manage"));
|
697 |
add_action('wp_head', array($this, 'add_custom_header_meta'));
|
698 |
|
699 |
-
|
700 |
-
catch(\Exception $ex)
|
701 |
-
|
702 |
$this->utils->stcr_logger( "\n [ERROR][$date] - $ex->getMessage()\n" );
|
703 |
-
|
|
|
704 |
}
|
705 |
|
|
|
706 |
return $posts;
|
|
|
707 |
}
|
708 |
-
|
709 |
/**
|
710 |
-
* Checks if current logged in user is the author
|
|
|
|
|
711 |
*/
|
712 |
public function is_author( $_post_author ) {
|
713 |
-
global $current_user;
|
714 |
|
|
|
715 |
return ! empty( $current_user ) && ( ( $_post_author == $current_user->ID ) || current_user_can( 'manage_options' ) );
|
|
|
716 |
}
|
717 |
-
// end is_author
|
718 |
|
719 |
/**
|
720 |
* Checks if a given email address is subscribed to a post
|
|
|
|
|
721 |
*/
|
722 |
public function is_user_subscribed( $_post_ID = 0, $_email = '', $_status = '' ) {
|
|
|
723 |
global $current_user;
|
724 |
|
|
|
725 |
if ( ( empty( $current_user->user_email ) && empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) && empty( $_email ) ) || empty( $_post_ID ) ) {
|
726 |
return false;
|
727 |
}
|
728 |
|
729 |
-
$operator
|
|
|
|
|
730 |
$subscriptions = $this->get_subscriptions(
|
731 |
array(
|
732 |
'post_id',
|
733 |
'status'
|
|
|
|
|
|
|
|
|
734 |
), array(
|
735 |
-
'equals',
|
736 |
-
$operator
|
737 |
-
), array(
|
738 |
$_post_ID,
|
739 |
$_status
|
740 |
)
|
741 |
-
|
742 |
|
|
|
743 |
if ( empty( $_email ) ) {
|
744 |
$user_email = ! empty( $current_user->user_email ) ? $current_user->user_email : ( ! empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ? stripslashes( esc_attr( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) : '#undefined#' );
|
|
|
|
|
745 |
} else {
|
746 |
$user_email = $_email;
|
747 |
}
|
748 |
|
|
|
749 |
foreach ( $subscriptions as $a_subscription ) {
|
750 |
if ( $user_email == $a_subscription->email ) {
|
751 |
return true;
|
752 |
}
|
753 |
}
|
754 |
|
|
|
755 |
return false;
|
|
|
756 |
}
|
757 |
-
|
758 |
/**
|
759 |
* Adds a new subscription
|
|
|
|
|
760 |
*/
|
761 |
public function add_subscription( $_post_id = 0, $_email = '', $_status = 'Y' ) {
|
|
|
762 |
global $wpdb;
|
763 |
-
|
|
|
764 |
$target_post = get_post( $_post_id );
|
765 |
if ( ( $_post_id > 0 ) && ! is_object( $target_post ) ) {
|
766 |
return;
|
767 |
}
|
768 |
|
769 |
-
//
|
770 |
if ( ! in_array( $_status, array( 'Y', 'YC', 'R', 'RC', 'C', '-C' ) ) || empty( $_status ) ) {
|
771 |
return;
|
772 |
}
|
773 |
|
774 |
-
//
|
775 |
$dt = date_i18n( 'Y-m-d H:i:s' );
|
776 |
|
|
|
777 |
$clean_email = $this->utils->clean_email( $_email );
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
}
|
798 |
}
|
799 |
-
|
800 |
/**
|
801 |
* Deletes one or more subscriptions from the database
|
|
|
|
|
802 |
*/
|
803 |
public function delete_subscriptions( $_post_id = 0, $_email = '' ) {
|
|
|
804 |
global $wpdb;
|
|
|
805 |
$has_subscriptions = false;
|
806 |
|
|
|
807 |
if ( empty( $_post_id ) ) {
|
808 |
return 0;
|
809 |
}
|
810 |
|
|
|
811 |
$posts_where = '';
|
812 |
if ( ! is_array( $_post_id ) ) {
|
813 |
$posts_where = "post_id = " . intval( $_post_id );
|
@@ -815,16 +1051,16 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
815 |
foreach ( $_post_id as $a_post_id ) {
|
816 |
$posts_where .= "post_id = '" . intval( $a_post_id ) . "' OR ";
|
817 |
}
|
818 |
-
|
819 |
$posts_where = substr( $posts_where, 0, - 4 );
|
820 |
}
|
821 |
|
|
|
822 |
if ( ! empty( $_email ) ) {
|
823 |
$emails_where = '';
|
824 |
if ( ! is_array( $_email ) ) {
|
825 |
$emails_where = "meta_key = '_stcr@_" . $this->utils->clean_email( $_email ) . "'";
|
826 |
$has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $_email );
|
827 |
-
if( $has_subscriptions === false) {
|
828 |
$this->utils->remove_user_subscriber_table( $_email );
|
829 |
}
|
830 |
} else {
|
@@ -832,19 +1068,26 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
832 |
$emails_where .= "meta_key = '_stcr@_" . $this->utils->clean_email( $a_email ) . "' OR ";
|
833 |
// Deletion on every email on the subscribers table.
|
834 |
$has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $a_email );
|
835 |
-
if( $has_subscriptions === false ) {
|
836 |
$this->utils->remove_user_subscriber_table( $a_email );
|
837 |
}
|
838 |
}
|
839 |
|
840 |
$emails_where = substr( $emails_where, 0, - 4 );
|
841 |
}
|
|
|
|
|
842 |
return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE ($posts_where) AND ($emails_where)" );
|
|
|
843 |
} else {
|
|
|
|
|
844 |
return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%' AND ($posts_where)" );
|
|
|
845 |
}
|
|
|
846 |
}
|
847 |
-
|
848 |
/**
|
849 |
* The function must search for subscription by a given post id.
|
850 |
*
|
@@ -857,44 +1100,60 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
857 |
* if $in is false the it could return the subscriptions or false, false means not found
|
858 |
*/
|
859 |
public function retrieve_user_subscriptions( $_post_id, $_email, $in = false ) {
|
|
|
860 |
global $wpdb;
|
|
|
861 |
$meta_key = '_stcr@_';
|
862 |
$in_values = '';
|
863 |
|
|
|
864 |
if( ! is_array( $_post_id ) ){
|
|
|
865 |
if ( ! $in ) {
|
866 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id <> %d AND meta_key = %s";
|
867 |
} else if ( $in ) {
|
868 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s";
|
869 |
}
|
870 |
-
|
|
|
|
|
|
|
871 |
} else {
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
$in_values = implode( ",",$_post_id );
|
876 |
if ( ! $in ) {
|
877 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id NOT IN ($in_values) AND meta_key = %s";
|
878 |
} else if ( $in ) {
|
879 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id IN ($in_values) AND meta_key = %s";
|
880 |
}
|
881 |
-
|
|
|
|
|
882 |
}
|
883 |
|
884 |
return $result === false || $result == 0 || empty( $result ) ? false : $result;
|
|
|
885 |
}
|
|
|
886 |
/**
|
887 |
* Updates the status of an existing subscription
|
|
|
|
|
888 |
*/
|
889 |
public function update_subscription_status( $_post_id = 0, $_email = '', $_new_status = 'C' ) {
|
|
|
890 |
global $wpdb;
|
891 |
|
892 |
-
//
|
893 |
if ( empty( $_new_status ) || ! in_array( $_new_status, array( 'Y', 'R', 'C', '-C' ) ) || empty( $_email ) ) {
|
894 |
return 0;
|
895 |
}
|
896 |
|
|
|
897 |
if ( ! empty( $_post_id ) ) {
|
|
|
|
|
898 |
$posts_where = '';
|
899 |
if ( ! is_array( $_post_id ) ) {
|
900 |
$posts_where = "post_id = " . intval( $_post_id );
|
@@ -902,13 +1161,15 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
902 |
foreach ( $_post_id as $a_post_id ) {
|
903 |
$posts_where .= "post_id = '" . intval( $a_post_id ) . "' OR ";
|
904 |
}
|
905 |
-
|
906 |
$posts_where = substr( $posts_where, 0, - 4 );
|
907 |
}
|
908 |
-
|
|
|
|
|
909 |
$posts_where = '1=1';
|
910 |
}
|
911 |
|
|
|
912 |
$emails_where = '';
|
913 |
if ( ! is_array( $_email ) ) {
|
914 |
$emails_where = "meta_key = '_stcr@_" . $this->utils->clean_email( $_email ) . "'";
|
@@ -916,46 +1177,51 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
916 |
foreach ( $_email as $a_email ) {
|
917 |
$emails_where .= "meta_key = '_stcr@_" . $this->utils->clean_email( $a_email ) . "' OR ";
|
918 |
}
|
919 |
-
|
920 |
$emails_where = substr( $emails_where, 0, - 4 );
|
921 |
}
|
922 |
|
923 |
$meta_length = ( strpos( $_new_status, 'C' ) !== false ) ? 21 : 20;
|
924 |
$new_status = ( $_new_status == '-C' ) ? '' : $_new_status;
|
925 |
|
|
|
926 |
return $wpdb->query(
|
927 |
-
"
|
928 |
-
|
929 |
-
|
930 |
-
WHERE ($posts_where) AND ($emails_where)"
|
931 |
);
|
|
|
932 |
}
|
933 |
-
|
934 |
/**
|
935 |
* Updates the email address of an existing subscription
|
|
|
|
|
936 |
*/
|
937 |
public function update_subscription_email( $_post_id = 0, $_email = '', $_new_email = '' ) {
|
|
|
938 |
global $wpdb;
|
939 |
|
940 |
-
//
|
941 |
if ( empty( $_email ) || empty( $_new_email ) || strpos( $_new_email, '@' ) == 0 ) {
|
942 |
return;
|
943 |
}
|
944 |
|
|
|
945 |
$clean_values[] = "_stcr@_" . $this->utils->clean_email( $_new_email );
|
946 |
$clean_values[] = "_stcr@_" . $this->utils->clean_email( $_email );
|
947 |
-
|
|
|
|
|
948 |
if ( ! empty( $_post_id ) ) {
|
949 |
-
$post_where
|
950 |
$clean_values[] = $_post_id;
|
951 |
}
|
952 |
|
953 |
-
|
954 |
-
|
955 |
-
$clean_values )
|
956 |
-
);
|
957 |
|
958 |
-
|
|
|
959 |
$salt = time();
|
960 |
$rowsAffected = $wpdb->query(
|
961 |
$wpdb->prepare("UPDATE ". $wpdb->prefix .
|
@@ -966,13 +1232,18 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
966 |
$_new_email, $salt, $this->utils->generate_temp_key( $salt . $_new_email ),$_email )
|
967 |
);
|
968 |
}
|
|
|
969 |
return false;
|
|
|
970 |
}
|
971 |
-
|
972 |
/**
|
973 |
-
* Retrieves a list of emails subscribed to
|
|
|
|
|
974 |
*/
|
975 |
public function get_subscriptions( $_search_field = array( 'email' ), $_operator = array( 'equals' ), $_search_value = array( '' ), $_order_by = 'dt', $_order = 'ASC', $_offset = 0, $_limit_results = 0 ) {
|
|
|
976 |
global $wpdb;
|
977 |
|
978 |
// Type adjustments
|
@@ -992,26 +1263,28 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
992 |
// Check if $parent_comment_author_email has any Replies Only (R) subscriptions for $comment_post_id
|
993 |
|
994 |
/*
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
*/
|
1002 |
|
1003 |
return $wpdb->get_results(
|
1004 |
$wpdb->prepare(
|
1005 |
-
"
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
AND pm.post_id = %d", $parent_comment_author_email, $comment_post_id
|
1012 |
), OBJECT
|
1013 |
);
|
|
|
1014 |
} else {
|
|
|
|
|
1015 |
$where_clause = '';
|
1016 |
foreach ( $search_fields as $a_idx => $a_field ) {
|
1017 |
$where_clause .= ' AND';
|
@@ -1048,6 +1321,8 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1048 |
$where_values[] = "%{$search_values[$a_idx]}%";
|
1049 |
}
|
1050 |
}
|
|
|
|
|
1051 |
switch ( $_order_by ) {
|
1052 |
case 'status':
|
1053 |
$order_by = "status";
|
@@ -1063,67 +1338,72 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1063 |
}
|
1064 |
$order = ( $_order != 'ASC' && $_order != 'DESC' ) ? 'DESC' : $_order;
|
1065 |
|
1066 |
-
//
|
1067 |
$row_count = ( $_limit_results <= 0 ) ? '18446744073709551610' : $_limit_results;
|
1068 |
|
|
|
1069 |
return $wpdb->get_results(
|
1070 |
$wpdb->prepare(
|
1071 |
-
"
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
LIMIT $_offset,$row_count", $where_values
|
1078 |
), OBJECT
|
1079 |
);
|
|
|
1080 |
}
|
|
|
1081 |
}
|
1082 |
-
|
1083 |
/**
|
1084 |
* Sends the notification message to a given user
|
|
|
|
|
1085 |
*/
|
1086 |
public function notify_user( $_post_ID = 0, $_email = '', $_comment_ID = 0 ) {
|
|
|
|
|
1087 |
$post = get_post( $_post_ID );
|
1088 |
$comment = get_comment( $_comment_ID );
|
1089 |
$post_permalink = get_permalink( $_post_ID );
|
1090 |
$comment_permalink = get_comment_link( $_comment_ID );
|
1091 |
$comment_reply_permalink = get_permalink( $_post_ID ) . '?replytocom=' . $_comment_ID . '#respond';
|
1092 |
$info = $this->_get_comment_object( $_comment_ID );
|
1093 |
-
|
1094 |
// WPML compatibility
|
1095 |
if ( defined('ICL_SITEPRESS_VERSION') && defined('ICL_LANGUAGE_CODE') ) {
|
1096 |
-
// Switch language
|
1097 |
global $sitepress;
|
1098 |
$language = $sitepress->get_language_for_element( $_post_ID, 'post_' . $post->post_type );
|
1099 |
$sitepress->switch_lang($language);
|
1100 |
}
|
1101 |
|
|
|
1102 |
$subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_subject', 'There is a new comment on the post [post_title]' ) ), ENT_QUOTES, 'UTF-8' );
|
1103 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_content', '' ) ), ENT_QUOTES, 'UTF-8' );
|
1104 |
$manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
|
1105 |
$one_click_unsubscribe_link = $manager_link;
|
1106 |
|
|
|
1107 |
if ( function_exists( 'qtrans_convertURL' ) ) {
|
1108 |
$manager_link = qtrans_convertURL( $manager_link );
|
1109 |
}
|
1110 |
|
|
|
1111 |
$clean_email = $this->utils->clean_email( $_email );
|
1112 |
$subscriber_salt = $this->utils->generate_temp_key( $clean_email );
|
1113 |
-
|
1114 |
$manager_link .= ( ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?' )
|
1115 |
. "srek=" . $this->utils->get_subscriber_key( $clean_email )
|
1116 |
. "&srk=$subscriber_salt";
|
1117 |
$one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' )
|
1118 |
. "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=$subscriber_salt"
|
1119 |
. "&sra=u&srsrc=e" . "&srp=" . $_post_ID;
|
1120 |
-
|
1121 |
$comment_content = $comment->comment_content;
|
1122 |
|
1123 |
-
//
|
1124 |
$subject = str_replace( '[post_title]', $post->post_title, $subject );
|
1125 |
$subject = str_replace( '[blog_name]' , get_bloginfo('name'), $subject );
|
1126 |
-
|
1127 |
$message = str_replace( '[post_permalink]', $post_permalink, $message );
|
1128 |
$message = str_replace( '[comment_permalink]', $comment_permalink, $message );
|
1129 |
$message = str_replace( '[comment_reply_permalink]', $comment_reply_permalink, $message );
|
@@ -1133,7 +1413,7 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1133 |
$message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $message );
|
1134 |
$message = str_replace( '[comment_gravatar]', get_avatar($info->comment_author_email, 40), $message );
|
1135 |
|
1136 |
-
//
|
1137 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
1138 |
$subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
|
1139 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $post->post_title ), $message );
|
@@ -1141,8 +1421,10 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1141 |
} else {
|
1142 |
$message = str_replace( '[post_title]', $post->post_title, $message );
|
1143 |
}
|
|
|
1144 |
$message = apply_filters( 'stcr_notify_user_message', $message, $_post_ID, $clean_email, $_comment_ID );
|
1145 |
-
|
|
|
1146 |
$email_settings = array(
|
1147 |
'subject' => $subject,
|
1148 |
'message' => $message,
|
@@ -1150,21 +1432,26 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1150 |
'XPostId' => $_post_ID,
|
1151 |
'XCommentId' => $_comment_ID
|
1152 |
);
|
|
|
|
|
1153 |
$this->utils->send_email( $email_settings );
|
|
|
1154 |
}
|
1155 |
-
|
1156 |
/**
|
1157 |
* Displays the checkbox to allow visitors to subscribe
|
|
|
|
|
1158 |
*/
|
1159 |
-
function subscribe_reloaded_show($submit_field = '' ) {
|
1160 |
|
1161 |
-
// echo on action
|
1162 |
-
// return on filter
|
1163 |
$echo = false;
|
1164 |
if ( doing_action( 'comment_form' ) ) {
|
1165 |
$echo = true;
|
1166 |
}
|
1167 |
|
|
|
1168 |
global $post, $wp_subscribe_reloaded;
|
1169 |
$checkbox_subscription_type = null;
|
1170 |
$_comment_ID = null;
|
@@ -1173,7 +1460,7 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1173 |
$post_type = get_post_type( $post->ID );
|
1174 |
$only_for_posts = get_option( 'subscribe_reloaded_only_for_posts', 'no' );
|
1175 |
|
1176 |
-
// if not enabled for this post type, return
|
1177 |
if ( $only_for_posts == 'yes' && $post_type !== 'post' ) {
|
1178 |
if ( $echo ) {
|
1179 |
echo $submit_field;
|
@@ -1183,37 +1470,45 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1183 |
return;
|
1184 |
}
|
1185 |
|
1186 |
-
//
|
1187 |
-
|
1188 |
wp_enqueue_style( 'stcr-plugin-style' );
|
1189 |
|
|
|
1190 |
$is_disabled = get_post_meta( $post->ID, 'stcr_disable_subscriptions', true );
|
1191 |
if ( ! empty( $is_disabled ) ) {
|
1192 |
return $_comment_ID;
|
1193 |
}
|
1194 |
|
|
|
1195 |
$show_subscription_box = true;
|
1196 |
$html_to_show = '';
|
1197 |
$user_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '' );
|
1198 |
|
|
|
1199 |
if ( function_exists( 'qtrans_convertURL' ) ) {
|
1200 |
$user_link = qtrans_convertURL( $user_link );
|
1201 |
}
|
1202 |
|
|
|
1203 |
$manager_link = ( strpos( $user_link, '?' ) !== false ) ?
|
1204 |
"$user_link&srp=$post->ID&srk=" . get_option( 'subscribe_reloaded_unique_key' ) :
|
1205 |
"$user_link?srp=$post->ID&srk=" . get_option( 'subscribe_reloaded_unique_key' );
|
1206 |
|
|
|
1207 |
$user_link = ( strpos( $user_link, '?' ) !== false ) ?
|
1208 |
"$user_link&" . $post_permalink :
|
1209 |
"$user_link?" . $post_permalink;
|
1210 |
|
|
|
1211 |
if ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '', 'C' ) ) {
|
1212 |
$html_to_show = str_replace(
|
1213 |
'[manager_link]', $user_link,
|
1214 |
html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribed_waiting_label', __( "Your subscription to this post needs to be confirmed. <a href='[manager_link]'>Manage your subscriptions</a>.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
|
1215 |
);
|
1216 |
$show_subscription_box = false;
|
|
|
|
|
1217 |
} elseif ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '' ) ) {
|
1218 |
$html_to_show = str_replace(
|
1219 |
'[manager_link]', $user_link ,
|
@@ -1222,7 +1517,8 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1222 |
$show_subscription_box = false;
|
1223 |
}
|
1224 |
|
1225 |
-
|
|
|
1226 |
if ( get_option( 'subscribe_reloaded_admin_subscribe', 'no' ) == 'no' ) {
|
1227 |
$show_subscription_box = false;
|
1228 |
}
|
@@ -1233,16 +1529,24 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1233 |
);
|
1234 |
}
|
1235 |
|
|
|
1236 |
if ( $show_subscription_box ) {
|
1237 |
-
|
|
|
|
|
1238 |
'[subscribe_link]', "$manager_link&sra=s&srsrc=f",
|
1239 |
html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_label', __( "Notify me of followup comments via e-mail. You can also <a href='[subscribe_link]'>subscribe</a> without commenting.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
|
1240 |
);
|
|
|
|
|
1241 |
$checkbox_inline_style = get_option( 'subscribe_reloaded_checkbox_inline_style', 'width:30px' );
|
1242 |
if ( ! empty( $checkbox_inline_style ) ) {
|
1243 |
$checkbox_inline_style = " style='$checkbox_inline_style'";
|
1244 |
}
|
|
|
1245 |
$checkbox_html_wrap = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_html', '' ) ), ENT_QUOTES, 'UTF-8' );
|
|
|
|
|
1246 |
if ( get_option( 'subscribe_reloaded_enable_advanced_subscriptions', 'no' ) == 'no' ) {
|
1247 |
switch ( get_option( 'subscribe_reloaded_checked_by_default_value' ) ) {
|
1248 |
case '0':
|
@@ -1253,6 +1557,8 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1253 |
break;
|
1254 |
}
|
1255 |
$checkbox_field = "<input$checkbox_inline_style type='checkbox' name='subscribe-reloaded' id='subscribe-reloaded' value='$checkbox_subscription_type'" . ( ( get_option( 'subscribe_reloaded_checked_by_default', 'no' ) == 'yes' ) ? " checked='checked'" : '' ) . " />";
|
|
|
|
|
1256 |
} else {
|
1257 |
$checkbox_field = "<select name='subscribe-reloaded' id='subscribe-reloaded'>
|
1258 |
<option value='none' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '0' ) ? "selected='selected'" : '' ) . ">" . __( "Don't subscribe", 'subscribe-to-comments-reloaded' ) . "</option>
|
@@ -1260,16 +1566,21 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1260 |
<option value='replies' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '2' ) ? "selected='selected'" : '' ) . ">" . __( "Replies to my comments", 'subscribe-to-comments-reloaded' ) . "</option>
|
1261 |
</select>";
|
1262 |
}
|
|
|
1263 |
if ( empty( $checkbox_html_wrap ) ) {
|
1264 |
$html_to_show = "$checkbox_field <label for='subscribe-reloaded'>$checkbox_label</label>" . $html_to_show;
|
1265 |
} else {
|
1266 |
$checkbox_html_wrap = str_replace( '[checkbox_field]', $checkbox_field, $checkbox_html_wrap );
|
1267 |
$html_to_show = str_replace( '[checkbox_label]', $checkbox_label, $checkbox_html_wrap ) . $html_to_show;
|
1268 |
}
|
|
|
1269 |
}
|
|
|
|
|
1270 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
1271 |
$html_to_show = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $html_to_show );
|
1272 |
}
|
|
|
1273 |
$output = '';
|
1274 |
// Check for the Comment Form location
|
1275 |
if( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
|
@@ -1286,16 +1597,22 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1286 |
$output .= "<!-- BEGIN: subscribe to comments reloaded -->" . $html_to_show . "<!-- END: subscribe to comments reloaded -->";
|
1287 |
}
|
1288 |
|
|
|
1289 |
if ( $echo ) {
|
1290 |
echo $output . $submit_field;
|
1291 |
} else {
|
1292 |
return $output . $submit_field;
|
1293 |
}
|
1294 |
|
1295 |
-
}
|
1296 |
|
1297 |
-
|
1298 |
-
|
|
|
|
|
|
|
|
|
|
|
1299 |
$subscribe_to_comments_action = ! empty( $_POST['sra'] ) ? $_POST['sra'] : ( ! empty( $_GET['sra'] ) ? $_GET['sra'] : 0 );
|
1300 |
$subscribe_to_comments_post_ID = ! empty( $_POST['srp'] ) ? intval( $_POST['srp'] ) : ( ! empty( $_GET['srp'] ) ? intval( $_GET['srp'] ) : 0 );
|
1301 |
|
@@ -1319,5 +1636,28 @@ if(!class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded')) {
|
|
1319 |
|
1320 |
}
|
1321 |
|
1322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1323 |
}
|
1 |
<?php
|
2 |
namespace stcr;
|
3 |
+
|
4 |
// Avoid direct access to this piece of code
|
5 |
if ( ! function_exists( 'add_action' ) ) {
|
6 |
header( 'Location: /' );
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
+
// globals
|
11 |
+
define( __NAMESPACE__.'\\VERSION','191009' );
|
12 |
+
define( __NAMESPACE__.'\\DEVELOPMENT', false );
|
13 |
define( __NAMESPACE__.'\\SLUG', "subscribe-to-comments-reloaded" );
|
14 |
|
15 |
+
// load files
|
16 |
require_once dirname(__FILE__).'/utils/stcr_manage.php';
|
17 |
require_once dirname(__FILE__).'/classes/stcr_i18n.php';
|
18 |
|
19 |
+
// Main plugin class
|
20 |
+
if( ! class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded') ) {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Main plugin class
|
24 |
+
*
|
25 |
+
* __construct ( Constructor )
|
26 |
+
* add_test_subscriptions ( Adds subscriptions for testing purposes )
|
27 |
+
* define_wp_hooks ( Define the WordPress Hooks that will be used by the plugin. )
|
28 |
+
* display_admin_header ( Display admin header menu )
|
29 |
+
* subscribe_reloaded_load_plugin_textdomain ( Load localization files )
|
30 |
+
* plugin_settings_link ( Add Settings link to plugin on plugins page )
|
31 |
+
* _get_comment_object ( Retrieves the comment information from the database )
|
32 |
+
* new_comment_posted ( Takes the appropriate action, when a new comment is posted )
|
33 |
+
* is_double_check_enabled ( Is double check ( subscriptions need to be confirmed ) enabled )
|
34 |
+
* comment_status_changed ( Actions when comments status changes ( approve/unapprove/spam/trash ) )
|
35 |
+
* comment_deleted ( Actions when comment is deleted )
|
36 |
+
* subscribe_post_author ( Subscribe the post author )
|
37 |
+
* subscribe_reloaded_manage ( Displays the appropriate management page )
|
38 |
+
* is_author ( Checks if current logged in user is the author )
|
39 |
+
* is_user_subscribed ( Checks if a given email address is subscribed to a post )
|
40 |
+
* add_subscription ( Adds a new subscription )
|
41 |
+
* delete_subscriptions ( Deletes one or more subscriptions from the database )
|
42 |
+
* retrieve_user_subscriptions ( Retries user subscriptions by post ID )
|
43 |
+
* update_subscription_status ( Updates the status of an existing subscription )
|
44 |
+
* update_subscription_email ( Updates the email address of an existing subscription )
|
45 |
+
* get_subscriptions ( Retrieves a list of emails subscribed to a specific post )
|
46 |
+
* notify_user ( Sends the notification message to a given user )
|
47 |
+
* subscribe_reloaded_show ( Displays the checkbox to allow visitors to subscribe )
|
48 |
+
* set_user_cookie ( Set a cookie if the user just subscribed without commenting )
|
49 |
+
* management_page_sc ( Management page shortcode )
|
50 |
+
* comment_content_prepend ( Add custom content before comment content )
|
51 |
+
*/
|
52 |
class wp_subscribe_reloaded extends stcr_manage {
|
53 |
+
|
54 |
+
public $stcr_i18n;
|
55 |
+
|
56 |
/**
|
57 |
+
* Constructor
|
58 |
*/
|
59 |
public function __construct() {
|
60 |
|
61 |
+
// run parent constructor.
|
62 |
+
parent::__construct();
|
63 |
|
64 |
$this->salt = defined( 'NONCE_KEY' ) ? NONCE_KEY : 'please create a unique key in your wp-config.php';
|
65 |
|
66 |
+
// show the checkbox - You can manually override this by adding the corresponding function in your template
|
67 |
+
if ( get_option( 'subscribe_reloaded_show_subscription_box' ) === 'yes' ) {
|
68 |
+
if( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
|
|
|
|
|
69 |
add_action( 'comment_form', array($this, 'subscribe_reloaded_show'), 5, 0 );
|
70 |
+
} else {
|
|
|
|
|
71 |
add_filter( 'comment_form_submit_field', array($this, 'subscribe_reloaded_show'), 5, 1 );
|
72 |
}
|
|
|
73 |
}
|
74 |
|
75 |
$this->maybe_update();
|
76 |
|
77 |
+
// define WordPress hooks the plugin uses
|
78 |
$this->define_wp_hooks();
|
79 |
|
80 |
+
// localization
|
81 |
+
$this->stcr_i18n = new stcr_i18n();
|
82 |
|
83 |
+
// add subscriptions for tests
|
84 |
+
if ( DEVELOPMENT ) {
|
85 |
+
$this->add_test_subscriptions( 10000, 18,'Y', 'dev', 30);
|
|
|
86 |
}
|
87 |
|
88 |
+
// management page shortcode
|
89 |
add_shortcode( 'stcr_management_page', array( $this, 'management_page_sc' ) );
|
90 |
|
91 |
}
|
92 |
|
93 |
+
/**
|
94 |
+
* Adds subscriptions for testing purposes
|
95 |
+
*
|
96 |
+
* @since 190705
|
97 |
+
*/
|
98 |
+
public function add_test_subscriptions( $iterations = 1 ,$post_id, $status = 'Y', $email_prefix = 'dev', $last_id_subs = 0 ) {
|
99 |
+
for ( $i = $last_id_subs+1; $i <= $iterations; $i++) {
|
100 |
+
$this->add_subscription( $post_id, "{$email_prefix}_{$i}@dev.com", $status );
|
101 |
}
|
102 |
+
}
|
103 |
+
|
104 |
/**
|
105 |
+
* Define the WordPress Hooks that will be used by the plugin.
|
106 |
*
|
107 |
+
* @since 180302
|
|
|
108 |
*/
|
109 |
+
public function define_wp_hooks() {
|
110 |
+
|
111 |
+
// new comment posted
|
112 |
+
add_action( 'comment_post', array( $this, 'new_comment_posted' ), 12, 2 );
|
113 |
+
|
114 |
+
// add hook for the subscribe_reloaded_purge, define on the constructure so that the hook is read on time.
|
115 |
add_action('_cron_subscribe_reloaded_purge', array($this, 'subscribe_reloaded_purge'), 10 );
|
116 |
add_action('_cron_log_file_purge', array($this, 'log_file_purge'), 10 );
|
117 |
|
118 |
+
// load text domain
|
119 |
add_action( 'plugins_loaded', array( $this, 'subscribe_reloaded_load_plugin_textdomain' ) );
|
120 |
|
121 |
+
// front end
|
122 |
if ( ! is_admin() ) {
|
123 |
|
124 |
+
// management page permalink
|
125 |
$manager_page_permalink = get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
|
126 |
if ( function_exists( 'qtrans_convertURL' ) ) {
|
127 |
$manager_page_permalink = qtrans_convertURL( $manager_page_permalink );
|
128 |
}
|
129 |
+
|
130 |
+
// management page permalink fallback
|
131 |
if ( empty( $manager_page_permalink ) ) {
|
|
|
132 |
$manager_page_permalink = '/comment-subscriptions/';
|
133 |
}
|
134 |
|
135 |
+
// if we are on the management page, filter the_posts
|
136 |
if ( ( strpos( $_SERVER["REQUEST_URI"], $manager_page_permalink ) !== false ) ) {
|
137 |
add_filter( 'the_posts', array( $this, 'subscribe_reloaded_manage' ), 10, 2 );
|
138 |
+
}
|
139 |
+
|
140 |
+
// filter to add custom output before comment content
|
141 |
+
add_filter( 'comment_text', array( $this, 'comment_content_prepend' ), 10, 2 );
|
142 |
|
143 |
+
// enqueue scripts
|
144 |
$this->utils->hook_plugin_scripts();
|
145 |
+
|
146 |
+
// wp admin
|
147 |
} else {
|
148 |
+
|
149 |
+
// hook for WPMU - new blog created
|
150 |
add_action( 'wpmu_new_blog', array( $this, 'new_blog' ), 10, 1 );
|
151 |
|
152 |
+
// remove subscriptions for post that is being deleted
|
153 |
add_action( 'delete_post', array( $this, 'delete_subscriptions' ), 10, 2 );
|
154 |
|
155 |
+
// remove subscriptions when a comment is deleted or status changed
|
156 |
add_action( 'deleted_comment', array( $this, 'comment_deleted' ) );
|
157 |
+
add_action( 'wp_set_comment_status', array( $this, 'comment_status_changed' ) );
|
158 |
+
|
159 |
+
// new columns in post/comment tables ( WP admin > Posts and WP admin > Comments )
|
160 |
add_filter( 'manage_edit-comments_columns', array( $this, 'add_column_header' ) );
|
161 |
add_filter( 'manage_posts_columns', array( $this, 'add_column_header' ) );
|
162 |
add_action( 'manage_comments_custom_column', array( $this, 'add_comment_column' ) );
|
167 |
add_action( 'admin_print_styles-edit-comments.php', array( $this, 'add_post_comments_stylesheet' ) );
|
168 |
add_action( 'admin_print_styles-edit.php', array( $this, 'add_post_comments_stylesheet' ) );
|
169 |
|
170 |
+
// admin header
|
171 |
add_action( 'in_admin_header', array( $this, 'display_admin_header' ), 100 );
|
172 |
|
173 |
+
// admin init
|
174 |
+
add_action( 'admin_init', array( $this, 'stcr_admin_init' ) );
|
175 |
+
|
176 |
+
// admin notices
|
177 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
178 |
|
179 |
+
// contextual help
|
180 |
add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 );
|
181 |
|
182 |
+
// shortcodes to use the management URL sitewide
|
183 |
add_shortcode( 'subscribe-url', array( $this, 'subscribe_url_shortcode' ) );
|
184 |
|
185 |
+
// action links for listing on WP admin > Plugins
|
186 |
+
add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
|
187 |
+
|
188 |
+
// subscribe post authors, if auto subscribe for authors enabled
|
189 |
if ( get_option( 'subscribe_reloaded_notify_authors' ) === 'yes' ) {
|
190 |
add_action( 'publish_post', array( $this, 'subscribe_post_author' ) );
|
191 |
+
}
|
192 |
+
|
193 |
+
// enqueue scripts
|
194 |
$this->utils->hook_admin_scripts();
|
195 |
|
196 |
+
// ajax for admin notices ( mark as read )
|
197 |
$this->utils->stcr_create_ajax_notices();
|
198 |
|
199 |
+
// download system information file
|
200 |
add_action( 'admin_init', array( $this, 'sysinfo_download' ) );
|
201 |
|
202 |
+
}
|
203 |
+
|
204 |
}
|
205 |
|
206 |
+
/**
|
207 |
+
* Display the admin header menu
|
208 |
+
*
|
209 |
+
* @since 190705 Cleanup
|
210 |
+
*/
|
211 |
+
public function display_admin_header () {
|
212 |
+
|
213 |
+
global $wp_locale;
|
214 |
+
|
215 |
+
$slug = 'stcr_manage_subscriptions';
|
216 |
+
$current_page = isset( $_GET['page'] ) ? $_GET['page'] : '';
|
217 |
+
|
218 |
+
// define the menu items
|
219 |
$array_pages = array(
|
220 |
+
'stcr_manage_subscriptions' => __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ),
|
221 |
+
'stcr_comment_form' => __( 'Comment Form', 'subscribe-to-comments-reloaded' ),
|
222 |
+
'stcr_management_page' => __( 'Management Page', 'subscribe-to-comments-reloaded' ),
|
223 |
+
'stcr_notifications' => __( 'Notifications', 'subscribe-to-comments-reloaded' ),
|
224 |
+
'stcr_options' => __( 'Options', 'subscribe-to-comments-reloaded' ),
|
225 |
+
'stcr_support' => __( 'Support', 'subscribe-to-comments-reloaded' ),
|
226 |
+
'stcr_system' => __( 'Options', 'subscribe-to-comments-reloaded' )
|
227 |
);
|
228 |
|
229 |
+
// do not proceed if not on a STCR admin page
|
|
|
230 |
if ( ! array_key_exists( $current_page, $array_pages) ) {
|
231 |
return;
|
232 |
}
|
234 |
?>
|
235 |
|
236 |
<nav class="navbar navbar-expand-lg navbar-light bg-light <?php echo $wp_locale->text_direction ?>">
|
237 |
+
|
238 |
+
<a class="navbar-brand"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/stcr-logo-150.png" alt="" width="25" height="19"></a>
|
239 |
+
|
240 |
+
<div class="collapse navbar-collapse">
|
241 |
+
|
242 |
<ul class="navbar-nav">
|
243 |
+
|
244 |
+
<?php
|
245 |
+
|
246 |
+
// go through each stcr admin page
|
247 |
+
foreach ( $array_pages as $page => $page_desc ) :
|
248 |
+
|
249 |
+
// skip strc_system because it's added as part of stcr_options
|
250 |
+
if ( $page == 'stcr_system' ) continue;
|
251 |
+
|
252 |
+
?><li class="<?php echo $page == 'stcr_options' ? 'dropdown' : ''; ?>"><?php
|
253 |
+
|
254 |
+
// dropdrown for options menu item
|
255 |
+
if ( $page == 'stcr_options' ) :
|
256 |
+
|
257 |
+
?>
|
258 |
+
<a
|
259 |
+
class="nav-link dropdown-toggle <?php echo ( $current_page == $page || $current_page == 'stcr_system' ? ' stcr-active-tab' : '' ); ?>"
|
260 |
+
style="padding: 5px 12px 0 0;"
|
261 |
+
href="#"
|
262 |
+
id="navbarDropdown"
|
263 |
+
role="button"
|
264 |
+
data-toggle="dropdown"
|
265 |
+
aria-haspopup="true"
|
266 |
+
aria-expanded="false">
|
267 |
+
<?php echo $page_desc; ?>
|
268 |
+
</a>
|
269 |
+
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
270 |
+
<a class="dropdown-item" href="admin.php?page=<?php echo $page; ?>"><?php echo __('StCR Options', 'subscribe-to-comments-reloaded'); ?></a>
|
271 |
+
<div class="dropdown-divider"></div>
|
272 |
+
<a class="dropdown-item" href="admin.php?page=stcr_system"><?php echo __('StCR System', 'subscribe-to-comments-reloaded'); ?></a>
|
273 |
+
</div>
|
274 |
+
<?php
|
275 |
+
|
276 |
+
// regular menu items
|
277 |
+
else :
|
278 |
+
|
279 |
+
?>
|
280 |
+
<a
|
281 |
+
class="navbar-brand <?php echo ( $current_page == $page ) ? ' stcr-active-tab' : ''; ?>"
|
282 |
+
href="admin.php?page=<?php echo $page; ?>">
|
283 |
+
<?php echo $page_desc; ?>
|
284 |
+
</a>
|
285 |
+
<?php
|
286 |
+
|
287 |
+
endif;
|
288 |
+
|
289 |
+
?></li><?php
|
290 |
+
|
291 |
+
endforeach;
|
292 |
+
|
293 |
+
?>
|
294 |
+
|
295 |
+
</ul><!-- .navbar-nav -->
|
296 |
+
|
297 |
+
</div><!-- .navbar-collapse -->
|
298 |
+
|
299 |
+
</nav><!-- .navbar -->
|
300 |
+
<?php
|
301 |
+
|
302 |
}
|
303 |
|
304 |
/**
|
305 |
* Load localization files
|
306 |
+
*
|
307 |
+
* @since 190705 cleanup
|
308 |
*/
|
309 |
function subscribe_reloaded_load_plugin_textdomain() {
|
310 |
+
|
311 |
+
load_plugin_textdomain( 'subscribe-to-comments-reloaded', FALSE, SLUG . '/langs/' );
|
312 |
+
|
313 |
}
|
314 |
|
315 |
+
/**
|
316 |
* Add Settings link to plugin on plugins page
|
317 |
+
*
|
318 |
+
* @since 190705 cleanup
|
319 |
*/
|
320 |
public function plugin_settings_link( $links, $file ) {
|
321 |
+
|
322 |
if ( $file == 'subscribe-to-comments-reloaded/subscribe-to-comments-reloaded.php' ) {
|
323 |
$links['settings'] = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
|
324 |
}
|
325 |
|
326 |
return $links;
|
327 |
+
|
328 |
}
|
329 |
|
330 |
/**
|
331 |
* Retrieves the comment information from the database
|
332 |
+
*
|
333 |
+
* @since 190705 cleanup
|
334 |
*/
|
335 |
public function _get_comment_object( $_comment_ID ) {
|
336 |
+
|
337 |
global $wpdb;
|
338 |
|
339 |
return $wpdb->get_row(
|
340 |
$wpdb->prepare(
|
341 |
+
"SELECT comment_post_ID, comment_author_email, comment_approved, comment_type, comment_parent
|
342 |
+
FROM $wpdb->comments
|
343 |
+
WHERE comment_ID = %d
|
344 |
+
LIMIT 1", $_comment_ID
|
345 |
), OBJECT
|
346 |
);
|
347 |
+
|
348 |
}
|
|
|
349 |
|
350 |
/**
|
351 |
* Takes the appropriate action, when a new comment is posted
|
352 |
+
*
|
353 |
+
* @since 190705 cleanup
|
354 |
*/
|
355 |
public function new_comment_posted( $_comment_ID = 0, $_comment_status = 0 ) {
|
356 |
+
|
357 |
+
// get information about the comment
|
358 |
$info = $this->_get_comment_object( $_comment_ID );
|
359 |
|
360 |
+
// return if no info found or comment marked as spam
|
361 |
if ( empty( $info ) || $info->comment_approved == 'spam' ) {
|
362 |
return $_comment_ID;
|
363 |
}
|
364 |
|
365 |
+
// return if subscriptions disabled for this post
|
366 |
$is_disabled = get_post_meta( $info->comment_post_ID, 'stcr_disable_subscriptions', true );
|
367 |
if ( ! empty( $is_disabled ) ) {
|
368 |
return $_comment_ID;
|
369 |
}
|
370 |
|
371 |
+
// return if trackback/pingback ( if set not to notify on those )
|
372 |
if ( ( get_option( 'subscribe_reloaded_process_trackbacks', 'no' ) == 'no' ) && ( $info->comment_type == 'trackback' || $info->comment_type == 'pingback' ) ) {
|
373 |
return $_comment_ID;
|
374 |
}
|
375 |
|
376 |
+
// process the subscription
|
377 |
if ( ! empty( $_POST['subscribe-reloaded'] ) && ! empty( $info->comment_author_email ) ) {
|
378 |
+
|
379 |
+
// check if subscription type is valid
|
380 |
if ( in_array( $_POST['subscribe-reloaded'], array( 'replies', 'digest', 'yes' ) ) ) {
|
381 |
|
382 |
+
// get subscription type
|
383 |
switch ($_POST['subscribe-reloaded']) {
|
384 |
case 'replies':
|
385 |
$status = 'R';
|
392 |
break;
|
393 |
}
|
394 |
|
395 |
+
// if not already subscribed
|
396 |
+
if ( ! $this->is_user_subscribed($info->comment_post_ID, $info->comment_author_email)) {
|
397 |
+
|
398 |
+
// if double check enabled, send confirmation email and append C to status
|
399 |
+
if ( $this->is_double_check_enabled($info) ) {
|
400 |
$this->sendConfirmationEMail($info);
|
401 |
$status = "{$status}C";
|
402 |
+
}
|
403 |
|
404 |
+
// add the subscription
|
405 |
$this->add_subscription($info->comment_post_ID, $info->comment_author_email, $status);
|
406 |
|
407 |
+
// return ( do not proceed with sending notifications ) if comment held for moderation
|
408 |
+
if ( $info->comment_approved == 0 ) {
|
|
|
409 |
return $_comment_ID;
|
410 |
+
}
|
411 |
+
|
412 |
+
}
|
413 |
+
|
414 |
+
}
|
415 |
+
|
416 |
}
|
417 |
|
418 |
+
// if comment approved, notify subscribed users about the comment
|
419 |
if ( $info->comment_approved == 1 ) {
|
420 |
+
|
421 |
+
// get all subscriptions
|
422 |
$subscriptions = $this->get_subscriptions(
|
423 |
array(
|
424 |
'post_id',
|
425 |
'status'
|
426 |
+
),
|
427 |
+
array(
|
428 |
+
'equals',
|
429 |
+
'equals'
|
430 |
+
),
|
431 |
+
array(
|
432 |
$info->comment_post_ID,
|
433 |
'Y'
|
434 |
)
|
435 |
);
|
436 |
+
|
437 |
+
// is this a reply to an existing comment?
|
438 |
if ( ! empty( $info->comment_parent ) ) {
|
439 |
+
|
440 |
+
// merge subscriptions
|
441 |
$subscriptions = array_merge(
|
442 |
+
$subscriptions,
|
443 |
+
$this->get_subscriptions(
|
444 |
+
'parent',
|
445 |
+
'equals',
|
446 |
+
array(
|
447 |
+
$info->comment_parent,
|
448 |
+
$info->comment_post_ID
|
449 |
+
)
|
450 |
)
|
|
|
451 |
);
|
452 |
+
|
453 |
}
|
454 |
|
455 |
// post author info
|
476 |
|
477 |
}
|
478 |
|
479 |
+
// notify author
|
480 |
if ( ! $post_author_notified && get_option( 'subscribe_reloaded_notify_authors', 'no' ) == 'yes' ) {
|
481 |
|
482 |
// send email to author unless the author made the comment
|
488 |
|
489 |
}
|
490 |
|
491 |
+
// that's all, return
|
492 |
return $_comment_ID;
|
493 |
+
|
494 |
}
|
495 |
|
496 |
+
/**
|
497 |
+
* Is double check ( subscriptions need to be confirmed ) enabled
|
498 |
+
*
|
499 |
+
* @since 190705
|
500 |
+
*/
|
501 |
+
public function is_double_check_enabled( $info ) {
|
502 |
|
503 |
+
$is_subscribe_to_post = false;
|
504 |
+
$is_user_logged_in = is_user_logged_in();
|
505 |
+
$is_option_enabled = false;
|
506 |
+
if ( get_option( 'subscribe_reloaded_enable_double_check', 'no' ) == 'yes' ) {
|
507 |
+
$is_option_enabled = true;
|
508 |
+
}
|
509 |
|
510 |
$approved_subscriptions = $this->get_subscriptions(
|
511 |
array(
|
512 |
'status',
|
513 |
'email'
|
514 |
+
),
|
515 |
+
array(
|
516 |
+
'equals',
|
517 |
+
'equals'
|
518 |
), array(
|
|
|
|
|
|
|
519 |
'Y',
|
520 |
$info->comment_author_email
|
521 |
)
|
522 |
);
|
523 |
|
524 |
+
// check if the user is already subscribed to the requested Post ID
|
525 |
+
foreach ( $approved_subscriptions as $subscription ) {
|
526 |
+
if ( $info->comment_post_ID == $subscription->post_id ) {
|
|
|
|
|
527 |
$is_subscribe_to_post = true;
|
528 |
}
|
529 |
}
|
530 |
|
531 |
+
// option enabled AND user not logged in AND not already subscribed
|
532 |
+
if ( $is_option_enabled && ! $is_user_logged_in && ( ! $is_subscribe_to_post || empty( $approved_subscriptions ) ) ) {
|
533 |
return true;
|
534 |
} else {
|
535 |
return false;
|
536 |
}
|
|
|
|
|
537 |
|
538 |
+
}
|
539 |
|
540 |
/**
|
541 |
+
* Actions when comments status changes ( approve/unapprove/spam/trash )
|
542 |
+
*
|
543 |
+
* @since 190705 cleanup
|
544 |
*/
|
545 |
public function comment_status_changed( $_comment_ID = 0, $_comment_status = 0 ) {
|
546 |
+
|
547 |
+
// get information about the comment
|
548 |
$info = $this->_get_comment_object( $_comment_ID );
|
549 |
+
|
550 |
+
// return, no information found
|
551 |
if ( empty( $info ) ) {
|
552 |
return $_comment_ID;
|
553 |
}
|
554 |
|
555 |
+
// go through the types of statuses
|
556 |
switch ( $info->comment_approved ) {
|
557 |
+
|
558 |
+
// unapproved
|
559 |
+
case '0':
|
560 |
+
|
561 |
$this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, 'C' );
|
562 |
break;
|
563 |
|
564 |
+
// approved
|
565 |
+
case '1':
|
566 |
+
|
567 |
$this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, '-C' );
|
568 |
+
|
569 |
+
// get subscriptions
|
570 |
$subscriptions = $this->get_subscriptions(
|
571 |
array(
|
572 |
'post_id',
|
573 |
'status'
|
574 |
), array(
|
575 |
+
'equals',
|
576 |
+
'equals'
|
577 |
+
), array(
|
578 |
$info->comment_post_ID,
|
579 |
'Y'
|
580 |
)
|
581 |
);
|
582 |
+
|
583 |
if ( ! empty( $info->comment_parent ) ) {
|
584 |
+
|
585 |
$subscriptions = array_merge(
|
586 |
$subscriptions, $this->get_subscriptions(
|
587 |
+
'parent',
|
588 |
+
'equals',
|
589 |
+
array(
|
590 |
+
$info->comment_parent,
|
591 |
+
$info->comment_post_ID
|
592 |
+
)
|
593 |
)
|
|
|
594 |
);
|
595 |
+
|
596 |
}
|
597 |
|
598 |
+
// go through subscriptions and notify subscribers
|
599 |
foreach ( $subscriptions as $a_subscription ) {
|
600 |
+
|
601 |
+
// skip the comment author
|
602 |
+
if ( $a_subscription->email != $info->comment_author_email ) {
|
603 |
$this->notify_user( $info->comment_post_ID, $a_subscription->email, $_comment_ID );
|
604 |
}
|
605 |
+
|
606 |
}
|
607 |
+
|
608 |
break;
|
609 |
|
610 |
case 'trash':
|
611 |
+
|
612 |
case 'spam':
|
613 |
+
|
614 |
+
// perform the same actions as if it were deleted
|
615 |
$this->comment_deleted( $_comment_ID );
|
616 |
break;
|
617 |
|
618 |
default:
|
619 |
break;
|
620 |
+
|
621 |
}
|
622 |
|
623 |
+
// return
|
624 |
return $_comment_ID;
|
625 |
+
|
626 |
}
|
|
|
627 |
|
628 |
/**
|
629 |
+
* Actions when comment is deleted
|
630 |
+
*
|
631 |
+
* @since 190705 cleanup
|
632 |
*/
|
633 |
public function comment_deleted( $_comment_ID ) {
|
634 |
+
|
635 |
global $wpdb;
|
636 |
|
637 |
+
// get information about the comments
|
638 |
$info = $this->_get_comment_object( $_comment_ID );
|
639 |
+
|
640 |
+
// return, no information found
|
641 |
if ( empty( $info ) ) {
|
642 |
return $_comment_ID;
|
643 |
}
|
644 |
|
645 |
+
// how many comments does the author have on this post
|
646 |
$count_approved_comments = $wpdb->get_var(
|
647 |
+
"SELECT COUNT(*)
|
648 |
+
FROM $wpdb->comments
|
649 |
+
WHERE comment_post_ID = '$info->comment_post_ID'
|
650 |
+
AND comment_author_email = '$info->comment_author_email'
|
651 |
+
AND comment_approved = 1"
|
652 |
);
|
653 |
+
|
654 |
+
// if author has no comments left on this post, remove his subscription
|
655 |
if ( intval( $count_approved_comments ) == 0 ) {
|
656 |
$this->delete_subscriptions( $info->comment_post_ID, $info->comment_author_email );
|
657 |
}
|
658 |
|
659 |
+
// return
|
660 |
return $_comment_ID;
|
661 |
}
|
|
|
662 |
|
663 |
/**
|
664 |
+
* Subscribe the post author
|
665 |
+
*
|
666 |
+
* @since 190705 cleanup
|
667 |
*/
|
668 |
public function subscribe_post_author( $_post_ID ) {
|
669 |
+
|
670 |
$new_post = get_post( $_post_ID );
|
671 |
$author_email = get_the_author_meta( 'user_email', $new_post->post_author );
|
672 |
+
|
673 |
if ( ! empty( $author_email ) ) {
|
674 |
$this->add_subscription( $_post_ID, $author_email, 'Y' );
|
675 |
}
|
676 |
+
|
677 |
+
}
|
678 |
|
679 |
/**
|
680 |
* Displays the appropriate management page
|
681 |
+
*
|
682 |
+
* @since 190705 cleanup
|
683 |
*/
|
684 |
public function subscribe_reloaded_manage( $_posts = '', $_query = '' ) {
|
685 |
|
686 |
+
// vars
|
687 |
global $current_user;
|
688 |
+
$stcr_unique_key = get_option( 'subscribe_reloaded_unique_key' );
|
689 |
$date = date_i18n( 'Y-m-d H:i:s' );
|
690 |
$error_exits = false;
|
691 |
$email = '';
|
698 |
|
699 |
try {
|
700 |
|
701 |
+
// get post ID
|
702 |
$post_ID = !empty($_POST['srp']) ? intval($_POST['srp']) : (!empty($_GET['srp']) ? intval($_GET['srp']) : 0);
|
703 |
|
704 |
+
// does a post with that ID exist
|
705 |
$target_post = get_post($post_ID);
|
706 |
+
if ( ( $post_ID > 0 ) && ! is_object($target_post) ) {
|
707 |
return $_posts;
|
708 |
}
|
709 |
|
710 |
+
// vars
|
711 |
$action = !empty($_POST['sra']) ? $_POST['sra'] : (!empty($_GET['sra']) ? $_GET['sra'] : 0);
|
712 |
$key = !empty($_POST['srk']) ? $_POST['srk'] : (!empty($_GET['srk']) ? $_GET['srk'] : 0);
|
713 |
$sre = !empty($_POST['sre']) ? $_POST['sre'] : (!empty($_GET['sre']) ? $_GET['sre'] : '');
|
714 |
$srek = !empty($_POST['srek']) ? $_POST['srek'] : (!empty($_GET['srek']) ? $_GET['srek'] : '');
|
715 |
$link_source = !empty($_POST['srsrc']) ? $_POST['srsrc'] : (!empty($_GET['srsrc']) ? $_GET['srsrc'] : '');
|
716 |
$key_expired = !empty($_POST['key_expired']) ? $_POST['key_expired'] : (!empty($_GET['key_expired']) ? $_GET['key_expired'] : '0');
|
717 |
+
|
718 |
+
// check if the current subscriber has valid email using the $srek key.
|
719 |
+
$email_by_key = $this->utils->get_subscriber_email_by_key($srek);
|
720 |
+
|
721 |
+
// stop if invalid SRE key
|
722 |
+
if ( ! $email_by_key && ! empty( $srek ) ) {
|
723 |
+
|
724 |
$this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find an email with the SRE key: ( $srek )\n");
|
725 |
+
$email = '';
|
726 |
+
|
727 |
+
// valid key, proceed
|
728 |
} else {
|
729 |
+
|
730 |
+
if ( ! $email_by_key && empty( $sre ) ) {
|
731 |
$email = '';
|
732 |
+
} else if ( $email_by_key && ! empty( $email_by_key ) ) {
|
733 |
$email = $email_by_key;
|
734 |
+
} else if ( ! empty( $sre ) ) {
|
735 |
$email = $this->utils->check_valid_email( $sre );
|
736 |
} else {
|
737 |
$email = '';
|
738 |
+
}
|
739 |
+
|
740 |
+
}
|
741 |
+
|
742 |
+
// comes from the comment form.
|
743 |
+
if ($link_source == 'f') {
|
744 |
+
|
745 |
+
// Check for a valid SRK key, until this point we know the email is correct but the $key has expired/change
|
746 |
// or is wrong, in that case display the request management page template
|
747 |
if ($email !== "" && $key !== 0 && $stcr_unique_key !== $key || $key_expired == "1") {
|
748 |
if ($key_expired == "1") {
|
751 |
$this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
|
752 |
$error_exits = true;
|
753 |
}
|
754 |
+
}
|
755 |
+
|
756 |
+
// comes from email link
|
757 |
+
} else if ($link_source == 'e') {
|
758 |
+
|
759 |
if ($email !== "" && $key !== 0 && !$this->utils->_is_valid_key($key, $email) || $key_expired == "1") {
|
760 |
if ($key_expired == "1") {
|
761 |
$error_exits = true;
|
763 |
$this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
|
764 |
$error_exits = true;
|
765 |
}
|
766 |
+
}
|
767 |
+
|
768 |
}
|
769 |
|
770 |
+
// error found, show message
|
771 |
if ($error_exits) {
|
772 |
+
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/key_expired.php';
|
773 |
+
|
774 |
+
// all fine, proceed
|
775 |
} else {
|
776 |
+
|
777 |
+
// subscribe without commenting
|
778 |
+
if (
|
779 |
+
!empty($action) &&
|
780 |
($action == 's') &&
|
781 |
($post_ID > 0) &&
|
782 |
$key_expired != "1"
|
783 |
) {
|
784 |
+
|
785 |
+
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/subscribe.php';
|
786 |
+
|
787 |
+
// post author
|
788 |
+
} elseif (
|
789 |
+
($post_ID > 0) &&
|
790 |
$this->is_author($target_post->post_author)
|
791 |
) {
|
792 |
+
|
793 |
+
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/author.php';
|
794 |
+
|
795 |
+
// confirm subscription
|
796 |
+
} elseif (
|
797 |
+
($post_ID > 0) &&
|
798 |
!empty($email) &&
|
799 |
!empty($key) &&
|
800 |
!empty($action) &&
|
803 |
($action == 'c') &&
|
804 |
$key_expired != "1"
|
805 |
) {
|
806 |
+
|
807 |
+
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/confirm.php';
|
808 |
+
|
809 |
+
// unsubscribe
|
810 |
+
} elseif (
|
811 |
+
($post_ID > 0) &&
|
812 |
!empty($email) &&
|
813 |
!empty($key) &&
|
814 |
!empty($action) &&
|
816 |
($action == 'u') &&
|
817 |
$key_expired != "1"
|
818 |
) {
|
819 |
+
|
820 |
+
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/one-click-unsubscribe.php';
|
821 |
+
|
822 |
+
// user management page
|
823 |
+
} elseif (
|
824 |
+
!empty($email) &&
|
825 |
($key !== 0 && $this->utils->_is_valid_key($key, $email) || (!empty($current_user->data->user_email) && ($current_user->data->user_email === $email && current_user_can('read'))))
|
826 |
) {
|
827 |
+
|
828 |
+
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/user.php';
|
829 |
+
|
830 |
+
// wrong request
|
831 |
+
} elseif (
|
832 |
+
!empty($email) &&
|
833 |
($key === 0 && (!empty($current_user->data->user_email) && ($current_user->data->user_email !== $email)))
|
834 |
) {
|
835 |
+
|
836 |
+
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/wrong-request.php';
|
837 |
+
|
838 |
}
|
839 |
|
840 |
+
// request management link
|
841 |
if (empty($include_post_content)) {
|
842 |
$include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/request-management-link.php';
|
843 |
+
}
|
844 |
+
|
845 |
}
|
846 |
|
847 |
global $wp_query;
|
848 |
|
849 |
+
// management page title
|
850 |
$manager_page_title = html_entity_decode(get_option('subscribe_reloaded_manager_page_title', 'Manage subscriptions'), ENT_QUOTES, 'UTF-8');
|
851 |
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
|
852 |
$manager_page_title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($manager_page_title);
|
854 |
$manager_page_title = $manager_page_title;
|
855 |
}
|
856 |
|
857 |
+
// fake posts
|
858 |
$posts[] =
|
859 |
(object)array(
|
860 |
'ID' => '9999999',
|
897 |
$wp_query->is_404 = false;
|
898 |
|
899 |
// Seems like WP adds its own HTML formatting code to the content, we don't need that here
|
900 |
+
remove_filter('the_content', 'wpautop');
|
901 |
+
|
902 |
// Look like the plugin is call twice and therefor subscribe to the "the_posts" filter again so we need to
|
903 |
// tell to WordPress to not register again.
|
904 |
remove_filter("the_posts", array($this, "subscribe_reloaded_manage"));
|
905 |
add_action('wp_head', array($this, 'add_custom_header_meta'));
|
906 |
|
907 |
+
// log the error
|
908 |
+
} catch(\Exception $ex) {
|
909 |
+
|
910 |
$this->utils->stcr_logger( "\n [ERROR][$date] - $ex->getMessage()\n" );
|
911 |
+
$this->utils->stcr_logger( "\n [ERROR][$date] - $ex->getTraceAsString()\n" );
|
912 |
+
|
913 |
}
|
914 |
|
915 |
+
// return filtered posts
|
916 |
return $posts;
|
917 |
+
|
918 |
}
|
919 |
+
|
920 |
/**
|
921 |
+
* Checks if current logged in user is the author
|
922 |
+
*
|
923 |
+
* @since 190705 cleanup
|
924 |
*/
|
925 |
public function is_author( $_post_author ) {
|
|
|
926 |
|
927 |
+
global $current_user;
|
928 |
return ! empty( $current_user ) && ( ( $_post_author == $current_user->ID ) || current_user_can( 'manage_options' ) );
|
929 |
+
|
930 |
}
|
|
|
931 |
|
932 |
/**
|
933 |
* Checks if a given email address is subscribed to a post
|
934 |
+
*
|
935 |
+
* @since 190705 cleanup
|
936 |
*/
|
937 |
public function is_user_subscribed( $_post_ID = 0, $_email = '', $_status = '' ) {
|
938 |
+
|
939 |
global $current_user;
|
940 |
|
941 |
+
// return, no info about email available
|
942 |
if ( ( empty( $current_user->user_email ) && empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) && empty( $_email ) ) || empty( $_post_ID ) ) {
|
943 |
return false;
|
944 |
}
|
945 |
|
946 |
+
$operator = ( $_status != '' ) ? 'equals' : 'contains';
|
947 |
+
|
948 |
+
// get subscriptions
|
949 |
$subscriptions = $this->get_subscriptions(
|
950 |
array(
|
951 |
'post_id',
|
952 |
'status'
|
953 |
+
),
|
954 |
+
array(
|
955 |
+
'equals',
|
956 |
+
$operator
|
957 |
), array(
|
|
|
|
|
|
|
958 |
$_post_ID,
|
959 |
$_status
|
960 |
)
|
961 |
+
);
|
962 |
|
963 |
+
// if email not supplied, tried to get it
|
964 |
if ( empty( $_email ) ) {
|
965 |
$user_email = ! empty( $current_user->user_email ) ? $current_user->user_email : ( ! empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ? stripslashes( esc_attr( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) : '#undefined#' );
|
966 |
+
|
967 |
+
// if supplied, use it
|
968 |
} else {
|
969 |
$user_email = $_email;
|
970 |
}
|
971 |
|
972 |
+
// go through all subscriptions and return true if the email is found
|
973 |
foreach ( $subscriptions as $a_subscription ) {
|
974 |
if ( $user_email == $a_subscription->email ) {
|
975 |
return true;
|
976 |
}
|
977 |
}
|
978 |
|
979 |
+
// return false, the email is not subscribed
|
980 |
return false;
|
981 |
+
|
982 |
}
|
983 |
+
|
984 |
/**
|
985 |
* Adds a new subscription
|
986 |
+
*
|
987 |
+
* @since 190705 cleanup
|
988 |
*/
|
989 |
public function add_subscription( $_post_id = 0, $_email = '', $_status = 'Y' ) {
|
990 |
+
|
991 |
global $wpdb;
|
992 |
+
|
993 |
+
// does the post exist?
|
994 |
$target_post = get_post( $_post_id );
|
995 |
if ( ( $_post_id > 0 ) && ! is_object( $target_post ) ) {
|
996 |
return;
|
997 |
}
|
998 |
|
999 |
+
// return if status incorrect
|
1000 |
if ( ! in_array( $_status, array( 'Y', 'YC', 'R', 'RC', 'C', '-C' ) ) || empty( $_status ) ) {
|
1001 |
return;
|
1002 |
}
|
1003 |
|
1004 |
+
// using Wordpress local time
|
1005 |
$dt = date_i18n( 'Y-m-d H:i:s' );
|
1006 |
|
1007 |
+
// sanitize email
|
1008 |
$clean_email = $this->utils->clean_email( $_email );
|
1009 |
+
|
1010 |
+
// insert subscriber into postmeta
|
1011 |
+
$wpdb->query( $wpdb->prepare(
|
1012 |
+
"INSERT IGNORE INTO $wpdb->postmeta (post_id, meta_key, meta_value)
|
1013 |
+
SELECT %d, %s, %s
|
1014 |
+
FROM DUAL
|
1015 |
+
WHERE NOT EXISTS (
|
1016 |
+
SELECT post_id
|
1017 |
+
FROM $wpdb->postmeta
|
1018 |
+
WHERE post_id = %d
|
1019 |
+
AND meta_key = %s
|
1020 |
+
LIMIT 0,1
|
1021 |
+
)", $_post_id, "_stcr@_$clean_email", "$dt|$_status", $_post_id, "_stcr@_$clean_email"
|
1022 |
+
));
|
1023 |
+
|
1024 |
+
// Insert user into subscribe_reloaded_subscribers table
|
1025 |
+
// TODO: Only on this section the user should be added to the subscribers table. On the send confirmation email is repeating this method.
|
1026 |
+
$OK = $this->utils->add_user_subscriber_table( $clean_email );
|
1027 |
+
|
|
|
1028 |
}
|
1029 |
+
|
1030 |
/**
|
1031 |
* Deletes one or more subscriptions from the database
|
1032 |
+
*
|
1033 |
+
* @since 190705 cleanup
|
1034 |
*/
|
1035 |
public function delete_subscriptions( $_post_id = 0, $_email = '' ) {
|
1036 |
+
|
1037 |
global $wpdb;
|
1038 |
+
|
1039 |
$has_subscriptions = false;
|
1040 |
|
1041 |
+
// no post ID supplied, return 0
|
1042 |
if ( empty( $_post_id ) ) {
|
1043 |
return 0;
|
1044 |
}
|
1045 |
|
1046 |
+
// generate search for the DB query
|
1047 |
$posts_where = '';
|
1048 |
if ( ! is_array( $_post_id ) ) {
|
1049 |
$posts_where = "post_id = " . intval( $_post_id );
|
1051 |
foreach ( $_post_id as $a_post_id ) {
|
1052 |
$posts_where .= "post_id = '" . intval( $a_post_id ) . "' OR ";
|
1053 |
}
|
|
|
1054 |
$posts_where = substr( $posts_where, 0, - 4 );
|
1055 |
}
|
1056 |
|
1057 |
+
// if email supplied, add it to the search for the DB query
|
1058 |
if ( ! empty( $_email ) ) {
|
1059 |
$emails_where = '';
|
1060 |
if ( ! is_array( $_email ) ) {
|
1061 |
$emails_where = "meta_key = '_stcr@_" . $this->utils->clean_email( $_email ) . "'";
|
1062 |
$has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $_email );
|
1063 |
+
if ( $has_subscriptions === false) {
|
1064 |
$this->utils->remove_user_subscriber_table( $_email );
|
1065 |
}
|
1066 |
} else {
|
1068 |
$emails_where .= "meta_key = '_stcr@_" . $this->utils->clean_email( $a_email ) . "' OR ";
|
1069 |
// Deletion on every email on the subscribers table.
|
1070 |
$has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $a_email );
|
1071 |
+
if ( $has_subscriptions === false ) {
|
1072 |
$this->utils->remove_user_subscriber_table( $a_email );
|
1073 |
}
|
1074 |
}
|
1075 |
|
1076 |
$emails_where = substr( $emails_where, 0, - 4 );
|
1077 |
}
|
1078 |
+
|
1079 |
+
// remove subscription from DB
|
1080 |
return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE ($posts_where) AND ($emails_where)" );
|
1081 |
+
|
1082 |
} else {
|
1083 |
+
|
1084 |
+
// remove all subscriptions for specific post from DB
|
1085 |
return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%' AND ($posts_where)" );
|
1086 |
+
|
1087 |
}
|
1088 |
+
|
1089 |
}
|
1090 |
+
|
1091 |
/**
|
1092 |
* The function must search for subscription by a given post id.
|
1093 |
*
|
1100 |
* if $in is false the it could return the subscriptions or false, false means not found
|
1101 |
*/
|
1102 |
public function retrieve_user_subscriptions( $_post_id, $_email, $in = false ) {
|
1103 |
+
|
1104 |
global $wpdb;
|
1105 |
+
|
1106 |
$meta_key = '_stcr@_';
|
1107 |
$in_values = '';
|
1108 |
|
1109 |
+
// single post
|
1110 |
if( ! is_array( $_post_id ) ){
|
1111 |
+
|
1112 |
if ( ! $in ) {
|
1113 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id <> %d AND meta_key = %s";
|
1114 |
} else if ( $in ) {
|
1115 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s";
|
1116 |
}
|
1117 |
+
|
1118 |
+
$result = $wpdb->get_results( $wpdb->prepare( $retrieve_subscriptions, $_post_id, $meta_key.$_email ), OBJECT );
|
1119 |
+
|
1120 |
+
// array of posts
|
1121 |
} else {
|
1122 |
+
|
1123 |
+
$in_values = implode( ',', $_post_id );
|
1124 |
+
|
|
|
1125 |
if ( ! $in ) {
|
1126 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id NOT IN ($in_values) AND meta_key = %s";
|
1127 |
} else if ( $in ) {
|
1128 |
$retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id IN ($in_values) AND meta_key = %s";
|
1129 |
}
|
1130 |
+
|
1131 |
+
$result = $wpdb->get_results($wpdb->prepare( $retrieve_subscriptions, $meta_key.$_email ), OBJECT);
|
1132 |
+
|
1133 |
}
|
1134 |
|
1135 |
return $result === false || $result == 0 || empty( $result ) ? false : $result;
|
1136 |
+
|
1137 |
}
|
1138 |
+
|
1139 |
/**
|
1140 |
* Updates the status of an existing subscription
|
1141 |
+
*
|
1142 |
+
* @since 190705 cleanup
|
1143 |
*/
|
1144 |
public function update_subscription_status( $_post_id = 0, $_email = '', $_new_status = 'C' ) {
|
1145 |
+
|
1146 |
global $wpdb;
|
1147 |
|
1148 |
+
// if not a valid status, return
|
1149 |
if ( empty( $_new_status ) || ! in_array( $_new_status, array( 'Y', 'R', 'C', '-C' ) ) || empty( $_email ) ) {
|
1150 |
return 0;
|
1151 |
}
|
1152 |
|
1153 |
+
// specific post ID supplied
|
1154 |
if ( ! empty( $_post_id ) ) {
|
1155 |
+
|
1156 |
+
// generate the WHERE for post ID for the DB query
|
1157 |
$posts_where = '';
|
1158 |
if ( ! is_array( $_post_id ) ) {
|
1159 |
$posts_where = "post_id = " . intval( $_post_id );
|
1161 |
foreach ( $_post_id as $a_post_id ) {
|
1162 |
$posts_where .= "post_id = '" . intval( $a_post_id ) . "' OR ";
|
1163 |
}
|
|
|
1164 |
$posts_where = substr( $posts_where, 0, - 4 );
|
1165 |
}
|
1166 |
+
|
1167 |
+
// all posts
|
1168 |
+
} else {
|
1169 |
$posts_where = '1=1';
|
1170 |
}
|
1171 |
|
1172 |
+
// generate WHERE for email for the DB query
|
1173 |
$emails_where = '';
|
1174 |
if ( ! is_array( $_email ) ) {
|
1175 |
$emails_where = "meta_key = '_stcr@_" . $this->utils->clean_email( $_email ) . "'";
|
1177 |
foreach ( $_email as $a_email ) {
|
1178 |
$emails_where .= "meta_key = '_stcr@_" . $this->utils->clean_email( $a_email ) . "' OR ";
|
1179 |
}
|
|
|
1180 |
$emails_where = substr( $emails_where, 0, - 4 );
|
1181 |
}
|
1182 |
|
1183 |
$meta_length = ( strpos( $_new_status, 'C' ) !== false ) ? 21 : 20;
|
1184 |
$new_status = ( $_new_status == '-C' ) ? '' : $_new_status;
|
1185 |
|
1186 |
+
// update DB
|
1187 |
return $wpdb->query(
|
1188 |
+
"UPDATE $wpdb->postmeta
|
1189 |
+
SET meta_value = CONCAT(SUBSTRING(meta_value, 1, $meta_length), '$new_status')
|
1190 |
+
WHERE ($posts_where) AND ($emails_where)"
|
|
|
1191 |
);
|
1192 |
+
|
1193 |
}
|
1194 |
+
|
1195 |
/**
|
1196 |
* Updates the email address of an existing subscription
|
1197 |
+
*
|
1198 |
+
* @since 190705 cleanup
|
1199 |
*/
|
1200 |
public function update_subscription_email( $_post_id = 0, $_email = '', $_new_email = '' ) {
|
1201 |
+
|
1202 |
global $wpdb;
|
1203 |
|
1204 |
+
// return if no email supplied
|
1205 |
if ( empty( $_email ) || empty( $_new_email ) || strpos( $_new_email, '@' ) == 0 ) {
|
1206 |
return;
|
1207 |
}
|
1208 |
|
1209 |
+
// sanitize old and new email
|
1210 |
$clean_values[] = "_stcr@_" . $this->utils->clean_email( $_new_email );
|
1211 |
$clean_values[] = "_stcr@_" . $this->utils->clean_email( $_email );
|
1212 |
+
|
1213 |
+
// generate WHERE for DB query
|
1214 |
+
$post_where = '';
|
1215 |
if ( ! empty( $_post_id ) ) {
|
1216 |
+
$post_where = ' AND post_id = %d';
|
1217 |
$clean_values[] = $_post_id;
|
1218 |
}
|
1219 |
|
1220 |
+
// update the email in postmeta table
|
1221 |
+
$rowsAffected = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_key = %s WHERE meta_key = %s $post_where", $clean_values ) );
|
|
|
|
|
1222 |
|
1223 |
+
// update the email in subscribe_reloaded_subscribers table
|
1224 |
+
if ( $rowsAffected > 0 || $rowsAffected !== false) {
|
1225 |
$salt = time();
|
1226 |
$rowsAffected = $wpdb->query(
|
1227 |
$wpdb->prepare("UPDATE ". $wpdb->prefix .
|
1232 |
$_new_email, $salt, $this->utils->generate_temp_key( $salt . $_new_email ),$_email )
|
1233 |
);
|
1234 |
}
|
1235 |
+
|
1236 |
return false;
|
1237 |
+
|
1238 |
}
|
1239 |
+
|
1240 |
/**
|
1241 |
+
* Retrieves a list of emails subscribed to a specific post
|
1242 |
+
*
|
1243 |
+
* @since 190705 cleanup
|
1244 |
*/
|
1245 |
public function get_subscriptions( $_search_field = array( 'email' ), $_operator = array( 'equals' ), $_search_value = array( '' ), $_order_by = 'dt', $_order = 'ASC', $_offset = 0, $_limit_results = 0 ) {
|
1246 |
+
|
1247 |
global $wpdb;
|
1248 |
|
1249 |
// Type adjustments
|
1263 |
// Check if $parent_comment_author_email has any Replies Only (R) subscriptions for $comment_post_id
|
1264 |
|
1265 |
/*
|
1266 |
+
Heads up: this will return Replies Only subscriptions for a given post, *not* for a given comment.
|
1267 |
+
This plugin does not track subscriptions for specific comments but rather for entire posts, so there
|
1268 |
+
is no way to figure out if a specific parent comment has a subscription (of any type). To make the
|
1269 |
+
Replies Only feature half-work, we check if a parent comment author has *any* Replies Only subscriptions
|
1270 |
+
for a given post. If they do, we assume that they must want to get notified of replies to *any* of their
|
1271 |
+
comments on *that* post.
|
1272 |
*/
|
1273 |
|
1274 |
return $wpdb->get_results(
|
1275 |
$wpdb->prepare(
|
1276 |
+
"SELECT pm.meta_id, REPLACE(pm.meta_key, '_stcr@_', '') AS email, pm.post_id, SUBSTRING(pm.meta_value, 1, 19) AS dt, SUBSTRING(pm.meta_value, 21) AS status, srs.subscriber_unique_id AS email_key
|
1277 |
+
FROM $wpdb->postmeta pm
|
1278 |
+
INNER JOIN {$wpdb->prefix}subscribe_reloaded_subscribers srs ON ( REPLACE(pm.meta_key, '_stcr@_', '') = srs.subscriber_email )
|
1279 |
+
WHERE pm.meta_key LIKE %s
|
1280 |
+
AND pm.meta_value LIKE '%%R'
|
1281 |
+
AND pm.post_id = %d", $parent_comment_author_email, $comment_post_id
|
|
|
1282 |
), OBJECT
|
1283 |
);
|
1284 |
+
|
1285 |
} else {
|
1286 |
+
|
1287 |
+
// generate WHERE for the DB query
|
1288 |
$where_clause = '';
|
1289 |
foreach ( $search_fields as $a_idx => $a_field ) {
|
1290 |
$where_clause .= ' AND';
|
1321 |
$where_values[] = "%{$search_values[$a_idx]}%";
|
1322 |
}
|
1323 |
}
|
1324 |
+
|
1325 |
+
// generated ORDER BY for the DB query
|
1326 |
switch ( $_order_by ) {
|
1327 |
case 'status':
|
1328 |
$order_by = "status";
|
1338 |
}
|
1339 |
$order = ( $_order != 'ASC' && $_order != 'DESC' ) ? 'DESC' : $_order;
|
1340 |
|
1341 |
+
// this is the 'official' way to have an offset without a limit
|
1342 |
$row_count = ( $_limit_results <= 0 ) ? '18446744073709551610' : $_limit_results;
|
1343 |
|
1344 |
+
// run the DB query
|
1345 |
return $wpdb->get_results(
|
1346 |
$wpdb->prepare(
|
1347 |
+
"SELECT meta_id, REPLACE(meta_key, '_stcr@_', '') AS email, post_id, SUBSTRING(meta_value, 1, 19) AS dt, SUBSTRING(meta_value, 21) AS status, srs.subscriber_unique_id AS email_key
|
1348 |
+
FROM $wpdb->postmeta
|
1349 |
+
INNER JOIN {$wpdb->prefix}subscribe_reloaded_subscribers srs ON ( REPLACE(meta_key, '_stcr@_', '') = srs.subscriber_email )
|
1350 |
+
WHERE meta_key LIKE '\_stcr@\_%%' $where_clause
|
1351 |
+
ORDER BY $order_by $order
|
1352 |
+
LIMIT $_offset,$row_count", $where_values
|
|
|
1353 |
), OBJECT
|
1354 |
);
|
1355 |
+
|
1356 |
}
|
1357 |
+
|
1358 |
}
|
1359 |
+
|
1360 |
/**
|
1361 |
* Sends the notification message to a given user
|
1362 |
+
*
|
1363 |
+
* @since 190705 cleanup
|
1364 |
*/
|
1365 |
public function notify_user( $_post_ID = 0, $_email = '', $_comment_ID = 0 ) {
|
1366 |
+
|
1367 |
+
// vars
|
1368 |
$post = get_post( $_post_ID );
|
1369 |
$comment = get_comment( $_comment_ID );
|
1370 |
$post_permalink = get_permalink( $_post_ID );
|
1371 |
$comment_permalink = get_comment_link( $_comment_ID );
|
1372 |
$comment_reply_permalink = get_permalink( $_post_ID ) . '?replytocom=' . $_comment_ID . '#respond';
|
1373 |
$info = $this->_get_comment_object( $_comment_ID );
|
1374 |
+
|
1375 |
// WPML compatibility
|
1376 |
if ( defined('ICL_SITEPRESS_VERSION') && defined('ICL_LANGUAGE_CODE') ) {
|
|
|
1377 |
global $sitepress;
|
1378 |
$language = $sitepress->get_language_for_element( $_post_ID, 'post_' . $post->post_type );
|
1379 |
$sitepress->switch_lang($language);
|
1380 |
}
|
1381 |
|
1382 |
+
// vars
|
1383 |
$subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_subject', 'There is a new comment on the post [post_title]' ) ), ENT_QUOTES, 'UTF-8' );
|
1384 |
$message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_content', '' ) ), ENT_QUOTES, 'UTF-8' );
|
1385 |
$manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
|
1386 |
$one_click_unsubscribe_link = $manager_link;
|
1387 |
|
1388 |
+
// qTranslate compatibility
|
1389 |
if ( function_exists( 'qtrans_convertURL' ) ) {
|
1390 |
$manager_link = qtrans_convertURL( $manager_link );
|
1391 |
}
|
1392 |
|
1393 |
+
// vars
|
1394 |
$clean_email = $this->utils->clean_email( $_email );
|
1395 |
$subscriber_salt = $this->utils->generate_temp_key( $clean_email );
|
|
|
1396 |
$manager_link .= ( ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?' )
|
1397 |
. "srek=" . $this->utils->get_subscriber_key( $clean_email )
|
1398 |
. "&srk=$subscriber_salt";
|
1399 |
$one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' )
|
1400 |
. "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=$subscriber_salt"
|
1401 |
. "&sra=u&srsrc=e" . "&srp=" . $_post_ID;
|
|
|
1402 |
$comment_content = $comment->comment_content;
|
1403 |
|
1404 |
+
// replace tags with their actual values
|
1405 |
$subject = str_replace( '[post_title]', $post->post_title, $subject );
|
1406 |
$subject = str_replace( '[blog_name]' , get_bloginfo('name'), $subject );
|
|
|
1407 |
$message = str_replace( '[post_permalink]', $post_permalink, $message );
|
1408 |
$message = str_replace( '[comment_permalink]', $comment_permalink, $message );
|
1409 |
$message = str_replace( '[comment_reply_permalink]', $comment_reply_permalink, $message );
|
1413 |
$message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $message );
|
1414 |
$message = str_replace( '[comment_gravatar]', get_avatar($info->comment_author_email, 40), $message );
|
1415 |
|
1416 |
+
// qTranslate support
|
1417 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
1418 |
$subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
|
1419 |
$message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $post->post_title ), $message );
|
1421 |
} else {
|
1422 |
$message = str_replace( '[post_title]', $post->post_title, $message );
|
1423 |
}
|
1424 |
+
|
1425 |
$message = apply_filters( 'stcr_notify_user_message', $message, $_post_ID, $clean_email, $_comment_ID );
|
1426 |
+
|
1427 |
+
// email settings
|
1428 |
$email_settings = array(
|
1429 |
'subject' => $subject,
|
1430 |
'message' => $message,
|
1432 |
'XPostId' => $_post_ID,
|
1433 |
'XCommentId' => $_comment_ID
|
1434 |
);
|
1435 |
+
|
1436 |
+
// send email
|
1437 |
$this->utils->send_email( $email_settings );
|
1438 |
+
|
1439 |
}
|
1440 |
+
|
1441 |
/**
|
1442 |
* Displays the checkbox to allow visitors to subscribe
|
1443 |
+
*
|
1444 |
+
* @since 190705 cleanup
|
1445 |
*/
|
1446 |
+
function subscribe_reloaded_show( $submit_field = '' ) {
|
1447 |
|
1448 |
+
// echo on action, return on filter
|
|
|
1449 |
$echo = false;
|
1450 |
if ( doing_action( 'comment_form' ) ) {
|
1451 |
$echo = true;
|
1452 |
}
|
1453 |
|
1454 |
+
// vars
|
1455 |
global $post, $wp_subscribe_reloaded;
|
1456 |
$checkbox_subscription_type = null;
|
1457 |
$_comment_ID = null;
|
1460 |
$post_type = get_post_type( $post->ID );
|
1461 |
$only_for_posts = get_option( 'subscribe_reloaded_only_for_posts', 'no' );
|
1462 |
|
1463 |
+
// if not enabled for this post type, return default
|
1464 |
if ( $only_for_posts == 'yes' && $post_type !== 'post' ) {
|
1465 |
if ( $echo ) {
|
1466 |
echo $submit_field;
|
1470 |
return;
|
1471 |
}
|
1472 |
|
1473 |
+
// enqueue scripts and styles
|
1474 |
+
$wp_subscribe_reloaded->stcr->utils->add_plugin_js_scripts();
|
1475 |
wp_enqueue_style( 'stcr-plugin-style' );
|
1476 |
|
1477 |
+
// return if subscriptions disabled for this post
|
1478 |
$is_disabled = get_post_meta( $post->ID, 'stcr_disable_subscriptions', true );
|
1479 |
if ( ! empty( $is_disabled ) ) {
|
1480 |
return $_comment_ID;
|
1481 |
}
|
1482 |
|
1483 |
+
// vars
|
1484 |
$show_subscription_box = true;
|
1485 |
$html_to_show = '';
|
1486 |
$user_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '' );
|
1487 |
|
1488 |
+
// qTranslate compatibility
|
1489 |
if ( function_exists( 'qtrans_convertURL' ) ) {
|
1490 |
$user_link = qtrans_convertURL( $user_link );
|
1491 |
}
|
1492 |
|
1493 |
+
// link for management page
|
1494 |
$manager_link = ( strpos( $user_link, '?' ) !== false ) ?
|
1495 |
"$user_link&srp=$post->ID&srk=" . get_option( 'subscribe_reloaded_unique_key' ) :
|
1496 |
"$user_link?srp=$post->ID&srk=" . get_option( 'subscribe_reloaded_unique_key' );
|
1497 |
|
1498 |
+
// link for user
|
1499 |
$user_link = ( strpos( $user_link, '?' ) !== false ) ?
|
1500 |
"$user_link&" . $post_permalink :
|
1501 |
"$user_link?" . $post_permalink;
|
1502 |
|
1503 |
+
// if subscription pending confirmation
|
1504 |
if ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '', 'C' ) ) {
|
1505 |
$html_to_show = str_replace(
|
1506 |
'[manager_link]', $user_link,
|
1507 |
html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribed_waiting_label', __( "Your subscription to this post needs to be confirmed. <a href='[manager_link]'>Manage your subscriptions</a>.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
|
1508 |
);
|
1509 |
$show_subscription_box = false;
|
1510 |
+
|
1511 |
+
// if subscription active
|
1512 |
} elseif ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '' ) ) {
|
1513 |
$html_to_show = str_replace(
|
1514 |
'[manager_link]', $user_link ,
|
1517 |
$show_subscription_box = false;
|
1518 |
}
|
1519 |
|
1520 |
+
// if current user is author of the post
|
1521 |
+
if ( $wp_subscribe_reloaded->stcr->is_author( $post->post_author ) ) {
|
1522 |
if ( get_option( 'subscribe_reloaded_admin_subscribe', 'no' ) == 'no' ) {
|
1523 |
$show_subscription_box = false;
|
1524 |
}
|
1529 |
);
|
1530 |
}
|
1531 |
|
1532 |
+
// show the subscription form
|
1533 |
if ( $show_subscription_box ) {
|
1534 |
+
|
1535 |
+
// label
|
1536 |
+
$checkbox_label = str_replace(
|
1537 |
'[subscribe_link]', "$manager_link&sra=s&srsrc=f",
|
1538 |
html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_label', __( "Notify me of followup comments via e-mail. You can also <a href='[subscribe_link]'>subscribe</a> without commenting.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
|
1539 |
);
|
1540 |
+
|
1541 |
+
// CSS style
|
1542 |
$checkbox_inline_style = get_option( 'subscribe_reloaded_checkbox_inline_style', 'width:30px' );
|
1543 |
if ( ! empty( $checkbox_inline_style ) ) {
|
1544 |
$checkbox_inline_style = " style='$checkbox_inline_style'";
|
1545 |
}
|
1546 |
+
|
1547 |
$checkbox_html_wrap = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_html', '' ) ), ENT_QUOTES, 'UTF-8' );
|
1548 |
+
|
1549 |
+
// regular subscriptions form
|
1550 |
if ( get_option( 'subscribe_reloaded_enable_advanced_subscriptions', 'no' ) == 'no' ) {
|
1551 |
switch ( get_option( 'subscribe_reloaded_checked_by_default_value' ) ) {
|
1552 |
case '0':
|
1557 |
break;
|
1558 |
}
|
1559 |
$checkbox_field = "<input$checkbox_inline_style type='checkbox' name='subscribe-reloaded' id='subscribe-reloaded' value='$checkbox_subscription_type'" . ( ( get_option( 'subscribe_reloaded_checked_by_default', 'no' ) == 'yes' ) ? " checked='checked'" : '' ) . " />";
|
1560 |
+
|
1561 |
+
// advanced subscriptions form
|
1562 |
} else {
|
1563 |
$checkbox_field = "<select name='subscribe-reloaded' id='subscribe-reloaded'>
|
1564 |
<option value='none' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '0' ) ? "selected='selected'" : '' ) . ">" . __( "Don't subscribe", 'subscribe-to-comments-reloaded' ) . "</option>
|
1566 |
<option value='replies' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '2' ) ? "selected='selected'" : '' ) . ">" . __( "Replies to my comments", 'subscribe-to-comments-reloaded' ) . "</option>
|
1567 |
</select>";
|
1568 |
}
|
1569 |
+
|
1570 |
if ( empty( $checkbox_html_wrap ) ) {
|
1571 |
$html_to_show = "$checkbox_field <label for='subscribe-reloaded'>$checkbox_label</label>" . $html_to_show;
|
1572 |
} else {
|
1573 |
$checkbox_html_wrap = str_replace( '[checkbox_field]', $checkbox_field, $checkbox_html_wrap );
|
1574 |
$html_to_show = str_replace( '[checkbox_label]', $checkbox_label, $checkbox_html_wrap ) . $html_to_show;
|
1575 |
}
|
1576 |
+
|
1577 |
}
|
1578 |
+
|
1579 |
+
// qTranslate compatiblity
|
1580 |
if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
|
1581 |
$html_to_show = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $html_to_show );
|
1582 |
}
|
1583 |
+
|
1584 |
$output = '';
|
1585 |
// Check for the Comment Form location
|
1586 |
if( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
|
1597 |
$output .= "<!-- BEGIN: subscribe to comments reloaded -->" . $html_to_show . "<!-- END: subscribe to comments reloaded -->";
|
1598 |
}
|
1599 |
|
1600 |
+
// echo or return
|
1601 |
if ( $echo ) {
|
1602 |
echo $output . $submit_field;
|
1603 |
} else {
|
1604 |
return $output . $submit_field;
|
1605 |
}
|
1606 |
|
1607 |
+
}
|
1608 |
|
1609 |
+
/**
|
1610 |
+
* Set a cookie if the user just subscribed without commenting
|
1611 |
+
*
|
1612 |
+
* @since 190705
|
1613 |
+
*/
|
1614 |
+
public function set_user_cookie() {
|
1615 |
+
|
1616 |
$subscribe_to_comments_action = ! empty( $_POST['sra'] ) ? $_POST['sra'] : ( ! empty( $_GET['sra'] ) ? $_GET['sra'] : 0 );
|
1617 |
$subscribe_to_comments_post_ID = ! empty( $_POST['srp'] ) ? intval( $_POST['srp'] ) : ( ! empty( $_GET['srp'] ) ? intval( $_GET['srp'] ) : 0 );
|
1618 |
|
1636 |
|
1637 |
}
|
1638 |
|
1639 |
+
/**
|
1640 |
+
* Add custom output before comment content
|
1641 |
+
*
|
1642 |
+
* @since 190801
|
1643 |
+
*/
|
1644 |
+
public function comment_content_prepend( $comment_text, $comment = null ) {
|
1645 |
+
|
1646 |
+
global $wp_subscribe_reloaded;
|
1647 |
+
global $post;
|
1648 |
+
|
1649 |
+
$prepend = '';
|
1650 |
+
|
1651 |
+
// comment held for moderation and email is subscribed to the post
|
1652 |
+
if ( $comment->comment_approved == '0' && $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, $comment->comment_author_email, 'C' ) ) {
|
1653 |
+
$prepend = '<p><em>' . __( 'Check your email to confirm your subscription.', 'subscribe-to-comments-reloaded' ) . '</em></p>';
|
1654 |
+
}
|
1655 |
+
|
1656 |
+
// pass it back
|
1657 |
+
return $prepend . $comment_text;
|
1658 |
+
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
}
|
1662 |
+
|
1663 |
}
|