Subscribe To Comments Reloaded - Version 191009

Version Description

Download this release

Release Info

Developer wpkube
Plugin Icon 128x128 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 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: 2018-02-25 23:10-0700\n"
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.0.6\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-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 _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'] ) ?>' />
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 _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,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 _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'] ) ?>' />
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 _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 _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,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 _e( 'Update', 'subscribe-to-comments-reloaded' ) ?>' ></td>
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 _e( 'Add', 'subscribe-to-comments-reloaded' ) ?>' >
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 _e( 'Generate New Key' ) ?>" class="btn btn-secondary subscribe-form-button" name="generate_key" >
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 _e( 'Reset All Options' ) ?>" class="btn btn-danger subscribe-form-button reset_all_options" name="reset_all_options" >
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 _e( 'Clean' ); ?>' class='btn btn-secondary subscribe-form-button' name='purge_log' >
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: 190529
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: 190529
6
* Author: WPKube
7
* Author URI: http://wpkube.com/
8
* License: GPL-2.0+
@@ -12,27 +12,41 @@
12
*/
13
14
namespace stcr;
15
- // Avoid direct access to this piece of code
16
if ( ! function_exists( 'add_action' ) ) {
17
header( 'Location: /' );
18
exit;
19
}
20
- require_once dirname(__FILE__).'/wp_subscribe_reloaded.php';
21
- if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_subscribe_reloaded'))
22
- {
23
class stcr_subscribe_reloaded {
24
- // http://www.garfieldtech.com/blog/class-constants-php54
25
- const CLASSNAME = __CLASS__;
26
27
public $stcr = null;
28
29
function __construct() {
30
$this->stcr = new wp_subscribe_reloaded();
31
- $this->stcr->setUserCoookie();
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 activate function located on utils/stcr_manage.php
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
- // Initialization routines that should be executed on activation/deactivation
54
- // Due to Wordpress restrinctions these hooks have to be on the main file.
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
- if ( ! isset( $GLOBALS['wp_subscribe_reloaded'] ) )
59
- {
60
- $GLOBALS['wp_subscribe_reloaded'] = new stcr_subscribe_reloaded(); // Initialize the cool stuff
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
- // Avoid direct access to this piece of code
3
if ( ! function_exists( 'add_action' ) ) {
4
header( 'Location: /' );
5
exit;
6
}
7
8
global $wp_subscribe_reloaded;
9
- $post_permalink = null;
10
11
- if (array_key_exists('post_permalink', $_GET))
12
- {
13
- if ( ! empty( $_GET['post_permalink'] ) )
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
- if ( isset( $post_permalink ) )
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>&nbsp; '. __('Return to Post','subscribe-to-comments-reloaded').'</a>
29
</p>';
30
}
31
32
- return "<p>$message</p>";
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>&nbsp; '. __('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 _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
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->post_name, $message );
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
- if ( isset($current_user) && $current_user->ID > 0 )
16
- {
17
$current_user_email = $current_user->data->user_email;
18
}
19
20
- if (array_key_exists('post_permalink', $_GET))
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 = str_replace( '[blog_name]', get_bloginfo( 'name' ), $subject );
63
- // Setup the fronted page message
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
- else
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>&nbsp; '. __('Return to Post','subscribe-to-comments-reloaded').'</a>
126
</p>';
127
}
128
129
}
130
- if( ! $valid_email )
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
- echo "<p> ". wpautop( $message ) . "</p>";?>
137
<form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
138
<fieldset style="border:0">
139
- <p><label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
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>&nbsp; '. __('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
- if ( isset($current_user) && $current_user->ID > 0 )
14
- {
15
$current_user_email = $current_user->data->user_email;
16
}
17
18
- ob_start();
19
$post_permalink = get_permalink( $post_ID );
20
21
- if ( ! empty( $email ) ) {
22
- $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
23
24
- if ( $stcr_post_email === false )
25
- {
26
$valid_email = false;
27
- }
28
- else
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
- // If the case, send a message to the administrator
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
- // Prepare email settings
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
- if ( get_option( 'subscribe_reloaded_enable_double_check' ) == 'yes'
71
- && ! $wp_subscribe_reloaded->stcr->is_user_subscribed( $post_ID, $clean_email, 'C' ) )
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
- else {
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
- echo wpautop($message);
90
}
91
- }
92
- else {
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
- echo "<p>";
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
- echo "</p>";
116
?>
117
- <form action="<?php
118
- echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>"
119
- method="post" name="sub-form">
120
<fieldset style="border:0">
121
- <p><label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
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 _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
124
- <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
125
- </p>
126
</fieldset>
127
</form>
128
<?php
129
}
130
- if( ! $valid_email )
131
- {
132
- echo "<p>";
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 _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
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
- <script type="text/javascript">
157
- ( function($){
158
- $(document).ready(function($){
159
- var stcr_request_form = $('form[name="sub-form"]');
160
- var email_input = $('form[name="sub-form"] input[name="sre"]');
161
- /**
162
- * Validate the email address.
163
- * @since 09-Sep-2016
164
- * @author reedyseth
165
- */
166
- stcr_request_form.on('submit',function (event) {
167
- 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,}))#x2F;;
168
- var email = $('input[name="sre"]');
169
-
170
- if( email.val() !== "email" && email.val() === "" )
171
- {
172
- event.preventDefault();
173
- $(".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);
174
- }
175
- else if( emailRegex.test( email.val() ) === false )
176
- {
177
- event.preventDefault();
178
- $(".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);
179
- }
180
- });
181
-
182
- email_input.focus(function(){
183
- if( $(this).val() == <?php echo wp_json_encode( $email ); ?> )
184
- {
185
- $(this).val("");
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
- } )( jQuery );
197
- </script>
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,}))#x2F;;
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
- if ($safeUnistall === "yes")
15
- {
16
- // Drop Only the Settings and not the subscriptions.
17
- // Goodbye options...
18
- foreach($stcr_options as $option)
19
- {
20
delete_option( $option->option_name );
21
}
22
- }
23
- else if ($safeUnistall === "no")
24
- {
25
- // Goodbye data...
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
- // Goodbye options...
30
- foreach($stcr_options as $option)
31
- {
32
delete_option( $option->option_name );
33
}
34
}
35
36
- // Remove scheduled autopurge events
37
wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
38
wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
39
40
-
41
- function stcr_get_settings($_wpdb)
42
- {
43
- $stcr_options = $_wpdb->get_results(
44
- " SELECT * FROM $_wpdb->options WHERE option_name like 'subscribe_reloaded\_%'
45
- ORDER BY option_name", OBJECT
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
- $this->upgrade->_import_stc_data();
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
- 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,7 +181,73 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_upgrade') ) {
181
);
182
}
183
}
184
- // end _import_stc_data
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
- set_error_handler( array( $this, 'exceptions_error_handler' ) );
24
- }
25
-
26
- public function __destruct()
27
- {
28
- // house keeping
29
- unset($this->menu_opts_cache);
30
- }
31
-
32
- /**
33
- * Check a given email to be valid.
34
- *
35
- * @since 15-Feb-2018
36
- * @author Reedyseth
37
- * @param $email
38
- * @return mixed
39
- */
40
- public function check_valid_email( $email )
41
- {
42
- $email = trim( $email );
43
- $email = sanitize_email( $email );
44
- return filter_var( $email, FILTER_VALIDATE_EMAIL );
45
- }
46
- /**
47
- * Check for a valid number.
48
- *
49
- * @since 15-Feb-2018
50
- * @author Reedyseth
51
- * @param $number String|Integer to be validated
52
- * @return bool True if number false otherwise
53
- */
54
- public function check_valid_number( $number )
55
- {
56
- $valid = true;
57
-
58
- if ( ! is_numeric( $number ) )
59
- {
60
- $valid = false;
61
- }
62
-
63
- return $valid;
64
- }
65
-
66
- /*
67
- * This will retrieve an user/email from the prefix_subscribe_reloaded_subscribers table.
68
- * @param String $email email to be added.
69
- * @return Mix false|unique_key false on failure, key un success
70
- * */
71
- public function get_subscriber_key( $email = null) {
72
- global $wpdb;
73
- $subscriber = null;
74
- // Check if the user is register and the unique key
75
- $retrieveEmail = "SELECT salt, subscriber_unique_id FROM ".$wpdb->prefix."subscribe_reloaded_subscribers WHERE subscriber_email = %s";
76
- if( $email != null ) {
77
- $subscriber = $wpdb->get_row($wpdb->prepare($retrieveEmail,$email), OBJECT);
78
- if( ! empty( $subscriber ) ) {
79
- return sanitize_key( $subscriber->subscriber_unique_id );
80
- }
81
- }
82
- return false;
83
- }
84
- /*
85
- * This will add an user/email to the prefix_subscribe_reloaded_subscribers table.
86
- * @param String $email email to be added.
87
- * @return Boolean true|false true on success, false on failure
88
- * */
89
- public function remove_user_subscriber_table($_email) {
90
- global $wpdb;
91
-
92
- $OK = $wpdb->query(
93
- "DELETE FROM ".$wpdb->prefix."subscribe_reloaded_subscribers WHERE subscriber_email = '$_email'"
94
- );
95
- return $OK === false || $OK == 0 || empty( $OK ) ? false : $OK;
96
- }
97
-
98
- /*
99
- * This will add an user/email to the prefix_subscribe_reloaded_subscribers table.
100
- * @param String $email email to be added.
101
- * @return Boolean true|false true on success, false on failure
102
- * */
103
- public function add_user_subscriber_table($_email) {
104
- global $wpdb;
105
- $OK = false;
106
- $checkEmailSql = "SELECT COUNT(subscriber_email) FROM " . $wpdb->prefix . "subscribe_reloaded_subscribers WHERE subscriber_email = %s";
107
- $numSubscribers = $wpdb->get_var( $wpdb->prepare($checkEmailSql, $_email) );
108
- // If subscribers not found then add it to the subscribers table.
109
- if ( (int)$numSubscribers == 0 ) {
110
- $salt = time();
111
- // Insert query
112
- $OK = $wpdb->insert(
113
- $wpdb->prefix . "subscribe_reloaded_subscribers",
114
- array(
115
- "subscriber_email" => $_email,
116
- "salt" => $salt,
117
- "subscriber_unique_id" => $this->generate_temp_key( $salt . $_email )
118
- ),
119
- array(
120
- "%s",
121
- "%d",
122
- "%s"
123
- )
124
- );
125
- }
126
- return $OK === false || $OK == 0 || empty( $OK ) ? false : $OK;
127
- }
128
- /**
129
- * @param null|key $key the Unique Key of the email
130
- *
131
- * @return bool|String false if no key is found or the email if found.
132
- */
133
- public function get_subscriber_email_by_key( $key = null) {
134
- global $wpdb;
135
-
136
- if( $key != null ) {
137
- // Sanitize the key just for precaution.
138
- $key = trim( sanitize_key($key) );
139
- // Check if the user is register and the unique key
140
- $retrieveEmail = "SELECT subscriber_email FROM "
141
- .$wpdb->prefix."subscribe_reloaded_subscribers WHERE subscriber_unique_id = %s";
142
-
143
- $subscriber = $wpdb->get_row($wpdb->prepare($retrieveEmail,$key), OBJECT);
144
-
145
- if( ! empty( $subscriber->subscriber_email ) ) {
146
- return $subscriber->subscriber_email;
147
- }
148
- }
149
- return false;
150
- }
151
- /**
152
- * Generate a unique key to allow users to manage their subscriptions
153
- */
154
- public function generate_key( $_email = "" ) {
155
- $salt = time();
156
- $dd_salt = md5( $salt );
157
- $uniqueKey = md5( $dd_salt . $salt . sanitize_email( $_email ) );
158
-
159
- return $uniqueKey;
160
- }
161
-
162
- public function generate_temp_key( $_email ) {
163
- $uniqueKey = sanitize_key( get_option( "subscribe_reloaded_unique_key" ) );
164
- $key = md5( $uniqueKey . $_email );
165
-
166
- return $key;
167
- }
168
- // end generate_key
169
- public function stcr_translate_month( $date_str )
170
- {
171
- $months_long = array (
172
- "January" => __("January",'subscribe-to-comments-reloaded'),
173
- "February" => __("February",'subscribe-to-comments-reloaded'),
174
- "March" => __("March",'subscribe-to-comments-reloaded'),
175
- "April" => __("April",'subscribe-to-comments-reloaded'),
176
- "May" => __("May",'subscribe-to-comments-reloaded'),
177
- "June" => __("June",'subscribe-to-comments-reloaded'),
178
- "July" => __("July",'subscribe-to-comments-reloaded'),
179
- "August" => __("August",'subscribe-to-comments-reloaded'),
180
- "September" => __("September",'subscribe-to-comments-reloaded'),
181
- "October" => __("October",'subscribe-to-comments-reloaded'),
182
- "November" => __("November",'subscribe-to-comments-reloaded'),
183
- "December" => __("December",'subscribe-to-comments-reloaded')
184
- );
185
-
186
- $months_short = array (
187
- "Jan" => __("Jan",'subscribe-to-comments-reloaded'),
188
- "Feb" => __("Feb",'subscribe-to-comments-reloaded'),
189
- "Mar" => __("Mar",'subscribe-to-comments-reloaded'),
190
- "Apr" => __("Apr",'subscribe-to-comments-reloaded'),
191
- "May" => __("May",'subscribe-to-comments-reloaded'),
192
- "Jun" => __("Jun",'subscribe-to-comments-reloaded'),
193
- "Jul" => __("Jul",'subscribe-to-comments-reloaded'),
194
- "Aug" => __("Aug",'subscribe-to-comments-reloaded'),
195
- "Sep" => __("Sep",'subscribe-to-comments-reloaded'),
196
- "Oct" => __("Oct",'subscribe-to-comments-reloaded'),
197
- "Nov" => __("Nov",'subscribe-to-comments-reloaded'),
198
- "Dec" => __("Dec",'subscribe-to-comments-reloaded')
199
- );
200
-
201
- // Replace String
202
- foreach( $months_long as $key => $value)
203
- {
204
- $date_str = str_replace( $key, $value, $date_str);
205
- }
206
- // Find String
207
- foreach( $months_short as $key => $value)
208
- {
209
- $date_str = str_replace( $key, $value, $date_str);
210
- }
211
- // Return string
212
- return $date_str;
213
- }
214
-
215
- public function to_num_ini_notation( $size )
216
- {
217
- $l = substr( $size, - 1 );
218
- $ret = substr( $size, 0, - 1 );
219
- switch ( strtoupper( $l ) ) {
220
- case 'P':
221
- $ret *= 1024;
222
- case 'T':
223
- $ret *= 1024;
224
- case 'G':
225
- $ret *= 1024;
226
- case 'M':
227
- $ret *= 1024;
228
- case 'K':
229
- $ret *= 1024;
230
- }
231
-
232
- return $ret;
233
- }
234
-
235
- /**
236
- * Get plugin info including status
237
- *
238
- * This is an enhanced version of get_plugins() that returns the status
239
- * (`active` or `inactive`) of all plugins. Does not include MU plugins.
240
- *
241
- * @version 1.0.0
242
- * @since 28-Nov-2018
243
- *
244
- * @return array Plugin info plus status
245
- */
246
- function stcr_get_plugins() {
247
- $plugins = get_plugins();
248
- $active_plugin_paths = (array) get_option( 'active_plugins', array() );
249
-
250
- if ( is_multisite() ) {
251
- $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
252
- $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
253
- }
254
-
255
- foreach ( $plugins as $plugin_path => $plugin_data ) {
256
- // Is plugin active?
257
- if ( in_array( $plugin_path, $active_plugin_paths ) ) {
258
- $plugins[ $plugin_path ]['Status'] = 'active';
259
- } else {
260
- $plugins[ $plugin_path ]['Status'] = 'inactive';
261
- }
262
- }
263
-
264
- return $plugins;
265
- }
266
-
267
- /**
268
- * Creates the HTML structure to properly handle HTML messages
269
- */
270
- public function wrap_html_message( $_message = '', $_subject = '' ) {
271
- global $wp_locale;
272
- $_message = apply_filters( 'stcr_wrap_html_message', $_message );
273
- // Add HTML paragraph tags to comment
274
- // See wp-includes/formatting.php for details on the wpautop() function
275
- $_message = wpautop( $_message );
276
-
277
- if( $wp_locale->text_direction == "rtl")
278
- {
279
- $locale = get_locale();
280
- $html = "<html xmlns='http://www.w3.org/1999/xhtml' dir='rtl' lang='$locale'>";
281
- $head = "<head><title>$_subject</title></head>";
282
- $body = "<body>$_message</body>";
283
- return $html . $head . $body . "</html>";
284
- }
285
- else
286
- {
287
- $html = "<html>";
288
- $head = "<head><title>$_subject</title></head>";
289
- $body = "<body>$_message</body>";
290
- return $html . $head . $body . "</html>";
291
- }
292
-
293
- }
294
- // end _wrap_html_message
295
-
296
- /**
297
- * Returns an email address where some possible 'offending' strings have been removed
298
- */
299
- public function clean_email( $_email ) {
300
- $offending_strings = array(
301
- "/to\:/i",
302
- "/from\:/i",
303
- "/bcc\:/i",
304
- "/cc\:/i",
305
- "/content\-transfer\-encoding\:/i",
306
- "/content\-type\:/i",
307
- "/mime\-version\:/i"
308
- );
309
-
310
- return sanitize_email( stripslashes( strip_tags( preg_replace( $offending_strings, '', $_email ) ) ) );
311
- }
312
- // end clean_email
313
-
314
- public function create_options()
315
- {
316
- // Messages related to the management page
317
- global $wp_rewrite;
318
-
319
- if ( empty( $wp_rewrite->permalink_structure ) ) {
320
- add_option( 'subscribe_reloaded_manager_page', '/?page_id=99999', '', 'yes' );
321
- } else {
322
- add_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/', '', 'yes' );
323
- }
324
-
325
- add_option( 'subscribe_reloaded_unique_key', $this->generate_key(), '', 'yes' );
326
- add_option( 'subscribe_reloaded_fresh_install', 'no', '', 'yes' );
327
- add_option( 'subscribe_reloaded_safely_uninstall', 'yes', '', 'yes' );
328
- add_option( 'subscribe_reloaded_stcr_position', 'no', '', 'yes' );
329
- add_option( 'subscribe_reloaded_reply_to', '', '', 'yes' );
330
- 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' );
331
- add_option( 'subscribe_reloaded_subscriber_table', 'no', '', 'yes' );
332
- add_option( 'subscribe_reloaded_data_sanitized', 'yes', '', 'yes' );
333
- add_option( 'subscribe_reloaded_show_subscription_box', 'yes', '', 'yes' );
334
- add_option( 'subscribe_reloaded_checked_by_default', 'no', '', 'yes' );
335
- add_option( 'subscribe_reloaded_enable_advanced_subscriptions', 'no', '', 'yes' );
336
- add_option( 'subscribe_reloaded_default_subscription_type', '2', '', 'yes' );
337
- add_option( 'subscribe_reloaded_checked_by_default_value', '0', '', 'yes' );
338
- add_option( 'subscribe_reloaded_checkbox_inline_style', 'width:30px', '', 'yes' );
339
- add_option( 'subscribe_reloaded_checkbox_html', "<p class='comment-form-subscriptions'><label for='subscribe-reloaded'>[checkbox_field] [checkbox_label]</label></p>", '', 'yes' );
340
- 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' );
341
- 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' );
342
- 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' );
343
- add_option( 'subscribe_reloaded_author_label', __( "You can <a href='[manager_link]'>manage the subscriptions</a> of this post.", 'subscribe-to-comments-reloaded' ), '', 'yes' );
344
-
345
- add_option( 'subscribe_reloaded_manager_page_enabled', 'yes', '', 'yes' );
346
- add_option( 'subscribe_reloaded_virtual_manager_page_enabled', 'yes', '', 'yes' );
347
- add_option( 'subscribe_reloaded_manager_page_title', __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ), '', 'yes' );
348
- add_option( 'subscribe_reloaded_custom_header_meta', "<meta name='robots' content='noindex,nofollow'>", '', 'yes' );
349
- 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' );
350
- 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' );
351
- 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' );
352
- 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' );
353
- 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' );
354
- 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' );
355
- 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' );
356
-
357
- add_option( 'subscribe_reloaded_from_name', get_bloginfo( 'name' ), '', 'yes' );
358
- add_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ), '', 'yes' );
359
- add_option( 'subscribe_reloaded_notification_subject', __( 'There is a new comment to [post_title]', 'subscribe-to-comments-reloaded' ), '', 'yes' );
360
- 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' );
361
- add_option( 'subscribe_reloaded_double_check_subject', __( 'Please confirm your subscription to [post_title]', 'subscribe-to-comments-reloaded' ), '', 'yes' );
362
- 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' );
363
- add_option( 'subscribe_reloaded_management_subject', __( 'Manage your subscriptions on [blog_name]', 'subscribe-to-comments-reloaded' ) );
364
- 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' ) );
365
- 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' ) );
366
-
367
- add_option( 'subscribe_reloaded_purge_days', '30', '', 'yes' );
368
- add_option( 'subscribe_reloaded_enable_double_check', 'yes', '', 'yes' );
369
- add_option( 'subscribe_reloaded_notify_authors', 'no', '', 'yes' );
370
- add_option( 'subscribe_reloaded_enable_html_emails', 'yes', '', 'yes' );
371
- add_option( 'subscribe_reloaded_htmlify_message_links', 'no', '', 'yes' );
372
- add_option( 'subscribe_reloaded_process_trackbacks', 'no', '', 'yes' );
373
- add_option( 'subscribe_reloaded_enable_admin_messages', 'no', '', 'yes' );
374
- add_option( 'subscribe_reloaded_admin_subscribe', 'no', '', 'yes' );
375
- add_option( 'subscribe_reloaded_admin_bcc', 'no', '', 'yes' );
376
- add_option( 'subscribe_reloaded_enable_log_data', 'no', '', 'yes' );
377
- add_option( 'subscribe_reloaded_auto_clean_log_data', 'yes', '', 'yes' );
378
- add_option( 'subscribe_reloaded_auto_clean_log_frecuency', 'daily', '', 'yes' );
379
- add_option( 'subscribe_reloaded_enable_font_awesome', 'yes', '', 'yes' );
380
- add_option( 'subscribe_reloaded_delete_options_subscriptions', 'no', '', 'no' );
381
- add_option( 'subscribe_reloaded_date_format', 'd M Y', '', 'no' );
382
- add_option( 'subscribe_reloaded_only_for_posts', 'no', '', 'yes' );
383
-
384
- }
385
- /**
386
- * @since 08-February-2018
387
- * @author reedyseth
388
- * @param $delete_subscriptions String Decide either to delete the subscriptions or not.
389
- * @return true|false Boolean on success or failure.
390
- */
391
- public function delete_all_settings( $delete_subscriptions = no )
392
- {
393
- global $wpdb;
394
- $sql = "SELECT * FROM $wpdb->options WHERE option_name like 'subscribe_reloaded\_%'
395
- ORDER BY option_name";
396
- $stcr_options = $wpdb->get_results( $sql , OBJECT );
397
- if( $stcr_options !== false && is_array( $stcr_options ) )
398
- {
399
- // Drop Only the Settings and not the subscriptions.
400
- // Goodbye options...
401
- foreach($stcr_options as $option)
402
- {
403
- delete_option( $option->option_name );
404
- }
405
- if ( $delete_subscriptions == "yes" )
406
- {
407
- // Delete the subscriptions in both tables.
408
- $wpdb->query( "DELETE FROM {$wpdb->prefix}subscribe_reloaded_subscribers" );
409
- $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '\_stcr@\_%'" );
410
- }
411
- }
412
-
413
-
414
- if ( $stcr_options === false )
415
- {
416
- return false;
417
- }
418
- else
419
- {
420
- return true;
421
- }
422
- }
423
- /**
424
- * Enqueue a script that was previous registered,
425
- *
426
- * @since 28-Mar-2018
427
- * @author reedyseth
428
- * @param string $handle Script handle that will be enqueue
429
- */
430
- public function enqueue_script_to_wp( $handle )
431
- {
432
- wp_enqueue_script( $handle );
433
- }
434
-
435
- /**
436
- *
437
- *
438
- * @since
439
- * @author Israel Barragan (Reedyseth)
440
- *
441
- * @param $severity
442
- * @param $message
443
- * @param $filename
444
- * @param $lineno
445
- */
446
- function exceptions_error_handler($severity, $message, $filename, $lineno)
447
- {
448
- $date = date_i18n( 'Y-m-d H:i:s' );
449
- // We don't want to break things out, so instead we add the error information to
450
- // the log file, thus allowing us to help more on the debug / error / support of StCR.
451
- $this->stcr_logger("\n [ERROR][$date] - An error occur, here is the detail information\n");
452
- $this->stcr_logger(" [ERROR][SEVERITY] - $severity\n");
453
- $this->stcr_logger(" [ERROR][MESSAGE] - $message\n");
454
- $this->stcr_logger(" [ERROR][FILENAME] - $filename\n");
455
- $this->stcr_logger(" [ERROR][LINE NUMBER] - $lineno\n\n");
456
-
457
- // throw new \ErrorException($message, 0, $severity,$filename, $lineno);
458
- }
459
- /**
460
- * Will send an email by adding the correct headers.
461
- *
462
- * @since 28-May-2016
463
- * @author reedyseth
464
- * @param $_emailSettings Array Associative array with settings.
465
- * @return true|false Boolean On success or failure
466
- */
467
- public function send_email( $_settings )
468
- { // Retrieve the options from the database
469
- $from_name = html_entity_decode(
470
- stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) ), ENT_QUOTES, 'UTF-8' );
471
- $from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
472
- $reply_to = get_option( "subscribe_reloaded_reply_to" ) == ''
473
- ? $from_email : get_option( "subscribe_reloaded_reply_to" );
474
- $content_type = ( get_option( 'subscribe_reloaded_enable_html_emails' ) == 'yes' )
475
- ? 'text/html' : 'text/plain';
476
- $headers = "Content-Type: $content_type; charset=" . get_bloginfo( 'charset' ) . "\n";
477
- $date = date_i18n( 'Y-m-d H:i:s' );
478
-
479
- $_emailSettings = array(
480
- 'fromEmail' => $from_email,
481
- 'fromName' => $from_name,
482
- 'toEmail' => '',
483
- 'subject' => __('StCR Notification' ,'subscribe-to-comments-reloaded'),
484
- 'message' => '',
485
- 'bcc' => '',
486
- 'reply_to' => $reply_to,
487
- 'XPostId' => '0',
488
- 'XCommentId' => '0'
489
- );
490
-
491
- $_emailSettings = array_merge( $_emailSettings, $_settings );
492
- $_emailSettings[ 'message' ] = $this->wrap_html_message( $_emailSettings['message'], $_emailSettings['subject'] );
493
-
494
- $headers .= "From: \"{$_emailSettings['fromName']}\" <{$_emailSettings['fromEmail']}>\n";
495
- $headers .= "Reply-To: {$_emailSettings['reply_to']}\n";
496
- $headers .= "X-Post-Id: {$_emailSettings['XPostId']}\n";
497
- $headers .= "X-Comment-Id: {$_emailSettings['XCommentId']}\n";
498
-
499
- if ( get_option( 'subscribe_reloaded_admin_bcc' ) == 'yes' ) {
500
- $headers .= "Bcc: $from_name <$from_email>\n"; // The StCR email define or otherwise the blog admin.
501
- }
502
-
503
- $this->stcr_logger( "*********************************************************************************" );
504
- $this->stcr_logger( "\n\nDate: " . $date );
505
- $this->stcr_logger( "\n\nTo Email: " . $_emailSettings['toEmail'] );
506
- $this->stcr_logger( "\n\nFrom Email: " . $_emailSettings['fromEmail'] );
507
- $this->stcr_logger( "\n\nMessage: " . $_emailSettings['message'] );
508
- $this->stcr_logger( "\n\nHeaders:\n\n" . $headers );
509
- $this->stcr_logger( "*********************************************************************************" );
510
-
511
- $sent_result = ( wp_mail( $_emailSettings['toEmail'], $_emailSettings['subject'], $_emailSettings['message'], $headers ) )
512
- ? true : false;
513
- if( ! $sent_result )
514
- {
515
- $this->stcr_logger( "*********************************************************************************" );
516
- $this->stcr_logger( "\nError sending email notification.\n" );
517
- $this->stcr_logger( "*********************************************************************************" );
518
- }
519
-
520
- return $sent_result;
521
- }// End send_email
522
- /**
523
- * Checks if a key is valid for a given email address
524
- */
525
- public function _is_valid_key( $_key, $_email ) {
526
- if ( $this->generate_temp_key( $_email ) === $_key ) {
527
- return true;
528
- } else {
529
- return false;
530
- }
531
- }
532
- // end _is_valid_key
533
- /**
534
- * Enqueue scripts to load the TinyMCE ritch editor. I could use the hook `after_wp_tiny_mce` but I will
535
- * controll the tinyMCE version within my plugin instead of using the WordPress embedded one.
536
- * @since 03-Agu-2015
537
- * @author reedyseth
538
- */
539
- public function add_ritch_editor_textarea() {
540
- wp_enqueue_script('stcr-tinyMCE'); // TODO: Only enqueue it the first time.
541
- wp_enqueue_script('stcr-tinyMCE-js');
542
- }
543
- /**
544
- * Register scripts for admin pages. I could use the hook `after_wp_tiny_mce` but I will
545
- * controll the tinyMCE version within my plugin instead of using the WordPress embedded one.
546
- * @since 03-Agu-2015
547
- * @author reedyseth
548
- */
549
- public function register_admin_scripts( $hook ) {
550
-
551
- // paths
552
- $stcr_admin_js = ( is_ssl() ? str_replace( 'http://', 'https://', WP_PLUGIN_URL ) : WP_PLUGIN_URL ) . '/subscribe-to-comments-reloaded/includes/js/stcr-admin.js';
553
- $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';
554
-
555
- // register scripts
556
- wp_register_script('stcr-admin-js', $stcr_admin_js, array( 'jquery' ) );
557
-
558
- // rergister styles
559
- wp_register_style( 'stcr-admin-style', $stcr_admin_css );
560
-
561
- // check if we're on our pages
562
- if ( strpos( $hook, 'stcr' ) !== false ) {
563
-
564
- // enqueue scripts
565
- wp_enqueue_script('stcr-admin-js');
566
-
567
- // enqueue styles
568
- wp_enqueue_style('stcr-admin-style');
569
-
570
- }
571
-
572
- }
573
- /**
574
- * Hooking scripts for admin pages.
575
- * @since 03-Agu-2015
576
- * @author reedyseth
577
- */
578
- public function hook_admin_scripts() {
579
- // link the hooks
580
- add_action('admin_enqueue_scripts',array( $this, 'register_admin_scripts') );
581
- }
582
- /**
583
- * Registers a Javacsript file to the `wp_register_script` hook.
584
- *
585
- * @since 28-Mar-2018
586
- * @author reedyseth
587
- * @param string $handle Script handle the data will be attached to.
588
- * @param string $script_name JS File name.
589
- * @param string $path_add Sometimes the path is not in the root, therefore you can use this to complete the path.
590
- */
591
- public function register_script_to_wp( $handle, $script_name, $path_add = "" )
592
- {
593
- $js_resource = ( is_ssl() ? str_replace( 'http://', 'https://', WP_PLUGIN_URL ) : WP_PLUGIN_URL ) . "/". SLUG ."/$path_add/$script_name";
594
- wp_register_script( $handle, $js_resource );
595
- }
596
- /**includes/js/admin
597
- * Hooking scripts for plugin pages.
598
- * @since 22-Sep-2015
599
- * @author reedyseth
600
- */
601
- public function hook_plugin_scripts() {
602
- // link the hooks
603
- add_action('wp_enqueue_scripts',array( $this, 'register_plugin_scripts') );
604
- }
605
- /**
606
- * Register scripts for plugin pages.
607
- * @since 22-Sep-2015
608
- * @author reedyseth
609
- */
610
- public function register_plugin_scripts() {
611
- $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';
612
- // Font Awesome
613
- if( get_option( 'subscribe_reloaded_enable_font_awesome' ) == "yes" )
614
- {
615
- wp_register_style( 'stcr-font-awesome', $stcr_font_awesome_css );
616
- wp_enqueue_style('stcr-font-awesome');
617
- }
618
- }
619
- /**
620
- * Enqueue `style for plugin pages
621
- * @since 22-Sep-2015
622
- * @author reedyseth
623
- */
624
- public function add_plugin_js_scripts() {
625
- // Enqueue Scripts
626
- //wp_enqueue_script('stcr-plugin-js');
627
- }
628
- /**
629
- * Create a notice array with its settings and add it to the subscribe_reloaded_deferred_admin_notices
630
- * option.
631
- *
632
- * @since 14-Agu-2015
633
- * @author reedyseth
634
- *
635
- * @param string $_name Name of the notice.
636
- * @param string $_status status read/unread. This will determine if the notice is display or not.
637
- * @param string $_message Message that you want to show.
638
- * @param string $_type What kind of notice you can use updated/error.
639
- */
640
- public function stcr_create_admin_notice( $_name = '', $_status = 'unread', $_message = '', $_type = 'updated' ) {
641
- $notices = get_option( 'subscribe_reloaded_deferred_admin_notices', array() );
642
- $notices[ $_name ] = array(
643
- "status" => $_status,
644
- "message" => $_message,
645
- "type" => $_type
646
- );
647
- update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
648
- }
649
-
650
- /**
651
- * Method to avoid using all the StCR option variable name. Return the given option value.
652
- *
653
- * @since 08-Apr-2018
654
- * @author Israel Barragan (Reedyseth)
655
- *
656
- * @param string $_option Option Name
657
- * @param string $_default Default value in case is not defined.
658
- * @return string The option value store in WP.
659
- */
660
- public function stcr_get_menu_options($_option = '', $_default = '' )
661
- {
662
- $value = null;
663
-
664
- if ( isset( $this->menu_opts_cache[$_option] ) )
665
- {
666
- return $this->menu_opts_cache[$_option];
667
- }
668
- else
669
- {
670
- $value = get_option( 'subscribe_reloaded_' . $_option, $_default );
671
- $value = html_entity_decode( stripslashes( $value ), ENT_QUOTES, 'UTF-8' );
672
- $value = stripslashes( $value );
673
- // Set the cache value
674
- $this->menu_opts_cache[$_option] = $value;
675
- }
676
-
677
- return $value;
678
- }
679
- /**
680
- * Update a given notice with the given arguments.
681
- *
682
- * @since 14-Agu-2015
683
- * @author reedyseth
684
- *
685
- * @param string $_name Name of the notice.
686
- * @param string $_status status read/unread. This will determine if the notice is display or not.
687
- * @param string $_message Message that you want to show.
688
- * @param string $_type What kind of notice you can use updated/error.
689
- */
690
- public function stcr_update_admin_notice( $_name = '', $_status = 'unread', $_message = '', $_type = 'updated', $_nonce = 'nonce-key' ) {
691
- $notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
692
- foreach ( $notices as $key => $notice ) {
693
- if ( $key == $_name ) {
694
- $notices[ $key ] = array(
695
- "status" => $_status,
696
- "message" => $_message,
697
- "type" => $_type,
698
- "nonce" => $_nonce
699
- );
700
- }
701
- }
702
- update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
703
- }
704
- /**
705
- * Update a given notice status.
706
- *
707
- * @since 18-Agu-2015
708
- * @author reedyseth
709
- *
710
- * @param string $_name Name of the notice.
711
- * @param string $_status status read/unread. This will determine if the notice is display or not.
712
- */
713
- public function stcr_update_admin_notice_status( $_name = '', $_status = 'unread', $_nonce = 0 ) {
714
- $notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
715
- foreach ( $notices as $key => $notice ) {
716
- if ( $key == $_name ) {
717
- if ( $_status == 'read' ) {
718
- unset( $notices[$key] );
719
- } else {
720
- $notices[ $key ] = array(
721
- "status" => $_status,
722
- "message" => $notice['message'],
723
- "type" => $notice['type'],
724
- "nonce" => $_nonce
725
- );
726
- }
727
- }
728
- }
729
- update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
730
- }
731
-
732
-
733
- /**
734
- * Method to avoid using all the StCR option variable name. It also verify the type of value to be store.
735
- *
736
- * @since 07-Apr-2018
737
- * @author Israel Barragan (Reedyseth)
738
- *
739
- * @param string $_option Option Name.
740
- * @param string $_value
741
- * @param string $_type type to use for the correct sanitation yesno|integer|text|text-html|email|url
742
- * @return bool false in case that the value is not defined.
743
- */
744
- public function stcr_update_menu_options($_option = '', $_value = '', $_type = '' )
745
- {
746
- if ( ! isset( $_value ) ) {
747
- return false;
748
- }
749
-
750
- // Prevent XSS/CSRF attacks
751
- $_value = trim( stripslashes( $_value ) );
752
-
753
- switch ( $_type ) {
754
- case 'yesno':
755
- if ( $_value == 'yes' || $_value == 'no' ) {
756
- update_option( 'subscribe_reloaded_' . $_option, esc_attr( $_value ) );
757
- }
758
- break;
759
- case 'integer':
760
- update_option( 'subscribe_reloaded_' . $_option, abs( intval( esc_attr( $_value ) ) ) );
761
-
762
- break;
763
- case 'text':
764
- update_option( 'subscribe_reloaded_' . $_option, sanitize_text_field( $_value ) );
765
-
766
- break;
767
- case 'text-html':
768
- update_option( 'subscribe_reloaded_' . $_option, esc_html( $_value ) );
769
-
770
- break;
771
- case 'email':
772
- update_option( 'subscribe_reloaded_' . $_option, sanitize_email( esc_attr( $_value ) ) );
773
-
774
- break;
775
- case 'url':
776
- update_option( 'subscribe_reloaded_' . $_option, esc_url( $_value ) );
777
-
778
- break;
779
- default:
780
- update_option( 'subscribe_reloaded_' . $_option, esc_attr( $_value ) );
781
-
782
- break;
783
- }
784
-
785
- return true;
786
- }
787
- /**
788
- * Delete a given notice with the given arguments.
789
- *
790
- * @since 14-Agu-2015
791
- * @author reedyseth
792
- *
793
- * @param string $_name Name of the notice to be deleted.
794
- */
795
- public function stcr_remove_admin_notice( $_name = '' ) {
796
- $notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
797
- foreach ( $notices as $key => $notice ) {
798
- if ( $key == $_name ) {
799
- unset( $notices[ $key ] );
800
- }
801
- }
802
- update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
803
- }
804
- /**
805
- * Bind the notices to the ajax hook.
806
- *
807
- * @since 14-Agu-2015
808
- * @author reedyseth
809
- *
810
- * @param string $_notices The notifice to be binded.
811
- */
812
- public function stcr_create_ajax_notices() {
813
- $notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
814
-
815
- if ( $notices ) {
816
- foreach ( $notices as $key => $notice ) {
817
- add_action( 'wp_ajax_' . $key, array( $this, 'stcr_ajax_update_notification') );
818
- }
819
- }
820
- return;
821
- }
822
- /**
823
- * Create a new Ajax Hook.
824
- *
825
- * @since 07-Dic-2018
826
- * @author reedyseth
827
- *
828
- * @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.
829
- */
830
- public function stcr_create_ajax_hook( array $_actions )
831
- {
832
- foreach ($_actions as $hookName => $functionToBind )
833
- {
834
- add_action( 'wp_ajax_' . $hookName, array( $this, $functionToBind ) );
835
- }
836
-
837
- return;
838
- }
839
-
840
- /**
841
- * Update a StCR notification status
842
- *
843
- * @since 14-Agu-2015
844
- * @author reedyseth
845
- *
846
- * @param string $_notification The notification Name of the notice to be deleted.
847
- */
848
- public function stcr_ajax_update_notification () {
849
- $_notification = $_POST['action'];
850
- // Check Nonce
851
- check_ajax_referer( $_notification, 'security' );
852
- // Update status
853
- $this->stcr_update_admin_notice_status( sanitize_text_field( $_notification ), 'read' ) ;
854
- // Send success message
855
- wp_send_json_success( 'Notification status updated for "' . $_notification . '"' );
856
- die();
857
- }
858
- /**
859
- * Check if the current user is a WordPress Admin
860
- *
861
- * @since 10-Dic-2018
862
- * @author reedyseth
863
- *
864
- */
865
- public function stcr_is_admin()
866
- {
867
- return is_admin();
868
- }
869
- /**
870
- * Function to log messages into a given file. The variable $file_path must have writing permissions.
871
- *
872
- * @param string $value The message to log
873
- * @since 13-Mar-2016
874
- * @author reedyseth
875
- */
876
- public function stcr_logger( $value = '' )
877
- {
878
- $file_path = plugin_dir_path( __FILE__ );
879
- $file_name = "log.txt";
880
- $loggin_info = get_option("subscribe_reloaded_enable_log_data", "no");
881
-
882
- if( is_writable( $file_path ) && $loggin_info === "yes")
883
- {
884
- $file = fopen( $file_path . "/" . $file_name, "a" );
885
-
886
- fputs( $file , $value);
887
-
888
- fclose($file);
889
- }
890
- // else
891
- // {
892
- // throw new \Exception("The path $file_path is not writable, please check the folder Permissions.", 1);
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