Subscribe To Comments Reloaded - Version 220502

Version Description

Download this release

Release Info

Developer wpkube
Plugin Icon 128x128 Subscribe To Comments Reloaded
Version 220502
Comparing to
See all releases

Code changes from version 211130 to 220502

includes/css/stcr-admin-style.css CHANGED
@@ -1,464 +1,541 @@
1
- /*
2
- Admin styles for StCR.
3
-
4
- @author reedyseth
5
- @since 21-Sep-2015
6
- */
7
- /* ----------------------------------------------------------
8
- Common styles and utilities on pages.
9
- @author Israel Barragan (Reedyseth)
10
- @since 01-Apr-2018
11
- ---------------------------------------------------------- */
12
- .validate-error-text {
13
- color: #f55252;
14
- font-weight: bold; }
15
-
16
- .validate-error-field {
17
- border: 1px solid #ff9595 !important; }
18
-
19
- .stcr-hidden {
20
- position: absolute !important;
21
- top: -9999px !important;
22
- left: -9999px !important; }
23
-
24
- .clearFix {
25
- clear: both; }
26
-
27
- .hidden {
28
- display: none; }
29
-
30
- .float-right {
31
- float: right; }
32
-
33
- .float-left {
34
- float: left; }
35
-
36
- .stcr-alert-box {
37
- font-size: .85em; }
38
-
39
- /* ----------------------------------------------------------
40
- Styles use on the interaction with the user.
41
- @author Israel Barragan (Reedyseth)
42
- @since 01-Apr-2018
43
- ---------------------------------------------------------- */
44
- .stcr-loading-animation {
45
- display: none; }
46
-
47
- .dismiss {
48
- background: #00a0d2;
49
- border-color: #0073aa;
50
- -webkit-box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.5), 0 1px 0 rgba(0, 0, 0, 0.15);
51
- box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.5), 0 1px 0 rgba(0, 0, 0, 0.15);
52
- color: #fff;
53
- text-decoration: none;
54
- display: inline-block;
55
- text-decoration: none;
56
- font-size: 13px;
57
- line-height: 26px;
58
- height: 28px;
59
- margin: 0 0 0 10px;
60
- padding: 0 10px 1px;
61
- cursor: pointer;
62
- border-width: 1px;
63
- border-style: solid;
64
- -webkit-appearance: none;
65
- -webkit-border-radius: 3px;
66
- border-radius: 3px;
67
- white-space: nowrap;
68
- -webkit-box-sizing: border-box;
69
- -moz-box-sizing: border-box;
70
- box-sizing: border-box; }
71
-
72
- .dismiss:hover {
73
- background: #0091cd;
74
- border-color: #0073aa;
75
- -webkit-box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.6);
76
- box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.6);
77
- color: #fff; }
78
-
79
- .info-panel {
80
- background-color: #BBBBBB;
81
- padding: 8px;
82
- font-style: italic; }
83
-
84
- .more-info {
85
- color: #008ec2;
86
- cursor: pointer;
87
- width: 10%;
88
- font-size: 1.4rem; }
89
-
90
- .stcr-dismiss-notice p {
91
- font-size: 0.8rem !important; }
92
-
93
- .stcr-dismiss-notice h2 {
94
- font-size: 1rem !important; }
95
-
96
- li {
97
- margin-bottom: 0; }
98
-
99
- .navbar-expand-lg .navbar-nav .dropdown-menu {
100
- top: 30px;
101
- font-size: 0.9rem; }
102
-
103
- /* ----------------------------------------------------------
104
- Styles use on form styles. Helpful to customize Bootstrap behavior.
105
- @author Israel Barragan (Reedyseth)
106
- @since 01-Apr-2018
107
- ---------------------------------------------------------- */
108
- .form-controls-font {
109
- font-size: 1em !important; }
110
-
111
- .col-form-label {
112
- font-size: 0.95rem !important;
113
- font-weight: 600 !important; }
114
-
115
- .subscribers-mass-actions {
116
- margin-top: 20px;
117
- font-size: 0.9rem; }
118
-
119
- .subscribers-mass-actions select,
120
- .subscribers-mass-actions button,
121
- .subscribers-mass-actions input {
122
- font-size: 0.9rem !important; }
123
-
124
- .mass-update-subs {
125
- /*height: 100%;*/
126
- margin-top: 0 !important; }
127
-
128
- .mass-update-select-status {
129
- width: 70% !important;
130
- display: inline !important; }
131
-
132
- .new-sub-select-status {
133
- width: 76% !important;
134
- display: inline !important; }
135
-
136
- .form-control-select {
137
- width: 42% !important;
138
- display: inline !important;
139
- font-size: 0.9rem !important; }
140
-
141
- .form-control-input-3 {
142
- width: 30% !important;
143
- display: inline !important;
144
- font-size: 0.9rem !important; }
145
-
146
- .form-control-input-4 {
147
- width: 40% !important;
148
- display: inline !important;
149
- font-size: 0.9rem !important; }
150
-
151
- .form-control-input-5 {
152
- width: 50% !important;
153
- display: inline !important;
154
- font-size: 0.9rem !important; }
155
-
156
- .form-control-input-6 {
157
- width: 60% !important;
158
- display: inline !important;
159
- font-size: 0.9rem !important; }
160
-
161
- .form-control-input-7 {
162
- width: 70% !important;
163
- display: inline !important;
164
- font-size: 0.9rem !important; }
165
-
166
- .form-control-input-8 {
167
- width: 80% !important;
168
- display: inline !important;
169
- font-size: 0.9rem !important; }
170
-
171
- .form-control-input-9 {
172
- width: 90% !important;
173
- display: inline !important;
174
- font-size: 0.9rem !important; }
175
-
176
- .add-new-subs {
177
- /*height: 100%;*/
178
- margin-top: 0 !important; }
179
-
180
- .mass-update-subs h6,
181
- .add-new-subs h6 {
182
- cursor: pointer; }
183
-
184
- .subscribe-form-button {
185
- font-size: 0.8rem !important; }
186
-
187
- .switch {
188
- position: relative;
189
- display: inline-flex;
190
- margin-top: 7px;
191
- height: 26px;
192
- width: 120px;
193
- background: rgba(45, 43, 42, 0.1);
194
- border-radius: 3px;
195
- -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.13), 0 1px rgba(255, 255, 255, 0.1);
196
- box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.13), 0 1px rgba(255, 255, 255, 0.1); }
197
-
198
- .switch-label {
199
- position: relative;
200
- z-index: 2;
201
- float: left;
202
- width: 58px;
203
- line-height: 26px;
204
- font-size: 11px;
205
- color: #949494;
206
- text-align: center;
207
- text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
208
- cursor: pointer; }
209
-
210
- .switch-label:active {
211
- font-weight: bold; }
212
-
213
- .switch-label-off {
214
- padding-left: 2px; }
215
-
216
- .switch-label-on {
217
- padding-right: 2px; }
218
-
219
- .switch-input {
220
- display: none !important; }
221
-
222
- .switch-input:checked + .switch-label {
223
- font-weight: bold;
224
- color: rgba(0, 0, 0, 0.65);
225
- text-shadow: 0 1px rgba(255, 255, 255, 0.25);
226
- -webkit-transition: 0.15s ease-out;
227
- -moz-transition: 0.15s ease-out;
228
- -o-transition: 0.15s ease-out;
229
- transition: 0.15s ease-out; }
230
-
231
- .switch-input:checked + .switch-label-on ~ .switch-selection {
232
- /* Note: left: 50% doesn't transition in WebKit */
233
- left: 60px;
234
- background-image: -webkit-linear-gradient(top, #f3e4f6, #82928f);
235
- background-image: -moz-linear-gradient(top, #f3e4f6, #82928f);
236
- background-image: -o-linear-gradient(top, #f3e4f6, #82928f);
237
- background-image: linear-gradient(to bottom, #f3e4f6, #82928f); }
238
-
239
- .switch-selection {
240
- display: block;
241
- position: absolute;
242
- z-index: 1;
243
- top: 2px;
244
- left: 2px;
245
- width: 58px;
246
- height: 22px;
247
- background: #65bd63;
248
- border-radius: 3px;
249
- background-image: -webkit-linear-gradient(top, #9dd993, #46d443);
250
- background-image: -moz-linear-gradient(top, #9dd993, #46d443);
251
- background-image: -o-linear-gradient(top, #9dd993, #46d443);
252
- background-image: linear-gradient(to bottom, #9dd993, #46d443);
253
- -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 0 2px rgba(0, 0, 0, 0.2);
254
- box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 0 2px rgba(0, 0, 0, 0.2);
255
- -webkit-transition: left 0.15s ease-out;
256
- -moz-transition: left 0.15s ease-out;
257
- -o-transition: left 0.15s ease-out;
258
- transition: left 0.15s ease-out; }
259
-
260
- .switch-blue .switch-selection {
261
- background: #3aa2d0;
262
- background-image: -webkit-linear-gradient(top, #4fc9ee, #3aa2d0);
263
- background-image: -moz-linear-gradient(top, #4fc9ee, #3aa2d0);
264
- background-image: -o-linear-gradient(top, #4fc9ee, #3aa2d0);
265
- background-image: linear-gradient(to bottom, #4fc9ee, #3aa2d0); }
266
-
267
- .switch-yellow .switch-selection {
268
- background: #c4bb61;
269
- background-image: -webkit-linear-gradient(top, #e0dd94, #c4bb61);
270
- background-image: -moz-linear-gradient(top, #e0dd94, #c4bb61);
271
- background-image: -o-linear-gradient(top, #e0dd94, #c4bb61);
272
- background-image: linear-gradient(to bottom, #e0dd94, #c4bb61); }
273
-
274
- .helpDescription {
275
- margin-left: 10px;
276
- display: inline-flex;
277
- color: #008ec2;
278
- font-size: 0.9rem;
279
- cursor: pointer; }
280
-
281
- .webui-popover-helpDescriptionContent {
282
- font-size: 0.85rem; }
283
-
284
- .arrow {
285
- left: -8px !important; }
286
-
287
- .arrow:after {
288
- left: 4px !important;
289
- top: 0px !important;
290
- width: 17px !important;
291
- height: 2px !important; }
292
-
293
- /* ----------------------------------------------------------
294
- Styles use on Cards styles. Helpful to customize Bootstrap Cards behavior.
295
- @author Israel Barragan (Reedyseth)
296
- @since 01-Apr-2018
297
- ---------------------------------------------------------- */
298
- .card {
299
- padding: 0 !important; }
300
-
301
- .card-subscribers {
302
- -webkit-box-shadow: 0 0 6px 0 #9E9E9E;
303
- box-shadow: 0 0 6px 0 #9E9E9E; }
304
-
305
- .card-header {
306
- background-color: #008ec2 !important;
307
- color: #ffffff; }
308
-
309
- .card-font-size {
310
- font-size: 0.85em; }
311
-
312
- .original-card-padding {
313
- padding: 1.25rem !important; }
314
-
315
- .card-no-max-width {
316
- max-width: 100% !important; }
317
-
318
- /* ----------------------------------------------------------
319
- Styles use on Table styles. Helpful to customize Bootstrap Tables behavior.
320
- @author Israel Barragan (Reedyseth)
321
- @since 01-Apr-2018
322
- ---------------------------------------------------------- */
323
- table.subscribers-table {
324
- width: 100% !important; }
325
-
326
- table.subscribers-table thead {
327
- background-color: #b3e0f1; }
328
-
329
- table.subscribers-table thead th {
330
- line-height: normal;
331
- vertical-align: middle;
332
- padding: 0.55rem; }
333
-
334
- table.subscribers-table thead th:first-child {
335
- width: 15%;
336
- text-align: center; }
337
-
338
- table.subscribers-table tbody tr td:first-child {
339
- text-align: center; }
340
-
341
- table.subscribers-table thead th i {
342
- margin-right: 5px;
343
- font-size: 1.0rem; }
344
-
345
- table.subscribers-table thead th span {
346
- vertical-align: text-bottom;
347
- font-size: 0.9rem;
348
- text-transform: uppercase; }
349
-
350
- @media screen and (max-width: 651px) {
351
- table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > td:first-child,
352
- table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child {
353
- padding-left: 40px !important; }
354
-
355
- table.subscribers-table thead th span {
356
- display: none;
357
- }
358
-
359
- }
360
-
361
- @media screen and (max-width: 350px) {
362
- table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > td:first-child,
363
- table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child {
364
- padding-left: 57px !important; } }
365
-
366
- /* Override rules from DataTables causing styling issues.*/
367
- .dataTables_wrapper .dataTables_paginate .paginate_button {
368
- padding: 0 !important;
369
- margin-left: 0 !important;
370
- border: none !important;
371
- border-radius: 0px !important; }
372
-
373
- .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
374
- .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
375
- background: none !important;
376
- -webkit-box-shadow: none !important;
377
- -moz-box-shadow: none !important;
378
- box-shadow: none !important; }
379
-
380
- .system-info-table a {
381
- color: #0073aa; }
382
-
383
- /* ----------------------------------------------------------
384
- Styles use on form styles. Helpful to customize Bootstrap Buttons behavior.
385
- @author Israel Barragan (Reedyseth)
386
- @since 01-Apr-2018
387
- ---------------------------------------------------------- */
388
- .btn-primary {
389
- color: #fff !important;
390
- background-color: #0085ba !important;
391
- border-color: #80bbd2 !important; }
392
-
393
- .btn-primary:hover {
394
- color: #fff !important;
395
- background-color: #4299b9 !important;
396
- border-color: #5495ad !important; }
397
-
398
- .btn-third {
399
- color: #444 !important;
400
- background-color: #ffc63c !important;
401
- border-color: #dcb456 !important; }
402
-
403
- .btn-third:hover {
404
- color: #444 !important;
405
- background-color: #fdd575 !important;
406
- border-color: #dcb456 !important; }
407
-
408
- .btn-download {
409
- color: #445435;
410
- background-color: #7bd774;
411
- border-color: #28a745 !important; }
412
-
413
- .btn-download:hover {
414
- color: #445435;
415
- background-color: #78c771;
416
- border-color: #28a745 !important; }
417
-
418
- /* ----------------------------------------------------------
419
- Styles use on loading events.
420
- @author Israel Barragan (Reedyseth)
421
- @since 01-Apr-2018
422
- ---------------------------------------------------------- */
423
- .fa-spinner, .fa-play-circle {
424
- color: #ffc53a;
425
- -webkit-animation-name: spin;
426
- -webkit-animation-duration: 900ms;
427
- -webkit-animation-iteration-count: infinite;
428
- -webkit-animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98);
429
- -moz-animation-name: spin;
430
- -moz-animation-duration: 900ms;
431
- -moz-animation-iteration-count: infinite;
432
- -moz-animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98);
433
- -ms-animation-name: spin;
434
- -ms-animation-duration: 900ms;
435
- -ms-animation-iteration-count: infinite;
436
- -ms-animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98);
437
- animation-name: spin;
438
- animation-duration: 900ms;
439
- animation-iteration-count: infinite;
440
- animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98); }
441
-
442
- @-ms-keyframes spin {
443
- from {
444
- -ms-transform: rotate(0deg); }
445
- to {
446
- -ms-transform: rotate(360deg); } }
447
-
448
- @-moz-keyframes spin {
449
- from {
450
- -moz-transform: rotate(0deg); }
451
- to {
452
- -moz-transform: rotate(360deg); } }
453
-
454
- @-webkit-keyframes spin {
455
- from {
456
- -webkit-transform: rotate(0deg); }
457
- to {
458
- -webkit-transform: rotate(360deg); } }
459
-
460
- @keyframes spin {
461
- from {
462
- transform: rotate(0deg); }
463
- to {
464
- transform: rotate(360deg); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Admin styles for StCR.
3
+
4
+ @author reedyseth
5
+ @since 21-Sep-2015
6
+ */
7
+ /* ----------------------------------------------------------
8
+ Common styles and utilities on pages.
9
+ @author Israel Barragan (Reedyseth)
10
+ @since 01-Apr-2018
11
+ ---------------------------------------------------------- */
12
+ .validate-error-text {
13
+ color: #f55252;
14
+ font-weight: bold;
15
+ }
16
+
17
+ .validate-error-field {
18
+ border: 1px solid #ff9595 !important;
19
+ }
20
+
21
+ .stcr-hidden {
22
+ position: absolute !important;
23
+ top: -9999px !important;
24
+ left: -9999px !important;
25
+ }
26
+
27
+ .clearFix {
28
+ clear: both;
29
+ }
30
+
31
+ .hidden {
32
+ display: none;
33
+ }
34
+
35
+ .float-right {
36
+ float: right;
37
+ }
38
+
39
+ .float-left {
40
+ float: left;
41
+ }
42
+
43
+ .stcr-alert-box {
44
+ font-size: 0.85em;
45
+ }
46
+
47
+ /* ----------------------------------------------------------
48
+ Styles use on the interaction with the user.
49
+ @author Israel Barragan (Reedyseth)
50
+ @since 01-Apr-2018
51
+ ---------------------------------------------------------- */
52
+ .stcr-loading-animation {
53
+ display: none;
54
+ }
55
+
56
+ .dismiss {
57
+ background: #00a0d2;
58
+ border-color: #0073aa;
59
+ -webkit-box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.5), 0 1px 0 rgba(0, 0, 0, 0.15);
60
+ box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.5), 0 1px 0 rgba(0, 0, 0, 0.15);
61
+ color: #fff;
62
+ text-decoration: none;
63
+ display: inline-block;
64
+ text-decoration: none;
65
+ font-size: 13px;
66
+ line-height: 26px;
67
+ height: 28px;
68
+ margin: 0 0 0 10px;
69
+ padding: 0 10px 1px;
70
+ cursor: pointer;
71
+ border-width: 1px;
72
+ border-style: solid;
73
+ -webkit-appearance: none;
74
+ -webkit-border-radius: 3px;
75
+ border-radius: 3px;
76
+ white-space: nowrap;
77
+ -webkit-box-sizing: border-box;
78
+ -moz-box-sizing: border-box;
79
+ box-sizing: border-box;
80
+ }
81
+
82
+ .dismiss:hover {
83
+ background: #0091cd;
84
+ border-color: #0073aa;
85
+ -webkit-box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.6);
86
+ box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.6);
87
+ color: #fff;
88
+ }
89
+
90
+ .info-panel {
91
+ background-color: #BBBBBB;
92
+ padding: 8px;
93
+ font-style: italic;
94
+ }
95
+
96
+ .more-info {
97
+ color: #008ec2;
98
+ cursor: pointer;
99
+ width: 10%;
100
+ font-size: 1.4rem;
101
+ }
102
+
103
+ .stcr-dismiss-notice p {
104
+ font-size: 0.8rem !important;
105
+ }
106
+ .stcr-dismiss-notice h2 {
107
+ font-size: 1rem !important;
108
+ }
109
+
110
+ li {
111
+ margin-bottom: 0;
112
+ }
113
+
114
+ .navbar-expand-lg .navbar-nav .dropdown-menu {
115
+ top: 30px;
116
+ font-size: 0.9rem;
117
+ }
118
+
119
+ /* ----------------------------------------------------------
120
+ Styles use on form styles. Helpful to customize Bootstrap behavior.
121
+ @author Israel Barragan (Reedyseth)
122
+ @since 01-Apr-2018
123
+ ---------------------------------------------------------- */
124
+ .form-controls-font {
125
+ font-size: 1em !important;
126
+ }
127
+
128
+ .col-form-label {
129
+ font-size: 0.95rem !important;
130
+ font-weight: 600 !important;
131
+ }
132
+
133
+ .subscribers-mass-actions {
134
+ margin-top: 20px;
135
+ font-size: 0.9rem;
136
+ }
137
+
138
+ .subscribers-mass-actions select,
139
+ .subscribers-mass-actions button,
140
+ .subscribers-mass-actions input {
141
+ font-size: 0.9rem !important;
142
+ }
143
+
144
+ .mass-update-subs {
145
+ /*height: 100%;*/
146
+ margin-top: 0 !important;
147
+ }
148
+
149
+ .mass-update-select-status {
150
+ width: 70% !important;
151
+ display: inline !important;
152
+ }
153
+
154
+ .new-sub-select-status {
155
+ width: 76% !important;
156
+ display: inline !important;
157
+ }
158
+
159
+ .form-control-select {
160
+ width: 42% !important;
161
+ display: inline !important;
162
+ font-size: 0.9rem !important;
163
+ }
164
+
165
+ .form-control-input-3 {
166
+ width: 30% !important;
167
+ display: inline !important;
168
+ font-size: 0.9rem !important;
169
+ }
170
+
171
+ .form-control-input-4 {
172
+ width: 40% !important;
173
+ display: inline !important;
174
+ font-size: 0.9rem !important;
175
+ }
176
+
177
+ .form-control-input-5 {
178
+ width: 50% !important;
179
+ display: inline !important;
180
+ font-size: 0.9rem !important;
181
+ }
182
+
183
+ .form-control-input-6 {
184
+ width: 60% !important;
185
+ display: inline !important;
186
+ font-size: 0.9rem !important;
187
+ }
188
+
189
+ .form-control-input-7 {
190
+ width: 70% !important;
191
+ display: inline !important;
192
+ font-size: 0.9rem !important;
193
+ }
194
+
195
+ .form-control-input-8 {
196
+ width: 80% !important;
197
+ display: inline !important;
198
+ font-size: 0.9rem !important;
199
+ }
200
+
201
+ .form-control-input-9 {
202
+ width: 90% !important;
203
+ display: inline !important;
204
+ font-size: 0.9rem !important;
205
+ }
206
+
207
+ .add-new-subs {
208
+ /*height: 100%;*/
209
+ margin-top: 0 !important;
210
+ }
211
+
212
+ .mass-update-subs h6,
213
+ .add-new-subs h6 {
214
+ cursor: pointer;
215
+ }
216
+
217
+ .subscribe-form-button {
218
+ font-size: 0.8rem !important;
219
+ }
220
+
221
+ .switch {
222
+ position: relative;
223
+ display: inline-flex;
224
+ margin-top: 7px;
225
+ height: 26px;
226
+ width: 120px;
227
+ background: rgba(45, 43, 42, 0.1);
228
+ border-radius: 3px;
229
+ -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.13), 0 1px rgba(255, 255, 255, 0.1);
230
+ box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.13), 0 1px rgba(255, 255, 255, 0.1);
231
+ }
232
+
233
+ .switch-label {
234
+ position: relative;
235
+ z-index: 2;
236
+ float: left;
237
+ width: 58px;
238
+ line-height: 26px;
239
+ font-size: 11px;
240
+ color: #949494;
241
+ text-align: center;
242
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
243
+ cursor: pointer;
244
+ }
245
+
246
+ .switch-label:active {
247
+ font-weight: bold;
248
+ }
249
+
250
+ .switch-label-off {
251
+ padding-left: 2px;
252
+ }
253
+
254
+ .switch-label-on {
255
+ padding-right: 2px;
256
+ }
257
+
258
+ .switch-input {
259
+ display: none !important;
260
+ }
261
+
262
+ .switch-input:checked + .switch-label {
263
+ font-weight: bold;
264
+ color: rgba(0, 0, 0, 0.65);
265
+ text-shadow: 0 1px rgba(255, 255, 255, 0.25);
266
+ -webkit-transition: 0.15s ease-out;
267
+ -moz-transition: 0.15s ease-out;
268
+ -o-transition: 0.15s ease-out;
269
+ transition: 0.15s ease-out;
270
+ }
271
+
272
+ .switch-input:checked + .switch-label-on ~ .switch-selection {
273
+ /* Note: left: 50% doesn't transition in WebKit */
274
+ left: 60px;
275
+ background-image: -webkit-linear-gradient(top, #f3e4f6, #82928f);
276
+ background-image: -moz-linear-gradient(top, #f3e4f6, #82928f);
277
+ background-image: -o-linear-gradient(top, #f3e4f6, #82928f);
278
+ background-image: linear-gradient(to bottom, #f3e4f6, #82928f);
279
+ }
280
+
281
+ .switch-selection {
282
+ display: block;
283
+ position: absolute;
284
+ z-index: 1;
285
+ top: 2px;
286
+ left: 2px;
287
+ width: 58px;
288
+ height: 22px;
289
+ background: #65bd63;
290
+ border-radius: 3px;
291
+ background-image: -webkit-linear-gradient(top, #9dd993, #46d443);
292
+ background-image: -moz-linear-gradient(top, #9dd993, #46d443);
293
+ background-image: -o-linear-gradient(top, #9dd993, #46d443);
294
+ background-image: linear-gradient(to bottom, #9dd993, #46d443);
295
+ -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 0 2px rgba(0, 0, 0, 0.2);
296
+ box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 0 2px rgba(0, 0, 0, 0.2);
297
+ -webkit-transition: left 0.15s ease-out;
298
+ -moz-transition: left 0.15s ease-out;
299
+ -o-transition: left 0.15s ease-out;
300
+ transition: left 0.15s ease-out;
301
+ }
302
+
303
+ .switch-blue .switch-selection {
304
+ background: #3aa2d0;
305
+ background-image: -webkit-linear-gradient(top, #4fc9ee, #3aa2d0);
306
+ background-image: -moz-linear-gradient(top, #4fc9ee, #3aa2d0);
307
+ background-image: -o-linear-gradient(top, #4fc9ee, #3aa2d0);
308
+ background-image: linear-gradient(to bottom, #4fc9ee, #3aa2d0);
309
+ }
310
+
311
+ .switch-yellow .switch-selection {
312
+ background: #c4bb61;
313
+ background-image: -webkit-linear-gradient(top, #e0dd94, #c4bb61);
314
+ background-image: -moz-linear-gradient(top, #e0dd94, #c4bb61);
315
+ background-image: -o-linear-gradient(top, #e0dd94, #c4bb61);
316
+ background-image: linear-gradient(to bottom, #e0dd94, #c4bb61);
317
+ }
318
+
319
+ .helpDescription {
320
+ margin-left: 10px;
321
+ display: inline-flex;
322
+ color: #008ec2;
323
+ font-size: 0.9rem;
324
+ cursor: pointer;
325
+ }
326
+
327
+ .webui-popover-helpDescriptionContent {
328
+ font-size: 0.85rem;
329
+ }
330
+
331
+ .arrow {
332
+ left: -8px !important;
333
+ }
334
+
335
+ .arrow:after {
336
+ left: 4px !important;
337
+ top: 0px !important;
338
+ width: 17px !important;
339
+ height: 2px !important;
340
+ }
341
+
342
+ /* ----------------------------------------------------------
343
+ Styles use on Cards styles. Helpful to customize Bootstrap Cards behavior.
344
+ @author Israel Barragan (Reedyseth)
345
+ @since 01-Apr-2018
346
+ ---------------------------------------------------------- */
347
+ .card {
348
+ padding: 0 !important;
349
+ }
350
+
351
+ .card-subscribers {
352
+ -webkit-box-shadow: 0 0 6px 0 #9E9E9E;
353
+ box-shadow: 0 0 6px 0 #9E9E9E;
354
+ }
355
+
356
+ .card-header {
357
+ background-color: #008ec2 !important;
358
+ color: #ffffff;
359
+ }
360
+
361
+ .card-font-size {
362
+ font-size: 0.85em;
363
+ }
364
+
365
+ .original-card-padding {
366
+ padding: 1.25rem !important;
367
+ }
368
+
369
+ .card-no-max-width {
370
+ max-width: 100% !important;
371
+ }
372
+
373
+ /* ----------------------------------------------------------
374
+ Styles use on Table styles. Helpful to customize Bootstrap Tables behavior.
375
+ @author Israel Barragan (Reedyseth)
376
+ @since 01-Apr-2018
377
+ ---------------------------------------------------------- */
378
+ table.subscribers-table {
379
+ width: 100% !important;
380
+ }
381
+
382
+ table.subscribers-table thead {
383
+ background-color: #b3e0f1;
384
+ }
385
+
386
+ table.subscribers-table thead th {
387
+ line-height: normal;
388
+ vertical-align: middle;
389
+ padding: 0.55rem;
390
+ }
391
+
392
+ table.subscribers-table thead th:first-child {
393
+ width: 15%;
394
+ text-align: center;
395
+ }
396
+
397
+ table.subscribers-table tbody tr td:first-child {
398
+ text-align: center;
399
+ }
400
+
401
+ table.subscribers-table thead th i {
402
+ margin-right: 5px;
403
+ font-size: 1rem;
404
+ }
405
+
406
+ table.subscribers-table thead th span {
407
+ vertical-align: text-bottom;
408
+ font-size: 0.9rem;
409
+ text-transform: uppercase;
410
+ }
411
+
412
+ @media screen and (max-width: 651px) {
413
+ table.dataTable.dtr-inline.collapsed > tbody > tr[role=row] > td:first-child,
414
+ table.dataTable.dtr-inline.collapsed > tbody > tr[role=row] > th:first-child {
415
+ padding-left: 40px !important;
416
+ }
417
+ }
418
+ @media screen and (max-width: 350px) {
419
+ table.dataTable.dtr-inline.collapsed > tbody > tr[role=row] > td:first-child,
420
+ table.dataTable.dtr-inline.collapsed > tbody > tr[role=row] > th:first-child {
421
+ padding-left: 57px !important;
422
+ }
423
+ }
424
+ /* Override rules from DataTables causing styling issues.*/
425
+ .dataTables_wrapper .dataTables_paginate .paginate_button {
426
+ padding: 0 !important;
427
+ margin-left: 0 !important;
428
+ border: none !important;
429
+ border-radius: 0px !important;
430
+ }
431
+
432
+ .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
433
+ .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
434
+ background: none !important;
435
+ -webkit-box-shadow: none !important;
436
+ -moz-box-shadow: none !important;
437
+ box-shadow: none !important;
438
+ }
439
+
440
+ .system-info-table a {
441
+ color: #0073aa;
442
+ }
443
+
444
+ /* ----------------------------------------------------------
445
+ Styles use on form styles. Helpful to customize Bootstrap Buttons behavior.
446
+ @author Israel Barragan (Reedyseth)
447
+ @since 01-Apr-2018
448
+ ---------------------------------------------------------- */
449
+ .btn-primary {
450
+ color: #fff !important;
451
+ background-color: #0085ba !important;
452
+ border-color: #80bbd2 !important;
453
+ }
454
+
455
+ .btn-primary:hover {
456
+ color: #fff !important;
457
+ background-color: #4299b9 !important;
458
+ border-color: #5495ad !important;
459
+ }
460
+
461
+ .btn-third {
462
+ color: #444 !important;
463
+ background-color: #ffc63c !important;
464
+ border-color: #dcb456 !important;
465
+ }
466
+
467
+ .btn-third:hover {
468
+ color: #444 !important;
469
+ background-color: #fdd575 !important;
470
+ border-color: #dcb456 !important;
471
+ }
472
+
473
+ .btn-download {
474
+ color: #445435;
475
+ background-color: #7bd774;
476
+ border-color: #28a745 !important;
477
+ }
478
+
479
+ .btn-download:hover {
480
+ color: #445435;
481
+ background-color: #78c771;
482
+ border-color: #28a745 !important;
483
+ }
484
+
485
+ /* ----------------------------------------------------------
486
+ Styles use on loading events.
487
+ @author Israel Barragan (Reedyseth)
488
+ @since 01-Apr-2018
489
+ ---------------------------------------------------------- */
490
+ .fa-spinner, .fa-play-circle {
491
+ color: #ffc53a;
492
+ -webkit-animation-name: spin;
493
+ -webkit-animation-duration: 900ms;
494
+ -webkit-animation-iteration-count: infinite;
495
+ -webkit-animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98);
496
+ -moz-animation-name: spin;
497
+ -moz-animation-duration: 900ms;
498
+ -moz-animation-iteration-count: infinite;
499
+ -moz-animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98);
500
+ -ms-animation-name: spin;
501
+ -ms-animation-duration: 900ms;
502
+ -ms-animation-iteration-count: infinite;
503
+ -ms-animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98);
504
+ animation-name: spin;
505
+ animation-duration: 900ms;
506
+ animation-iteration-count: infinite;
507
+ animation-timing-function: cubic-bezier(0.4, 0.62, 0.93, 0.98);
508
+ }
509
+
510
+ @-ms-keyframes spin {
511
+ from {
512
+ -ms-transform: rotate(0deg);
513
+ }
514
+ to {
515
+ -ms-transform: rotate(360deg);
516
+ }
517
+ }
518
+ @-moz-keyframes spin {
519
+ from {
520
+ -moz-transform: rotate(0deg);
521
+ }
522
+ to {
523
+ -moz-transform: rotate(360deg);
524
+ }
525
+ }
526
+ @-webkit-keyframes spin {
527
+ from {
528
+ -webkit-transform: rotate(0deg);
529
+ }
530
+ to {
531
+ -webkit-transform: rotate(360deg);
532
+ }
533
+ }
534
+ @keyframes spin {
535
+ from {
536
+ transform: rotate(0deg);
537
+ }
538
+ to {
539
+ transform: rotate(360deg);
540
+ }
541
+ }
options/index.php CHANGED
@@ -1,27 +1,26 @@
1
- <?php
2
- // Avoid direct access to this piece of code
3
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
4
- header( 'Location: /' );
5
- exit;
6
- }
7
- global $wp_subscribe_reloaded;
8
- global $wp_locale;
9
-
10
- ?>
11
-
12
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
13
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/Font-Awesome/web-fonts-with-css/css/fontawesome-all.min.css" rel="stylesheet"/>
14
- <style type="text/css">
15
- #wpcontent {
16
- background: #f1f1f1 !important;
17
- padding-left: 0 !important;
18
- position: relative;
19
- /* WordPress Fonts */
20
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
21
- color: #464646 !important;
22
- }
23
- .navbar a { font-size: 1em !important; font-weight: 600; color: #464646 !important;}
24
- </style>
25
-
26
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
27
-
1
+ <?php
2
+ // Avoid direct access to this piece of code
3
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
4
+ header( 'Location: /' );
5
+ exit;
6
+ }
7
+ global $wp_subscribe_reloaded;
8
+ global $wp_locale;
9
+
10
+ ?>
11
+
12
+ <link href="<?php echo esc_url( plugins_url( '/vendor/bootstrap/dist/css/bootstrap.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
13
+ <link href="<?php echo esc_url( plugins_url( '/vendor/Font-Awesome/web-fonts-with-css/css/fontawesome-all.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
14
+ <style type="text/css">
15
+ #wpcontent {
16
+ background: #f1f1f1 !important;
17
+ padding-left: 0 !important;
18
+ position: relative;
19
+ /* WordPress Fonts */
20
+ font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
21
+ color: #464646 !important;
22
+ }
23
+ .navbar a { font-size: 1em !important; font-weight: 600; color: #464646 !important;}
24
+ </style>
25
+
26
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/bootstrap/dist/js/bootstrap.bundle.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
 
options/options_template.php CHANGED
@@ -1,112 +1,133 @@
1
- <?php
2
- // Options
3
-
4
- // Avoid direct access to this piece of code
5
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
- header( 'Location: /' );
7
- exit;
8
- }
9
-
10
- $options = array(
11
- 'show_subscription_box' => 'yesno',
12
- 'safely_uninstall' => 'yesno',
13
- 'purge_days' => 'integer',
14
- 'date_format' => 'text',
15
- 'stcr_position' => 'yesno',
16
- 'enable_double_check' => 'yesno',
17
- 'notify_authors' => 'yesno',
18
- 'enable_html_emails' => 'yesno',
19
- 'process_trackbacks' => 'yesno',
20
- 'enable_admin_messages' => 'yesno',
21
- 'admin_subscribe' => 'yesno',
22
- 'admin_bcc' => 'yesno',
23
- 'enable_font_awesome' => 'yesno',
24
- 'delete_options_subscriptions' => 'yesno',
25
- 'only_for_posts' => 'yesno',
26
- 'only_for_logged_in' => 'yesno',
27
- 'use_cookies' => 'yesno',
28
- 'use_challenge_question' => 'yesno',
29
- 'challenge_question' => 'text',
30
- 'challenge_answer' => 'text',
31
- 'use_captcha' => 'yesno',
32
- 'captcha_site_key' => 'text',
33
- 'captcha_secret_key' => 'text',
34
- 'allow_subscribe_without_comment' => 'yesno',
35
- 'allow_request_management_link' => 'yesno',
36
- );
37
-
38
- // Update options
39
- if ( isset( $_POST['options'] ) ) {
40
- $faulty_fields = array();
41
-
42
- foreach ( $_POST['options'] as $option => $value )
43
- {
44
- // echo $option . '<br>';
45
-
46
- if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
47
- {
48
- array_push( $faulty_fields, $option );
49
- }
50
- }
51
-
52
- // Display an alert in the admin interface if something went wrong
53
- echo '<div class="updated"><p>';
54
- if ( sizeof( $faulty_fields ) == 0 ) {
55
- _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
56
- } else {
57
- _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
58
- // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
59
- }
60
- echo "</p></div>";
61
- }
62
- wp_print_scripts( 'quicktags' );
63
-
64
- ?>
65
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.css" rel="stylesheet"/>
66
-
67
- <div class="container-fluid">
68
- <div class="mt-3"></div>
69
- <div class="row">
70
- <div class="col-sm-9">
71
- <form action="" method="post">
72
-
73
-
74
-
75
- <div class="form-group row">
76
- <div class="col-sm-9 offset-sm-1">
77
- <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
78
- <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
79
- </button>
80
- </div>
81
- </div>
82
-
83
- </form>
84
- </div>
85
-
86
- <div class="col-md-3">
87
- <div class="card card-font-size">
88
- <div class="card-body">
89
- <p>
90
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
91
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
92
- </p>
93
- <p>
94
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
95
- </p>
96
- </div>
97
- </div>
98
- </div>
99
-
100
- </div>
101
- </div>
102
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.js"></script>
103
- <?php
104
- //global $wp_subscribe_reloaded;
105
- // Tell WP that we are going to use a resource.
106
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
107
- // Includes the Panel JS resource file as well as the JS text domain translations.
108
- //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
109
- // Enqueue the JS File
110
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
111
-
112
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This is just a template/example file, not used
4
+ */
5
+
6
+ // Options
7
+
8
+ // Avoid direct access to this piece of code
9
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
10
+ header( 'Location: /' );
11
+ exit;
12
+ }
13
+
14
+ $options = array(
15
+ 'show_subscription_box' => 'yesno',
16
+ 'safely_uninstall' => 'yesno',
17
+ 'purge_days' => 'integer',
18
+ 'date_format' => 'text',
19
+ 'stcr_position' => 'yesno',
20
+ 'enable_double_check' => 'yesno',
21
+ 'notify_authors' => 'yesno',
22
+ 'enable_html_emails' => 'yesno',
23
+ 'process_trackbacks' => 'yesno',
24
+ 'enable_admin_messages' => 'yesno',
25
+ 'admin_subscribe' => 'yesno',
26
+ 'admin_bcc' => 'yesno',
27
+ 'enable_font_awesome' => 'yesno',
28
+ 'delete_options_subscriptions' => 'yesno',
29
+ 'only_for_logged_in' => 'yesno',
30
+ 'use_cookies' => 'yesno',
31
+ 'use_challenge_question' => 'yesno',
32
+ 'challenge_question' => 'text',
33
+ 'challenge_answer' => 'text',
34
+ 'use_captcha' => 'yesno',
35
+ 'captcha_site_key' => 'text',
36
+ 'captcha_secret_key' => 'text',
37
+ 'allow_subscribe_without_comment' => 'yesno',
38
+ 'allow_request_management_link' => 'yesno',
39
+ 'recaptcha_version' => 'select',
40
+ 'blacklisted_emails' => 'textarea',
41
+ 'post_type_supports' => 'multicheck',
42
+ );
43
+
44
+ // Update options
45
+ if ( isset( $_POST['options'] ) ) {
46
+
47
+ if ( empty( $_POST['stcr_action_nonce'] ) ) {
48
+ return;
49
+ }
50
+
51
+ if ( ! wp_verify_nonce( $_POST['stcr_action_nonce'], 'stcr_action_nonce' ) ) {
52
+ return;
53
+ }
54
+
55
+ if ( ! current_user_can( 'manage_options' ) ) {
56
+ return;
57
+ }
58
+
59
+ $faulty_fields = array();
60
+
61
+ foreach ( $_POST['options'] as $option => $value )
62
+ {
63
+ // echo $option . '<br>';
64
+
65
+ if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
66
+ {
67
+ array_push( $faulty_fields, $option );
68
+ }
69
+ }
70
+
71
+ // Display an alert in the admin interface if something went wrong
72
+ echo '<div class="updated"><p>';
73
+ if ( sizeof( $faulty_fields ) == 0 ) {
74
+ _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
75
+ } else {
76
+ _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
77
+ // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
78
+ }
79
+ echo "</p></div>";
80
+ }
81
+ wp_print_scripts( 'quicktags' );
82
+
83
+ ?>
84
+ <link href="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
85
+
86
+ <div class="container-fluid">
87
+ <div class="mt-3"></div>
88
+ <div class="row">
89
+ <div class="col-sm-9">
90
+ <form action="" method="post">
91
+
92
+
93
+
94
+ <div class="form-group row">
95
+ <div class="col-sm-9 offset-sm-1">
96
+ <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
97
+ <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
98
+ </button>
99
+ </div>
100
+ </div>
101
+
102
+ <?php wp_nonce_field( 'stcr_action_nonce', 'stcr_action_nonce' ); ?>
103
+
104
+ </form>
105
+ </div>
106
+
107
+ <div class="col-md-3">
108
+ <div class="card card-font-size">
109
+ <div class="card-body">
110
+ <p>
111
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
112
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
113
+ </p>
114
+ <p>
115
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
116
+ </p>
117
+ </div>
118
+ </div>
119
+ </div>
120
+
121
+ </div>
122
+ </div>
123
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
124
+ <?php
125
+ //global $wp_subscribe_reloaded;
126
+ // Tell WP that we are going to use a resource.
127
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
128
+ // Includes the Panel JS resource file as well as the JS text domain translations.
129
+ //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
130
+ // Enqueue the JS File
131
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
132
+
133
+ ?>
options/panel1-add-subscription.php CHANGED
@@ -28,5 +28,8 @@ echo ' <strong>' . get_the_title( intval( $_GET['srp'] ) ) . " (" . intval( $_GE
28
  <input type='hidden' name='sra' value='add' />
29
  <input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
30
  </fieldset>
 
 
 
31
  </form>
32
  </div>
28
  <input type='hidden' name='sra' value='add' />
29
  <input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
30
  </fieldset>
31
+
32
+ <?php wp_nonce_field( 'stcr_add_subscription_nonce', 'stcr_add_subscription_nonce' ); ?>
33
+
34
  </form>
35
  </div>
options/panel1-business-logic.php CHANGED
@@ -17,6 +17,19 @@ $status = sanitize_text_field( trim( $status ) );
17
 
18
  switch ( $action ) {
19
  case 'add':
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_post_email );
21
  $valid_post_id = $wp_subscribe_reloaded->stcr->utils->check_valid_number( $post_id );
22
 
@@ -41,6 +54,19 @@ switch ( $action ) {
41
  break;
42
 
43
  case 'edit':
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_post_email );
45
  $stcr_old_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_old_post_email );
46
  $valid_post_id = $wp_subscribe_reloaded->stcr->utils->check_valid_number( $post_id );
@@ -66,6 +92,19 @@ switch ( $action ) {
66
  break;
67
 
68
  case 'delete-subscription':
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_post_email );
70
  $valid_post_id = $wp_subscribe_reloaded->stcr->utils->check_valid_number( $post_id );
71
 
@@ -82,6 +121,19 @@ switch ( $action ) {
82
 
83
  default:
84
  if ( ! empty( $_POST['subscriptions_list'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  $post_list = $email_list = array();
86
  foreach ( $_POST['subscriptions_list'] as $a_subscription ) {
87
  list( $a_post, $a_email ) = explode( ',', $a_subscription );
17
 
18
  switch ( $action ) {
19
  case 'add':
20
+
21
+ if ( empty( $_POST['stcr_add_subscription_nonce'] ) ) {
22
+ exit();
23
+ }
24
+
25
+ if ( ! wp_verify_nonce( $_POST['stcr_add_subscription_nonce'], 'stcr_add_subscription_nonce' ) ) {
26
+ exit();
27
+ }
28
+
29
+ if ( ! current_user_can( 'manage_options' ) ) {
30
+ exit();
31
+ }
32
+
33
  $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_post_email );
34
  $valid_post_id = $wp_subscribe_reloaded->stcr->utils->check_valid_number( $post_id );
35
 
54
  break;
55
 
56
  case 'edit':
57
+
58
+ if ( empty( $_POST['stcr_edit_subscription_nonce'] ) ) {
59
+ exit();
60
+ }
61
+
62
+ if ( ! wp_verify_nonce( $_POST['stcr_edit_subscription_nonce'], 'stcr_edit_subscription_nonce' ) ) {
63
+ exit();
64
+ }
65
+
66
+ if ( ! current_user_can( 'manage_options' ) ) {
67
+ exit();
68
+ }
69
+
70
  $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_post_email );
71
  $stcr_old_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_old_post_email );
72
  $valid_post_id = $wp_subscribe_reloaded->stcr->utils->check_valid_number( $post_id );
92
  break;
93
 
94
  case 'delete-subscription':
95
+
96
+ if ( empty( $_GET['stcr_delete_subscription_nonce'] ) ) {
97
+ exit();
98
+ }
99
+
100
+ if ( ! wp_verify_nonce( $_GET['stcr_delete_subscription_nonce'], 'stcr_delete_subscription_nonce' ) ) {
101
+ exit();
102
+ }
103
+
104
+ if ( ! current_user_can( 'manage_options' ) ) {
105
+ exit();
106
+ }
107
+
108
  $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $stcr_post_email );
109
  $valid_post_id = $wp_subscribe_reloaded->stcr->utils->check_valid_number( $post_id );
110
 
121
 
122
  default:
123
  if ( ! empty( $_POST['subscriptions_list'] ) ) {
124
+
125
+ if ( empty( $_POST['stcr_update_subscriptions_nonce'] ) ) {
126
+ exit();
127
+ }
128
+
129
+ if ( ! wp_verify_nonce( $_POST['stcr_update_subscriptions_nonce'], 'stcr_update_subscriptions_nonce' ) ) {
130
+ exit();
131
+ }
132
+
133
+ if ( ! current_user_can( 'manage_options' ) ) {
134
+ exit();
135
+ }
136
+
137
  $post_list = $email_list = array();
138
  foreach ( $_POST['subscriptions_list'] as $a_subscription ) {
139
  list( $a_post, $a_email ) = explode( ',', $a_subscription );
options/panel1-edit-subscription.php CHANGED
@@ -34,6 +34,7 @@ echo ' <strong>' . get_the_title( intval( $_GET['srp'] ) ) . " (" . intval( $_GE
34
  </p>
35
  <input type='hidden' name='sra' value='edit' />
36
  <input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
 
37
  </fieldset>
38
  </form>
39
  </div>
34
  </p>
35
  <input type='hidden' name='sra' value='edit' />
36
  <input type='hidden' name='srp' value='<?php echo intval( $_GET['srp'] ) ?>' />
37
+ <?php wp_nonce_field( 'stcr_edit_subscription_nonce', 'stcr_edit_subscription_nonce' ); ?>
38
  </fieldset>
39
  </form>
40
  </div>
options/stcr_comment_form.php CHANGED
@@ -1,373 +1,388 @@
1
- <?php
2
- // Comment Form
3
- //
4
- // Avoid direct access to this piece of code
5
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
- header( 'Location: /' );
7
- exit;
8
- }
9
-
10
- $options = array(
11
- "show_subscription_box" => "yesno",
12
- "checked_by_default" => "yesno",
13
- "checked_by_default_value" => "integer",
14
- "enable_advanced_subscriptions" => "yesno",
15
- "default_subscription_type" => "integer",
16
- "checkbox_inline_style" => "text-html",
17
- "checkbox_html" => "text-html",
18
- "checkbox_label" => "text-html",
19
- "subscribed_label" => "text-html",
20
- "subscribed_waiting_label" => "text-html",
21
- "author_label" => "text-html"
22
- );
23
-
24
- // Update options
25
- if ( isset( $_POST['options'] ) ) {
26
- $faulty_fields = array();
27
-
28
- foreach ( $_POST['options'] as $option => $value )
29
- {
30
- // echo $option . '<br>';
31
- if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
32
- {
33
- array_push( $faulty_fields, $option );
34
- }
35
- }
36
-
37
- // Display an alert in the admin interface if something went wrong
38
- echo '<div class="updated"><p>';
39
- if ( sizeof( $faulty_fields ) == 0 ) {
40
- _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
41
- } else {
42
- _e( 'There was an error updating the following fields:', 'subscribe-to-comments-reloaded' );
43
- // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
44
- }
45
- echo "</p></div>";
46
- }
47
- ?>
48
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.css" rel="stylesheet"/>
49
-
50
- <div class="container-fluid">
51
- <div class="mt-3"></div>
52
- <div class="row">
53
- <div class="col-sm-9">
54
- <form action="" method="post">
55
- <div class="form-group row">
56
- <label for="show_subscription_box" class="col-sm-3 col-form-label text-right"><?php _e( 'Enable default checkbox', 'subscribe-to-comments-reloaded' ) ?></label>
57
- <div class="col-sm-7">
58
- <div class="switch">
59
- <input type="radio" class="switch-input" name="options[show_subscription_box]"
60
- value="yes" id="show_subscription_box-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'yes' ) ? ' checked' : ''; ?> />
61
- <label for="show_subscription_box-yes" class="switch-label switch-label-off">
62
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
63
- </label>
64
- <input type="radio" class="switch-input" name="options[show_subscription_box]" value="no" id="show_subscription_box-no"
65
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'no' ) ? ' checked' : ''; ?> />
66
- <label for="show_subscription_box-no" class="switch-label switch-label-on">
67
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
68
- </label>
69
- <span class="switch-selection"></span>
70
- </div>
71
- <div class="helpDescription subsOptDescriptions"
72
- data-content="<?php _e( 'Disable this option if you want to move the subscription checkbox to a different place on your page.', 'subscribe-to-comments-reloaded' ); ?>"
73
- data-placement="right"
74
- aria-label="<?php _e( 'Disable this option if you want to move the subscription checkbox to a different place on your page.', 'subscribe-to-comments-reloaded' ); ?>">
75
- <i class="fas fa-question-circle"></i>
76
- </div>
77
- </div>
78
- </div>
79
-
80
- <div class="form-group row">
81
- <label for="checked_by_default" class="col-sm-3 col-form-label text-right"><?php _e( 'Checked by default', 'subscribe-to-comments-reloaded' ) ?></label>
82
- <div class="col-sm-7">
83
- <div class="switch">
84
- <input type="radio" class="switch-input" name="options[checked_by_default]"
85
- value="yes" id="checked_by_default-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default' ) == 'yes' ) ? ' checked' : ''; ?> />
86
- <label for="checked_by_default-yes" class="switch-label switch-label-off">
87
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
88
- </label>
89
- <input type="radio" class="switch-input" name="options[checked_by_default]" value="no" id="checked_by_default-no"
90
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default' ) == 'no' ) ? ' checked' : ''; ?> />
91
- <label for="checked_by_default-no" class="switch-label switch-label-on">
92
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
93
- </label>
94
- <span class="switch-selection"></span>
95
- </div>
96
- <div class="helpDescription subsOptDescriptions"
97
- data-content="<?php _e( 'Decide if the checkbox should be checked by default or not.', 'subscribe-to-comments-reloaded' ); ?>"
98
- data-placement="right"
99
- aria-label="<?php _e( 'Decide if the checkbox should be checked by default or not.', 'subscribe-to-comments-reloaded' ); ?>">
100
- <i class="fas fa-question-circle"></i>
101
- </div>
102
- </div>
103
- </div>
104
- <?php
105
- // This option will be visible only when the Checkbox option is enable
106
- if ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'no' ) :
107
- ?>
108
- <div class="form-group row">
109
- <label for="checked_by_default_value" class="col-sm-3 col-form-label text-right"><?php _e( 'Subscription type', 'subscribe-to-comments-reloaded' ) ?></label>
110
- <div class="col-sm-7">
111
- <select name="options[checked_by_default_value]" id="checked_by_default_value" class="form-control form-control-select">
112
- <option value="0" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default_value' ) === '0' ) ? "selected='selected'" : ''; ?>><?php _e( 'All new comments', 'subscribe-to-comments-reloaded' ); ?></option>
113
- <option value="1" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default_value' ) === '1' ) ? "selected='selected'" : ''; ?>><?php _e( 'Replies to this comment', 'subscribe-to-comments-reloaded' ); ?></option>
114
- </select>
115
- <div class="helpDescription subsOptDescriptions"
116
- data-content="<?php _e( 'Select the type of subscription.', 'subscribe-to-comments-reloaded' ); ?>"
117
- data-placement="right"
118
- aria-label="<?php _e( 'Select the type of subscription.', 'subscribe-to-comments-reloaded' ); ?>">
119
- <i class="fas fa-question-circle"></i>
120
- </div>
121
- </div>
122
- </div>
123
- <?php
124
- else :
125
- echo "<input type='hidden' name='options[checked_by_default_value]' value = '0'>";
126
- endif; ?>
127
-
128
- <div class="form-group row">
129
- <label for="enable_advanced_subscriptions" class="col-sm-3 col-form-label text-right">
130
- <?php _e( 'Advanced subscription', 'subscribe-to-comments-reloaded' ) ?></label>
131
- <div class="col-sm-7">
132
- <div class="switch">
133
- <input type="radio" class="switch-input" name="options[enable_advanced_subscriptions]"
134
- value="yes" id="enable_advanced_subscriptions-yes"
135
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'yes' ) ? ' checked' : ''; ?> />
136
- <label for="enable_advanced_subscriptions-yes" class="switch-label switch-label-off">
137
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
138
- </label>
139
- <input type="radio" class="switch-input" name="options[enable_advanced_subscriptions]" value="no" id="enable_advanced_subscriptions-no"
140
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'no' ) ? ' checked' : ''; ?> />
141
- <label for="enable_advanced_subscriptions-no" class="switch-label switch-label-on">
142
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
143
- </label>
144
- <span class="switch-selection"></span>
145
- </div>
146
- <div class="helpDescription subsOptDescriptions"
147
- data-content="<?php _e( 'Allow users to choose from different subscription types (all, replies only).', 'subscribe-to-comments-reloaded' ); ?>"
148
- data-placement="right"
149
- aria-label="<?php _e( 'Allow users to choose from different subscription types (all, replies only).', 'subscribe-to-comments-reloaded' ); ?>">
150
- <i class="fas fa-question-circle"></i>
151
- </div>
152
- </div>
153
- </div>
154
-
155
- <?php
156
- // Make sure that the default subscription type is visible only when advance subscriptions are set to yes.
157
- if ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'yes' ): ?>
158
- <div class="form-group row">
159
- <label for="default_subscription_type" class="col-sm-3 col-form-label text-right">
160
- <?php _e( 'Advanced default', 'subscribe-to-comments-reloaded' ) ?></label>
161
- <div class="col-sm-7">
162
- <select name="options[default_subscription_type]" id="default_subscription_type" class="form-control form-control-select">
163
- <option value="0" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'default_subscription_type' ) === '0' ) ? "selected='selected'" : ''; ?>><?php _e( 'None', 'subscribe-to-comments-reloaded' ); ?></option>
164
- <option value="1" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'default_subscription_type' ) === '1' ) ? "selected='selected'" : ''; ?>><?php _e( 'All new comments', 'subscribe-to-comments-reloaded' ); ?></option>
165
- <option value="2" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'default_subscription_type' ) === '2' ) ? "selected='selected'" : ''; ?>><?php _e( 'Replies to this comment', 'subscribe-to-comments-reloaded' ); ?></option>
166
- </select>
167
- <div class="helpDescription subsOptDescriptions"
168
- data-content="<?php _e( 'The default subscription type that should be selected when Advanced subscriptions are enable.', 'subscribe-to-comments-reloaded' ); ?>"
169
- data-placement="right"
170
- aria-label="<?php _e( 'The default subscription type that should be selected when Advanced subscriptions are enable.', 'subscribe-to-comments-reloaded' ); ?>">
171
- <i class="fas fa-question-circle"></i>
172
- </div>
173
- </div>
174
- </div>
175
- <?php
176
- else :
177
- echo "<input type='hidden' name='options[default_subscription_type]' value = '0'>";
178
- endif; ?>
179
-
180
- <div class="form-group row">
181
- <label for="checkbox_inline_style" class="col-sm-3 col-form-label text-right">
182
- <?php _e( 'Custom inline style', 'subscribe-to-comments-reloaded' ) ?></label>
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' ); ?>"
190
- data-placement="right"
191
- aria-label="<?php _e( 'Custom inline CSS to add to the checkbox.', 'subscribe-to-comments-reloaded' ); ?>">
192
- <i class="fas fa-question-circle"></i>
193
- </div>
194
- </div>
195
- </div>
196
-
197
- <div class="form-group row">
198
- <label for="checkbox_html" class="col-sm-3 offset-sm-1 col-form-label">
199
- <?php _e( 'Custom HTML', 'subscribe-to-comments-reloaded' ) ?>
200
-
201
- <div class="helpDescription subsOptDescriptions"
202
- data-content="<?php _e( 'Custom HTML code to be used when displaying the checkbox. Allowed tags: [checkbox_field], [checkbox_label]', 'subscribe-to-comments-reloaded' ); ?>"
203
- data-placement="right"
204
- aria-label="<?php _e( 'Custom HTML code to be used when displaying the checkbox. Allowed tags: [checkbox_field], [checkbox_label]', 'subscribe-to-comments-reloaded' ); ?>">
205
- <i class="fas fa-question-circle"></i>
206
- </div>
207
-
208
- </label>
209
- <div class="clearfix"></div>
210
- <div class="col-sm-9 offset-sm-1">
211
- <?php
212
- $id_checkbox_html = "checkbox_html";
213
- $args_notificationContent = array(
214
- "media_buttons" => false,
215
- "textarea_rows" => 5,
216
- "teeny" => true,
217
- "textarea_name" => "options[{$id_checkbox_html}]",
218
- "tinymce" => false
219
- );
220
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_checkbox_html ), $id_checkbox_html, $args_notificationContent );
221
- ?>
222
- </div>
223
- </div>
224
-
225
- <h3><?php _e( 'Messages for your visitors', 'subscribe-to-comments-reloaded' ) ?></h3>
226
-
227
- <div class="form-group row">
228
- <label for="checkbox_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
229
- <?php _e( 'Default label', 'subscribe-to-comments-reloaded' ) ?>
230
-
231
- <div class="helpDescription subsOptDescriptions"
232
- data-content="<?php _e( 'Label associated to the checkbox. Allowed tag: [subscribe_link]', 'subscribe-to-comments-reloaded' ); ?>"
233
- data-placement="right"
234
- aria-label="<?php _e( 'Label associated to the checkbox. Allowed tag: [subscribe_link]', 'subscribe-to-comments-reloaded' ); ?>">
235
- <i class="fas fa-question-circle"></i>
236
- </div>
237
-
238
- </label>
239
- <div class="clearfix"></div>
240
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
241
- <?php
242
- $id_checkbox_label = "checkbox_label";
243
- $args_notificationContent = array(
244
- "media_buttons" => false,
245
- "textarea_rows" => 3,
246
- "teeny" => true,
247
- "textarea_name" => "options[{$id_checkbox_label}]"
248
- );
249
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_checkbox_label ), $id_checkbox_label, $args_notificationContent );
250
- ?>
251
- </div>
252
- </div>
253
-
254
- <div class="form-group row">
255
- <label for="subscribed_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
256
- <?php _e( 'Subscribed label', 'subscribe-to-comments-reloaded' ) ?>
257
-
258
- <div class="helpDescription subsOptDescriptions"
259
- data-content="<?php _e( 'Label shown to those who are already subscribed to a post. Allowed tag: [manager_link]', 'subscribe-to-comments-reloaded' ); ?>"
260
- data-placement="right"
261
- aria-label="<?php _e( 'Label shown to those who are already subscribed to a post. Allowed tag: [manager_link]', 'subscribe-to-comments-reloaded' ); ?>">
262
- <i class="fas fa-question-circle"></i>
263
- </div>
264
-
265
- </label>
266
- <div class="clearfix"></div>
267
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
268
- <?php
269
- $id_subscribed_label = "subscribed_label";
270
- $args_notificationContent = array(
271
- "media_buttons" => false,
272
- "textarea_rows" => 3,
273
- "teeny" => true,
274
- "textarea_name" => "options[{$id_subscribed_label}]"
275
- );
276
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscribed_label ), $id_subscribed_label, $args_notificationContent );
277
- ?>
278
- </div>
279
- </div>
280
-
281
- <div class="form-group row">
282
- <label for="subscribed_waiting_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
283
- <?php _e( 'Pending label', 'subscribe-to-comments-reloaded' ) ?>
284
-
285
- <div class="helpDescription subsOptDescriptions"
286
- data-content="<?php _e( "Label shown to those who are already subscribed, but haven't clicked on the confirmation link yet. Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>"
287
- data-placement="right"
288
- aria-label="<?php _e( "Label shown to those who are already subscribed, but haven't clicked on the confirmation link yet. Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>">
289
- <i class="fas fa-question-circle"></i>
290
- </div>
291
-
292
- </label>
293
- <div class="clearfix"></div>
294
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
295
- <?php
296
- $id_subscribed_waiting_label = "subscribed_waiting_label";
297
- $args_notificationContent = array(
298
- "media_buttons" => false,
299
- "textarea_rows" => 3,
300
- "teeny" => true,
301
- "textarea_name" => "options[{$id_subscribed_waiting_label}]"
302
- );
303
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscribed_waiting_label ), $id_subscribed_waiting_label, $args_notificationContent );
304
- ?>
305
- </div>
306
- </div>
307
-
308
- <div class="form-group row">
309
- <label for="author_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
310
- <?php _e( 'Author label', 'subscribe-to-comments-reloaded' ) ?>
311
-
312
- <div class="helpDescription subsOptDescriptions"
313
- data-content="<?php _e( "Label shown to authors (and administrators). Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>"
314
- data-placement="right"
315
- aria-label="<?php _e( "Label shown to authors (and administrators). Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>">
316
- <i class="fas fa-question-circle"></i>
317
- </div>
318
-
319
- </label>
320
- <div class="clearfix"></div>
321
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
322
- <?php
323
- $id_author_label = "author_label";
324
- $args_notificationContent = array(
325
- "media_buttons" => false,
326
- "textarea_rows" => 3,
327
- "teeny" => true,
328
- "textarea_name" => "options[{$id_author_label}]"
329
- );
330
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_author_label ), $id_author_label, $args_notificationContent );
331
- ?>
332
- </div>
333
- </div>
334
-
335
- <div class="form-group row">
336
- <div class="col-sm-9 offset-sm-1">
337
- <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
338
- <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
339
- </button>
340
- </div>
341
- </div>
342
-
343
- </form>
344
- </div>
345
-
346
- <div class="col-md-3">
347
- <div class="card card-font-size">
348
- <div class="card-body">
349
- <p>
350
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
351
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
352
- </p>
353
- <p>
354
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
355
- </p>
356
- </div>
357
- </div>
358
- </div>
359
-
360
- </div>
361
- </div>
362
-
363
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.js"></script>
364
- <?php
365
- global $wp_subscribe_reloaded;
366
- // Tell WP that we are going to use a resource.
367
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
368
- // Includes the Panel JS resource file as well as the JS text domain translations.
369
- //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
370
- // Enqueue the JS File
371
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
372
-
373
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Comment Form
3
+ //
4
+ // Avoid direct access to this piece of code
5
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
+ header( 'Location: /' );
7
+ exit;
8
+ }
9
+
10
+ $options = array(
11
+ "show_subscription_box" => "yesno",
12
+ "checked_by_default" => "yesno",
13
+ "checked_by_default_value" => "integer",
14
+ "enable_advanced_subscriptions" => "yesno",
15
+ "default_subscription_type" => "integer",
16
+ "checkbox_inline_style" => "text-html",
17
+ "checkbox_html" => "text-html",
18
+ "checkbox_label" => "text-html",
19
+ "subscribed_label" => "text-html",
20
+ "subscribed_waiting_label" => "text-html",
21
+ "author_label" => "text-html"
22
+ );
23
+
24
+ // Update options
25
+ if ( isset( $_POST['options'] ) ) {
26
+
27
+ if ( empty( $_POST['stcr_save_comment_form_nonce'] ) ) {
28
+ return;
29
+ }
30
+
31
+ if ( ! wp_verify_nonce( $_POST['stcr_save_comment_form_nonce'], 'stcr_save_comment_form_nonce' ) ) {
32
+ return;
33
+ }
34
+
35
+ if ( ! current_user_can( 'manage_options' ) ) {
36
+ return;
37
+ }
38
+
39
+ $faulty_fields = array();
40
+
41
+ foreach ( $_POST['options'] as $option => $value )
42
+ {
43
+
44
+ if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
45
+ {
46
+ array_push( $faulty_fields, $option );
47
+ }
48
+ }
49
+
50
+ // Display an alert in the admin interface if something went wrong
51
+ echo '<div class="updated"><p>';
52
+ if ( sizeof( $faulty_fields ) == 0 ) {
53
+ _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
54
+ } else {
55
+ _e( 'There was an error updating the following fields:', 'subscribe-to-comments-reloaded' );
56
+ // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
57
+ }
58
+ echo "</p></div>";
59
+ }
60
+ ?>
61
+ <link href="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
62
+
63
+ <div class="container-fluid">
64
+ <div class="mt-3"></div>
65
+ <div class="row">
66
+ <div class="col-sm-9">
67
+ <form action="" method="post">
68
+ <div class="form-group row">
69
+ <label for="show_subscription_box" class="col-sm-3 col-form-label text-right"><?php _e( 'Enable default checkbox', 'subscribe-to-comments-reloaded' ) ?></label>
70
+ <div class="col-sm-7">
71
+ <div class="switch">
72
+ <input type="radio" class="switch-input" name="options[show_subscription_box]"
73
+ value="yes" id="show_subscription_box-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'yes' ) ? ' checked' : ''; ?> />
74
+ <label for="show_subscription_box-yes" class="switch-label switch-label-off">
75
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
76
+ </label>
77
+ <input type="radio" class="switch-input" name="options[show_subscription_box]" value="no" id="show_subscription_box-no"
78
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'no' ) ? ' checked' : ''; ?> />
79
+ <label for="show_subscription_box-no" class="switch-label switch-label-on">
80
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
81
+ </label>
82
+ <span class="switch-selection"></span>
83
+ </div>
84
+ <div class="helpDescription subsOptDescriptions"
85
+ data-content="<?php _e( 'Disable this option if you want to move the subscription checkbox to a different place on your page.', 'subscribe-to-comments-reloaded' ); ?>"
86
+ data-placement="right"
87
+ aria-label="<?php _e( 'Disable this option if you want to move the subscription checkbox to a different place on your page.', 'subscribe-to-comments-reloaded' ); ?>">
88
+ <i class="fas fa-question-circle"></i>
89
+ </div>
90
+ </div>
91
+ </div>
92
+
93
+ <div class="form-group row">
94
+ <label for="checked_by_default" class="col-sm-3 col-form-label text-right"><?php _e( 'Checked by default', 'subscribe-to-comments-reloaded' ) ?></label>
95
+ <div class="col-sm-7">
96
+ <div class="switch">
97
+ <input type="radio" class="switch-input" name="options[checked_by_default]"
98
+ value="yes" id="checked_by_default-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default' ) == 'yes' ) ? ' checked' : ''; ?> />
99
+ <label for="checked_by_default-yes" class="switch-label switch-label-off">
100
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
101
+ </label>
102
+ <input type="radio" class="switch-input" name="options[checked_by_default]" value="no" id="checked_by_default-no"
103
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default' ) == 'no' ) ? ' checked' : ''; ?> />
104
+ <label for="checked_by_default-no" class="switch-label switch-label-on">
105
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
106
+ </label>
107
+ <span class="switch-selection"></span>
108
+ </div>
109
+ <div class="helpDescription subsOptDescriptions"
110
+ data-content="<?php _e( 'Decide if the checkbox should be checked by default or not.', 'subscribe-to-comments-reloaded' ); ?>"
111
+ data-placement="right"
112
+ aria-label="<?php _e( 'Decide if the checkbox should be checked by default or not.', 'subscribe-to-comments-reloaded' ); ?>">
113
+ <i class="fas fa-question-circle"></i>
114
+ </div>
115
+ </div>
116
+ </div>
117
+ <?php
118
+ // This option will be visible only when the Checkbox option is enable
119
+ if ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'no' ) :
120
+ ?>
121
+ <div class="form-group row">
122
+ <label for="checked_by_default_value" class="col-sm-3 col-form-label text-right"><?php _e( 'Subscription type', 'subscribe-to-comments-reloaded' ) ?></label>
123
+ <div class="col-sm-7">
124
+ <select name="options[checked_by_default_value]" id="checked_by_default_value" class="form-control form-control-select">
125
+ <option value="0" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default_value' ) === '0' ) ? "selected='selected'" : ''; ?>><?php _e( 'All new comments', 'subscribe-to-comments-reloaded' ); ?></option>
126
+ <option value="1" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checked_by_default_value' ) === '1' ) ? "selected='selected'" : ''; ?>><?php _e( 'Replies to this comment', 'subscribe-to-comments-reloaded' ); ?></option>
127
+ </select>
128
+ <div class="helpDescription subsOptDescriptions"
129
+ data-content="<?php _e( 'Select the type of subscription.', 'subscribe-to-comments-reloaded' ); ?>"
130
+ data-placement="right"
131
+ aria-label="<?php _e( 'Select the type of subscription.', 'subscribe-to-comments-reloaded' ); ?>">
132
+ <i class="fas fa-question-circle"></i>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ <?php
137
+ else :
138
+ echo "<input type='hidden' name='options[checked_by_default_value]' value = '0'>";
139
+ endif; ?>
140
+
141
+ <div class="form-group row">
142
+ <label for="enable_advanced_subscriptions" class="col-sm-3 col-form-label text-right">
143
+ <?php _e( 'Advanced subscription', 'subscribe-to-comments-reloaded' ) ?></label>
144
+ <div class="col-sm-7">
145
+ <div class="switch">
146
+ <input type="radio" class="switch-input" name="options[enable_advanced_subscriptions]"
147
+ value="yes" id="enable_advanced_subscriptions-yes"
148
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'yes' ) ? ' checked' : ''; ?> />
149
+ <label for="enable_advanced_subscriptions-yes" class="switch-label switch-label-off">
150
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
151
+ </label>
152
+ <input type="radio" class="switch-input" name="options[enable_advanced_subscriptions]" value="no" id="enable_advanced_subscriptions-no"
153
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'no' ) ? ' checked' : ''; ?> />
154
+ <label for="enable_advanced_subscriptions-no" class="switch-label switch-label-on">
155
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
156
+ </label>
157
+ <span class="switch-selection"></span>
158
+ </div>
159
+ <div class="helpDescription subsOptDescriptions"
160
+ data-content="<?php _e( 'Allow users to choose from different subscription types (all, replies only).', 'subscribe-to-comments-reloaded' ); ?>"
161
+ data-placement="right"
162
+ aria-label="<?php _e( 'Allow users to choose from different subscription types (all, replies only).', 'subscribe-to-comments-reloaded' ); ?>">
163
+ <i class="fas fa-question-circle"></i>
164
+ </div>
165
+ </div>
166
+ </div>
167
+
168
+ <?php
169
+ // Make sure that the default subscription type is visible only when advance subscriptions are set to yes.
170
+ if ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_advanced_subscriptions' ) == 'yes' ): ?>
171
+ <div class="form-group row">
172
+ <label for="default_subscription_type" class="col-sm-3 col-form-label text-right">
173
+ <?php _e( 'Advanced default', 'subscribe-to-comments-reloaded' ) ?></label>
174
+ <div class="col-sm-7">
175
+ <select name="options[default_subscription_type]" id="default_subscription_type" class="form-control form-control-select">
176
+ <option value="0" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'default_subscription_type' ) === '0' ) ? "selected='selected'" : ''; ?>><?php _e( 'None', 'subscribe-to-comments-reloaded' ); ?></option>
177
+ <option value="1" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'default_subscription_type' ) === '1' ) ? "selected='selected'" : ''; ?>><?php _e( 'All new comments', 'subscribe-to-comments-reloaded' ); ?></option>
178
+ <option value="2" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'default_subscription_type' ) === '2' ) ? "selected='selected'" : ''; ?>><?php _e( 'Replies to this comment', 'subscribe-to-comments-reloaded' ); ?></option>
179
+ </select>
180
+ <div class="helpDescription subsOptDescriptions"
181
+ data-content="<?php _e( 'The default subscription type that should be selected when Advanced subscriptions are enable.', 'subscribe-to-comments-reloaded' ); ?>"
182
+ data-placement="right"
183
+ aria-label="<?php _e( 'The default subscription type that should be selected when Advanced subscriptions are enable.', 'subscribe-to-comments-reloaded' ); ?>">
184
+ <i class="fas fa-question-circle"></i>
185
+ </div>
186
+ </div>
187
+ </div>
188
+ <?php
189
+ else :
190
+ echo "<input type='hidden' name='options[default_subscription_type]' value = '0'>";
191
+ endif; ?>
192
+
193
+ <div class="form-group row">
194
+ <label for="checkbox_inline_style" class="col-sm-3 col-form-label text-right">
195
+ <?php _e( 'Custom inline style', 'subscribe-to-comments-reloaded' ) ?></label>
196
+ <div class="col-sm-7">
197
+ <input type="text" name="options[checkbox_inline_style]" id="checkbox_inline_style"
198
+ class="form-control form-control-input-8"
199
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'checkbox_inline_style' ) ); ?>" size="20">
200
+
201
+ <div class="helpDescription subsOptDescriptions"
202
+ data-content="<?php _e( 'Custom inline CSS to add to the checkbox.', 'subscribe-to-comments-reloaded' ); ?>"
203
+ data-placement="right"
204
+ aria-label="<?php _e( 'Custom inline CSS to add to the checkbox.', 'subscribe-to-comments-reloaded' ); ?>">
205
+ <i class="fas fa-question-circle"></i>
206
+ </div>
207
+ </div>
208
+ </div>
209
+
210
+ <div class="form-group row">
211
+ <label for="checkbox_html" class="col-sm-3 offset-sm-1 col-form-label">
212
+ <?php _e( 'Custom HTML', 'subscribe-to-comments-reloaded' ) ?>
213
+
214
+ <div class="helpDescription subsOptDescriptions"
215
+ data-content="<?php _e( 'Custom HTML code to be used when displaying the checkbox. Allowed tags: [checkbox_field], [checkbox_label]', 'subscribe-to-comments-reloaded' ); ?>"
216
+ data-placement="right"
217
+ aria-label="<?php _e( 'Custom HTML code to be used when displaying the checkbox. Allowed tags: [checkbox_field], [checkbox_label]', 'subscribe-to-comments-reloaded' ); ?>">
218
+ <i class="fas fa-question-circle"></i>
219
+ </div>
220
+
221
+ </label>
222
+ <div class="clearfix"></div>
223
+ <div class="col-sm-9 offset-sm-1">
224
+ <?php
225
+ $id_checkbox_html = "checkbox_html";
226
+ $args_notificationContent = array(
227
+ "media_buttons" => false,
228
+ "textarea_rows" => 5,
229
+ "teeny" => true,
230
+ "textarea_name" => "options[{$id_checkbox_html}]",
231
+ "tinymce" => false
232
+ );
233
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_checkbox_html ), $id_checkbox_html, $args_notificationContent );
234
+ ?>
235
+ </div>
236
+ </div>
237
+
238
+ <h3><?php _e( 'Messages for your visitors', 'subscribe-to-comments-reloaded' ) ?></h3>
239
+
240
+ <div class="form-group row">
241
+ <label for="checkbox_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
242
+ <?php _e( 'Default label', 'subscribe-to-comments-reloaded' ) ?>
243
+
244
+ <div class="helpDescription subsOptDescriptions"
245
+ data-content="<?php _e( 'Label associated to the checkbox. Allowed tag: [subscribe_link]', 'subscribe-to-comments-reloaded' ); ?>"
246
+ data-placement="right"
247
+ aria-label="<?php _e( 'Label associated to the checkbox. Allowed tag: [subscribe_link]', 'subscribe-to-comments-reloaded' ); ?>">
248
+ <i class="fas fa-question-circle"></i>
249
+ </div>
250
+
251
+ </label>
252
+ <div class="clearfix"></div>
253
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
254
+ <?php
255
+ $id_checkbox_label = "checkbox_label";
256
+ $args_notificationContent = array(
257
+ "media_buttons" => false,
258
+ "textarea_rows" => 3,
259
+ "teeny" => true,
260
+ "textarea_name" => "options[{$id_checkbox_label}]"
261
+ );
262
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_checkbox_label ), $id_checkbox_label, $args_notificationContent );
263
+ ?>
264
+ </div>
265
+ </div>
266
+
267
+ <div class="form-group row">
268
+ <label for="subscribed_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
269
+ <?php _e( 'Subscribed label', 'subscribe-to-comments-reloaded' ) ?>
270
+
271
+ <div class="helpDescription subsOptDescriptions"
272
+ data-content="<?php _e( 'Label shown to those who are already subscribed to a post. Allowed tag: [manager_link]', 'subscribe-to-comments-reloaded' ); ?>"
273
+ data-placement="right"
274
+ aria-label="<?php _e( 'Label shown to those who are already subscribed to a post. Allowed tag: [manager_link]', 'subscribe-to-comments-reloaded' ); ?>">
275
+ <i class="fas fa-question-circle"></i>
276
+ </div>
277
+
278
+ </label>
279
+ <div class="clearfix"></div>
280
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
281
+ <?php
282
+ $id_subscribed_label = "subscribed_label";
283
+ $args_notificationContent = array(
284
+ "media_buttons" => false,
285
+ "textarea_rows" => 3,
286
+ "teeny" => true,
287
+ "textarea_name" => "options[{$id_subscribed_label}]"
288
+ );
289
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscribed_label ), $id_subscribed_label, $args_notificationContent );
290
+ ?>
291
+ </div>
292
+ </div>
293
+
294
+ <div class="form-group row">
295
+ <label for="subscribed_waiting_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
296
+ <?php _e( 'Pending label', 'subscribe-to-comments-reloaded' ) ?>
297
+
298
+ <div class="helpDescription subsOptDescriptions"
299
+ data-content="<?php _e( "Label shown to those who are already subscribed, but haven't clicked on the confirmation link yet. Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>"
300
+ data-placement="right"
301
+ aria-label="<?php _e( "Label shown to those who are already subscribed, but haven't clicked on the confirmation link yet. Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>">
302
+ <i class="fas fa-question-circle"></i>
303
+ </div>
304
+
305
+ </label>
306
+ <div class="clearfix"></div>
307
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
308
+ <?php
309
+ $id_subscribed_waiting_label = "subscribed_waiting_label";
310
+ $args_notificationContent = array(
311
+ "media_buttons" => false,
312
+ "textarea_rows" => 3,
313
+ "teeny" => true,
314
+ "textarea_name" => "options[{$id_subscribed_waiting_label}]"
315
+ );
316
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscribed_waiting_label ), $id_subscribed_waiting_label, $args_notificationContent );
317
+ ?>
318
+ </div>
319
+ </div>
320
+
321
+ <div class="form-group row">
322
+ <label for="author_label" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
323
+ <?php _e( 'Author label', 'subscribe-to-comments-reloaded' ) ?>
324
+
325
+ <div class="helpDescription subsOptDescriptions"
326
+ data-content="<?php _e( "Label shown to authors (and administrators). Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>"
327
+ data-placement="right"
328
+ aria-label="<?php _e( "Label shown to authors (and administrators). Allowed tag: [manager_link]", 'subscribe-to-comments-reloaded' ); ?>">
329
+ <i class="fas fa-question-circle"></i>
330
+ </div>
331
+
332
+ </label>
333
+ <div class="clearfix"></div>
334
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
335
+ <?php
336
+ $id_author_label = "author_label";
337
+ $args_notificationContent = array(
338
+ "media_buttons" => false,
339
+ "textarea_rows" => 3,
340
+ "teeny" => true,
341
+ "textarea_name" => "options[{$id_author_label}]"
342
+ );
343
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_author_label ), $id_author_label, $args_notificationContent );
344
+ ?>
345
+ </div>
346
+ </div>
347
+
348
+ <div class="form-group row">
349
+ <div class="col-sm-9 offset-sm-1">
350
+ <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
351
+ <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
352
+ </button>
353
+ </div>
354
+ </div>
355
+
356
+ <?php wp_nonce_field( 'stcr_save_comment_form_nonce', 'stcr_save_comment_form_nonce' ); ?>
357
+
358
+ </form>
359
+ </div>
360
+
361
+ <div class="col-md-3">
362
+ <div class="card card-font-size">
363
+ <div class="card-body">
364
+ <p>
365
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
366
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
367
+ </p>
368
+ <p>
369
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
370
+ </p>
371
+ </div>
372
+ </div>
373
+ </div>
374
+
375
+ </div>
376
+ </div>
377
+
378
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
379
+ <?php
380
+ global $wp_subscribe_reloaded;
381
+ // Tell WP that we are going to use a resource.
382
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
383
+ // Includes the Panel JS resource file as well as the JS text domain translations.
384
+ //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
385
+ // Enqueue the JS File
386
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
387
+
388
+ ?>
options/stcr_manage_subscriptions.php CHANGED
@@ -1,354 +1,360 @@
1
- <?php
2
- // Avoid direct access to this piece of code
3
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
4
- header( 'Location: /' );
5
- exit;
6
- }
7
-
8
- $action = esc_attr( ! empty( $_POST['sra'] ) ? $_POST['sra'] : ( ! empty( $_GET['sra'] ) ? $_GET['sra'] : '' ) );
9
- if ( $action == 'edit-subscription' || $action == 'add-subscription' ) {
10
- require_once WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/options/panel1-' . $action . '.php';
11
-
12
- return;
13
- }
14
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/panel1-business-logic.php" ) ) {
15
-
16
- require_once WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/options/panel1-business-logic.php';
17
-
18
- // Display an alert in the admin interface if the email is wrong or the post id is not a number.
19
- if ( ! $valid_email )
20
- {
21
- echo '<div class="notice notice-error is-dismissible"><p>';
22
- _e( 'The email that you typed is not correct.', 'subscribe-to-comments-reloaded' );
23
- echo "</p></div>";
24
- }
25
-
26
- if ( ! $valid_post_id )
27
- {
28
- echo '<div class="notice notice-error is-dismissible"><p>';
29
- _e( 'Please enter a valid Post ID.', 'subscribe-to-comments-reloaded' );
30
- echo "</p></div>";
31
- }
32
- }
33
-
34
- ?>
35
- <style type="text/css">
36
-
37
- </style>
38
-
39
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables/media/css/jquery.dataTables.min.css" rel="stylesheet"/>
40
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables/media/css/dataTables.bootstrap4.min.css" rel="stylesheet"/>
41
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet"/>
42
-
43
- <div class="container-fluid">
44
-
45
- <div class="row mx-auto">
46
- <div class="col-sm-6">
47
- <div class="card card-font-size mass-update-subs">
48
- <h6 class="card-header">
49
- <i class="fas fa-exchange-alt"></i> <?php _e( 'Mass Update Subscriptions', 'subscribe-to-comments-reloaded' ) ?>
50
- <i class="fas fa-caret-down pull-right"></i>
51
- </h6>
52
- <div class="card-body cbody-mass" style="padding: 0;">
53
- <div class="card-text stcr-hidden">
54
- <form action="" method="post" id="mass_update_address_form">
55
-
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>
68
- </tr>
69
- <tr>
70
- <td><label for='srs'><?php _e( 'Status', 'subscribe-to-comments-reloaded' ) ?></label></td>
71
- <td><select class="form-control form-controls-font mass-update-select-status" name="srs" id="srs">
72
- <option value=''><?php _e( 'Keep unchanged', 'subscribe-to-comments-reloaded' ) ?></option>
73
- <option value='Y'><?php _e( 'Active', 'subscribe-to-comments-reloaded' ) ?></option>
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">
81
- <div class="more-info" data-infopanel="info-panel-mass-update" aria-label="<?php _e("More info", 'subscribe-to-comments-reloaded'); ?>">
82
- <i class="fas fa-question-circle"></i>
83
- </div>
84
- </td>
85
-
86
- </tr>
87
- <tr>
88
- <td colspan="2"><input type='hidden' name='sra' value='edit' /></td>
89
- </tr>
90
- </table>
91
-
92
- <div class="alert alert-info hidden info-panel-mass-update" role="alert">
93
- <?php _e('This option will allow you to change an email address for another one or to update the same status for all the subscription on a specific email address.', 'subscribe-to-comments-reloaded' ); ?>
94
- </div>
95
- </form>
96
- </div>
97
- </div>
98
- </div>
99
- </div>
100
-
101
- <div class="col-sm-6">
102
- <div class="card card-font-size add-new-subs">
103
- <h6 class="card-header">
104
- <i class="fas fa-plus-square"></i> <?php _e( 'Add New Subscription', 'subscribe-to-comments-reloaded' ) ?>
105
- <i class="fas fa-caret-down pull-right"></i>
106
- </h6>
107
- <div class="card-body" style="padding: 0;">
108
- <div class="card-text stcr-hidden">
109
- <form action="" method="post" id="add_new_subscription">
110
- <fieldset style="border:0">
111
- <table>
112
- <tr>
113
- <td><?php _e( 'Post ID', 'subscribe-to-comments-reloaded' ) ?></td>
114
- <td><input class="form-control form-controls-font" type='text' size='30' name='srp' value='' ></td>
115
- <td><span class="validate-error-text validate-error-text-srp stcr-hidden "></span></td>
116
- </tr>
117
- <tr>
118
- <td><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></td>
119
- <td><input class="form-control form-controls-font" type='text' size='30' name='sre' value='' ></td>
120
- <td><span class="validate-error-text validate-error-text-sre stcr-hidden "></span></td>
121
- </tr>
122
- <tr>
123
- <td><?php _e( 'Status', 'subscribe-to-comments-reloaded' ) ?></td>
124
- <td>
125
- <select name="srs" class="form-control form-controls-font new-sub-select-status">
126
- <option value='Y'><?php _e( 'Active', 'subscribe-to-comments-reloaded' ) ?></option>
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>
134
- <td><input type='hidden' name='sra' value='add' ></td>
135
- </tr>
136
- </table>
137
- &nbsp;
138
- </fieldset>
139
- </form>
140
- </div>
141
- </div>
142
- </div>
143
- </div>
144
- </div>
145
-
146
- <div class="clearfix"></div>
147
-
148
- <div class="row mx-auto">
149
- <div class="col-sm-12 col-md-12 col-lg-12">
150
- <div class="card card-subscribers" style="max-width: 100% !important;">
151
- <div class="card-body">
152
-
153
- <div class="card-text postbox" style="border: none;">
154
-
155
- <h4><i class="fas fa-search"></i> <?php _e( 'Search subscriptions', 'subscribe-to-comments-reloaded' ) ?></h4>
156
-
157
- <?php if ( ! empty( $_POST['srv'] ) || ( is_array( $subscriptions ) && count( $subscriptions ) == 1000 ) ) : ?>
158
-
159
- <?php
160
- $search_term = '';
161
- if ( ! empty( $_POST['srv'] ) ) {
162
- $search_term = sanitize_text_field( $_POST['srv'] );
163
- }
164
- ?>
165
- <form action="" method="post" style="background: #f5f5f5; padding: 15px; margin-top: 20px;">
166
- <p>
167
- <strong><?php esc_html_e( 'The table below is limited to loading 1000 latest subscriptions.', 'subscribe-to-comments-reloaded' ); ?></strong>
168
- <br><?php esc_html_e( 'You have more than that, if you need to find an older subscription just enter a search term ( full email, partial email, post ID...) below.', 'subscribe-to-comments-reloaded' ); ?>
169
- </p>
170
- <p>
171
- <input type="text" name="srv" placeholder="<?php esc_attr_e( 'Enter search term', 'subscribe-to-comments-reloaded' ); ?>" value="<?php echo esc_attr( $search_term ); ?>">
172
- <input type="submit" class="button button-primary">
173
- </p>
174
- </form>
175
-
176
- <?php endif; ?>
177
-
178
- <div class="col-md-2 subs-spinner mx-auto"><h5><?php _e( "Loading", 'subscribe-to-comments-reloaded'); ?> <i class="fas fa-play-circle"></i></h5></div>
179
-
180
- <div class="clearfix"></div>
181
-
182
- <form style="border: 1px solid #eee; padding: 15px; margin-top: 20px;" action="" method="post" id="subscription_form" name="subscription_form"
183
- onsubmit="if(this.sra[0].checked) return confirm('<?php _e( 'Please remember: this operation cannot be undone. Are you sure you want to proceed?', 'subscribe-to-comments-reloaded' ) ?>')">
184
-
185
- <?php
186
-
187
- $alternate = '';
188
- $date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
189
- // Let us form those status
190
- $status_arry = array(
191
- 'R' => __( 'Replies', 'subscribe-to-comments-reloaded'),
192
- 'RC' => __( 'Replies Unconfirmed', 'subscribe-to-comments-reloaded'),
193
- 'Y' => __( "All Comments", 'subscribe-to-comments-reloaded'),
194
- 'YC' => __( "Unconfirmed", 'subscribe-to-comments-reloaded'),
195
- 'C' => __( "Inactive", 'subscribe-to-comments-reloaded'),
196
- '-C' => __( "Active", 'subscribe-to-comments-reloaded')
197
- );
198
-
199
- if ( ! empty( $subscriptions ) && is_array( $subscriptions ) ) {
200
-
201
- $show_post_column = ( $operator != 'equals' || $search_field != 'post_id' ) ? __( 'Post (ID)', 'subscribe-to-comments-reloaded' ) : '';
202
- $show_email_column = ( $operator != 'equals' || $search_field != 'email' ) ? __( 'Email', 'subscribe-to-comments-reloaded' ) : '';
203
-
204
- echo "<table class=\"table table-smx table-hover table-striped subscribers-table stcr-hidden\" style=\"font-size: 0.8em\">
205
- <thead>";
206
-
207
- if( $wp_locale->text_direction == 'rtl' )
208
- {
209
-
210
- echo "<tr>
211
- <th scope=\"col\">
212
- &nbsp;&nbsp;&nbsp;<i class=\"fas fa-exchange-alt\"></i> <span>" . __('Actions', 'subscribe-to-comments-reloaded') ."</span>
213
- <input class='checkbox' type='checkbox' name='subscription_list_select_all' id='stcr_select_all' class='stcr_select_all'/>
214
- </th>
215
- <th scope=\"col\"><i class=\"fas fa-thumbtack\"></i><span>$show_post_column</span></th>
216
- <th scope=\"col\"><i class=\"fas fa-address-card\"></i><span>$show_email_column</span></th>
217
- <th scope=\"col\"><i class=\"fas fa-calendar-alt\"></i><span>". __( 'Date and Time', 'subscribe-to-comments-reloaded' ) . "</span></th>
218
- <th scope=\"col\"><i class=\"fas fa-info-circle\"></i><span>". __( 'Status', 'subscribe-to-comments-reloaded' ) . "</span></th>
219
- </tr>";
220
- }
221
- else
222
- {
223
- echo "<tr>
224
- <th scope=\"col\">
225
- <input class='checkbox' type='checkbox' name='subscription_list_select_all' id='stcr_select_all' class='stcr_select_all'/>
226
- &nbsp;&nbsp;&nbsp;<i class=\"fas fa-exchange-alt\"></i> <span>" . __('Actions', 'subscribe-to-comments-reloaded') ."</span>
227
- </th>
228
- <th scope=\"col\"><i class=\"fas fa-thumbtack\"></i><span>$show_post_column</span></th>
229
- <th scope=\"col\"><i class=\"fas fa-address-card\"></i><span>$show_email_column</span></th>
230
- <th scope=\"col\"><i class=\"fas fa-calendar-alt\"></i><span>". __( 'Date and Time', 'subscribe-to-comments-reloaded' ) . "</span></th>
231
- <th scope=\"col\"><i class=\"fas fa-info-circle\"></i><span>". __( 'Status', 'subscribe-to-comments-reloaded' ) . "</span></th>
232
- </tr>";
233
- }
234
-
235
- echo "</thead>";
236
- echo "<tbody>";
237
-
238
- foreach ( $subscriptions as $a_subscription ) {
239
- //$wp_subscribe_reloaded->stcr->utils->stcr_logger( print_r($a_subscription, true) );
240
- $title = get_the_title( $a_subscription->post_id );
241
- $title = ( strlen( $title ) > 35 ) ? substr( $title, 0, 35 ) . '..' : $title;
242
- if( $wp_locale->text_direction == 'rtl' )
243
- {
244
- $row_post = ( $operator != 'equals' || $search_field != 'post_id' ) ? "<a href='admin.php?page=stcr_manage_subscriptions&amp;srf=post_id&amp;srt=equals&amp;srv=$a_subscription->post_id'>($a_subscription->post_id) $title</a> " : '';
245
- }
246
- else
247
- {
248
- $row_post = ( $operator != 'equals' || $search_field != 'post_id' ) ? "<a href='admin.php?page=stcr_manage_subscriptions&amp;srf=post_id&amp;srt=equals&amp;srv=$a_subscription->post_id'>$title ($a_subscription->post_id)</a> " : '';
249
- }
250
- $row_email = ( $operator != 'equals' || $search_field != 'email' ) ? "<a href='admin.php?page=stcr_manage_subscriptions&amp;srf=email&amp;srt=equals&amp;srv=" . urlencode( $a_subscription->email ) . "' title='email unique key: ( $a_subscription->email_key )'>$a_subscription->email</a> " : '';
251
- $date_time = date_i18n( $date_time_format, strtotime( $a_subscription->dt ) );
252
- $date_time_sort = date_i18n( 'YmdHis', strtotime( $a_subscription->dt ) );
253
-
254
- $status_desc = $status_arry[$a_subscription->status];
255
-
256
- if( $wp_locale->text_direction == 'rtl' )
257
- {
258
- echo "<tr>
259
- <td>
260
- <label for='sub_{$a_subscription->meta_id}' class='hidden'>" . __( 'Subscription', 'subscribe-to-comments-reloaded' ) . " {$a_subscription->meta_id}</label>
261
- <input class='checkbox' type='checkbox' name='subscriptions_list[]' value='$a_subscription->post_id," . urlencode( $a_subscription->email ) . "' id='sub_{$a_subscription->meta_id}' />
262
- <a href='admin.php?page=stcr_manage_subscriptions&amp;sra=edit-subscription&amp;srp=" . $a_subscription->post_id . "&amp;sre=" . urlencode( $a_subscription->email ) . "' alt='" . __( 'Edit', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-edit\" style='font-size: 1.1em;color: #ffc53a;'></i></a>
263
- &nbsp;&nbsp;&nbsp;&nbsp;<a href='admin.php?page=stcr_manage_subscriptions&amp;sra=delete-subscription&amp;srp=" . $a_subscription->post_id . "&amp;sre=" . urlencode( $a_subscription->email ) . "' onclick='return confirm(\"" . __( 'Please remember: this operation cannot be undone. Are you sure you want to proceed?', 'subscribe-to-comments-reloaded' ) . "\");' alt='" . __( 'Delete', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-trash-alt\" style='font-size: 1.1em;color: #ff695a;'></i></a>
264
- </td>
265
- <td>$row_post</td>
266
- <td>$row_email</td>
267
- <td data-sort='$date_time_sort'>$date_time</td>
268
- <td>$status_desc</td>
269
- </tr>";
270
- }
271
- else
272
- {
273
- echo "<tr>
274
- <td>
275
- <label for='sub_{$a_subscription->meta_id}' class='hidden'>" . __( 'Subscription', 'subscribe-to-comments-reloaded' ) . " {$a_subscription->meta_id}</label>
276
- <input class='checkbox' type='checkbox' name='subscriptions_list[]' value='$a_subscription->post_id," . urlencode( $a_subscription->email ) . "' id='sub_{$a_subscription->meta_id}' />
277
- <a href='admin.php?page=stcr_manage_subscriptions&amp;sra=edit-subscription&amp;srp=" . $a_subscription->post_id . "&amp;sre=" . urlencode( $a_subscription->email ) . "' alt='" . __( 'Edit', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-edit\" style='font-size: 1.1em;color: #ffc53a;'></i></a>
278
- &nbsp;&nbsp;&nbsp;&nbsp;<a href='admin.php?page=stcr_manage_subscriptions&amp;sra=delete-subscription&amp;srp=" . $a_subscription->post_id . "&amp;sre=" . urlencode( $a_subscription->email ) . "' onclick='return confirm(\"" . __( 'Please remember: this operation cannot be undone. Are you sure you want to proceed?', 'subscribe-to-comments-reloaded' ) . "\");' alt='" . __( 'Delete', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-trash-alt\" style='font-size: 1.1em;color: #ff695a;'></i></a>
279
- </td>
280
- <td>$row_post</td>
281
- <td>$row_email</td>
282
- <td data-sort='$date_time_sort'>$date_time</td>
283
- <td>$status_desc</td>
284
- </tr>";
285
- }
286
-
287
- }
288
- echo "</tbody>";
289
-
290
- echo "</table>";
291
-
292
- echo "<div class='subscribers-mass-actions form-group row'>";
293
- echo '<label for="action_type" class="col-sm-1 col-form-label">' . __( 'Action:', 'subscribe-to-comments-reloaded' ) . '</label >' ;
294
- ?> <div class="col-sm-3">
295
- <select name="sra" id="action_type" class="form-control">
296
- <option value="delete"><?php _e( 'Delete forever', 'subscribe-to-comments-reloaded' ) ?></option>
297
- <option value="suspend"><?php _e( 'Suspend', 'subscribe-to-comments-reloaded' ) ?></option>
298
- <option value="force_y"><?php _e( 'Activate and set to notify on all comments', 'subscribe-to-comments-reloaded' ) ?></option>
299
- <option value="force_r"><?php _e( 'Activate and set to notify on replies only ', 'subscribe-to-comments-reloaded' ) ?></option>
300
- <option value="activate"><?php _e( 'Activate', 'subscribe-to-comments-reloaded' ) ?></option>
301
- </select>
302
- </div>
303
- <?php
304
- echo '<div class="col-sm-2"><button type="submit" class="subscribe-form-button btn btn-primary" >' . __( 'Update subscriptions', 'subscribe-to-comments-reloaded' ) . '</button></div>';
305
- echo "<input type='hidden' name='srf' value='$search_field'/><input type='hidden' name='srt' value='$operator'/><input type='hidden' name='srv' value='$search_value'/><input type='hidden' name='srsf' value='$offset'/><input type='hidden' name='srrp' value='$limit_results'/><input type='hidden' name='srob' value='$order_by'/><input type='hidden' name='sro' value='$order'/>";
306
- echo "</div>";
307
-
308
- } elseif ( $action == 'search' ) {
309
- echo '<p>' . __( 'Sorry, no subscriptions match your search criteria.', 'subscribe-to-comments-reloaded' ) . "</p>";
310
- }
311
- ?>
312
-
313
- </form>
314
- </div>
315
- </div>
316
- </div>
317
- </div>
318
- </div>
319
-
320
- <div class="clearfix"></div>
321
-
322
- <div class="row">
323
- <div class="col-sm-6 col-md-6 col-lg-6 mx-auto">
324
- <div class="card" style="max-width: 100% !important;">
325
- <div class="card-body">
326
- <p>
327
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
328
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
329
- </p>
330
- <p>
331
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
332
- </p>
333
- </div>
334
- </div>
335
- </div>
336
- </div>
337
- </div>
338
-
339
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables/media/js/jquery.dataTables.min.js"></script>
340
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables/media/js/jquery.dataTables.min.js"></script>
341
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables/media/js/dataTables.bootstrap4.min.js"></script>
342
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
343
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script>
344
-
345
- <?php
346
- // Tell WP that we are going to use a resource.
347
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-management", "subs_management.js", "includes/js/admin");
348
- // Includes the Panel JS resource file as well as the JS text domain translations.
349
- $wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-management", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
350
- // Enqueue the JS File
351
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-management" );
352
-
353
- ?>
354
-
 
 
 
 
 
 
1
+ <?php
2
+ // Avoid direct access to this piece of code
3
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
4
+ header( 'Location: /' );
5
+ exit;
6
+ }
7
+
8
+ $action = esc_attr( ! empty( $_POST['sra'] ) ? $_POST['sra'] : ( ! empty( $_GET['sra'] ) ? $_GET['sra'] : '' ) );
9
+ if ( $action == 'edit-subscription' || $action == 'add-subscription' ) {
10
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/panel1-' . $action . '.php';
11
+
12
+ return;
13
+ }
14
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/panel1-business-logic.php' ) ) {
15
+
16
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/panel1-business-logic.php';
17
+
18
+ // Display an alert in the admin interface if the email is wrong or the post id is not a number.
19
+ if ( ! $valid_email )
20
+ {
21
+ echo '<div class="notice notice-error is-dismissible"><p>';
22
+ _e( 'The email that you typed is not correct.', 'subscribe-to-comments-reloaded' );
23
+ echo "</p></div>";
24
+ }
25
+
26
+ if ( ! $valid_post_id )
27
+ {
28
+ echo '<div class="notice notice-error is-dismissible"><p>';
29
+ _e( 'Please enter a valid Post ID.', 'subscribe-to-comments-reloaded' );
30
+ echo "</p></div>";
31
+ }
32
+ }
33
+
34
+ ?>
35
+ <style type="text/css">
36
+
37
+ </style>
38
+
39
+ <link href="<?php echo esc_url( plugins_url( '/vendor/datatables/media/css/jquery.dataTables.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
40
+ <link href="<?php echo esc_url( plugins_url( '/vendor/datatables/media/css/dataTables.bootstrap4.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
41
+ <link href="<?php echo esc_url( plugins_url( '/vendor/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
42
+
43
+ <div class="container-fluid">
44
+
45
+ <div class="row mx-auto">
46
+ <div class="col-sm-6">
47
+ <div class="card card-font-size mass-update-subs">
48
+ <h6 class="card-header">
49
+ <i class="fas fa-exchange-alt"></i> <?php _e( 'Mass Update Subscriptions', 'subscribe-to-comments-reloaded' ) ?>
50
+ <i class="fas fa-caret-down pull-right"></i>
51
+ </h6>
52
+ <div class="card-body cbody-mass" style="padding: 0;">
53
+ <div class="card-text stcr-hidden">
54
+ <form action="" method="post" id="mass_update_address_form">
55
+
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>
68
+ </tr>
69
+ <tr>
70
+ <td><label for='srs'><?php _e( 'Status', 'subscribe-to-comments-reloaded' ) ?></label></td>
71
+ <td><select class="form-control form-controls-font mass-update-select-status" name="srs" id="srs">
72
+ <option value=''><?php _e( 'Keep unchanged', 'subscribe-to-comments-reloaded' ) ?></option>
73
+ <option value='Y'><?php _e( 'Active', 'subscribe-to-comments-reloaded' ) ?></option>
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">
81
+ <div class="more-info" data-infopanel="info-panel-mass-update" aria-label="<?php _e("More info", 'subscribe-to-comments-reloaded'); ?>">
82
+ <i class="fas fa-question-circle"></i>
83
+ </div>
84
+ </td>
85
+
86
+ </tr>
87
+ <tr>
88
+ <td colspan="2"><input type='hidden' name='sra' value='edit' /></td>
89
+ </tr>
90
+ </table>
91
+
92
+ <div class="alert alert-info hidden info-panel-mass-update" role="alert">
93
+ <?php _e('This option will allow you to change an email address for another one or to update the same status for all the subscription on a specific email address.', 'subscribe-to-comments-reloaded' ); ?>
94
+ </div>
95
+
96
+ <?php wp_nonce_field( 'stcr_edit_subscription_nonce', 'stcr_edit_subscription_nonce' ); ?>
97
+ </form>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+
103
+ <div class="col-sm-6">
104
+ <div class="card card-font-size add-new-subs">
105
+ <h6 class="card-header">
106
+ <i class="fas fa-plus-square"></i> <?php _e( 'Add New Subscription', 'subscribe-to-comments-reloaded' ) ?>
107
+ <i class="fas fa-caret-down pull-right"></i>
108
+ </h6>
109
+ <div class="card-body" style="padding: 0;">
110
+ <div class="card-text stcr-hidden">
111
+ <form action="" method="post" id="add_new_subscription">
112
+ <fieldset style="border:0">
113
+ <table>
114
+ <tr>
115
+ <td><?php _e( 'Post ID', 'subscribe-to-comments-reloaded' ) ?></td>
116
+ <td><input class="form-control form-controls-font" type='text' size='30' name='srp' value='' ></td>
117
+ <td><span class="validate-error-text validate-error-text-srp stcr-hidden "></span></td>
118
+ </tr>
119
+ <tr>
120
+ <td><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></td>
121
+ <td><input class="form-control form-controls-font" type='text' size='30' name='sre' value='' ></td>
122
+ <td><span class="validate-error-text validate-error-text-sre stcr-hidden "></span></td>
123
+ </tr>
124
+ <tr>
125
+ <td><?php _e( 'Status', 'subscribe-to-comments-reloaded' ) ?></td>
126
+ <td>
127
+ <select name="srs" class="form-control form-controls-font new-sub-select-status">
128
+ <option value='Y'><?php _e( 'Active', 'subscribe-to-comments-reloaded' ) ?></option>
129
+ <option value='R'><?php _e( 'Replies only', 'subscribe-to-comments-reloaded' ) ?></option>
130
+ <option value='YC'><?php _e( 'Ask user to confirm', 'subscribe-to-comments-reloaded' ) ?></option>
131
+ </select>
132
+ <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' ) ?>' >
133
+ </td>
134
+ </tr>
135
+ <tr>
136
+ <td><input type='hidden' name='sra' value='add' ></td>
137
+ </tr>
138
+ </table>
139
+ &nbsp;
140
+ </fieldset>
141
+ <?php wp_nonce_field( 'stcr_add_subscription_nonce', 'stcr_add_subscription_nonce' ); ?>
142
+ </form>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ </div>
148
+
149
+ <div class="clearfix"></div>
150
+
151
+ <div class="row mx-auto">
152
+ <div class="col-sm-12 col-md-12 col-lg-12">
153
+ <div class="card card-subscribers" style="max-width: 100% !important;">
154
+ <div class="card-body">
155
+
156
+ <div class="card-text postbox" style="border: none;">
157
+
158
+ <h4><i class="fas fa-search"></i> <?php _e( 'Search subscriptions', 'subscribe-to-comments-reloaded' ) ?></h4>
159
+
160
+ <?php if ( ! empty( $_POST['srv'] ) || ( is_array( $subscriptions ) && count( $subscriptions ) == 1000 ) ) : ?>
161
+
162
+ <?php
163
+ $search_term = '';
164
+ if ( ! empty( $_POST['srv'] ) ) {
165
+ $search_term = sanitize_text_field( $_POST['srv'] );
166
+ }
167
+ ?>
168
+ <form action="" method="post" style="background: #f5f5f5; padding: 15px; margin-top: 20px;">
169
+ <p>
170
+ <strong><?php esc_html_e( 'The table below is limited to loading 1000 latest subscriptions.', 'subscribe-to-comments-reloaded' ); ?></strong>
171
+ <br><?php esc_html_e( 'You have more than that, if you need to find an older subscription just enter a search term ( full email, partial email, post ID...) below.', 'subscribe-to-comments-reloaded' ); ?>
172
+ </p>
173
+ <p>
174
+ <input type="text" name="srv" placeholder="<?php esc_attr_e( 'Enter search term', 'subscribe-to-comments-reloaded' ); ?>" value="<?php echo esc_attr( $search_term ); ?>">
175
+ <input type="submit" class="button button-primary">
176
+ </p>
177
+ </form>
178
+
179
+ <?php endif; ?>
180
+
181
+ <div class="col-md-2 subs-spinner mx-auto"><h5><?php _e( "Loading", 'subscribe-to-comments-reloaded'); ?> <i class="fas fa-play-circle"></i></h5></div>
182
+
183
+ <div class="clearfix"></div>
184
+
185
+ <form style="border: 1px solid #eee; padding: 15px; margin-top: 20px;" action="" method="post" id="subscription_form" name="subscription_form"
186
+ onsubmit="if(this.sra[0].checked) return confirm('<?php _e( 'Please remember: this operation cannot be undone. Are you sure you want to proceed?', 'subscribe-to-comments-reloaded' ) ?>')">
187
+
188
+ <?php
189
+
190
+ $alternate = '';
191
+ $date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
192
+ // Let us form those status
193
+ $status_arry = array(
194
+ 'R' => __( 'Replies', 'subscribe-to-comments-reloaded'),
195
+ 'RC' => __( 'Replies Unconfirmed', 'subscribe-to-comments-reloaded'),
196
+ 'Y' => __( "All Comments", 'subscribe-to-comments-reloaded'),
197
+ 'YC' => __( "Unconfirmed", 'subscribe-to-comments-reloaded'),
198
+ 'C' => __( "Inactive", 'subscribe-to-comments-reloaded'),
199
+ '-C' => __( "Active", 'subscribe-to-comments-reloaded')
200
+ );
201
+
202
+ if ( ! empty( $subscriptions ) && is_array( $subscriptions ) ) {
203
+
204
+ $show_post_column = ( $operator != 'equals' || $search_field != 'post_id' ) ? __( 'Post (ID)', 'subscribe-to-comments-reloaded' ) : '';
205
+ $show_email_column = ( $operator != 'equals' || $search_field != 'email' ) ? __( 'Email', 'subscribe-to-comments-reloaded' ) : '';
206
+
207
+ echo "<table class=\"table table-smx table-hover table-striped subscribers-table stcr-hidden\" style=\"font-size: 0.8em\">
208
+ <thead>";
209
+
210
+ if( $wp_locale->text_direction == 'rtl' )
211
+ {
212
+
213
+ echo "<tr>
214
+ <th scope=\"col\">
215
+ &nbsp;&nbsp;&nbsp;<i class=\"fas fa-exchange-alt\"></i> <span>" . __('Actions', 'subscribe-to-comments-reloaded') ."</span>
216
+ <input class='checkbox' type='checkbox' name='subscription_list_select_all' id='stcr_select_all' class='stcr_select_all'/>
217
+ </th>
218
+ <th scope=\"col\"><i class=\"fas fa-thumbtack\"></i><span>$show_post_column</span></th>
219
+ <th scope=\"col\"><i class=\"fas fa-address-card\"></i><span>$show_email_column</span></th>
220
+ <th scope=\"col\"><i class=\"fas fa-calendar-alt\"></i><span>". __( 'Date and Time', 'subscribe-to-comments-reloaded' ) . "</span></th>
221
+ <th scope=\"col\"><i class=\"fas fa-info-circle\"></i><span>". __( 'Status', 'subscribe-to-comments-reloaded' ) . "</span></th>
222
+ </tr>";
223
+ }
224
+ else
225
+ {
226
+ echo "<tr>
227
+ <th scope=\"col\">
228
+ <input class='checkbox' type='checkbox' name='subscription_list_select_all' id='stcr_select_all' class='stcr_select_all'/>
229
+ &nbsp;&nbsp;&nbsp;<i class=\"fas fa-exchange-alt\"></i> <span>" . __('Actions', 'subscribe-to-comments-reloaded') ."</span>
230
+ </th>
231
+ <th scope=\"col\"><i class=\"fas fa-thumbtack\"></i><span>$show_post_column</span></th>
232
+ <th scope=\"col\"><i class=\"fas fa-address-card\"></i><span>$show_email_column</span></th>
233
+ <th scope=\"col\"><i class=\"fas fa-calendar-alt\"></i><span>". __( 'Date and Time', 'subscribe-to-comments-reloaded' ) . "</span></th>
234
+ <th scope=\"col\"><i class=\"fas fa-info-circle\"></i><span>". __( 'Status', 'subscribe-to-comments-reloaded' ) . "</span></th>
235
+ </tr>";
236
+ }
237
+
238
+ echo "</thead>";
239
+ echo "<tbody>";
240
+
241
+ foreach ( $subscriptions as $a_subscription ) {
242
+ //$wp_subscribe_reloaded->stcr->utils->stcr_logger( print_r($a_subscription, true) );
243
+ $title = get_the_title( $a_subscription->post_id );
244
+ $title = ( strlen( $title ) > 35 ) ? substr( $title, 0, 35 ) . '..' : $title;
245
+ if( $wp_locale->text_direction == 'rtl' )
246
+ {
247
+ $row_post = ( $operator != 'equals' || $search_field != 'post_id' ) ? "<a href='admin.php?page=stcr_manage_subscriptions&amp;srf=post_id&amp;srt=equals&amp;srv=$a_subscription->post_id'>($a_subscription->post_id) $title</a> " : '';
248
+ }
249
+ else
250
+ {
251
+ $row_post = ( $operator != 'equals' || $search_field != 'post_id' ) ? "<a href='admin.php?page=stcr_manage_subscriptions&amp;srf=post_id&amp;srt=equals&amp;srv=$a_subscription->post_id'>$title ($a_subscription->post_id)</a> " : '';
252
+ }
253
+ $row_email = ( $operator != 'equals' || $search_field != 'email' ) ? "<a href='admin.php?page=stcr_manage_subscriptions&amp;srf=email&amp;srt=equals&amp;srv=" . urlencode( $a_subscription->email ) . "' title='email unique key: ( $a_subscription->email_key )'>$a_subscription->email</a> " : '';
254
+ $date_time = date_i18n( $date_time_format, strtotime( $a_subscription->dt ) );
255
+ $date_time_sort = date_i18n( 'YmdHis', strtotime( $a_subscription->dt ) );
256
+
257
+ $status_desc = $status_arry[$a_subscription->status];
258
+
259
+ $delete_url = "admin.php?page=stcr_manage_subscriptions&sra=delete-subscription&srp=" . $a_subscription->post_id . "&sre=" . urlencode( $a_subscription->email );
260
+ $delete_url = wp_nonce_url( $delete_url, 'stcr_delete_subscription_nonce', 'stcr_delete_subscription_nonce' );
261
+
262
+ if( $wp_locale->text_direction == 'rtl' )
263
+ {
264
+ echo "<tr>
265
+ <td>
266
+ <label for='sub_{$a_subscription->meta_id}' class='hidden'>" . __( 'Subscription', 'subscribe-to-comments-reloaded' ) . " {$a_subscription->meta_id}</label>
267
+ <input class='checkbox' type='checkbox' name='subscriptions_list[]' value='$a_subscription->post_id," . urlencode( $a_subscription->email ) . "' id='sub_{$a_subscription->meta_id}' />
268
+ <a href='admin.php?page=stcr_manage_subscriptions&amp;sra=edit-subscription&amp;srp=" . $a_subscription->post_id . "&amp;sre=" . urlencode( $a_subscription->email ) . "' alt='" . __( 'Edit', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-edit\" style='font-size: 1.1em;color: #ffc53a;'></i></a>
269
+ &nbsp;&nbsp;&nbsp;&nbsp;<a href='$delete_url' onclick='return confirm(\"" . __( 'Please remember: this operation cannot be undone. Are you sure you want to proceed?', 'subscribe-to-comments-reloaded' ) . "\");' alt='" . __( 'Delete', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-trash-alt\" style='font-size: 1.1em;color: #ff695a;'></i></a>
270
+ </td>
271
+ <td>$row_post</td>
272
+ <td>$row_email</td>
273
+ <td data-sort='$date_time_sort'>$date_time</td>
274
+ <td>$status_desc</td>
275
+ </tr>";
276
+ }
277
+ else
278
+ {
279
+ echo "<tr>
280
+ <td>
281
+ <label for='sub_{$a_subscription->meta_id}' class='hidden'>" . __( 'Subscription', 'subscribe-to-comments-reloaded' ) . " {$a_subscription->meta_id}</label>
282
+ <input class='checkbox' type='checkbox' name='subscriptions_list[]' value='$a_subscription->post_id," . urlencode( $a_subscription->email ) . "' id='sub_{$a_subscription->meta_id}' />
283
+ <a href='admin.php?page=stcr_manage_subscriptions&amp;sra=edit-subscription&amp;srp=" . $a_subscription->post_id . "&amp;sre=" . urlencode( $a_subscription->email ) . "' alt='" . __( 'Edit', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-edit\" style='font-size: 1.1em;color: #ffc53a;'></i></a>
284
+ &nbsp;&nbsp;&nbsp;&nbsp;<a href='$delete_url' onclick='return confirm(\"" . __( 'Please remember: this operation cannot be undone. Are you sure you want to proceed?', 'subscribe-to-comments-reloaded' ) . "\");' alt='" . __( 'Delete', 'subscribe-to-comments-reloaded' ) . "'><i class=\"fas fa-trash-alt\" style='font-size: 1.1em;color: #ff695a;'></i></a>
285
+ </td>
286
+ <td>$row_post</td>
287
+ <td>$row_email</td>
288
+ <td data-sort='$date_time_sort'>$date_time</td>
289
+ <td>$status_desc</td>
290
+ </tr>";
291
+ }
292
+
293
+ }
294
+ echo "</tbody>";
295
+
296
+ echo "</table>";
297
+
298
+ echo "<div class='subscribers-mass-actions form-group row'>";
299
+ echo '<label for="action_type" class="col-sm-1 col-form-label">' . __( 'Action:', 'subscribe-to-comments-reloaded' ) . '</label >' ;
300
+ ?> <div class="col-sm-3">
301
+ <select name="sra" id="action_type" class="form-control">
302
+ <option value="delete"><?php _e( 'Delete forever', 'subscribe-to-comments-reloaded' ) ?></option>
303
+ <option value="suspend"><?php _e( 'Suspend', 'subscribe-to-comments-reloaded' ) ?></option>
304
+ <option value="force_y"><?php _e( 'Activate and set to notify on all comments', 'subscribe-to-comments-reloaded' ) ?></option>
305
+ <option value="force_r"><?php _e( 'Activate and set to notify on replies only ', 'subscribe-to-comments-reloaded' ) ?></option>
306
+ <option value="activate"><?php _e( 'Activate', 'subscribe-to-comments-reloaded' ) ?></option>
307
+ </select>
308
+ </div>
309
+ <?php
310
+ echo '<div class="col-sm-2"><button type="submit" class="subscribe-form-button btn btn-primary" >' . __( 'Update subscriptions', 'subscribe-to-comments-reloaded' ) . '</button></div>';
311
+ echo "<input type='hidden' name='srf' value='$search_field'/><input type='hidden' name='srt' value='$operator'/><input type='hidden' name='srv' value='$search_value'/><input type='hidden' name='srsf' value='$offset'/><input type='hidden' name='srrp' value='$limit_results'/><input type='hidden' name='srob' value='$order_by'/><input type='hidden' name='sro' value='$order'/>";
312
+ echo "</div>";
313
+
314
+ } elseif ( $action == 'search' ) {
315
+ echo '<p>' . __( 'Sorry, no subscriptions match your search criteria.', 'subscribe-to-comments-reloaded' ) . "</p>";
316
+ }
317
+ ?>
318
+
319
+ <?php wp_nonce_field( 'stcr_update_subscriptions_nonce', 'stcr_update_subscriptions_nonce' ); ?>
320
+
321
+ </form>
322
+ </div>
323
+ </div>
324
+ </div>
325
+ </div>
326
+ </div>
327
+
328
+ <div class="clearfix"></div>
329
+
330
+ <div class="row">
331
+ <div class="col-sm-6 col-md-6 col-lg-6 mx-auto">
332
+ <div class="card" style="max-width: 100% !important;">
333
+ <div class="card-body">
334
+ <p>
335
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
336
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
337
+ </p>
338
+ <p>
339
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
340
+ </p>
341
+ </div>
342
+ </div>
343
+ </div>
344
+ </div>
345
+ </div>
346
+
347
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/datatables/media/js/jquery.dataTables.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
348
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/datatables/media/js/dataTables.bootstrap4.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
349
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/datatables.net-responsive/js/dataTables.responsive.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
350
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
351
+
352
+ <?php
353
+ // Tell WP that we are going to use a resource.
354
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-management", "subs_management.js", "includes/js/admin");
355
+ // Includes the Panel JS resource file as well as the JS text domain translations.
356
+ $wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-management", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
357
+ // Enqueue the JS File
358
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-management" );
359
+
360
+ ?>
options/stcr_management_page.php CHANGED
@@ -1,440 +1,455 @@
1
- <?php
2
- // Management Page
3
-
4
- // Avoid direct access to this piece of code
5
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
- header( 'Location: /' );
7
- exit;
8
- }
9
-
10
- $options = array(
11
- "manager_page_enabled" => "yesno",
12
- "manager_page_title" => "text",
13
- "manager_page" => "url",
14
- "custom_header_meta" => "text-html",
15
- "request_mgmt_link" => "text-html",
16
- "request_mgmt_link_thankyou" => "text-html",
17
- "subscribe_without_commenting" => "text-html",
18
- "subscription_confirmed" => "text-html",
19
- "subscription_confirmed_dci" => "text-html",
20
- "author_text" => "text-html",
21
- "user_text" => "text-html",
22
- 'allow_subscribe_without_comment' => 'yesno',
23
- 'allow_request_management_link' => 'yesno',
24
- );
25
-
26
- $options_readable = array(
27
- "manager_page" => __("Management URL",'subscribe-to-comments-reloaded')
28
- );
29
-
30
- // Update options
31
- if ( isset( $_POST['options'] ) ) {
32
- $faulty_fields = array();
33
-
34
- foreach ( $_POST['options'] as $option => $value )
35
- {
36
- if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
37
- {
38
- array_push( $faulty_fields, $option );
39
- }
40
- if( $option == "manager_page" && $value == "") //TODO: Add validation for all he require fields.
41
- {
42
- array_push( $faulty_fields, $option );
43
- }
44
- }
45
-
46
- // Display an alert in the admin interface if something went wrong
47
- if ( sizeof( $faulty_fields ) == 0 ) {
48
- echo '<div class="updated"><p>';
49
- _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
50
- echo "</p></div>";
51
- } else {
52
- echo '<div class="error"><p>';
53
- _e( 'There was an error updating the following fields:', 'subscribe-to-comments-reloaded' );
54
- echo "<ul style='font-size: 0.8em;'>";
55
- foreach( $faulty_fields as $field )
56
- {
57
- echo ' <li>> ' . $options_readable[$field] . '</li>';
58
- }
59
- echo "</ul>";
60
- echo "</p></div>";
61
- }
62
- }
63
- wp_print_scripts( 'quicktags' );
64
-
65
- ?>
66
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.css" rel="stylesheet"/>
67
-
68
- <div class="container-fluid">
69
- <div class="mt-3"></div>
70
- <div class="row">
71
- <div class="col-sm-9">
72
- <form class="management_page_form" action="" method="post">
73
-
74
- <div class="form-group row">
75
- <label for="manager_page_enabled" class="col-sm-3 col-form-label text-right"><?php _e( 'Virtual Management Page', 'subscribe-to-comments-reloaded' ) ?></label>
76
- <div class="col-sm-7">
77
- <div class="switch">
78
- <input type="radio" class="switch-input" name="options[manager_page_enabled]"
79
- value="yes" id="manager_page_enabled-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_enabled' ) == 'yes' ) ? ' checked' : ''; ?> />
80
- <label for="manager_page_enabled-yes" class="switch-label switch-label-off">
81
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
82
- </label>
83
- <input type="radio" class="switch-input" name="options[manager_page_enabled]" value="no" id="manager_page_enabled-no"
84
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_enabled' ) == 'no' ) ? ' checked' : ''; ?> />
85
- <label for="manager_page_enabled-no" class="switch-label switch-label-on">
86
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
87
- </label>
88
- <span class="switch-selection"></span>
89
- </div>
90
- <div class="helpDescription subsOptDescriptions"
91
- data-content="<?php _e( "Disable the virtual management page if you need to create a <a href='https://github.com/stcr/subscribe-to-comments-reloaded/wiki/KB#create-a-real-management-page'>real page</a> to make your theme happy.", 'subscribe-to-comments-reloaded' ); ?>"
92
- data-placement="right"
93
- aria-label="<?php _e( "Disable the virtual management page if you need to create a <a href='https://github.com/stcr/subscribe-to-comments-reloaded/wiki/KB#create-a-real-management-page'>real page</a> to make your theme happy.", 'subscribe-to-comments-reloaded' ); ?>">
94
- <i class="fas fa-question-circle"></i>
95
- </div>
96
- </div>
97
- </div>
98
-
99
- <div class="form-group row">
100
- <label for="manager_page_title" class="col-sm-3 col-form-label text-right">
101
- <?php _e( 'Page title', 'subscribe-to-comments-reloaded' ) ?></label>
102
- <div class="col-sm-7">
103
- <input type="text" name="options[manager_page_title]" id="manager_page_title"
104
- class="form-control form-control-input-8"
105
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_title' ) ); ?>" size="20">
106
-
107
- <div class="helpDescription subsOptDescriptions"
108
- data-content="<?php _e( 'Title of the page your visitors will use to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>"
109
- data-placement="right"
110
- aria-label="<?php _e( 'Title of the page your visitors will use to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>">
111
- <i class="fas fa-question-circle"></i>
112
- </div>
113
- </div>
114
- </div>
115
-
116
- <div class="form-group row">
117
- <label for="manager_page" class="col-sm-3 col-form-label text-right">
118
- <?php _e( 'Management URL', 'subscribe-to-comments-reloaded' ) ?></label>
119
- <div class="col-sm-7">
120
- <code><?php echo get_bloginfo( 'url' ) ?></code>
121
- <input type="text" name="options[manager_page]" id="manager_page"
122
- class="form-control form-control-input-8"
123
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page' ) ); ?>" style=" width: 60% !important;">
124
-
125
- <div class="helpDescription subsOptDescriptions"
126
- 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' ); ?>"
127
- data-placement="bottom"
128
- aria-label="<?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' ); ?>">
129
- <i class="fas fa-question-circle"></i>
130
- </div>
131
-
132
- <?php
133
- if ( ( get_option( 'permalink_structure' ) == '' ) && ( strpos( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page' ), '?page_id=' ) === false ) ) {
134
- echo "<div class=\"alert alert-danger\" role=\"alert\">";
135
- echo '<strong>' . __( "Warning: it looks like the value you are using may be incompatible with your permalink structure", 'subscribe-to-comments-reloaded' ) . '</strong>';
136
- echo "</div>";
137
- }
138
- ?>
139
- </div>
140
- </div>
141
-
142
- <div class="form-group row">
143
- <label for="custom_header_meta" class="col-sm-3 col-form-label text-right">
144
- <?php _e( 'Custom HEAD meta', 'subscribe-to-comments-reloaded' ) ?></label>
145
- <div class="col-sm-7">
146
- <input type="text" name="options[custom_header_meta]" id="custom_header_meta"
147
- class="form-control form-control-input-8"
148
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'custom_header_meta' ) ); ?>" size="20">
149
-
150
- <div class="helpDescription subsOptDescriptions"
151
- 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' ); ?>"
152
- data-placement="right"
153
- aria-label="<?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' ); ?>">
154
- <i class="fas fa-question-circle"></i>
155
- </div>
156
- </div>
157
- </div>
158
-
159
- <div class="form-group row">
160
- <label for="allow_subscribe_without_comment" class="col-sm-3 col-form-label text-right"><?php _e( 'Allow "Subscribe Without Comment"', 'subscribe-to-comments-reloaded' ) ?></label>
161
- <div class="col-sm-7">
162
- <div class="switch">
163
- <input type="radio" class="switch-input" name="options[allow_subscribe_without_comment]"
164
- value="yes" id="allow_subscribe_without_comment-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_subscribe_without_comment', 'yes' ) == 'yes' ) ? ' checked' : ''; ?> />
165
- <label for="allow_subscribe_without_comment-yes" class="switch-label switch-label-off">
166
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
167
- </label>
168
- <input type="radio" class="switch-input" name="options[allow_subscribe_without_comment]" value="no" id="allow_subscribe_without_comment-no"
169
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_subscribe_without_comment', 'yes' ) == 'no' ) ? ' checked' : ''; ?> />
170
- <label for="allow_subscribe_without_comment-no" class="switch-label switch-label-on">
171
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
172
- </label>
173
- <span class="switch-selection"></span>
174
- </div>
175
- <div class="helpDescription subsOptDescriptions"
176
- data-content="<?php _e( "Enable or disable the form that allows visitors to subscribe to comments notifications without commenting.", 'subscribe-to-comments-reloaded' ); ?>"
177
- data-placement="right"
178
- aria-label="<?php _e( "Enable or disable the form that allows visitors to subscribe to comments notifications without commenting.", 'subscribe-to-comments-reloaded' ); ?>">
179
- <i class="fas fa-question-circle"></i>
180
- </div>
181
- </div>
182
- </div>
183
-
184
- <div class="form-group row">
185
- <label for="allow_request_management_link" class="col-sm-3 col-form-label text-right"><?php _e( 'Allow "Request Management Link"', 'subscribe-to-comments-reloaded' ) ?></label>
186
- <div class="col-sm-7">
187
- <div class="switch">
188
- <input type="radio" class="switch-input" name="options[allow_request_management_link]"
189
- value="yes" id="allow_request_management_link-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_request_management_link', 'yes' ) == 'yes' ) ? ' checked' : ''; ?> />
190
- <label for="allow_request_management_link-yes" class="switch-label switch-label-off">
191
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
192
- </label>
193
- <input type="radio" class="switch-input" name="options[allow_request_management_link]" value="no" id="allow_request_management_link-no"
194
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_request_management_link', 'yes' ) == 'no' ) ? ' checked' : ''; ?> />
195
- <label for="allow_request_management_link-no" class="switch-label switch-label-on">
196
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
197
- </label>
198
- <span class="switch-selection"></span>
199
- </div>
200
- <div class="helpDescription subsOptDescriptions"
201
- data-content="<?php _e( "Enable or disable the form that allows visitors to to request a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>"
202
- data-placement="right"
203
- aria-label="<?php _e( "Enable or disable the form that allows visitors to to request a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>">
204
- <i class="fas fa-question-circle"></i>
205
- </div>
206
- </div>
207
- </div>
208
-
209
- <h3><?php _e( 'Messages', 'subscribe-to-comments-reloaded' ) ?></h3>
210
-
211
- <div class="form-group row">
212
- <label for="request_mgmt_link" class="col-sm-2 offset-sm-1 col-form-label" style="z-index: 9999;">
213
- <?php _e( 'Request link', 'subscribe-to-comments-reloaded' ) ?>
214
-
215
- <div class="helpDescription subsOptDescriptions"
216
- data-content="<?php _e( 'Text shown to those who request to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>"
217
- data-placement="right"
218
- aria-label="<?php _e( 'Text shown to those who request to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>">
219
- <i class="fas fa-question-circle"></i>
220
- </div>
221
-
222
- </label>
223
- <div class="clearfix"></div>
224
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
225
- <?php
226
- $id_request_mgmt_link = "request_mgmt_link";
227
- $args_notificationContent = array(
228
- "media_buttons" => false,
229
- "textarea_rows" => 3,
230
- "teeny" => true,
231
- "textarea_name" => "options[{$id_request_mgmt_link}]"
232
- );
233
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_request_mgmt_link ), $id_request_mgmt_link, $args_notificationContent );
234
- ?>
235
- </div>
236
- </div>
237
-
238
- <div class="form-group row" style="display: none;">
239
- <label for="request_mgmt_link_thankyou" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
240
- <?php _e( 'Request submitted', 'subscribe-to-comments-reloaded' ) ?>
241
-
242
- <div class="helpDescription subsOptDescriptions"
243
- data-content="<?php _e( 'Thank you note shown after the request here above has been processed. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
244
- data-placement="right"
245
- aria-label="<?php _e( 'Thank you note shown after the request here above has been processed. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
246
- <i class="fas fa-question-circle"></i>
247
- </div>
248
-
249
- </label>
250
- <div class="clearfix"></div>
251
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
252
- <?php
253
- $id_request_mgmt_link_thankyou = "request_mgmt_link_thankyou";
254
- $args_notificationContent = array(
255
- "media_buttons" => false,
256
- "textarea_rows" => 3,
257
- "teeny" => true,
258
- "textarea_name" => "options[{$id_request_mgmt_link_thankyou}]"
259
- );
260
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_request_mgmt_link_thankyou ), $id_request_mgmt_link_thankyou, $args_notificationContent );
261
- ?>
262
- </div>
263
- </div>
264
-
265
- <div class="form-group row">
266
- <label for="subscribe_without_commenting" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
267
- <?php _e( 'Subscribe without commenting', 'subscribe-to-comments-reloaded' ) ?>
268
-
269
- <div class="helpDescription subsOptDescriptions"
270
- data-content="<?php _e( 'Text shown to those who want to subscribe without commenting. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
271
- data-placement="right"
272
- aria-label="<?php _e( 'Text shown to those who want to subscribe without commenting. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
273
- <i class="fas fa-question-circle"></i>
274
- </div>
275
-
276
- </label>
277
- <div class="clearfix"></div>
278
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
279
- <?php
280
- $id_subscribe_without_commenting = "subscribe_without_commenting";
281
- $args_notificationContent = array(
282
- "media_buttons" => false,
283
- "textarea_rows" => 3,
284
- "teeny" => true,
285
- "textarea_name" => "options[{$id_subscribe_without_commenting}]"
286
- );
287
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscribe_without_commenting ), $id_subscribe_without_commenting, $args_notificationContent );
288
- ?>
289
- </div>
290
- </div>
291
-
292
- <div class="form-group row">
293
- <label for="subscription_confirmed" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
294
- <?php _e( 'Subscription processed', 'subscribe-to-comments-reloaded' ) ?>
295
-
296
- <div class="helpDescription subsOptDescriptions"
297
- data-content="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in disabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
298
- data-placement="right"
299
- aria-label="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in disabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
300
- <i class="fas fa-question-circle"></i>
301
- </div>
302
-
303
- </label>
304
- <div class="clearfix"></div>
305
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
306
- <?php
307
- $id_subscription_confirmed = "subscription_confirmed";
308
- $args_notificationContent = array(
309
- "media_buttons" => false,
310
- "textarea_rows" => 3,
311
- "teeny" => true,
312
- "textarea_name" => "options[{$id_subscription_confirmed}]"
313
- );
314
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscription_confirmed ), $id_subscription_confirmed, $args_notificationContent );
315
- ?>
316
- </div>
317
- </div>
318
-
319
- <div class="form-group row">
320
- <label for="subscription_confirmed_dci" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
321
- <?php _e( 'Subscription processed (DCI)', 'subscribe-to-comments-reloaded' ) ?>
322
-
323
- <div class="helpDescription subsOptDescriptions"
324
- data-content="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in enabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
325
- data-placement="right"
326
- aria-label="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in enabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
327
- <i class="fas fa-question-circle"></i>
328
- </div>
329
-
330
- </label>
331
- <div class="clearfix"></div>
332
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
333
- <?php
334
- $id_subscription_confirmed_dci = "subscription_confirmed_dci";
335
- $args_notificationContent = array(
336
- "media_buttons" => false,
337
- "textarea_rows" => 3,
338
- "teeny" => true,
339
- "textarea_name" => "options[{$id_subscription_confirmed_dci}]"
340
- );
341
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscription_confirmed_dci ), $id_subscription_confirmed_dci, $args_notificationContent );
342
- ?>
343
- </div>
344
- </div>
345
-
346
- <div class="form-group row">
347
- <label for="author_text" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
348
- <?php _e( 'Authors', 'subscribe-to-comments-reloaded' ) ?>
349
-
350
- <div class="helpDescription subsOptDescriptions"
351
- data-content="<?php _e( "Introductory text for the authors' management page.", 'subscribe-to-comments-reloaded' ); ?>"
352
- data-placement="right"
353
- aria-label="<?php _e( "Introductory text for the authors' management page.", 'subscribe-to-comments-reloaded' ); ?>">
354
- <i class="fas fa-question-circle"></i>
355
- </div>
356
-
357
- </label>
358
- <div class="clearfix"></div>
359
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
360
- <?php
361
- $id_author_text = "author_text";
362
- $args_notificationContent = array(
363
- "media_buttons" => false,
364
- "textarea_rows" => 3,
365
- "teeny" => true,
366
- "textarea_name" => "options[{$id_author_text}]"
367
- );
368
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_author_text ), $id_author_text, $args_notificationContent );
369
- ?>
370
- </div>
371
- </div>
372
-
373
- <div class="form-group row">
374
- <label for="user_text" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
375
- <?php _e( 'Users', 'subscribe-to-comments-reloaded' ) ?>
376
-
377
- <div class="helpDescription subsOptDescriptions"
378
- data-content="<?php _e( "Introductory text for the users' management page.", 'subscribe-to-comments-reloaded' ); ?>"
379
- data-placement="right"
380
- aria-label="<?php _e( "Introductory text for the users' management page.", 'subscribe-to-comments-reloaded' ); ?>">
381
- <i class="fas fa-question-circle"></i>
382
- </div>
383
-
384
- </label>
385
- <div class="clearfix"></div>
386
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
387
- <?php
388
- $id_user_text = "user_text";
389
- $args_notificationContent = array(
390
- "media_buttons" => false,
391
- "textarea_rows" => 3,
392
- "teeny" => true,
393
- "textarea_name" => "options[{$id_user_text}]"
394
- );
395
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_user_text ), $id_user_text, $args_notificationContent );
396
- ?>
397
- </div>
398
- </div>
399
-
400
- <div class="form-group row">
401
- <div class="col-sm-9 offset-sm-1">
402
- <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
403
- <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
404
- </button>
405
- </div>
406
- </div>
407
-
408
- </form>
409
- </div>
410
-
411
- <div class="col-md-3">
412
- <div class="card card-font-size">
413
- <div class="card-body">
414
- <p>
415
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
416
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
417
- </p>
418
- <p>
419
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
420
- </p>
421
- </div>
422
- </div>
423
- </div>
424
-
425
- </div>
426
- </div>
427
-
428
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.js"></script>
429
- <?php
430
- global $wp_subscribe_reloaded;
431
- // Tell WP that we are going to use a resource.
432
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
433
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-management-page", "management_page.js", "includes/js/admin");
434
- // Includes the Panel JS resource file as well as the JS text domain translations.
435
- //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
436
- // Enqueue the JS File
437
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
438
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-management-page" );
439
-
440
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Management Page
3
+
4
+ // Avoid direct access to this piece of code
5
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
+ header( 'Location: /' );
7
+ exit;
8
+ }
9
+
10
+ $options = array(
11
+ "manager_page_enabled" => "yesno",
12
+ "manager_page_title" => "text",
13
+ "manager_page" => "url",
14
+ "custom_header_meta" => "text-html",
15
+ "request_mgmt_link" => "text-html",
16
+ "request_mgmt_link_thankyou" => "text-html",
17
+ "subscribe_without_commenting" => "text-html",
18
+ "subscription_confirmed" => "text-html",
19
+ "subscription_confirmed_dci" => "text-html",
20
+ "author_text" => "text-html",
21
+ "user_text" => "text-html",
22
+ 'allow_subscribe_without_comment' => 'yesno',
23
+ 'allow_request_management_link' => 'yesno',
24
+ );
25
+
26
+ $options_readable = array(
27
+ "manager_page" => __("Management URL",'subscribe-to-comments-reloaded')
28
+ );
29
+
30
+ // Update options
31
+ if ( isset( $_POST['options'] ) ) {
32
+
33
+ if ( empty( $_POST['stcr_save_management_page_nonce'] ) ) {
34
+ return;
35
+ }
36
+
37
+ if ( ! wp_verify_nonce( $_POST['stcr_save_management_page_nonce'], 'stcr_save_management_page_nonce' ) ) {
38
+ return;
39
+ }
40
+
41
+ if ( ! current_user_can( 'manage_options' ) ) {
42
+ return;
43
+ }
44
+
45
+ $faulty_fields = array();
46
+
47
+ foreach ( $_POST['options'] as $option => $value )
48
+ {
49
+ if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
50
+ {
51
+ array_push( $faulty_fields, $option );
52
+ }
53
+ if( $option == "manager_page" && $value == "") //TODO: Add validation for all he require fields.
54
+ {
55
+ array_push( $faulty_fields, $option );
56
+ }
57
+ }
58
+
59
+ // Display an alert in the admin interface if something went wrong
60
+ if ( sizeof( $faulty_fields ) == 0 ) {
61
+ echo '<div class="updated"><p>';
62
+ _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
63
+ echo "</p></div>";
64
+ } else {
65
+ echo '<div class="error"><p>';
66
+ _e( 'There was an error updating the following fields:', 'subscribe-to-comments-reloaded' );
67
+ echo "<ul style='font-size: 0.8em;'>";
68
+ foreach( $faulty_fields as $field )
69
+ {
70
+ echo ' <li>> ' . $options_readable[$field] . '</li>';
71
+ }
72
+ echo "</ul>";
73
+ echo "</p></div>";
74
+ }
75
+ }
76
+ wp_print_scripts( 'quicktags' );
77
+
78
+ ?>
79
+ <link href="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
80
+
81
+ <div class="container-fluid">
82
+ <div class="mt-3"></div>
83
+ <div class="row">
84
+ <div class="col-sm-9">
85
+ <form class="management_page_form" action="" method="post">
86
+
87
+ <div class="form-group row">
88
+ <label for="manager_page_enabled" class="col-sm-3 col-form-label text-right"><?php _e( 'Virtual Management Page', 'subscribe-to-comments-reloaded' ) ?></label>
89
+ <div class="col-sm-7">
90
+ <div class="switch">
91
+ <input type="radio" class="switch-input" name="options[manager_page_enabled]"
92
+ value="yes" id="manager_page_enabled-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_enabled' ) == 'yes' ) ? ' checked' : ''; ?> />
93
+ <label for="manager_page_enabled-yes" class="switch-label switch-label-off">
94
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
95
+ </label>
96
+ <input type="radio" class="switch-input" name="options[manager_page_enabled]" value="no" id="manager_page_enabled-no"
97
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_enabled' ) == 'no' ) ? ' checked' : ''; ?> />
98
+ <label for="manager_page_enabled-no" class="switch-label switch-label-on">
99
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
100
+ </label>
101
+ <span class="switch-selection"></span>
102
+ </div>
103
+ <div class="helpDescription subsOptDescriptions"
104
+ data-content="<?php _e( "Disable the virtual management page if you need to create a <a href='https://github.com/stcr/subscribe-to-comments-reloaded/wiki/KB#create-a-real-management-page'>real page</a> to make your theme happy.", 'subscribe-to-comments-reloaded' ); ?>"
105
+ data-placement="right"
106
+ aria-label="<?php _e( "Disable the virtual management page if you need to create a <a href='https://github.com/stcr/subscribe-to-comments-reloaded/wiki/KB#create-a-real-management-page'>real page</a> to make your theme happy.", 'subscribe-to-comments-reloaded' ); ?>">
107
+ <i class="fas fa-question-circle"></i>
108
+ </div>
109
+ </div>
110
+ </div>
111
+
112
+ <div class="form-group row">
113
+ <label for="manager_page_title" class="col-sm-3 col-form-label text-right">
114
+ <?php _e( 'Page title', 'subscribe-to-comments-reloaded' ) ?></label>
115
+ <div class="col-sm-7">
116
+ <input type="text" name="options[manager_page_title]" id="manager_page_title"
117
+ class="form-control form-control-input-8"
118
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page_title' ) ); ?>" size="20">
119
+
120
+ <div class="helpDescription subsOptDescriptions"
121
+ data-content="<?php _e( 'Title of the page your visitors will use to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>"
122
+ data-placement="right"
123
+ aria-label="<?php _e( 'Title of the page your visitors will use to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>">
124
+ <i class="fas fa-question-circle"></i>
125
+ </div>
126
+ </div>
127
+ </div>
128
+
129
+ <div class="form-group row">
130
+ <label for="manager_page" class="col-sm-3 col-form-label text-right">
131
+ <?php _e( 'Management URL', 'subscribe-to-comments-reloaded' ) ?></label>
132
+ <div class="col-sm-7">
133
+ <code><?php echo get_bloginfo( 'url' ) ?></code>
134
+ <input type="text" name="options[manager_page]" id="manager_page"
135
+ class="form-control form-control-input-8"
136
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page' ) ); ?>" style=" width: 60% !important;">
137
+
138
+ <div class="helpDescription subsOptDescriptions"
139
+ 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' ); ?>"
140
+ data-placement="bottom"
141
+ aria-label="<?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
+ <i class="fas fa-question-circle"></i>
143
+ </div>
144
+
145
+ <?php
146
+ if ( ( get_option( 'permalink_structure' ) == '' ) && ( strpos( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'manager_page' ), '?page_id=' ) === false ) ) {
147
+ echo "<div class=\"alert alert-danger\" role=\"alert\">";
148
+ echo '<strong>' . __( "Warning: it looks like the value you are using may be incompatible with your permalink structure", 'subscribe-to-comments-reloaded' ) . '</strong>';
149
+ echo "</div>";
150
+ }
151
+ ?>
152
+ </div>
153
+ </div>
154
+
155
+ <div class="form-group row">
156
+ <label for="custom_header_meta" class="col-sm-3 col-form-label text-right">
157
+ <?php _e( 'Custom HEAD meta', 'subscribe-to-comments-reloaded' ) ?></label>
158
+ <div class="col-sm-7">
159
+ <input type="text" name="options[custom_header_meta]" id="custom_header_meta"
160
+ class="form-control form-control-input-8"
161
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'custom_header_meta' ) ); ?>" size="20">
162
+
163
+ <div class="helpDescription subsOptDescriptions"
164
+ 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' ); ?>"
165
+ data-placement="right"
166
+ aria-label="<?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' ); ?>">
167
+ <i class="fas fa-question-circle"></i>
168
+ </div>
169
+ </div>
170
+ </div>
171
+
172
+ <div class="form-group row">
173
+ <label for="allow_subscribe_without_comment" class="col-sm-3 col-form-label text-right"><?php _e( 'Allow "Subscribe Without Comment"', 'subscribe-to-comments-reloaded' ) ?></label>
174
+ <div class="col-sm-7">
175
+ <div class="switch">
176
+ <input type="radio" class="switch-input" name="options[allow_subscribe_without_comment]"
177
+ value="yes" id="allow_subscribe_without_comment-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_subscribe_without_comment', 'yes' ) == 'yes' ) ? ' checked' : ''; ?> />
178
+ <label for="allow_subscribe_without_comment-yes" class="switch-label switch-label-off">
179
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
180
+ </label>
181
+ <input type="radio" class="switch-input" name="options[allow_subscribe_without_comment]" value="no" id="allow_subscribe_without_comment-no"
182
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_subscribe_without_comment', 'yes' ) == 'no' ) ? ' checked' : ''; ?> />
183
+ <label for="allow_subscribe_without_comment-no" class="switch-label switch-label-on">
184
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
185
+ </label>
186
+ <span class="switch-selection"></span>
187
+ </div>
188
+ <div class="helpDescription subsOptDescriptions"
189
+ data-content="<?php _e( "Enable or disable the form that allows visitors to subscribe to comments notifications without commenting.", 'subscribe-to-comments-reloaded' ); ?>"
190
+ data-placement="right"
191
+ aria-label="<?php _e( "Enable or disable the form that allows visitors to subscribe to comments notifications without commenting.", 'subscribe-to-comments-reloaded' ); ?>">
192
+ <i class="fas fa-question-circle"></i>
193
+ </div>
194
+ </div>
195
+ </div>
196
+
197
+ <div class="form-group row">
198
+ <label for="allow_request_management_link" class="col-sm-3 col-form-label text-right"><?php _e( 'Allow "Request Management Link"', 'subscribe-to-comments-reloaded' ) ?></label>
199
+ <div class="col-sm-7">
200
+ <div class="switch">
201
+ <input type="radio" class="switch-input" name="options[allow_request_management_link]"
202
+ value="yes" id="allow_request_management_link-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_request_management_link', 'yes' ) == 'yes' ) ? ' checked' : ''; ?> />
203
+ <label for="allow_request_management_link-yes" class="switch-label switch-label-off">
204
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
205
+ </label>
206
+ <input type="radio" class="switch-input" name="options[allow_request_management_link]" value="no" id="allow_request_management_link-no"
207
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'allow_request_management_link', 'yes' ) == 'no' ) ? ' checked' : ''; ?> />
208
+ <label for="allow_request_management_link-no" class="switch-label switch-label-on">
209
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
210
+ </label>
211
+ <span class="switch-selection"></span>
212
+ </div>
213
+ <div class="helpDescription subsOptDescriptions"
214
+ data-content="<?php _e( "Enable or disable the form that allows visitors to to request a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>"
215
+ data-placement="right"
216
+ aria-label="<?php _e( "Enable or disable the form that allows visitors to to request a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>">
217
+ <i class="fas fa-question-circle"></i>
218
+ </div>
219
+ </div>
220
+ </div>
221
+
222
+ <h3><?php _e( 'Messages', 'subscribe-to-comments-reloaded' ) ?></h3>
223
+
224
+ <div class="form-group row">
225
+ <label for="request_mgmt_link" class="col-sm-2 offset-sm-1 col-form-label" style="z-index: 9999;">
226
+ <?php _e( 'Request link', 'subscribe-to-comments-reloaded' ) ?>
227
+
228
+ <div class="helpDescription subsOptDescriptions"
229
+ data-content="<?php _e( 'Text shown to those who request to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>"
230
+ data-placement="right"
231
+ aria-label="<?php _e( 'Text shown to those who request to manage their subscriptions.', 'subscribe-to-comments-reloaded' ); ?>">
232
+ <i class="fas fa-question-circle"></i>
233
+ </div>
234
+
235
+ </label>
236
+ <div class="clearfix"></div>
237
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
238
+ <?php
239
+ $id_request_mgmt_link = "request_mgmt_link";
240
+ $args_notificationContent = array(
241
+ "media_buttons" => false,
242
+ "textarea_rows" => 3,
243
+ "teeny" => true,
244
+ "textarea_name" => "options[{$id_request_mgmt_link}]"
245
+ );
246
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_request_mgmt_link ), $id_request_mgmt_link, $args_notificationContent );
247
+ ?>
248
+ </div>
249
+ </div>
250
+
251
+ <div class="form-group row" style="display: none;">
252
+ <label for="request_mgmt_link_thankyou" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
253
+ <?php _e( 'Request submitted', 'subscribe-to-comments-reloaded' ) ?>
254
+
255
+ <div class="helpDescription subsOptDescriptions"
256
+ data-content="<?php _e( 'Thank you note shown after the request here above has been processed. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
257
+ data-placement="right"
258
+ aria-label="<?php _e( 'Thank you note shown after the request here above has been processed. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
259
+ <i class="fas fa-question-circle"></i>
260
+ </div>
261
+
262
+ </label>
263
+ <div class="clearfix"></div>
264
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
265
+ <?php
266
+ $id_request_mgmt_link_thankyou = "request_mgmt_link_thankyou";
267
+ $args_notificationContent = array(
268
+ "media_buttons" => false,
269
+ "textarea_rows" => 3,
270
+ "teeny" => true,
271
+ "textarea_name" => "options[{$id_request_mgmt_link_thankyou}]"
272
+ );
273
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_request_mgmt_link_thankyou ), $id_request_mgmt_link_thankyou, $args_notificationContent );
274
+ ?>
275
+ </div>
276
+ </div>
277
+
278
+ <div class="form-group row">
279
+ <label for="subscribe_without_commenting" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
280
+ <?php _e( 'Subscribe without commenting', 'subscribe-to-comments-reloaded' ) ?>
281
+
282
+ <div class="helpDescription subsOptDescriptions"
283
+ data-content="<?php _e( 'Text shown to those who want to subscribe without commenting. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
284
+ data-placement="right"
285
+ aria-label="<?php _e( 'Text shown to those who want to subscribe without commenting. Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
286
+ <i class="fas fa-question-circle"></i>
287
+ </div>
288
+
289
+ </label>
290
+ <div class="clearfix"></div>
291
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
292
+ <?php
293
+ $id_subscribe_without_commenting = "subscribe_without_commenting";
294
+ $args_notificationContent = array(
295
+ "media_buttons" => false,
296
+ "textarea_rows" => 3,
297
+ "teeny" => true,
298
+ "textarea_name" => "options[{$id_subscribe_without_commenting}]"
299
+ );
300
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscribe_without_commenting ), $id_subscribe_without_commenting, $args_notificationContent );
301
+ ?>
302
+ </div>
303
+ </div>
304
+
305
+ <div class="form-group row">
306
+ <label for="subscription_confirmed" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
307
+ <?php _e( 'Subscription processed', 'subscribe-to-comments-reloaded' ) ?>
308
+
309
+ <div class="helpDescription subsOptDescriptions"
310
+ data-content="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in disabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
311
+ data-placement="right"
312
+ aria-label="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in disabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
313
+ <i class="fas fa-question-circle"></i>
314
+ </div>
315
+
316
+ </label>
317
+ <div class="clearfix"></div>
318
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
319
+ <?php
320
+ $id_subscription_confirmed = "subscription_confirmed";
321
+ $args_notificationContent = array(
322
+ "media_buttons" => false,
323
+ "textarea_rows" => 3,
324
+ "teeny" => true,
325
+ "textarea_name" => "options[{$id_subscription_confirmed}]"
326
+ );
327
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscription_confirmed ), $id_subscription_confirmed, $args_notificationContent );
328
+ ?>
329
+ </div>
330
+ </div>
331
+
332
+ <div class="form-group row">
333
+ <label for="subscription_confirmed_dci" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
334
+ <?php _e( 'Subscription processed (DCI)', 'subscribe-to-comments-reloaded' ) ?>
335
+
336
+ <div class="helpDescription subsOptDescriptions"
337
+ data-content="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in enabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>"
338
+ data-placement="right"
339
+ aria-label="<?php _e( 'Thank you note shown after the subscription request has been processed (double check-in enabled). Allowed tags: [post_title], [post_permalink]', 'subscribe-to-comments-reloaded' ); ?>">
340
+ <i class="fas fa-question-circle"></i>
341
+ </div>
342
+
343
+ </label>
344
+ <div class="clearfix"></div>
345
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
346
+ <?php
347
+ $id_subscription_confirmed_dci = "subscription_confirmed_dci";
348
+ $args_notificationContent = array(
349
+ "media_buttons" => false,
350
+ "textarea_rows" => 3,
351
+ "teeny" => true,
352
+ "textarea_name" => "options[{$id_subscription_confirmed_dci}]"
353
+ );
354
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_subscription_confirmed_dci ), $id_subscription_confirmed_dci, $args_notificationContent );
355
+ ?>
356
+ </div>
357
+ </div>
358
+
359
+ <div class="form-group row">
360
+ <label for="author_text" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
361
+ <?php _e( 'Authors', 'subscribe-to-comments-reloaded' ) ?>
362
+
363
+ <div class="helpDescription subsOptDescriptions"
364
+ data-content="<?php _e( "Introductory text for the authors' management page.", 'subscribe-to-comments-reloaded' ); ?>"
365
+ data-placement="right"
366
+ aria-label="<?php _e( "Introductory text for the authors' management page.", 'subscribe-to-comments-reloaded' ); ?>">
367
+ <i class="fas fa-question-circle"></i>
368
+ </div>
369
+
370
+ </label>
371
+ <div class="clearfix"></div>
372
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
373
+ <?php
374
+ $id_author_text = "author_text";
375
+ $args_notificationContent = array(
376
+ "media_buttons" => false,
377
+ "textarea_rows" => 3,
378
+ "teeny" => true,
379
+ "textarea_name" => "options[{$id_author_text}]"
380
+ );
381
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_author_text ), $id_author_text, $args_notificationContent );
382
+ ?>
383
+ </div>
384
+ </div>
385
+
386
+ <div class="form-group row">
387
+ <label for="user_text" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
388
+ <?php _e( 'Users', 'subscribe-to-comments-reloaded' ) ?>
389
+
390
+ <div class="helpDescription subsOptDescriptions"
391
+ data-content="<?php _e( "Introductory text for the users' management page.", 'subscribe-to-comments-reloaded' ); ?>"
392
+ data-placement="right"
393
+ aria-label="<?php _e( "Introductory text for the users' management page.", 'subscribe-to-comments-reloaded' ); ?>">
394
+ <i class="fas fa-question-circle"></i>
395
+ </div>
396
+
397
+ </label>
398
+ <div class="clearfix"></div>
399
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
400
+ <?php
401
+ $id_user_text = "user_text";
402
+ $args_notificationContent = array(
403
+ "media_buttons" => false,
404
+ "textarea_rows" => 3,
405
+ "teeny" => true,
406
+ "textarea_name" => "options[{$id_user_text}]"
407
+ );
408
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_user_text ), $id_user_text, $args_notificationContent );
409
+ ?>
410
+ </div>
411
+ </div>
412
+
413
+ <div class="form-group row">
414
+ <div class="col-sm-9 offset-sm-1">
415
+ <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
416
+ <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
417
+ </button>
418
+ </div>
419
+ </div>
420
+
421
+ <?php wp_nonce_field( 'stcr_save_management_page_nonce', 'stcr_save_management_page_nonce' ); ?>
422
+
423
+ </form>
424
+ </div>
425
+
426
+ <div class="col-md-3">
427
+ <div class="card card-font-size">
428
+ <div class="card-body">
429
+ <p>
430
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
431
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
432
+ </p>
433
+ <p>
434
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
435
+ </p>
436
+ </div>
437
+ </div>
438
+ </div>
439
+
440
+ </div>
441
+ </div>
442
+
443
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
444
+ <?php
445
+ global $wp_subscribe_reloaded;
446
+ // Tell WP that we are going to use a resource.
447
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
448
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-management-page", "management_page.js", "includes/js/admin");
449
+ // Includes the Panel JS resource file as well as the JS text domain translations.
450
+ //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
451
+ // Enqueue the JS File
452
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
453
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-management-page" );
454
+
455
+ ?>
options/stcr_notifications.php CHANGED
@@ -1,371 +1,385 @@
1
- <?php
2
- // Notifications
3
-
4
- // Avoid direct access to this piece of code
5
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
- header( 'Location: /' );
7
- exit;
8
- }
9
-
10
- $options = array(
11
- "from_name" => "text",
12
- "from_email" => "email",
13
- "reply_to" => "email",
14
- "notification_subject" => "text",
15
- "notification_content" => "text-html",
16
- "double_check_subject" => "text",
17
- "double_check_content" => "text-html",
18
- "management_subject" => "text",
19
- "management_content" => "text-html",
20
- "management_email_content" => "text-html",
21
- "oneclick_text" => "text-html"
22
- );
23
-
24
- // Update options
25
- if ( isset( $_POST['options'] ) ) {
26
- $faulty_fields = array();
27
-
28
- foreach ( $_POST['options'] as $option => $value )
29
- {
30
- // echo $option . '<br>';
31
-
32
- if ( $option === "notification_content" )
33
- {
34
- if ( trim( $value ) === "" &&
35
- ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, "<h1>There is a new comment on [post_title].</h1><hr><p><strong>Comment link:</strong>&nbsp;<a href=\"[comment_permalink]\" data-mce-href=\"[comment_permalink]\">[comment_permalink]</a>&nbsp;<br><strong>Author:</strong>&nbsp;[comment_author]</p><p><strong>Comment:</strong><br>[comment_content]</p><div style=\"font-size: 0.8em\" data-mce-style=\"font-size: 0.8em;\"><strong>Permalink:</strong>&nbsp;<a href=\"[post_permalink]\" data-mce-href=\"[post_permalink]\">[post_permalink]</a><br><a href=\"[manager_link]\" data-mce-href=\"[manager_link]\">Manage your subscriptions</a>&nbsp;|&nbsp;<a href=\"[oneclick_link]\" data-mce-href=\"[oneclick_link]\">One click unsubscribe</a></div>", $options[$option] ) )
36
- {
37
- array_push( $faulty_fields, $option );
38
- }
39
-
40
- if ( trim( $value ) !== "" &&
41
- ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
42
- {
43
- array_push( $faulty_fields, $option );
44
- }
45
- }
46
- elseif ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
47
- {
48
- array_push( $faulty_fields, $option );
49
- }
50
- }
51
-
52
- // Display an alert in the admin interface if something went wrong
53
- echo '<div class="updated"><p>';
54
- if ( sizeof( $faulty_fields ) == 0 ) {
55
- _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
56
- } else {
57
- _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
58
- // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
59
- }
60
- echo "</p></div>";
61
- }
62
- wp_print_scripts( 'quicktags' );
63
-
64
- ?>
65
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.css" rel="stylesheet"/>
66
-
67
- <div class="container-fluid">
68
- <div class="mt-3"></div>
69
- <div class="row">
70
- <div class="col-sm-9">
71
- <form action="" method="post">
72
-
73
- <div class="form-group row">
74
- <label for="from_name" class="col-sm-3 col-form-label text-right">
75
- <?php _e( 'Sender email address', 'subscribe-to-comments-reloaded' ) ?></label>
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 esc_attr_e( "Name to use for the 'from' field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
83
- data-placement="right"
84
- aria-label="<?php esc_attr_e( "Name to use for the 'from' field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>">
85
- <i class="fas fa-question-circle"></i>
86
- </div>
87
- </div>
88
- </div>
89
-
90
- <div class="form-group row">
91
- <label for="from_email" class="col-sm-3 col-form-label text-right">
92
- <?php _e( 'Sender email address', 'subscribe-to-comments-reloaded' ) ?></label>
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 esc_attr_e( "Email address to use for the \"from\" field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
100
- data-placement="right"
101
- aria-label="<?php esc_attr_e( "Email address to use for the \"from\" field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>">
102
- <i class="fas fa-question-circle"></i>
103
- </div>
104
- </div>
105
- </div>
106
-
107
- <div class="form-group row">
108
- <label for="reply_to" class="col-sm-3 col-form-label text-right">
109
- <?php _e( 'Reply To', 'subscribe-to-comments-reloaded' ) ?></label>
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 esc_attr_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' ); ?>"
117
- data-placement="right"
118
- aria-label="<?php esc_attr_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' ); ?>">
119
- <i class="fas fa-question-circle"></i>
120
- </div>
121
- </div>
122
- </div>
123
-
124
- <h3><?php _e( 'Messages', 'subscribe-to-comments-reloaded' ) ?></h3>
125
-
126
- <div class="form-group row">
127
- <label for="notification_subject" class="col-sm-3 col-form-label text-right">
128
- <?php _e( 'Notification subject', 'subscribe-to-comments-reloaded' ) ?></label>
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 esc_attr_e( "Subject of the notification email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
136
- data-placement="right"
137
- aria-label="<?php esc_attr_e( "Subject of the notification email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>">
138
- <i class="fas fa-question-circle"></i>
139
- </div>
140
- </div>
141
- </div>
142
-
143
- <div class="form-group row">
144
- <label for="notification_content" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
145
- <?php _e( 'Notification message', 'subscribe-to-comments-reloaded' ) ?>
146
-
147
- <div class="helpDescription subsOptDescriptions"
148
- data-content="<?php esc_attr_e( "Content of the notification email. Allowed tags: [post_title], [comment_permalink], [comment_author], [comment_content], [post_permalink], [manager_link], [comment_gravatar]<p style='color: #156dc7;'><strong>Note: To get a default template clear all the content and save the options.</strong></p>", 'subscribe-to-comments-reloaded' ); ?>"
149
- data-placement="right"
150
- aria-label="<?php esc_attr_e( "Content of the notification email. Allowed tags: [post_title], [comment_permalink], [comment_author], [comment_content], [post_permalink], [manager_link], [comment_gravatar]<p style='color: #156dc7;'><strong>Note: To get a default template clear all the content and save the options.</strong></p>", 'subscribe-to-comments-reloaded' ); ?>">
151
- <i class="fas fa-question-circle"></i>
152
- </div>
153
-
154
- </label>
155
- <div class="clearfix"></div>
156
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
157
- <?php
158
- $id_notification_content = "notification_content";
159
- $args_notificationContent = array(
160
- "media_buttons" => false,
161
- "textarea_rows" => 15,
162
- "teeny" => true,
163
- "textarea_name" => "options[$id_notification_content]"
164
- // "tinymce" => array(
165
- // "theme_advance_buttons1" => "bold, italic, ul, min_size, max_size"
166
- // )
167
- );
168
-
169
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_notification_content ), $id_notification_content, $args_notificationContent );
170
- ?>
171
- </div>
172
- </div>
173
-
174
- <div class="form-group row">
175
- <label for="double_check_subject" class="col-sm-3 col-form-label text-right">
176
- <?php _e( 'Double check subject', 'subscribe-to-comments-reloaded' ) ?></label>
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 esc_attr_e( "Subject of the confirmation email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
184
- data-placement="right"
185
- aria-label="<?php esc_attr_e( "Subject of the confirmation email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>">
186
- <i class="fas fa-question-circle"></i>
187
- </div>
188
- </div>
189
- </div>
190
-
191
- <div class="form-group row">
192
- <label for="double_check_content" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
193
- <?php _e( 'Double check message', 'subscribe-to-comments-reloaded' ) ?>
194
-
195
- <div class="helpDescription subsOptDescriptions"
196
- data-content="<?php esc_attr_e( "Content of the confirmation email. Allowed tags: [post_permalink], [confirm_link], [post_title], [manager_link]", 'subscribe-to-comments-reloaded' ); ?>"
197
- data-placement="right"
198
- aria-label="<?php esc_attr_e( "Content of the confirmation email. Allowed tags: [post_permalink], [confirm_link], [post_title], [manager_link]", 'subscribe-to-comments-reloaded' ); ?>">
199
- <i class="fas fa-question-circle"></i>
200
- </div>
201
-
202
- </label>
203
- <div class="clearfix"></div>
204
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
205
- <?php
206
- $id_double_check_content = "double_check_content";
207
- $args_notificationContent = array(
208
- "media_buttons" => false,
209
- "textarea_rows" => 7,
210
- "teeny" => true,
211
- "textarea_name" => "options[{$id_double_check_content}]"
212
- );
213
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_double_check_content ), $id_double_check_content, $args_notificationContent );
214
- ?>
215
- </div>
216
- </div>
217
-
218
- <div class="form-group row">
219
- <label for="management_subject" class="col-sm-3 col-form-label text-right">
220
- <?php _e( 'Management subject', 'subscribe-to-comments-reloaded' ) ?></label>
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 esc_attr_e( "Subject of the mail sent to those who request to access their management page. Allowed tag: [blog_name]", 'subscribe-to-comments-reloaded' ); ?>"
228
- data-placement="right"
229
- aria-label="<?php esc_attr_e( "Subject of the mail sent to those who request to access their management page. Allowed tag: [blog_name]", 'subscribe-to-comments-reloaded' ); ?>">
230
- <i class="fas fa-question-circle"></i>
231
- </div>
232
- </div>
233
- </div>
234
-
235
- <?php
236
- $disallowed_tags = array();
237
- $management_page_message = $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'management_content' );
238
- if ( empty( $management_page_message ) ) { $management_page_message = ''; }
239
- if ( strpos( $management_page_message, '[manager_link]' ) ) {
240
- $disallowed_tags['manager_link'] = __( '[manager_link] tag only works for "Management Email message". It is a private link that takes to a management page and for security reasons has to be sent to the email address.', 'subscribe-to-comments-reloaded' );
241
- }
242
- ?>
243
- <div class="form-group row">
244
- <label for="management_content" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
245
- <?php _e( 'Management Page message', 'subscribe-to-comments-reloaded' ) ?>
246
-
247
- <div class="helpDescription subsOptDescriptions"
248
- data-content="<?php esc_attr_e( "Content of the management Page message. Allowed tags: [blog_name].", 'subscribe-to-comments-reloaded' ); ?>"
249
- data-placement="right"
250
- aria-label="<?php esc_attr_e( "Content of the management Page message. Allowed tags: [blog_name].", 'subscribe-to-comments-reloaded' ); ?>">
251
- <i class="fas fa-question-circle"></i>
252
- </div>
253
- </label>
254
- <div class="clearfix"></div>
255
- <div class="col-sm-9 offset-sm-1" <?php if ( empty( $disallowed_tags ) ) { echo 'style="margin-top:-30px;"'; } ?>>
256
-
257
- <?php if ( ! empty( $disallowed_tags ) ) : ?>
258
- <p class="notice notice-error" style="margin: 0;padding:8px;">
259
- <?php foreach ( $disallowed_tags as $disallowed_tag_id => $disallowed_tag_message ) : ?>
260
- <?php echo $disallowed_tag_message; ?>
261
- <?php endforeach; ?>
262
- </ul>
263
- </p>
264
- <?php endif; ?>
265
-
266
- <?php
267
- $id_management_content = "management_content";
268
- $args_notificationContent = array(
269
- "media_buttons" => false,
270
- "textarea_rows" => 5,
271
- "teeny" => true,
272
- "textarea_name" => "options[{$id_management_content}]"
273
- );
274
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_management_content ), $id_management_content, $args_notificationContent );
275
- ?>
276
- </div>
277
- </div>
278
-
279
- <div class="form-group row">
280
- <label for="management_email_content" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
281
- <?php _e( 'Management Email message', 'subscribe-to-comments-reloaded' ) ?>
282
-
283
- <div class="helpDescription subsOptDescriptions"
284
- data-content="<?php esc_attr_e( "Content of the management email message. Allowed tags: [blog_name], [manager_link].", 'subscribe-to-comments-reloaded' ); ?>"
285
- data-placement="right"
286
- aria-label="<?php esc_attr_e( "Content of the management email message. Allowed tags: [blog_name], [manager_link].", 'subscribe-to-comments-reloaded' ); ?>">
287
- <i class="fas fa-question-circle"></i>
288
- </div>
289
-
290
- </label>
291
- <div class="clearfix"></div>
292
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
293
- <?php
294
- $id_management_email_content = "management_email_content";
295
- $args_notificationContent = array(
296
- "media_buttons" => false,
297
- "textarea_rows" => 5,
298
- "teeny" => true,
299
- "textarea_name" => "options[{$id_management_email_content}]"
300
- );
301
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_management_email_content ), $id_management_email_content, $args_notificationContent );
302
- ?>
303
- </div>
304
- </div>
305
-
306
- <div class="form-group row">
307
- <label for="oneclick_text" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
308
- <?php _e( 'One Click Unsubscribe', 'subscribe-to-comments-reloaded' ) ?>
309
-
310
- <div class="helpDescription subsOptDescriptions"
311
- data-content="<?php esc_attr_e( "Content of the One Click confirmation. Allowed tags: [post_title], [blog_name].", 'subscribe-to-comments-reloaded' ); ?>"
312
- data-placement="right"
313
- aria-label="<?php esc_attr_e( "Content of the One Click confirmation. Allowed tags: [post_title], [blog_name].", 'subscribe-to-comments-reloaded' ); ?>">
314
- <i class="fas fa-question-circle"></i>
315
- </div>
316
-
317
- </label>
318
- <div class="clearfix"></div>
319
- <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
320
- <?php
321
- $id_oneclick_text = "oneclick_text";
322
- $args_notificationContent = array(
323
- "media_buttons" => false,
324
- "textarea_rows" => 5,
325
- "teeny" => true,
326
- "textarea_name" => "options[{$id_oneclick_text}]"
327
- );
328
- wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_oneclick_text ), $id_oneclick_text, $args_notificationContent );
329
- ?>
330
- </div>
331
- </div>
332
-
333
- <div class="form-group row">
334
- <div class="col-sm-9 offset-sm-1">
335
- <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
336
- <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
337
- </button>
338
- </div>
339
- </div>
340
-
341
- </form>
342
- </div>
343
-
344
- <div class="col-md-3">
345
- <div class="card card-font-size">
346
- <div class="card-body">
347
- <p>
348
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
349
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
350
- </p>
351
- <p>
352
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
353
- </p>
354
- </div>
355
- </div>
356
- </div>
357
-
358
- </div>
359
- </div>
360
-
361
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.js"></script>
362
- <?php
363
- //global $wp_subscribe_reloaded;
364
- // Tell WP that we are going to use a resource.
365
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
366
- // Includes the Panel JS resource file as well as the JS text domain translations.
367
- //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
368
- // Enqueue the JS File
369
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
370
-
371
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Notifications
3
+
4
+ // Avoid direct access to this piece of code
5
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
+ header( 'Location: /' );
7
+ exit;
8
+ }
9
+
10
+ $options = array(
11
+ "from_name" => "text",
12
+ "from_email" => "email",
13
+ "reply_to" => "email",
14
+ "notification_subject" => "text",
15
+ "notification_content" => "text-html",
16
+ "double_check_subject" => "text",
17
+ "double_check_content" => "text-html",
18
+ "management_subject" => "text",
19
+ "management_content" => "text-html",
20
+ "management_email_content" => "text-html",
21
+ "oneclick_text" => "text-html"
22
+ );
23
+
24
+ // Update options
25
+ if ( isset( $_POST['options'] ) ) {
26
+
27
+ if ( empty( $_POST['stcr_save_notifications_nonce'] ) ) {
28
+ return;
29
+ }
30
+
31
+ if ( ! wp_verify_nonce( $_POST['stcr_save_notifications_nonce'], 'stcr_save_notifications_nonce' ) ) {
32
+ return;
33
+ }
34
+
35
+ if ( ! current_user_can( 'manage_options' ) ) {
36
+ return;
37
+ }
38
+
39
+ $faulty_fields = array();
40
+
41
+ foreach ( $_POST['options'] as $option => $value )
42
+ {
43
+
44
+ if ( $option === "notification_content" )
45
+ {
46
+ if ( trim( $value ) === "" &&
47
+ ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, "<h1>There is a new comment on [post_title].</h1><hr><p><strong>Comment link:</strong>&nbsp;<a href=\"[comment_permalink]\" data-mce-href=\"[comment_permalink]\">[comment_permalink]</a>&nbsp;<br><strong>Author:</strong>&nbsp;[comment_author]</p><p><strong>Comment:</strong><br>[comment_content]</p><div style=\"font-size: 0.8em\" data-mce-style=\"font-size: 0.8em;\"><strong>Permalink:</strong>&nbsp;<a href=\"[post_permalink]\" data-mce-href=\"[post_permalink]\">[post_permalink]</a><br><a href=\"[manager_link]\" data-mce-href=\"[manager_link]\">Manage your subscriptions</a>&nbsp;|&nbsp;<a href=\"[oneclick_link]\" data-mce-href=\"[oneclick_link]\">One click unsubscribe</a></div>", $options[$option] ) )
48
+ {
49
+ array_push( $faulty_fields, $option );
50
+ }
51
+
52
+ if ( trim( $value ) !== "" &&
53
+ ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
54
+ {
55
+ array_push( $faulty_fields, $option );
56
+ }
57
+ }
58
+ elseif ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
59
+ {
60
+ array_push( $faulty_fields, $option );
61
+ }
62
+ }
63
+
64
+ // Display an alert in the admin interface if something went wrong
65
+ echo '<div class="updated"><p>';
66
+ if ( sizeof( $faulty_fields ) == 0 ) {
67
+ _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
68
+ } else {
69
+ _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
70
+ // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
71
+ }
72
+ echo "</p></div>";
73
+ }
74
+ wp_print_scripts( 'quicktags' );
75
+
76
+ ?>
77
+ <link href="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
78
+
79
+ <div class="container-fluid">
80
+ <div class="mt-3"></div>
81
+ <div class="row">
82
+ <div class="col-sm-9">
83
+ <form action="" method="post">
84
+
85
+ <div class="form-group row">
86
+ <label for="from_name" class="col-sm-3 col-form-label text-right">
87
+ <?php _e( 'Sender email address', 'subscribe-to-comments-reloaded' ) ?></label>
88
+ <div class="col-sm-7">
89
+ <input type="text" name="options[from_name]" id="from_name"
90
+ class="form-control form-control-input-8"
91
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'from_name' ) ); ?>" size="20">
92
+
93
+ <div class="helpDescription subsOptDescriptions"
94
+ data-content="<?php esc_attr_e( "Name to use for the 'from' field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
95
+ data-placement="right"
96
+ aria-label="<?php esc_attr_e( "Name to use for the 'from' field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>">
97
+ <i class="fas fa-question-circle"></i>
98
+ </div>
99
+ </div>
100
+ </div>
101
+
102
+ <div class="form-group row">
103
+ <label for="from_email" class="col-sm-3 col-form-label text-right">
104
+ <?php _e( 'Sender email address', 'subscribe-to-comments-reloaded' ) ?></label>
105
+ <div class="col-sm-7">
106
+ <input type="text" name="options[from_email]" id="from_email"
107
+ class="form-control form-control-input-8"
108
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'from_email' ) ); ?>" size="20">
109
+
110
+ <div class="helpDescription subsOptDescriptions"
111
+ data-content="<?php esc_attr_e( "Email address to use for the \"from\" field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>"
112
+ data-placement="right"
113
+ aria-label="<?php esc_attr_e( "Email address to use for the \"from\" field when sending a new notification to the user.", 'subscribe-to-comments-reloaded' ); ?>">
114
+ <i class="fas fa-question-circle"></i>
115
+ </div>
116
+ </div>
117
+ </div>
118
+
119
+ <div class="form-group row">
120
+ <label for="reply_to" class="col-sm-3 col-form-label text-right">
121
+ <?php _e( 'Reply To', 'subscribe-to-comments-reloaded' ) ?></label>
122
+ <div class="col-sm-7">
123
+ <input type="text" name="options[reply_to]" id="reply_to"
124
+ class="form-control form-control-input-8"
125
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'reply_to' ) ); ?>" size="20">
126
+
127
+ <div class="helpDescription subsOptDescriptions"
128
+ data-content="<?php esc_attr_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
+ data-placement="right"
130
+ aria-label="<?php esc_attr_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' ); ?>">
131
+ <i class="fas fa-question-circle"></i>
132
+ </div>
133
+ </div>
134
+ </div>
135
+
136
+ <h3><?php _e( 'Messages', 'subscribe-to-comments-reloaded' ) ?></h3>
137
+
138
+ <div class="form-group row">
139
+ <label for="notification_subject" class="col-sm-3 col-form-label text-right">
140
+ <?php _e( 'Notification subject', 'subscribe-to-comments-reloaded' ) ?></label>
141
+ <div class="col-sm-7">
142
+ <input type="text" name="options[notification_subject]" id="notification_subject"
143
+ class="form-control form-control-input-8"
144
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'notification_subject' ) ); ?>" size="20">
145
+
146
+ <div class="helpDescription subsOptDescriptions"
147
+ data-content="<?php esc_attr_e( "Subject of the notification email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
148
+ data-placement="right"
149
+ aria-label="<?php esc_attr_e( "Subject of the notification email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>">
150
+ <i class="fas fa-question-circle"></i>
151
+ </div>
152
+ </div>
153
+ </div>
154
+
155
+ <div class="form-group row">
156
+ <label for="notification_content" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
157
+ <?php _e( 'Notification message', 'subscribe-to-comments-reloaded' ) ?>
158
+
159
+ <div class="helpDescription subsOptDescriptions"
160
+ data-content="<?php esc_attr_e( "Content of the notification email. Allowed tags: [post_title], [comment_permalink], [comment_author], [comment_content], [post_permalink], [manager_link], [comment_gravatar]<p style='color: #156dc7;'><strong>Note: To get a default template clear all the content and save the options.</strong></p>", 'subscribe-to-comments-reloaded' ); ?>"
161
+ data-placement="right"
162
+ aria-label="<?php esc_attr_e( "Content of the notification email. Allowed tags: [post_title], [comment_permalink], [comment_author], [comment_content], [post_permalink], [manager_link], [comment_gravatar]<p style='color: #156dc7;'><strong>Note: To get a default template clear all the content and save the options.</strong></p>", 'subscribe-to-comments-reloaded' ); ?>">
163
+ <i class="fas fa-question-circle"></i>
164
+ </div>
165
+
166
+ </label>
167
+ <div class="clearfix"></div>
168
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
169
+ <?php
170
+ $id_notification_content = "notification_content";
171
+ $args_notificationContent = array(
172
+ "media_buttons" => false,
173
+ "textarea_rows" => 15,
174
+ "teeny" => true,
175
+ "textarea_name" => "options[$id_notification_content]"
176
+ // "tinymce" => array(
177
+ // "theme_advance_buttons1" => "bold, italic, ul, min_size, max_size"
178
+ // )
179
+ );
180
+
181
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_notification_content ), $id_notification_content, $args_notificationContent );
182
+ ?>
183
+ </div>
184
+ </div>
185
+
186
+ <div class="form-group row">
187
+ <label for="double_check_subject" class="col-sm-3 col-form-label text-right">
188
+ <?php _e( 'Double check subject', 'subscribe-to-comments-reloaded' ) ?></label>
189
+ <div class="col-sm-7">
190
+ <input type="text" name="options[double_check_subject]" id="double_check_subject"
191
+ class="form-control form-control-input-8"
192
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'double_check_subject' ) ); ?>" size="20">
193
+
194
+ <div class="helpDescription subsOptDescriptions"
195
+ data-content="<?php esc_attr_e( "Subject of the confirmation email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>"
196
+ data-placement="right"
197
+ aria-label="<?php esc_attr_e( "Subject of the confirmation email. Allowed tag: [post_title]", 'subscribe-to-comments-reloaded' ); ?>">
198
+ <i class="fas fa-question-circle"></i>
199
+ </div>
200
+ </div>
201
+ </div>
202
+
203
+ <div class="form-group row">
204
+ <label for="double_check_content" class="col-sm-3 offset-sm-1 col-form-label" style="z-index: 9999;">
205
+ <?php _e( 'Double check message', 'subscribe-to-comments-reloaded' ) ?>
206
+
207
+ <div class="helpDescription subsOptDescriptions"
208
+ data-content="<?php esc_attr_e( "Content of the confirmation email. Allowed tags: [post_permalink], [confirm_link], [post_title], [manager_link]", 'subscribe-to-comments-reloaded' ); ?>"
209
+ data-placement="right"
210
+ aria-label="<?php esc_attr_e( "Content of the confirmation email. Allowed tags: [post_permalink], [confirm_link], [post_title], [manager_link]", 'subscribe-to-comments-reloaded' ); ?>">
211
+ <i class="fas fa-question-circle"></i>
212
+ </div>
213
+
214
+ </label>
215
+ <div class="clearfix"></div>
216
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
217
+ <?php
218
+ $id_double_check_content = "double_check_content";
219
+ $args_notificationContent = array(
220
+ "media_buttons" => false,
221
+ "textarea_rows" => 7,
222
+ "teeny" => true,
223
+ "textarea_name" => "options[{$id_double_check_content}]"
224
+ );
225
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_double_check_content ), $id_double_check_content, $args_notificationContent );
226
+ ?>
227
+ </div>
228
+ </div>
229
+
230
+ <div class="form-group row">
231
+ <label for="management_subject" class="col-sm-3 col-form-label text-right">
232
+ <?php _e( 'Management subject', 'subscribe-to-comments-reloaded' ) ?></label>
233
+ <div class="col-sm-7">
234
+ <input type="text" name="options[management_subject]" id="management_subject"
235
+ class="form-control form-control-input-8"
236
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'management_subject' ) ); ?>" size="20">
237
+
238
+ <div class="helpDescription subsOptDescriptions"
239
+ data-content="<?php esc_attr_e( "Subject of the mail sent to those who request to access their management page. Allowed tag: [blog_name]", 'subscribe-to-comments-reloaded' ); ?>"
240
+ data-placement="right"
241
+ aria-label="<?php esc_attr_e( "Subject of the mail sent to those who request to access their management page. Allowed tag: [blog_name]", 'subscribe-to-comments-reloaded' ); ?>">
242
+ <i class="fas fa-question-circle"></i>
243
+ </div>
244
+ </div>
245
+ </div>
246
+
247
+ <?php
248
+ $disallowed_tags = array();
249
+ $management_page_message = $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'management_content' );
250
+ if ( empty( $management_page_message ) ) { $management_page_message = ''; }
251
+ if ( strpos( $management_page_message, '[manager_link]' ) ) {
252
+ $disallowed_tags['manager_link'] = __( '[manager_link] tag only works for "Management Email message". It is a private link that takes to a management page and for security reasons has to be sent to the email address.', 'subscribe-to-comments-reloaded' );
253
+ }
254
+ ?>
255
+ <div class="form-group row">
256
+ <label for="management_content" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
257
+ <?php _e( 'Management Page message', 'subscribe-to-comments-reloaded' ) ?>
258
+
259
+ <div class="helpDescription subsOptDescriptions"
260
+ data-content="<?php esc_attr_e( "Content of the management Page message. Allowed tags: [blog_name].", 'subscribe-to-comments-reloaded' ); ?>"
261
+ data-placement="right"
262
+ aria-label="<?php esc_attr_e( "Content of the management Page message. Allowed tags: [blog_name].", 'subscribe-to-comments-reloaded' ); ?>">
263
+ <i class="fas fa-question-circle"></i>
264
+ </div>
265
+ </label>
266
+ <div class="clearfix"></div>
267
+ <div class="col-sm-9 offset-sm-1" <?php if ( empty( $disallowed_tags ) ) { echo 'style="margin-top:-30px;"'; } ?>>
268
+
269
+ <?php if ( ! empty( $disallowed_tags ) ) : ?>
270
+ <p class="notice notice-error" style="margin: 0;padding:8px;">
271
+ <?php foreach ( $disallowed_tags as $disallowed_tag_id => $disallowed_tag_message ) : ?>
272
+ <?php echo $disallowed_tag_message; ?>
273
+ <?php endforeach; ?>
274
+ </ul>
275
+ </p>
276
+ <?php endif; ?>
277
+
278
+ <?php
279
+ $id_management_content = "management_content";
280
+ $args_notificationContent = array(
281
+ "media_buttons" => false,
282
+ "textarea_rows" => 5,
283
+ "teeny" => true,
284
+ "textarea_name" => "options[{$id_management_content}]"
285
+ );
286
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_management_content ), $id_management_content, $args_notificationContent );
287
+ ?>
288
+ </div>
289
+ </div>
290
+
291
+ <div class="form-group row">
292
+ <label for="management_email_content" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
293
+ <?php _e( 'Management Email message', 'subscribe-to-comments-reloaded' ) ?>
294
+
295
+ <div class="helpDescription subsOptDescriptions"
296
+ data-content="<?php esc_attr_e( "Content of the management email message. Allowed tags: [blog_name], [manager_link].", 'subscribe-to-comments-reloaded' ); ?>"
297
+ data-placement="right"
298
+ aria-label="<?php esc_attr_e( "Content of the management email message. Allowed tags: [blog_name], [manager_link].", 'subscribe-to-comments-reloaded' ); ?>">
299
+ <i class="fas fa-question-circle"></i>
300
+ </div>
301
+
302
+ </label>
303
+ <div class="clearfix"></div>
304
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
305
+ <?php
306
+ $id_management_email_content = "management_email_content";
307
+ $args_notificationContent = array(
308
+ "media_buttons" => false,
309
+ "textarea_rows" => 5,
310
+ "teeny" => true,
311
+ "textarea_name" => "options[{$id_management_email_content}]"
312
+ );
313
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_management_email_content ), $id_management_email_content, $args_notificationContent );
314
+ ?>
315
+ </div>
316
+ </div>
317
+
318
+ <div class="form-group row">
319
+ <label for="oneclick_text" class="col-sm-4 offset-sm-1 col-form-label" style="z-index: 9999;">
320
+ <?php _e( 'One Click Unsubscribe', 'subscribe-to-comments-reloaded' ) ?>
321
+
322
+ <div class="helpDescription subsOptDescriptions"
323
+ data-content="<?php esc_attr_e( "Content of the One Click confirmation. Allowed tags: [post_title], [blog_name].", 'subscribe-to-comments-reloaded' ); ?>"
324
+ data-placement="right"
325
+ aria-label="<?php esc_attr_e( "Content of the One Click confirmation. Allowed tags: [post_title], [blog_name].", 'subscribe-to-comments-reloaded' ); ?>">
326
+ <i class="fas fa-question-circle"></i>
327
+ </div>
328
+
329
+ </label>
330
+ <div class="clearfix"></div>
331
+ <div class="col-sm-9 offset-sm-1" style="margin-top: -30px;">
332
+ <?php
333
+ $id_oneclick_text = "oneclick_text";
334
+ $args_notificationContent = array(
335
+ "media_buttons" => false,
336
+ "textarea_rows" => 5,
337
+ "teeny" => true,
338
+ "textarea_name" => "options[{$id_oneclick_text}]"
339
+ );
340
+ wp_editor( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( $id_oneclick_text ), $id_oneclick_text, $args_notificationContent );
341
+ ?>
342
+ </div>
343
+ </div>
344
+
345
+ <div class="form-group row">
346
+ <div class="col-sm-9 offset-sm-1">
347
+ <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
348
+ <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
349
+ </button>
350
+ </div>
351
+ </div>
352
+
353
+ <?php wp_nonce_field( 'stcr_save_notifications_nonce', 'stcr_save_notifications_nonce' ); ?>
354
+
355
+ </form>
356
+ </div>
357
+
358
+ <div class="col-md-3">
359
+ <div class="card card-font-size">
360
+ <div class="card-body">
361
+ <p>
362
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
363
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
364
+ </p>
365
+ <p>
366
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
367
+ </p>
368
+ </div>
369
+ </div>
370
+ </div>
371
+
372
+ </div>
373
+ </div>
374
+
375
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
376
+ <?php
377
+ //global $wp_subscribe_reloaded;
378
+ // Tell WP that we are going to use a resource.
379
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
380
+ // Includes the Panel JS resource file as well as the JS text domain translations.
381
+ //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
382
+ // Enqueue the JS File
383
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
384
+
385
+ ?>
options/stcr_options.php CHANGED
@@ -1,727 +1,827 @@
1
- <?php
2
- // Options
3
-
4
- // Avoid direct access to this piece of code
5
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
- header( 'Location: /' );
7
- exit;
8
- }
9
-
10
- $options = array(
11
- 'show_subscription_box' => 'yesno',
12
- 'safely_uninstall' => 'yesno',
13
- 'purge_days' => 'integer',
14
- 'date_format' => 'text',
15
- 'stcr_position' => 'yesno',
16
- 'enable_double_check' => 'yesno',
17
- 'notify_authors' => 'yesno',
18
- 'enable_html_emails' => 'yesno',
19
- 'process_trackbacks' => 'yesno',
20
- 'enable_admin_messages' => 'yesno',
21
- 'admin_subscribe' => 'yesno',
22
- 'admin_bcc' => 'yesno',
23
- 'enable_font_awesome' => 'yesno',
24
- 'delete_options_subscriptions' => 'yesno',
25
- 'only_for_posts' => 'yesno',
26
- 'only_for_logged_in' => 'yesno',
27
- 'use_cookies' => 'yesno',
28
- 'use_challenge_question' => 'yesno',
29
- 'challenge_question' => 'text',
30
- 'challenge_answer' => 'text',
31
- 'use_captcha' => 'yesno',
32
- 'captcha_site_key' => 'text',
33
- 'captcha_secret_key' => 'text',
34
- );
35
-
36
- if ( array_key_exists( "generate_key", $_POST ) ) {
37
- $unique_key = $wp_subscribe_reloaded->stcr->utils->generate_key();
38
- $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( 'unique_key', $unique_key, 'text' );
39
-
40
- echo '<div class="updated"><p>';
41
- echo __( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
42
- echo "</p></div>";
43
-
44
- } elseif ( array_key_exists( "reset_all_options", $_POST ) ) {
45
- $delete_subscriptions_selection = $_POST['options']['delete_options_subscriptions'];
46
- $deletion_result = $wp_subscribe_reloaded->stcr->utils->delete_all_settings( $delete_subscriptions_selection );
47
-
48
- if( $deletion_result )
49
- {
50
- // Restore settings
51
- $wp_subscribe_reloaded->stcr->utils->create_options();
52
- }
53
- } elseif( isset( $_POST['options'] ) ) { // Update options
54
-
55
- $faulty_fields = array();
56
-
57
- foreach ( $_POST['options'] as $option => $value )
58
- {
59
- // echo $option . '<br>';
60
-
61
- if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
62
- {
63
- array_push( $faulty_fields, $option );
64
- }
65
- }
66
-
67
- // Display an alert in the admin interface if something went wrong
68
- echo '<div class="updated"><p>';
69
- if ( sizeof( $faulty_fields ) == 0 ) {
70
- _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
71
- } else {
72
- _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
73
- // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
74
- }
75
- echo "</p></div>";
76
- }
77
- wp_print_scripts( 'quicktags' );
78
-
79
- ?>
80
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.css" rel="stylesheet"/>
81
-
82
- <div class="container-fluid">
83
- <div class="mt-3"></div>
84
- <div class="row">
85
- <div class="col-sm-9">
86
- <form action="" method="post">
87
-
88
- <div class="form-group row" style="margin-bottom: 0;">
89
- <label for="show_subscription_box" class="col-sm-3 col-form-label text-right"><?php _e( 'Show StCR checkbox / dropdown', 'subscribe-to-comments-reloaded' ) ?></label>
90
- <div class="col-sm-7">
91
- <div class="switch">
92
- <input type="radio" class="switch-input" name="options[show_subscription_box]"
93
- value="yes" id="show_subscription_box-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'yes' ) ? ' checked' : ''; ?> />
94
- <label for="show_subscription_box-yes" class="switch-label switch-label-off">
95
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
96
- </label>
97
- <input type="radio" class="switch-input" name="options[show_subscription_box]" value="no" id="show_subscription_box-no"
98
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'no' ) ? ' checked' : ''; ?> />
99
- <label for="show_subscription_box-no" class="switch-label switch-label-on">
100
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
101
- </label>
102
- <span class="switch-selection"></span>
103
- </div>
104
- <div class="helpDescription subsOptDescriptions"
105
- data-content="<?php _e( "This option will disable the StCR checkbox or dropdown in your comment form. You should leave it to Yes always.", 'subscribe-to-comments-reloaded' ); ?>"
106
- data-placement="right"
107
- aria-label="<?php _e( "This option will disable the StCR checkbox or dropdown in your comment form. You should leave it to Yes always.", 'subscribe-to-comments-reloaded' ); ?>">
108
- <i class="fas fa-question-circle"></i>
109
- </div>
110
- </div>
111
- </div>
112
-
113
- <div class="form-group row">
114
- <label for="safely_uninstall" class="col-sm-3 col-form-label text-right"><?php _e( 'Safely Uninstall', 'subscribe-to-comments-reloaded' ) ?></label>
115
- <div class="col-sm-7">
116
- <div class="switch">
117
- <input type="radio" class="switch-input" name="options[safely_uninstall]"
118
- value="yes" id="safely_uninstall-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'safely_uninstall' ) == 'yes' ) ? ' checked' : ''; ?> />
119
- <label for="safely_uninstall-yes" class="switch-label switch-label-off">
120
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
121
- </label>
122
- <input type="radio" class="switch-input" name="options[safely_uninstall]" value="no" id="safely_uninstall-no"
123
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'safely_uninstall' ) == 'no' ) ? ' checked' : ''; ?> />
124
- <label for="safely_uninstall-no" class="switch-label switch-label-on">
125
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
126
- </label>
127
- <span class="switch-selection"></span>
128
- </div>
129
- <div class="helpDescription subsOptDescriptions"
130
- data-content="<?php _e( "This option will allow you to delete the plugin with WordPress without loosing your subscribers. Any database table and plugin options are wipeout.", 'subscribe-to-comments-reloaded' ); ?>"
131
- data-placement="right"
132
- aria-label="<?php _e( "This option will allow you to delete the plugin with WordPress without loosing your subscribers. Any database table and plugin options are wipeout.", 'subscribe-to-comments-reloaded' ); ?>">
133
- <i class="fas fa-question-circle"></i>
134
- </div>
135
- </div>
136
- </div>
137
-
138
- <div class="form-group row">
139
- <label for="purge_days" class="col-sm-3 col-form-label text-right">
140
- <?php _e( 'Autopurge requests', 'subscribe-to-comments-reloaded' ) ?></label>
141
- <div class="col-sm-7">
142
- <input type="number" name="options[purge_days]" id="purge_days"
143
- class="form-control form-control-input-3"
144
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'purge_days' ) ); ?>" size="20">
145
-
146
- <div class="helpDescription subsOptDescriptions"
147
- data-content="<?php _e( "Delete pending subscriptions (not confirmed) after X days. Zero disables this feature.", 'subscribe-to-comments-reloaded' ); ?>"
148
- data-placement="right"
149
- aria-label="<?php _e( "Delete pending subscriptions (not confirmed) after X days. Zero disables this feature.", 'subscribe-to-comments-reloaded' ); ?>">
150
- <i class="fas fa-question-circle"></i>
151
- </div>
152
- </div>
153
- </div>
154
-
155
- <div class="form-group row">
156
- <label for="date_format" class="col-sm-3 col-form-label text-right">
157
- <?php _e( 'Date Format', 'subscribe-to-comments-reloaded' ) ?></label>
158
- <div class="col-sm-7">
159
- <input type="text" name="options[date_format]" id="date_format"
160
- class="form-control form-control-input-3"
161
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'date_format' ) ); ?>" size="20">
162
-
163
- <div class="helpDescription subsOptDescriptions"
164
- 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' ); ?>"
165
- data-placement="right"
166
- aria-label="<?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' ); ?>">
167
- <i class="fas fa-question-circle"></i>
168
- </div>
169
- </div>
170
- </div>
171
-
172
- <div class="form-group row">
173
- <label for="stcr_position" class="col-sm-3 col-form-label text-right"><?php _e( 'StCR Position', 'subscribe-to-comments-reloaded' ) ?></label>
174
- <div class="col-sm-7">
175
- <div class="switch">
176
- <input type="radio" class="switch-input" name="options[stcr_position]"
177
- value="yes" id="stcr_position-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'stcr_position' ) == 'yes' ) ? ' checked' : ''; ?> />
178
- <label for="stcr_position-yes" class="switch-label switch-label-off">
179
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
180
- </label>
181
- <input type="radio" class="switch-input" name="options[stcr_position]" value="no" id="stcr_position-no"
182
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'stcr_position' ) == 'no' ) ? ' checked' : ''; ?> />
183
- <label for="stcr_position-no" class="switch-label switch-label-on">
184
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
185
- </label>
186
- <span class="switch-selection"></span>
187
- </div>
188
- <div class="helpDescription subsOptDescriptions"
189
- data-content="<?php _e( "If this option is enable the subscription box will be above the submit button in your comment form. Use this when your theme is outdated and using the incorrect WordPress Hooks and the checkbox is not displayed.", 'subscribe-to-comments-reloaded' ); ?>"
190
- data-placement="right"
191
- aria-label="<?php _e( "If this option is enable the subscription box will be above the submit button in your comment form. Use this when your theme is outdated and using the incorrect WordPress Hooks and the checkbox is not displayed.", 'subscribe-to-comments-reloaded' ); ?>">
192
- <i class="fas fa-question-circle"></i>
193
- </div>
194
- </div>
195
- </div>
196
-
197
- <div class="form-group row">
198
- <label for="enable_double_check" class="col-sm-3 col-form-label text-right">
199
- <?php _e( 'Enable double check', 'subscribe-to-comments-reloaded' ) ?>
200
- </label>
201
- <div class="col-sm-7">
202
- <div class="switch">
203
- <input type="radio" class="switch-input" name="options[enable_double_check]"
204
- value="yes" id="enable_double_check-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_double_check' ) == 'yes' ) ? ' checked' : ''; ?> />
205
- <label for="enable_double_check-yes" class="switch-label switch-label-off">
206
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
207
- </label>
208
- <input type="radio" class="switch-input" name="options[enable_double_check]" value="no" id="enable_double_check-no"
209
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_double_check' ) == 'no' ) ? ' checked' : ''; ?> />
210
- <label for="enable_double_check-no" class="switch-label switch-label-on">
211
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
212
- </label>
213
- <span class="switch-selection"></span>
214
- </div>
215
- <div class="helpDescription subsOptDescriptions"
216
- data-content="<?php _e( "Send a notification email to confirm the subscription (to avoid addresses misuse).", 'subscribe-to-comments-reloaded' ); ?>"
217
- data-placement="right"
218
- aria-label="<?php _e( "Send a notification email to confirm the subscription (to avoid addresses misuse).", 'subscribe-to-comments-reloaded' ); ?>">
219
- <i class="fas fa-question-circle"></i>
220
- </div>
221
- </div>
222
- </div>
223
-
224
- <div class="form-group row">
225
- <label for="notify_authors" class="col-sm-3 col-form-label text-right">
226
- <?php _e( 'Subscribe authors', 'subscribe-to-comments-reloaded' ) ?>
227
- </label>
228
- <div class="col-sm-7">
229
- <div class="switch">
230
- <input type="radio" class="switch-input" name="options[notify_authors]"
231
- value="yes" id="notify_authors-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'notify_authors' ) == 'yes' ) ? ' checked' : ''; ?> />
232
- <label for="notify_authors-yes" class="switch-label switch-label-off">
233
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
234
- </label>
235
- <input type="radio" class="switch-input" name="options[notify_authors]" value="no" id="notify_authors-no"
236
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'notify_authors' ) == 'no' ) ? ' checked' : ''; ?> />
237
- <label for="notify_authors-no" class="switch-label switch-label-on">
238
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
239
- </label>
240
- <span class="switch-selection"></span>
241
- </div>
242
- <div class="helpDescription subsOptDescriptions"
243
- data-content="<?php _e( "Automatically subscribe authors to their own articles (not retroactive).", 'subscribe-to-comments-reloaded' ); ?>"
244
- data-placement="right"
245
- aria-label="<?php _e( "Automatically subscribe authors to their own articles (not retroactive).", 'subscribe-to-comments-reloaded' ); ?>">
246
- <i class="fas fa-question-circle"></i>
247
- </div>
248
- </div>
249
- </div>
250
-
251
- <div class="form-group row">
252
- <label for="enable_html_emails" class="col-sm-3 col-form-label text-right">
253
- <?php _e( 'Enable HTML emails', 'subscribe-to-comments-reloaded' ) ?>
254
- </label>
255
- <div class="col-sm-7">
256
- <div class="switch">
257
- <input type="radio" class="switch-input" name="options[enable_html_emails]"
258
- value="yes" id="enable_html_emails-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_html_emails' ) == 'yes' ) ? ' checked' : ''; ?> />
259
- <label for="enable_html_emails-yes" class="switch-label switch-label-off">
260
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
261
- </label>
262
- <input type="radio" class="switch-input" name="options[enable_html_emails]" value="no" id="enable_html_emails-no"
263
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_html_emails' ) == 'no' ) ? ' checked' : ''; ?> />
264
- <label for="enable_html_emails-no" class="switch-label switch-label-on">
265
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
266
- </label>
267
- <span class="switch-selection"></span>
268
- </div>
269
- <div class="helpDescription subsOptDescriptions"
270
- data-content="<?php _e( "If enabled, will send email messages with content-type = text/html instead of text/plain", 'subscribe-to-comments-reloaded' ); ?>"
271
- data-placement="right"
272
- aria-label="<?php _e( "If enabled, will send email messages with content-type = text/html instead of text/plain", 'subscribe-to-comments-reloaded' ); ?>">
273
- <i class="fas fa-question-circle"></i>
274
- </div>
275
- </div>
276
- </div>
277
-
278
- <div class="form-group row">
279
- <label for="process_trackbacks" class="col-sm-3 col-form-label text-right">
280
- <?php _e( 'Process trackbacks', 'subscribe-to-comments-reloaded' ) ?>
281
- </label>
282
- <div class="col-sm-7">
283
- <div class="switch">
284
- <input type="radio" class="switch-input" name="options[process_trackbacks]"
285
- value="yes" id="process_trackbacks-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'process_trackbacks' ) == 'yes' ) ? ' checked' : ''; ?> />
286
- <label for="process_trackbacks-yes" class="switch-label switch-label-off">
287
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
288
- </label>
289
- <input type="radio" class="switch-input" name="options[process_trackbacks]" value="no" id="process_trackbacks-no"
290
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'process_trackbacks' ) == 'no' ) ? ' checked' : ''; ?> />
291
- <label for="process_trackbacks-no" class="switch-label switch-label-on">
292
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
293
- </label>
294
- <span class="switch-selection"></span>
295
- </div>
296
- <div class="helpDescription subsOptDescriptions"
297
- data-content="<?php _e( "Notify users when a new trackback or pingback is added to the discussion.", 'subscribe-to-comments-reloaded' ); ?>"
298
- data-placement="right"
299
- aria-label="<?php _e( "Notify users when a new trackback or pingback is added to the discussion.", 'subscribe-to-comments-reloaded' ); ?>">
300
- <i class="fas fa-question-circle"></i>
301
- </div>
302
- </div>
303
- </div>
304
-
305
- <div class="form-group row">
306
- <label for="enable_admin_messages" class="col-sm-3 col-form-label text-right">
307
- <?php _e( 'Track all subscriptions', 'subscribe-to-comments-reloaded' ) ?>
308
- </label>
309
- <div class="col-sm-7">
310
- <div class="switch">
311
- <input type="radio" class="switch-input" name="options[enable_admin_messages]"
312
- value="yes" id="enable_admin_messages-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_admin_messages' ) == 'yes' ) ? ' checked' : ''; ?> />
313
- <label for="enable_admin_messages-yes" class="switch-label switch-label-off">
314
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
315
- </label>
316
- <input type="radio" class="switch-input" name="options[enable_admin_messages]" value="no" id="enable_admin_messages-no"
317
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_admin_messages' ) == 'no' ) ? ' checked' : ''; ?> />
318
- <label for="enable_admin_messages-no" class="switch-label switch-label-on">
319
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
320
- </label>
321
- <span class="switch-selection"></span>
322
- </div>
323
- <div class="helpDescription subsOptDescriptions"
324
- data-content="<?php _e( "Notify the administrator when users subscribe without commenting.", 'subscribe-to-comments-reloaded' ); ?>"
325
- data-placement="right"
326
- aria-label="<?php _e( "Notify the administrator when users subscribe without commenting.", 'subscribe-to-comments-reloaded' ); ?>">
327
- <i class="fas fa-question-circle"></i>
328
- </div>
329
- </div>
330
- </div>
331
-
332
- <div class="form-group row">
333
- <label for="admin_subscribe" class="col-sm-3 col-form-label text-right">
334
- <?php _e( 'Let Admin Subscribe', 'subscribe-to-comments-reloaded' ) ?>
335
- </label>
336
- <div class="col-sm-7">
337
- <div class="switch">
338
- <input type="radio" class="switch-input" name="options[admin_subscribe]"
339
- value="yes" id="admin_subscribe-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_subscribe' ) == 'yes' ) ? ' checked' : ''; ?> />
340
- <label for="admin_subscribe-yes" class="switch-label switch-label-off">
341
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
342
- </label>
343
- <input type="radio" class="switch-input" name="options[admin_subscribe]" value="no" id="admin_subscribe-no"
344
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_subscribe' ) == 'no' ) ? ' checked' : ''; ?> />
345
- <label for="admin_subscribe-no" class="switch-label switch-label-on">
346
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
347
- </label>
348
- <span class="switch-selection"></span>
349
- </div>
350
- <div class="helpDescription subsOptDescriptions"
351
- data-content="<?php _e( "Let the administrator subscribe to comments when logged in.", 'subscribe-to-comments-reloaded' ); ?>"
352
- data-placement="right"
353
- aria-label="<?php _e( "Let the administrator subscribe to comments when logged in.", 'subscribe-to-comments-reloaded' ); ?>">
354
- <i class="fas fa-question-circle"></i>
355
- </div>
356
- </div>
357
- </div>
358
-
359
- <div class="form-group row" style="margin-bottom: 0;">
360
- <label for="admin_bcc" class="col-sm-3 col-form-label text-right">
361
- <?php _e( 'BCC admin on Notifications', 'subscribe-to-comments-reloaded' ) ?>
362
- </label>
363
- <div class="col-sm-7">
364
- <div class="switch">
365
- <input type="radio" class="switch-input" name="options[admin_bcc]"
366
- value="yes" id="admin_bcc-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_bcc' ) == 'yes' ) ? ' checked' : ''; ?> />
367
- <label for="admin_bcc-yes" class="switch-label switch-label-off">
368
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
369
- </label>
370
- <input type="radio" class="switch-input" name="options[admin_bcc]" value="no" id="admin_bcc-no"
371
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_bcc' ) == 'no' ) ? ' checked' : ''; ?> />
372
- <label for="admin_bcc-no" class="switch-label switch-label-on">
373
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
374
- </label>
375
- <span class="switch-selection"></span>
376
- </div>
377
- <div class="helpDescription subsOptDescriptions"
378
- data-content="<?php _e( "Send a copy of all Notifications to the administrator.", 'subscribe-to-comments-reloaded' ); ?>"
379
- data-placement="right"
380
- aria-label="<?php _e( "Send a copy of all Notifications to the administrator.", 'subscribe-to-comments-reloaded' ); ?>">
381
- <i class="fas fa-question-circle"></i>
382
- </div>
383
- </div>
384
- </div>
385
-
386
- <div class="form-group row">
387
- <label for="enable_font_awesome" class="col-sm-3 col-form-label text-right">
388
- <?php _e( 'Enable Font Awesome', 'subscribe-to-comments-reloaded' ) ?>
389
- </label>
390
- <div class="col-sm-7">
391
- <div class="switch">
392
- <input type="radio" class="switch-input" name="options[enable_font_awesome]"
393
- value="yes" id="enable_font_awesome-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_font_awesome' ) == 'yes' ) ? ' checked' : ''; ?> />
394
- <label for="enable_font_awesome-yes" class="switch-label switch-label-off">
395
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
396
- </label>
397
- <input type="radio" class="switch-input" name="options[enable_font_awesome]" value="no" id="enable_font_awesome-no"
398
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_font_awesome' ) == 'no' ) ? ' checked' : ''; ?> />
399
- <label for="enable_font_awesome-no" class="switch-label switch-label-on">
400
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
401
- </label>
402
- <span class="switch-selection"></span>
403
- </div>
404
- <div class="helpDescription subsOptDescriptions"
405
- data-content="<?php _e( "Let you control the inclusion of the Font Awesome into your site. Disable if your theme already add this into your site.", 'subscribe-to-comments-reloaded' ); ?>"
406
- data-placement="right"
407
- aria-label="<?php _e( "Let you control the inclusion of the Font Awesome into your site. Disable if your theme already add this into your site.", 'subscribe-to-comments-reloaded' ); ?>">
408
- <i class="fas fa-question-circle"></i>
409
- </div>
410
- </div>
411
- </div>
412
-
413
- <div class="form-group row">
414
- <label for="only_for_posts" class="col-sm-3 col-form-label text-right">
415
- <?php _e( 'Enable only on blog posts', 'subscribe-to-comments-reloaded' ) ?>
416
- </label>
417
- <div class="col-sm-7">
418
- <div class="switch">
419
- <input type="radio" class="switch-input" name="options[only_for_posts]"
420
- value="yes" id="only_for_posts-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'only_for_posts', 'no' ) == 'yes' ) ? ' checked' : ''; ?> />
421
- <label for="only_for_posts-yes" class="switch-label switch-label-off">
422
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
423
- </label>
424
- <input type="radio" class="switch-input" name="options[only_for_posts]" value="no" id="only_for_posts-no"
425
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'only_for_posts', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
426
- <label for="only_for_posts-no" class="switch-label switch-label-on">
427
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
428
- </label>
429
- <span class="switch-selection"></span>
430
- </div>
431
- <div class="helpDescription subsOptDescriptions"
432
- data-content="<?php _e( "Enable only for blog posts (pages and custom post types will be excluded).", 'subscribe-to-comments-reloaded' ); ?>"
433
- data-placement="right"
434
- aria-label="<?php _e( "Enable only for blog posts (pages and custom post types will be excluded).", 'subscribe-to-comments-reloaded' ); ?>">
435
- <i class="fas fa-question-circle"></i>
436
- </div>
437
- </div>
438
- </div>
439
-
440
- <div class="form-group row">
441
- <label for="only_for_logged_in" class="col-sm-3 col-form-label text-right">
442
- <?php _e( 'Enable only for logged in users', 'subscribe-to-comments-reloaded' ) ?>
443
- </label>
444
- <div class="col-sm-7">
445
- <div class="switch">
446
- <input type="radio" class="switch-input" name="options[only_for_logged_in]"
447
- value="yes" id="only_for_logged_in-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'only_for_logged_in', 'no' ) == 'yes' ) ? ' checked' : ''; ?> />
448
- <label for="only_for_logged_in-yes" class="switch-label switch-label-off">
449
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
450
- </label>
451
- <input type="radio" class="switch-input" name="options[only_for_logged_in]" value="no" id="only_for_logged_in-no"
452
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'only_for_logged_in', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
453
- <label for="only_for_logged_in-no" class="switch-label switch-label-on">
454
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
455
- </label>
456
- <span class="switch-selection"></span>
457
- </div>
458
- <div class="helpDescription subsOptDescriptions"
459
- data-content="<?php _e( "Enable subscription only for logged in users.", 'subscribe-to-comments-reloaded' ); ?>"
460
- data-placement="right"
461
- aria-label="<?php _e( "Enable subscription only for logged in users.", 'subscribe-to-comments-reloaded' ); ?>">
462
- <i class="fas fa-question-circle"></i>
463
- </div>
464
- </div>
465
- </div>
466
-
467
- <div class="form-group row">
468
- <label for="use_cookies" class="col-sm-3 col-form-label text-right">
469
- <?php _e( 'Enable cookies', 'subscribe-to-comments-reloaded' ) ?>
470
- </label>
471
- <div class="col-sm-7">
472
- <div class="switch">
473
- <input type="radio" class="switch-input" name="options[use_cookies]"
474
- value="yes" id="use_cookies-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_cookies', 'yes' ) == 'yes' ) ? ' checked' : ''; ?> />
475
- <label for="use_cookies-yes" class="switch-label switch-label-off">
476
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
477
- </label>
478
- <input type="radio" class="switch-input" name="options[use_cookies]" value="no" id="use_cookies-no"
479
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_cookies', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
480
- <label for="use_cookies-no" class="switch-label switch-label-on">
481
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
482
- </label>
483
- <span class="switch-selection"></span>
484
- </div>
485
- <div class="helpDescription subsOptDescriptions"
486
- data-content="<?php _e( "Remembers the email address to prepopulate StCR forms.", 'subscribe-to-comments-reloaded' ); ?>"
487
- data-placement="right"
488
- aria-label="<?php _e( "Remembers the email address to prepopulate StCR forms.", 'subscribe-to-comments-reloaded' ); ?>">
489
- <i class="fas fa-question-circle"></i>
490
- </div>
491
- </div>
492
- </div>
493
-
494
- <div class="form-group row">
495
- <label for="use_challenge_question" class="col-sm-3 col-form-label text-right">
496
- <?php _e( 'Enable challenge question', 'subscribe-to-comments-reloaded' ) ?>
497
- </label>
498
- <div class="col-sm-7">
499
- <div class="switch">
500
- <input type="radio" class="switch-input" name="options[use_challenge_question]"
501
- value="yes" id="use_challenge_question-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_challenge_question', 'no' ) == 'yes' ) ? ' checked' : ''; ?> />
502
- <label for="use_challenge_question-yes" class="switch-label switch-label-off">
503
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
504
- </label>
505
- <input type="radio" class="switch-input" name="options[use_challenge_question]" value="no" id="use_challenge_question-no"
506
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_challenge_question', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
507
- <label for="use_challenge_question-no" class="switch-label switch-label-on">
508
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
509
- </label>
510
- <span class="switch-selection"></span>
511
- </div>
512
- <div class="helpDescription subsOptDescriptions"
513
- data-content="<?php _e( "Enables input for challenge question/answer on the subscription form.", 'subscribe-to-comments-reloaded' ); ?>"
514
- data-placement="right"
515
- aria-label="<?php _e( "Enables input for challenge question/answer on the subscription form.", 'subscribe-to-comments-reloaded' ); ?>">
516
- <i class="fas fa-question-circle"></i>
517
- </div>
518
- </div>
519
- </div>
520
-
521
- <div class="form-group row">
522
- <label for="challenge_question" class="col-sm-3 col-form-label text-right">
523
- <?php _e( 'Challenge question', 'subscribe-to-comments-reloaded' ) ?></label>
524
- <div class="col-sm-7">
525
- <input type="text" name="options[challenge_question]" id="challenge_question"
526
- class="form-control form-control-input-3"
527
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'challenge_question', 'What is 1 + 2?' ) ); ?>">
528
-
529
- <div class="helpDescription subsOptDescriptions"
530
- data-content="<?php _e( "The question shown to visitor when subscribing without commenting or when requesting a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>"
531
- data-placement="right"
532
- aria-label="<?php _e( "The question shown to visitor when subscribing without commenting or when requesting a subscription management link", 'subscribe-to-comments-reloaded' ); ?>">
533
- <i class="fas fa-question-circle"></i>
534
- </div>
535
- </div>
536
- </div>
537
-
538
- <div class="form-group row">
539
- <label for="challenge_answer" class="col-sm-3 col-form-label text-right">
540
- <?php _e( 'Challenge answer', 'subscribe-to-comments-reloaded' ) ?></label>
541
- <div class="col-sm-7">
542
- <input type="text" name="options[challenge_answer]" id="challenge_answer"
543
- class="form-control form-control-input-3"
544
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'challenge_answer', 3 ) ); ?>">
545
-
546
- <div class="helpDescription subsOptDescriptions"
547
- data-content="<?php _e( "The visitor needs to provide this answer to proceed with subscription.", 'subscribe-to-comments-reloaded' ); ?>"
548
- data-placement="right"
549
- aria-label="<?php _e( "The visitor needs to provide this answer to proceed with subscription.", 'subscribe-to-comments-reloaded' ); ?>">
550
- <i class="fas fa-question-circle"></i>
551
- </div>
552
- </div>
553
- </div>
554
-
555
- <?php /* captcha options start */ ?>
556
-
557
- <div class="form-group row">
558
- <label for="use_captcha" class="col-sm-3 col-form-label text-right">
559
- <?php _e( 'Enable Google reCAPTCHA', 'subscribe-to-comments-reloaded' ) ?>
560
- </label>
561
- <div class="col-sm-7">
562
- <div class="switch">
563
- <input type="radio" class="switch-input" name="options[use_captcha]"
564
- value="yes" id="use_captcha-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_captcha', 'no' ) == 'yes' ) ? ' checked' : ''; ?> />
565
- <label for="use_captcha-yes" class="switch-label switch-label-off">
566
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
567
- </label>
568
- <input type="radio" class="switch-input" name="options[use_captcha]" value="no" id="use_captcha-no"
569
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_captcha', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
570
- <label for="use_captcha-no" class="switch-label switch-label-on">
571
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
572
- </label>
573
- <span class="switch-selection"></span>
574
- </div>
575
- <div class="helpDescription subsOptDescriptions"
576
- data-content="<?php _e( "Shown to visitor when subscribing without commenting or when requesting a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>"
577
- data-placement="right"
578
- aria-label="<?php _e( "Shown to visitor when subscribing without commenting or when requesting a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>">
579
- <i class="fas fa-question-circle"></i>
580
- </div>
581
- </div>
582
- </div>
583
-
584
- <div class="form-group row">
585
- <label for="captcha_site_key" class="col-sm-3 col-form-label text-right">
586
- <?php _e( 'reCAPTCHA site key', 'subscribe-to-comments-reloaded' ) ?></label>
587
- <div class="col-sm-7">
588
- <input type="text" name="options[captcha_site_key]" id="captcha_site_key"
589
- class="form-control form-control-input-3"
590
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'captcha_site_key', '' ) ); ?>">
591
-
592
- <div class="helpDescription subsOptDescriptions"
593
- data-content="<?php _e( "The site key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>"
594
- data-placement="right"
595
- aria-label="<?php _e( "The site key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>">
596
- <i class="fas fa-question-circle"></i>
597
- </div>
598
- </div>
599
- </div>
600
-
601
- <div class="form-group row">
602
- <label for="captcha_secret_key" class="col-sm-3 col-form-label text-right">
603
- <?php _e( 'reCAPTCHA secret key', 'subscribe-to-comments-reloaded' ) ?></label>
604
- <div class="col-sm-7">
605
- <input type="text" name="options[captcha_secret_key]" id="captcha_secret_key"
606
- class="form-control form-control-input-3"
607
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'captcha_secret_key', '' ) ); ?>">
608
-
609
- <div class="helpDescription subsOptDescriptions"
610
- data-content="<?php _e( "The secret key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>"
611
- data-placement="right"
612
- aria-label="<?php _e( "The secret key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>">
613
- <i class="fas fa-question-circle"></i>
614
- </div>
615
- </div>
616
- </div>
617
-
618
- <?php /* captcha options end */ ?>
619
-
620
- <div class="form-group row">
621
- <label for="unique_key" class="col-sm-3 col-form-label text-right">
622
- <?php _e( 'StCR Unique Key', 'subscribe-to-comments-reloaded' ) ?></label>
623
- <div class="col-sm-7">
624
-
625
- <?php
626
- if ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'unique_key' ) == "" ) {
627
-
628
- echo "<div class=\"alert alert-danger\" role=\"alert\" style='font-size: 0.85rem;'>";
629
- echo '<strong>' . __( "This Unique Key is not set, please click the following button to ", 'subscribe-to-comments-reloaded' ) . '</strong>';
630
- echo "<input type='submit' value='" . __( 'Generate' ) ."' class='btn btn-secondary subscribe-form-button' name='generate_key' >";
631
- echo "</div>";
632
- }
633
- else {
634
- ?>
635
- <input type="text" name="options[unique_key]" id="unique_key"
636
- class="form-control form-control-input-6"
637
- value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'unique_key' ) ); ?>" size="20">
638
-
639
- <input type="submit" value="<?php esc_attr_e( 'Generate New Key' ) ?>" class="btn btn-secondary subscribe-form-button" name="generate_key" >
640
- <?php } ?>
641
-
642
-
643
- <div class="helpDescription subsOptDescriptions"
644
- data-content="<?php _e( "This Unique Key will be use to send the notification to your subscribers with more security.", 'subscribe-to-comments-reloaded' ); ?>"
645
- data-placement="right"
646
- aria-label="<?php _e( "This Unique Key will be use to send the notification to your subscribers with more security.", 'subscribe-to-comments-reloaded' ); ?>">
647
- <i class="fas fa-question-circle"></i>
648
- </div>
649
- </div>
650
- </div>
651
-
652
- <div class="form-group row">
653
- <label for="" class="col-sm-3 col-form-label text-right">
654
- <?php _e( 'Reset All Options', 'subscribe-to-comments-reloaded' ) ?>
655
- </label>
656
- <div class="col-sm-7">
657
-
658
- <div class="alert alert-danger" role="alert">
659
- <strong>Danger!</strong>
660
- <p>
661
- <?php _e( 'This will reset all the options and messages of the plugin. Please proceed with caution.', 'subscribe-to-comments-reloaded' ); ?>
662
- </p>
663
-
664
- <p>
665
- <?php _e( '<strong>Yes</strong> = Delete Options including subscriptions.', 'subscribe-to-comments-reloaded' ) ?><br/>
666
- <?php _e( '<strong>No</strong> = Only delete the StCR Options.', 'subscribe-to-comments-reloaded' ) ?>
667
- </p>
668
-
669
-
670
- <div class="switch">
671
- <input type="radio" class="switch-input" name="options[delete_options_subscriptions]"
672
- value="yes" id="delete_options_subscriptions-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'delete_options_subscriptions' ) == 'yes' ) ? ' checked' : ''; ?> />
673
- <label for="delete_options_subscriptions-yes" class="switch-label switch-label-off">
674
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
675
- </label>
676
- <input type="radio" class="switch-input" name="options[delete_options_subscriptions]" value="no" id="delete_options_subscriptions-no"
677
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'delete_options_subscriptions' ) == 'no' ) ? ' checked' : ''; ?> />
678
- <label for="delete_options_subscriptions-no" class="switch-label switch-label-on">
679
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
680
- </label>
681
- <span class="switch-selection"></span>
682
- </div>
683
-
684
- <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" >
685
-
686
- </div>
687
- </div>
688
- </div>
689
-
690
- <div class="form-group row">
691
- <div class="col-sm-9 offset-sm-1">
692
- <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
693
- <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
694
- </button>
695
- </div>
696
- </div>
697
-
698
- </form>
699
- </div>
700
-
701
- <div class="col-md-3">
702
- <div class="card card-font-size">
703
- <div class="card-body">
704
- <p>
705
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
706
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
707
- </p>
708
- <p>
709
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
710
- </p>
711
- </div>
712
- </div>
713
- </div>
714
-
715
- </div>
716
- </div>
717
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.js"></script>
718
- <?php
719
- //global $wp_subscribe_reloaded;
720
- // Tell WP that we are going to use a resource.
721
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
722
- // Includes the Panel JS resource file as well as the JS text domain translations.
723
- //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
724
- // Enqueue the JS File
725
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
726
-
727
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Options
3
+
4
+ // Avoid direct access to this piece of code
5
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
+ header( 'Location: /' );
7
+ exit;
8
+ }
9
+
10
+ $options = array(
11
+ 'show_subscription_box' => 'yesno',
12
+ 'safely_uninstall' => 'yesno',
13
+ 'purge_days' => 'integer',
14
+ 'date_format' => 'text',
15
+ 'stcr_position' => 'yesno',
16
+ 'enable_double_check' => 'yesno',
17
+ 'notify_authors' => 'yesno',
18
+ 'enable_html_emails' => 'yesno',
19
+ 'process_trackbacks' => 'yesno',
20
+ 'enable_admin_messages' => 'yesno',
21
+ 'admin_subscribe' => 'yesno',
22
+ 'admin_bcc' => 'yesno',
23
+ 'enable_font_awesome' => 'yesno',
24
+ 'delete_options_subscriptions' => 'yesno',
25
+ 'only_for_logged_in' => 'yesno',
26
+ 'use_cookies' => 'yesno',
27
+ 'use_challenge_question' => 'yesno',
28
+ 'challenge_question' => 'text',
29
+ 'challenge_answer' => 'text',
30
+ 'use_captcha' => 'yesno',
31
+ 'captcha_site_key' => 'text',
32
+ 'captcha_secret_key' => 'text',
33
+ 'unique_key' => '',
34
+ 'recaptcha_version' => 'select',
35
+ 'blacklisted_emails' => 'textarea',
36
+ 'post_type_supports' => 'multicheck',
37
+ );
38
+
39
+ if ( array_key_exists( "generate_key", $_POST ) ) {
40
+
41
+ if ( empty( $_POST['stcr_save_options_nonce'] ) ) {
42
+ return;
43
+ }
44
+
45
+ if ( ! wp_verify_nonce( $_POST['stcr_save_options_nonce'], 'stcr_save_options_nonce' ) ) {
46
+ return;
47
+ }
48
+
49
+ if ( ! current_user_can( 'manage_options' ) ) {
50
+ return;
51
+ }
52
+
53
+ $unique_key = $wp_subscribe_reloaded->stcr->utils->generate_key();
54
+ $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( 'unique_key', $unique_key, 'text' );
55
+
56
+ echo '<div class="updated"><p>';
57
+ echo __( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
58
+ echo "</p></div>";
59
+
60
+ } elseif ( array_key_exists( "reset_all_options", $_POST ) ) {
61
+
62
+ if ( empty( $_POST['stcr_save_options_nonce'] ) ) {
63
+ return;
64
+ }
65
+
66
+ if ( ! wp_verify_nonce( $_POST['stcr_save_options_nonce'], 'stcr_save_options_nonce' ) ) {
67
+ return;
68
+ }
69
+
70
+ if ( ! current_user_can( 'manage_options' ) ) {
71
+ return;
72
+ }
73
+
74
+ $delete_subscriptions_selection = $_POST['options']['delete_options_subscriptions'];
75
+ $deletion_result = $wp_subscribe_reloaded->stcr->utils->delete_all_settings( $delete_subscriptions_selection );
76
+
77
+ if( $deletion_result )
78
+ {
79
+ // Restore settings
80
+ $wp_subscribe_reloaded->stcr->utils->create_options();
81
+ }
82
+ } elseif( isset( $_POST['options'] ) ) { // Update options
83
+
84
+ if ( empty( $_POST['stcr_save_options_nonce'] ) ) {
85
+ return;
86
+ }
87
+
88
+ if ( ! wp_verify_nonce( $_POST['stcr_save_options_nonce'], 'stcr_save_options_nonce' ) ) {
89
+ return;
90
+ }
91
+
92
+ if ( ! current_user_can( 'manage_options' ) ) {
93
+ return;
94
+ }
95
+
96
+ $faulty_fields = array();
97
+
98
+ foreach ( $_POST['options'] as $option => $value )
99
+ {
100
+ // echo $option . '<br>';
101
+
102
+ if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
103
+ {
104
+ array_push( $faulty_fields, $option );
105
+ }
106
+ }
107
+
108
+ // Display an alert in the admin interface if something went wrong
109
+ echo '<div class="updated"><p>';
110
+ if ( sizeof( $faulty_fields ) == 0 ) {
111
+ _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
112
+ } else {
113
+ _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
114
+ // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
115
+ }
116
+ echo "</p></div>";
117
+ }
118
+ wp_print_scripts( 'quicktags' );
119
+
120
+ ?>
121
+ <link href="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
122
+
123
+ <div class="container-fluid">
124
+ <div class="mt-3"></div>
125
+ <div class="row">
126
+ <div class="col-sm-9">
127
+ <form action="" method="post">
128
+
129
+ <div class="form-group row" style="margin-bottom: 0;">
130
+ <label for="show_subscription_box" class="col-sm-3 col-form-label text-right"><?php _e( 'Show StCR checkbox / dropdown', 'subscribe-to-comments-reloaded' ) ?></label>
131
+ <div class="col-sm-7">
132
+ <div class="switch">
133
+ <input type="radio" class="switch-input" name="options[show_subscription_box]"
134
+ value="yes" id="show_subscription_box-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'yes' ) ? ' checked' : ''; ?> />
135
+ <label for="show_subscription_box-yes" class="switch-label switch-label-off">
136
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
137
+ </label>
138
+ <input type="radio" class="switch-input" name="options[show_subscription_box]" value="no" id="show_subscription_box-no"
139
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'show_subscription_box' ) == 'no' ) ? ' checked' : ''; ?> />
140
+ <label for="show_subscription_box-no" class="switch-label switch-label-on">
141
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
142
+ </label>
143
+ <span class="switch-selection"></span>
144
+ </div>
145
+ <div class="helpDescription subsOptDescriptions"
146
+ data-content="<?php _e( "This option will disable the StCR checkbox or dropdown in your comment form. You should leave it to Yes always.", 'subscribe-to-comments-reloaded' ); ?>"
147
+ data-placement="right"
148
+ aria-label="<?php _e( "This option will disable the StCR checkbox or dropdown in your comment form. You should leave it to Yes always.", 'subscribe-to-comments-reloaded' ); ?>">
149
+ <i class="fas fa-question-circle"></i>
150
+ </div>
151
+ </div>
152
+ </div>
153
+
154
+ <div class="form-group row">
155
+ <label for="safely_uninstall" class="col-sm-3 col-form-label text-right"><?php _e( 'Safely Uninstall', 'subscribe-to-comments-reloaded' ) ?></label>
156
+ <div class="col-sm-7">
157
+ <div class="switch">
158
+ <input type="radio" class="switch-input" name="options[safely_uninstall]"
159
+ value="yes" id="safely_uninstall-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'safely_uninstall' ) == 'yes' ) ? ' checked' : ''; ?> />
160
+ <label for="safely_uninstall-yes" class="switch-label switch-label-off">
161
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
162
+ </label>
163
+ <input type="radio" class="switch-input" name="options[safely_uninstall]" value="no" id="safely_uninstall-no"
164
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'safely_uninstall' ) == 'no' ) ? ' checked' : ''; ?> />
165
+ <label for="safely_uninstall-no" class="switch-label switch-label-on">
166
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
167
+ </label>
168
+ <span class="switch-selection"></span>
169
+ </div>
170
+ <div class="helpDescription subsOptDescriptions"
171
+ data-content="<?php _e( "This option will allow you to delete the plugin with WordPress without loosing your subscribers. Any database table and plugin options are wipeout.", 'subscribe-to-comments-reloaded' ); ?>"
172
+ data-placement="right"
173
+ aria-label="<?php _e( "This option will allow you to delete the plugin with WordPress without loosing your subscribers. Any database table and plugin options are wipeout.", 'subscribe-to-comments-reloaded' ); ?>">
174
+ <i class="fas fa-question-circle"></i>
175
+ </div>
176
+ </div>
177
+ </div>
178
+
179
+ <div class="form-group row">
180
+ <label for="purge_days" class="col-sm-3 col-form-label text-right">
181
+ <?php _e( 'Autopurge requests', 'subscribe-to-comments-reloaded' ) ?></label>
182
+ <div class="col-sm-7">
183
+ <input type="number" name="options[purge_days]" id="purge_days"
184
+ class="form-control form-control-input-3"
185
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'purge_days' ) ); ?>" size="20">
186
+
187
+ <div class="helpDescription subsOptDescriptions"
188
+ data-content="<?php _e( "Delete pending subscriptions (not confirmed) after X days. Zero disables this feature.", 'subscribe-to-comments-reloaded' ); ?>"
189
+ data-placement="right"
190
+ aria-label="<?php _e( "Delete pending subscriptions (not confirmed) after X days. Zero disables this feature.", 'subscribe-to-comments-reloaded' ); ?>">
191
+ <i class="fas fa-question-circle"></i>
192
+ </div>
193
+ </div>
194
+ </div>
195
+
196
+ <div class="form-group row">
197
+ <label for="date_format" class="col-sm-3 col-form-label text-right">
198
+ <?php _e( 'Date Format', 'subscribe-to-comments-reloaded' ) ?></label>
199
+ <div class="col-sm-7">
200
+ <input type="text" name="options[date_format]" id="date_format"
201
+ class="form-control form-control-input-3"
202
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'date_format' ) ); ?>" size="20">
203
+
204
+ <div class="helpDescription subsOptDescriptions"
205
+ 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' ); ?>"
206
+ data-placement="right"
207
+ aria-label="<?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' ); ?>">
208
+ <i class="fas fa-question-circle"></i>
209
+ </div>
210
+ </div>
211
+ </div>
212
+
213
+ <div class="form-group row">
214
+ <label for="stcr_position" class="col-sm-3 col-form-label text-right"><?php _e( 'StCR Position', 'subscribe-to-comments-reloaded' ) ?></label>
215
+ <div class="col-sm-7">
216
+ <div class="switch">
217
+ <input type="radio" class="switch-input" name="options[stcr_position]"
218
+ value="yes" id="stcr_position-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'stcr_position' ) == 'yes' ) ? ' checked' : ''; ?> />
219
+ <label for="stcr_position-yes" class="switch-label switch-label-off">
220
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
221
+ </label>
222
+ <input type="radio" class="switch-input" name="options[stcr_position]" value="no" id="stcr_position-no"
223
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'stcr_position' ) == 'no' ) ? ' checked' : ''; ?> />
224
+ <label for="stcr_position-no" class="switch-label switch-label-on">
225
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
226
+ </label>
227
+ <span class="switch-selection"></span>
228
+ </div>
229
+ <div class="helpDescription subsOptDescriptions"
230
+ data-content="<?php _e( "If this option is enable the subscription box will be above the submit button in your comment form. Use this when your theme is outdated and using the incorrect WordPress Hooks and the checkbox is not displayed.", 'subscribe-to-comments-reloaded' ); ?>"
231
+ data-placement="right"
232
+ aria-label="<?php _e( "If this option is enable the subscription box will be above the submit button in your comment form. Use this when your theme is outdated and using the incorrect WordPress Hooks and the checkbox is not displayed.", 'subscribe-to-comments-reloaded' ); ?>">
233
+ <i class="fas fa-question-circle"></i>
234
+ </div>
235
+ </div>
236
+ </div>
237
+
238
+ <div class="form-group row">
239
+ <label for="enable_double_check" class="col-sm-3 col-form-label text-right">
240
+ <?php _e( 'Enable double check', 'subscribe-to-comments-reloaded' ) ?>
241
+ </label>
242
+ <div class="col-sm-7">
243
+ <div class="switch">
244
+ <input type="radio" class="switch-input" name="options[enable_double_check]"
245
+ value="yes" id="enable_double_check-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_double_check' ) == 'yes' ) ? ' checked' : ''; ?> />
246
+ <label for="enable_double_check-yes" class="switch-label switch-label-off">
247
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
248
+ </label>
249
+ <input type="radio" class="switch-input" name="options[enable_double_check]" value="no" id="enable_double_check-no"
250
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_double_check' ) == 'no' ) ? ' checked' : ''; ?> />
251
+ <label for="enable_double_check-no" class="switch-label switch-label-on">
252
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
253
+ </label>
254
+ <span class="switch-selection"></span>
255
+ </div>
256
+ <div class="helpDescription subsOptDescriptions"
257
+ data-content="<?php _e( "Send a notification email to confirm the subscription (to avoid addresses misuse).", 'subscribe-to-comments-reloaded' ); ?>"
258
+ data-placement="right"
259
+ aria-label="<?php _e( "Send a notification email to confirm the subscription (to avoid addresses misuse).", 'subscribe-to-comments-reloaded' ); ?>">
260
+ <i class="fas fa-question-circle"></i>
261
+ </div>
262
+ </div>
263
+ </div>
264
+
265
+ <div class="form-group row">
266
+ <label for="notify_authors" class="col-sm-3 col-form-label text-right">
267
+ <?php _e( 'Subscribe authors', 'subscribe-to-comments-reloaded' ) ?>
268
+ </label>
269
+ <div class="col-sm-7">
270
+ <div class="switch">
271
+ <input type="radio" class="switch-input" name="options[notify_authors]"
272
+ value="yes" id="notify_authors-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'notify_authors' ) == 'yes' ) ? ' checked' : ''; ?> />
273
+ <label for="notify_authors-yes" class="switch-label switch-label-off">
274
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
275
+ </label>
276
+ <input type="radio" class="switch-input" name="options[notify_authors]" value="no" id="notify_authors-no"
277
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'notify_authors' ) == 'no' ) ? ' checked' : ''; ?> />
278
+ <label for="notify_authors-no" class="switch-label switch-label-on">
279
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
280
+ </label>
281
+ <span class="switch-selection"></span>
282
+ </div>
283
+ <div class="helpDescription subsOptDescriptions"
284
+ data-content="<?php _e( "Automatically subscribe authors to their own articles (not retroactive).", 'subscribe-to-comments-reloaded' ); ?>"
285
+ data-placement="right"
286
+ aria-label="<?php _e( "Automatically subscribe authors to their own articles (not retroactive).", 'subscribe-to-comments-reloaded' ); ?>">
287
+ <i class="fas fa-question-circle"></i>
288
+ </div>
289
+ </div>
290
+ </div>
291
+
292
+ <div class="form-group row">
293
+ <label for="enable_html_emails" class="col-sm-3 col-form-label text-right">
294
+ <?php _e( 'Enable HTML emails', 'subscribe-to-comments-reloaded' ) ?>
295
+ </label>
296
+ <div class="col-sm-7">
297
+ <div class="switch">
298
+ <input type="radio" class="switch-input" name="options[enable_html_emails]"
299
+ value="yes" id="enable_html_emails-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_html_emails' ) == 'yes' ) ? ' checked' : ''; ?> />
300
+ <label for="enable_html_emails-yes" class="switch-label switch-label-off">
301
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
302
+ </label>
303
+ <input type="radio" class="switch-input" name="options[enable_html_emails]" value="no" id="enable_html_emails-no"
304
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_html_emails' ) == 'no' ) ? ' checked' : ''; ?> />
305
+ <label for="enable_html_emails-no" class="switch-label switch-label-on">
306
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
307
+ </label>
308
+ <span class="switch-selection"></span>
309
+ </div>
310
+ <div class="helpDescription subsOptDescriptions"
311
+ data-content="<?php _e( "If enabled, will send email messages with content-type = text/html instead of text/plain", 'subscribe-to-comments-reloaded' ); ?>"
312
+ data-placement="right"
313
+ aria-label="<?php _e( "If enabled, will send email messages with content-type = text/html instead of text/plain", 'subscribe-to-comments-reloaded' ); ?>">
314
+ <i class="fas fa-question-circle"></i>
315
+ </div>
316
+ </div>
317
+ </div>
318
+
319
+ <div class="form-group row">
320
+ <label for="process_trackbacks" class="col-sm-3 col-form-label text-right">
321
+ <?php _e( 'Process trackbacks', 'subscribe-to-comments-reloaded' ) ?>
322
+ </label>
323
+ <div class="col-sm-7">
324
+ <div class="switch">
325
+ <input type="radio" class="switch-input" name="options[process_trackbacks]"
326
+ value="yes" id="process_trackbacks-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'process_trackbacks' ) == 'yes' ) ? ' checked' : ''; ?> />
327
+ <label for="process_trackbacks-yes" class="switch-label switch-label-off">
328
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
329
+ </label>
330
+ <input type="radio" class="switch-input" name="options[process_trackbacks]" value="no" id="process_trackbacks-no"
331
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'process_trackbacks' ) == 'no' ) ? ' checked' : ''; ?> />
332
+ <label for="process_trackbacks-no" class="switch-label switch-label-on">
333
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
334
+ </label>
335
+ <span class="switch-selection"></span>
336
+ </div>
337
+ <div class="helpDescription subsOptDescriptions"
338
+ data-content="<?php _e( "Notify users when a new trackback or pingback is added to the discussion.", 'subscribe-to-comments-reloaded' ); ?>"
339
+ data-placement="right"
340
+ aria-label="<?php _e( "Notify users when a new trackback or pingback is added to the discussion.", 'subscribe-to-comments-reloaded' ); ?>">
341
+ <i class="fas fa-question-circle"></i>
342
+ </div>
343
+ </div>
344
+ </div>
345
+
346
+ <div class="form-group row">
347
+ <label for="enable_admin_messages" class="col-sm-3 col-form-label text-right">
348
+ <?php _e( 'Track all subscriptions', 'subscribe-to-comments-reloaded' ) ?>
349
+ </label>
350
+ <div class="col-sm-7">
351
+ <div class="switch">
352
+ <input type="radio" class="switch-input" name="options[enable_admin_messages]"
353
+ value="yes" id="enable_admin_messages-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_admin_messages' ) == 'yes' ) ? ' checked' : ''; ?> />
354
+ <label for="enable_admin_messages-yes" class="switch-label switch-label-off">
355
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
356
+ </label>
357
+ <input type="radio" class="switch-input" name="options[enable_admin_messages]" value="no" id="enable_admin_messages-no"
358
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_admin_messages' ) == 'no' ) ? ' checked' : ''; ?> />
359
+ <label for="enable_admin_messages-no" class="switch-label switch-label-on">
360
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
361
+ </label>
362
+ <span class="switch-selection"></span>
363
+ </div>
364
+ <div class="helpDescription subsOptDescriptions"
365
+ data-content="<?php _e( "Notify the administrator when users subscribe without commenting.", 'subscribe-to-comments-reloaded' ); ?>"
366
+ data-placement="right"
367
+ aria-label="<?php _e( "Notify the administrator when users subscribe without commenting.", 'subscribe-to-comments-reloaded' ); ?>">
368
+ <i class="fas fa-question-circle"></i>
369
+ </div>
370
+ </div>
371
+ </div>
372
+
373
+ <div class="form-group row">
374
+ <label for="admin_subscribe" class="col-sm-3 col-form-label text-right">
375
+ <?php _e( 'Let Admin Subscribe', 'subscribe-to-comments-reloaded' ) ?>
376
+ </label>
377
+ <div class="col-sm-7">
378
+ <div class="switch">
379
+ <input type="radio" class="switch-input" name="options[admin_subscribe]"
380
+ value="yes" id="admin_subscribe-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_subscribe' ) == 'yes' ) ? ' checked' : ''; ?> />
381
+ <label for="admin_subscribe-yes" class="switch-label switch-label-off">
382
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
383
+ </label>
384
+ <input type="radio" class="switch-input" name="options[admin_subscribe]" value="no" id="admin_subscribe-no"
385
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_subscribe' ) == 'no' ) ? ' checked' : ''; ?> />
386
+ <label for="admin_subscribe-no" class="switch-label switch-label-on">
387
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
388
+ </label>
389
+ <span class="switch-selection"></span>
390
+ </div>
391
+ <div class="helpDescription subsOptDescriptions"
392
+ data-content="<?php _e( "Let the administrator subscribe to comments when logged in.", 'subscribe-to-comments-reloaded' ); ?>"
393
+ data-placement="right"
394
+ aria-label="<?php _e( "Let the administrator subscribe to comments when logged in.", 'subscribe-to-comments-reloaded' ); ?>">
395
+ <i class="fas fa-question-circle"></i>
396
+ </div>
397
+ </div>
398
+ </div>
399
+
400
+ <div class="form-group row" style="margin-bottom: 0;">
401
+ <label for="admin_bcc" class="col-sm-3 col-form-label text-right">
402
+ <?php _e( 'BCC admin on Notifications', 'subscribe-to-comments-reloaded' ) ?>
403
+ </label>
404
+ <div class="col-sm-7">
405
+ <div class="switch">
406
+ <input type="radio" class="switch-input" name="options[admin_bcc]"
407
+ value="yes" id="admin_bcc-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_bcc' ) == 'yes' ) ? ' checked' : ''; ?> />
408
+ <label for="admin_bcc-yes" class="switch-label switch-label-off">
409
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
410
+ </label>
411
+ <input type="radio" class="switch-input" name="options[admin_bcc]" value="no" id="admin_bcc-no"
412
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'admin_bcc' ) == 'no' ) ? ' checked' : ''; ?> />
413
+ <label for="admin_bcc-no" class="switch-label switch-label-on">
414
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
415
+ </label>
416
+ <span class="switch-selection"></span>
417
+ </div>
418
+ <div class="helpDescription subsOptDescriptions"
419
+ data-content="<?php _e( "Send a copy of all Notifications to the administrator.", 'subscribe-to-comments-reloaded' ); ?>"
420
+ data-placement="right"
421
+ aria-label="<?php _e( "Send a copy of all Notifications to the administrator.", 'subscribe-to-comments-reloaded' ); ?>">
422
+ <i class="fas fa-question-circle"></i>
423
+ </div>
424
+ </div>
425
+ </div>
426
+
427
+ <div class="form-group row">
428
+ <label for="enable_font_awesome" class="col-sm-3 col-form-label text-right">
429
+ <?php _e( 'Enable Font Awesome', 'subscribe-to-comments-reloaded' ) ?>
430
+ </label>
431
+ <div class="col-sm-7">
432
+ <div class="switch">
433
+ <input type="radio" class="switch-input" name="options[enable_font_awesome]"
434
+ value="yes" id="enable_font_awesome-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_font_awesome' ) == 'yes' ) ? ' checked' : ''; ?> />
435
+ <label for="enable_font_awesome-yes" class="switch-label switch-label-off">
436
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
437
+ </label>
438
+ <input type="radio" class="switch-input" name="options[enable_font_awesome]" value="no" id="enable_font_awesome-no"
439
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_font_awesome' ) == 'no' ) ? ' checked' : ''; ?> />
440
+ <label for="enable_font_awesome-no" class="switch-label switch-label-on">
441
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
442
+ </label>
443
+ <span class="switch-selection"></span>
444
+ </div>
445
+ <div class="helpDescription subsOptDescriptions"
446
+ data-content="<?php _e( "Let you control the inclusion of the Font Awesome into your site. Disable if your theme already add this into your site.", 'subscribe-to-comments-reloaded' ); ?>"
447
+ data-placement="right"
448
+ aria-label="<?php _e( "Let you control the inclusion of the Font Awesome into your site. Disable if your theme already add this into your site.", 'subscribe-to-comments-reloaded' ); ?>">
449
+ <i class="fas fa-question-circle"></i>
450
+ </div>
451
+ </div>
452
+ </div>
453
+
454
+ <div class="form-group row">
455
+ <label for="post_type_supports" class="col-sm-3 col-form-label text-right">
456
+ <?php esc_html_e( 'Enable on post types', 'subscribe-to-comments-reloaded' ) ?>
457
+ </label>
458
+ <div class="col-sm-7">
459
+ <div class="multicheck">
460
+ <?php
461
+ $args = array(
462
+ '_builtin' => false,
463
+ 'public' => true,
464
+ );
465
+ $post_types = get_post_types( $args );
466
+ $default_post_types = array(
467
+ 'post',
468
+ 'page',
469
+ );
470
+ $post_types = array_merge( $default_post_types, $post_types );
471
+ $post_types_enabled = $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'post_type_supports', '' );
472
+
473
+ foreach ( $post_types as $post_type ) {
474
+ $checked = '';
475
+ foreach ( (array) $post_types_enabled as $post_type_enabled ) {
476
+ if ( $post_type_enabled === $post_type ) {
477
+ $checked = checked( $post_type_enabled, $post_type, false );
478
+ }
479
+ }
480
+ ?>
481
+ <div class="form-check pl-0">
482
+ <input type="checkbox" id="<?php echo esc_attr( $post_type ); ?>" name="options[post_type_supports][]" value="<?php echo esc_attr( $post_type ) ?>" <?php echo $checked; ?> />
483
+
484
+ <label for="<?php echo esc_attr( $post_type ); ?>">
485
+ <?php echo esc_html( get_post_type_object( $post_type )->label ); ?>
486
+ </label>
487
+ </div>
488
+ <?php } ?>
489
+
490
+ <input type="hidden" value="stcr_none" name="options[post_type_supports][]" />
491
+ </div>
492
+
493
+ <div class="helpDescription subsOptDescriptions ml-0"
494
+ data-content="<?php _e( "Enable for these specific post types only.", 'subscribe-to-comments-reloaded' ); ?>"
495
+ data-placement="right"
496
+ aria-label="<?php _e( "Enable for these specific post types only.", 'subscribe-to-comments-reloaded' ); ?>">
497
+ <i class="fas fa-question-circle"></i>
498
+ </div>
499
+ </div>
500
+ </div>
501
+
502
+ <div class="form-group row">
503
+ <label for="only_for_logged_in" class="col-sm-3 col-form-label text-right">
504
+ <?php _e( 'Enable only for logged in users', 'subscribe-to-comments-reloaded' ) ?>
505
+ </label>
506
+ <div class="col-sm-7">
507
+ <div class="switch">
508
+ <input type="radio" class="switch-input" name="options[only_for_logged_in]"
509
+ value="yes" id="only_for_logged_in-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'only_for_logged_in', 'no' ) == 'yes' ) ? ' checked' : ''; ?> />
510
+ <label for="only_for_logged_in-yes" class="switch-label switch-label-off">
511
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
512
+ </label>
513
+ <input type="radio" class="switch-input" name="options[only_for_logged_in]" value="no" id="only_for_logged_in-no"
514
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'only_for_logged_in', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
515
+ <label for="only_for_logged_in-no" class="switch-label switch-label-on">
516
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
517
+ </label>
518
+ <span class="switch-selection"></span>
519
+ </div>
520
+ <div class="helpDescription subsOptDescriptions"
521
+ data-content="<?php _e( "Enable subscription only for logged in users.", 'subscribe-to-comments-reloaded' ); ?>"
522
+ data-placement="right"
523
+ aria-label="<?php _e( "Enable subscription only for logged in users.", 'subscribe-to-comments-reloaded' ); ?>">
524
+ <i class="fas fa-question-circle"></i>
525
+ </div>
526
+ </div>
527
+ </div>
528
+
529
+ <div class="form-group row">
530
+ <label for="use_cookies" class="col-sm-3 col-form-label text-right">
531
+ <?php _e( 'Enable cookies', 'subscribe-to-comments-reloaded' ) ?>
532
+ </label>
533
+ <div class="col-sm-7">
534
+ <div class="switch">
535
+ <input type="radio" class="switch-input" name="options[use_cookies]"
536
+ value="yes" id="use_cookies-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_cookies', 'yes' ) == 'yes' ) ? ' checked' : ''; ?> />
537
+ <label for="use_cookies-yes" class="switch-label switch-label-off">
538
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
539
+ </label>
540
+ <input type="radio" class="switch-input" name="options[use_cookies]" value="no" id="use_cookies-no"
541
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_cookies', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
542
+ <label for="use_cookies-no" class="switch-label switch-label-on">
543
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
544
+ </label>
545
+ <span class="switch-selection"></span>
546
+ </div>
547
+ <div class="helpDescription subsOptDescriptions"
548
+ data-content="<?php _e( "Remembers the email address to prepopulate StCR forms.", 'subscribe-to-comments-reloaded' ); ?>"
549
+ data-placement="right"
550
+ aria-label="<?php _e( "Remembers the email address to prepopulate StCR forms.", 'subscribe-to-comments-reloaded' ); ?>">
551
+ <i class="fas fa-question-circle"></i>
552
+ </div>
553
+ </div>
554
+ </div>
555
+
556
+ <div class="form-group row">
557
+ <label for="use_challenge_question" class="col-sm-3 col-form-label text-right">
558
+ <?php _e( 'Enable challenge question', 'subscribe-to-comments-reloaded' ) ?>
559
+ </label>
560
+ <div class="col-sm-7">
561
+ <div class="switch">
562
+ <input type="radio" class="switch-input" name="options[use_challenge_question]"
563
+ value="yes" id="use_challenge_question-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_challenge_question', 'no' ) == 'yes' ) ? ' checked' : ''; ?> />
564
+ <label for="use_challenge_question-yes" class="switch-label switch-label-off">
565
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
566
+ </label>
567
+ <input type="radio" class="switch-input" name="options[use_challenge_question]" value="no" id="use_challenge_question-no"
568
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_challenge_question', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
569
+ <label for="use_challenge_question-no" class="switch-label switch-label-on">
570
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
571
+ </label>
572
+ <span class="switch-selection"></span>
573
+ </div>
574
+ <div class="helpDescription subsOptDescriptions"
575
+ data-content="<?php _e( "Enables input for challenge question/answer on the subscription form.", 'subscribe-to-comments-reloaded' ); ?>"
576
+ data-placement="right"
577
+ aria-label="<?php _e( "Enables input for challenge question/answer on the subscription form.", 'subscribe-to-comments-reloaded' ); ?>">
578
+ <i class="fas fa-question-circle"></i>
579
+ </div>
580
+ </div>
581
+ </div>
582
+
583
+ <div class="form-group row">
584
+ <label for="challenge_question" class="col-sm-3 col-form-label text-right">
585
+ <?php _e( 'Challenge question', 'subscribe-to-comments-reloaded' ) ?></label>
586
+ <div class="col-sm-7">
587
+ <input type="text" name="options[challenge_question]" id="challenge_question"
588
+ class="form-control form-control-input-3"
589
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'challenge_question', 'What is 1 + 2?' ) ); ?>">
590
+
591
+ <div class="helpDescription subsOptDescriptions"
592
+ data-content="<?php _e( "The question shown to visitor when subscribing without commenting or when requesting a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>"
593
+ data-placement="right"
594
+ aria-label="<?php _e( "The question shown to visitor when subscribing without commenting or when requesting a subscription management link", 'subscribe-to-comments-reloaded' ); ?>">
595
+ <i class="fas fa-question-circle"></i>
596
+ </div>
597
+ </div>
598
+ </div>
599
+
600
+ <div class="form-group row">
601
+ <label for="challenge_answer" class="col-sm-3 col-form-label text-right">
602
+ <?php _e( 'Challenge answer', 'subscribe-to-comments-reloaded' ) ?></label>
603
+ <div class="col-sm-7">
604
+ <input type="text" name="options[challenge_answer]" id="challenge_answer"
605
+ class="form-control form-control-input-3"
606
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'challenge_answer', 3 ) ); ?>">
607
+
608
+ <div class="helpDescription subsOptDescriptions"
609
+ data-content="<?php _e( "The visitor needs to provide this answer to proceed with subscription.", 'subscribe-to-comments-reloaded' ); ?>"
610
+ data-placement="right"
611
+ aria-label="<?php _e( "The visitor needs to provide this answer to proceed with subscription.", 'subscribe-to-comments-reloaded' ); ?>">
612
+ <i class="fas fa-question-circle"></i>
613
+ </div>
614
+ </div>
615
+ </div>
616
+
617
+ <?php /* captcha options start */ ?>
618
+
619
+ <div class="form-group row">
620
+ <label for="use_captcha" class="col-sm-3 col-form-label text-right">
621
+ <?php _e( 'Enable Google reCAPTCHA', 'subscribe-to-comments-reloaded' ) ?>
622
+ </label>
623
+ <div class="col-sm-7">
624
+ <div class="switch">
625
+ <input type="radio" class="switch-input" name="options[use_captcha]"
626
+ value="yes" id="use_captcha-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_captcha', 'no' ) == 'yes' ) ? ' checked' : ''; ?> />
627
+ <label for="use_captcha-yes" class="switch-label switch-label-off">
628
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
629
+ </label>
630
+ <input type="radio" class="switch-input" name="options[use_captcha]" value="no" id="use_captcha-no"
631
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'use_captcha', 'no' ) == 'no' ) ? ' checked' : ''; ?> />
632
+ <label for="use_captcha-no" class="switch-label switch-label-on">
633
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
634
+ </label>
635
+ <span class="switch-selection"></span>
636
+ </div>
637
+ <div class="helpDescription subsOptDescriptions"
638
+ data-content="<?php _e( "Shown to visitor when subscribing without commenting or when requesting a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>"
639
+ data-placement="right"
640
+ aria-label="<?php _e( "Shown to visitor when subscribing without commenting or when requesting a subscription management link.", 'subscribe-to-comments-reloaded' ); ?>">
641
+ <i class="fas fa-question-circle"></i>
642
+ </div>
643
+ </div>
644
+ </div>
645
+
646
+ <div class="form-group row">
647
+ <label for="recaptcha_version" class="col-sm-3 col-form-label text-right">
648
+ <?php esc_html_e( 'reCAPTCHA Version', 'subscribe-to-comments-reloaded' ) ?>
649
+ </label>
650
+ <div class="col-sm-7">
651
+ <select class="form-control form-control-input-3" id="recaptcha_version" name="options[recaptcha_version]">
652
+ <option value="v2" <?php selected( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'recaptcha_version', 'v2' ), 'v2', true ) ?>><?php esc_html_e( 'V2', 'subscribe-to-comments-reloaded' ); ?></option>
653
+ <option value="v3" <?php selected( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'recaptcha_version', 'v2' ), 'v3', true ) ?>><?php esc_html_e( 'V3', 'subscribe-to-comments-reloaded' ); ?></option>
654
+ </select>
655
+
656
+ <div class="helpDescription subsOptDescriptions"
657
+ data-content="<?php esc_html_e( "reCAPTCHA version to be used.", 'subscribe-to-comments-reloaded' ); ?>"
658
+ data-placement="right"
659
+ aria-label="<?php esc_html_e( "reCAPTCHA version to be used.", 'subscribe-to-comments-reloaded' ); ?>">
660
+ <i class="fas fa-question-circle"></i>
661
+ </div>
662
+ </div>
663
+ </div>
664
+
665
+ <div class="form-group row">
666
+ <label for="captcha_site_key" class="col-sm-3 col-form-label text-right">
667
+ <?php _e( 'reCAPTCHA site key', 'subscribe-to-comments-reloaded' ) ?></label>
668
+ <div class="col-sm-7">
669
+ <input type="text" name="options[captcha_site_key]" id="captcha_site_key"
670
+ class="form-control form-control-input-3"
671
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'captcha_site_key', '' ) ); ?>">
672
+
673
+ <div class="helpDescription subsOptDescriptions"
674
+ data-content="<?php _e( "The site key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>"
675
+ data-placement="right"
676
+ aria-label="<?php _e( "The site key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>">
677
+ <i class="fas fa-question-circle"></i>
678
+ </div>
679
+ </div>
680
+ </div>
681
+
682
+ <div class="form-group row">
683
+ <label for="captcha_secret_key" class="col-sm-3 col-form-label text-right">
684
+ <?php _e( 'reCAPTCHA secret key', 'subscribe-to-comments-reloaded' ) ?></label>
685
+ <div class="col-sm-7">
686
+ <input type="text" name="options[captcha_secret_key]" id="captcha_secret_key"
687
+ class="form-control form-control-input-3"
688
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'captcha_secret_key', '' ) ); ?>">
689
+
690
+ <div class="helpDescription subsOptDescriptions"
691
+ data-content="<?php _e( "The secret key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>"
692
+ data-placement="right"
693
+ aria-label="<?php _e( "The secret key for Google reCAPTCHA.", 'subscribe-to-comments-reloaded' ); ?>">
694
+ <i class="fas fa-question-circle"></i>
695
+ </div>
696
+ </div>
697
+ </div>
698
+
699
+ <div class="form-group row">
700
+ <label for="blacklisted_emails" class="col-sm-3 col-form-label text-right">
701
+ <?php _e( 'Blacklisted Emails', 'subscribe-to-comments-reloaded' ) ?></label>
702
+ <div class="col-sm-7">
703
+ <textarea name="options[blacklisted_emails]" id="blacklisted_emails"
704
+ class="form-control form-control-input-9" cols="10" rows="6"
705
+ ><?php echo esc_textarea( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'blacklisted_emails', '' ) ); ?></textarea>
706
+
707
+ <div class="helpDescription subsOptDescriptions"
708
+ data-content="<?php esc_html_e( "Add a comma separated list of emails to blacklist them from subscribing to comments. Example: example@example.com, mail@mail.com", 'subscribe-to-comments-reloaded' ); ?>"
709
+ data-placement="right"
710
+ aria-label="<?php esc_html_e( "Add a comma separated list of emails to blacklist them from subscribing to comments. Example: example@example.com, mail@mail.com", 'subscribe-to-comments-reloaded' ); ?>">
711
+ <i class="fas fa-question-circle"></i>
712
+ </div>
713
+ </div>
714
+ </div>
715
+
716
+ <?php /* captcha options end */ ?>
717
+
718
+ <div class="form-group row">
719
+ <label for="unique_key" class="col-sm-3 col-form-label text-right">
720
+ <?php _e( 'StCR Unique Key', 'subscribe-to-comments-reloaded' ) ?></label>
721
+ <div class="col-sm-7">
722
+
723
+ <?php
724
+ if ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'unique_key' ) == "" ) {
725
+
726
+ echo "<div class=\"alert alert-danger\" role=\"alert\" style='font-size: 0.85rem;'>";
727
+ echo '<strong>' . __( "This Unique Key is not set, please click the following button to ", 'subscribe-to-comments-reloaded' ) . '</strong>';
728
+ echo "<input type='submit' value='" . __( 'Generate' ) ."' class='btn btn-secondary subscribe-form-button' name='generate_key' >";
729
+ echo "</div>";
730
+ }
731
+ else {
732
+ ?>
733
+ <input type="text" name="options[unique_key]" id="unique_key"
734
+ class="form-control form-control-input-6"
735
+ value="<?php echo esc_attr( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'unique_key' ) ); ?>" size="20">
736
+
737
+ <input type="submit" value="<?php esc_attr_e( 'Generate New Key' ) ?>" class="btn btn-secondary subscribe-form-button" name="generate_key" >
738
+ <?php } ?>
739
+
740
+
741
+ <div class="helpDescription subsOptDescriptions"
742
+ data-content="<?php _e( "This Unique Key will be use to send the notification to your subscribers with more security.", 'subscribe-to-comments-reloaded' ); ?>"
743
+ data-placement="right"
744
+ aria-label="<?php _e( "This Unique Key will be use to send the notification to your subscribers with more security.", 'subscribe-to-comments-reloaded' ); ?>">
745
+ <i class="fas fa-question-circle"></i>
746
+ </div>
747
+ </div>
748
+ </div>
749
+
750
+ <div class="form-group row">
751
+ <label for="" class="col-sm-3 col-form-label text-right">
752
+ <?php _e( 'Reset All Options', 'subscribe-to-comments-reloaded' ) ?>
753
+ </label>
754
+ <div class="col-sm-7">
755
+
756
+ <div class="alert alert-danger" role="alert">
757
+ <strong>Danger!</strong>
758
+ <p>
759
+ <?php _e( 'This will reset all the options and messages of the plugin. Please proceed with caution.', 'subscribe-to-comments-reloaded' ); ?>
760
+ </p>
761
+
762
+ <p>
763
+ <?php _e( '<strong>Yes</strong> = Delete Options including subscriptions.', 'subscribe-to-comments-reloaded' ) ?><br/>
764
+ <?php _e( '<strong>No</strong> = Only delete the StCR Options.', 'subscribe-to-comments-reloaded' ) ?>
765
+ </p>
766
+
767
+
768
+ <div class="switch">
769
+ <input type="radio" class="switch-input" name="options[delete_options_subscriptions]"
770
+ value="yes" id="delete_options_subscriptions-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'delete_options_subscriptions' ) == 'yes' ) ? ' checked' : ''; ?> />
771
+ <label for="delete_options_subscriptions-yes" class="switch-label switch-label-off">
772
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
773
+ </label>
774
+ <input type="radio" class="switch-input" name="options[delete_options_subscriptions]" value="no" id="delete_options_subscriptions-no"
775
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'delete_options_subscriptions' ) == 'no' ) ? ' checked' : ''; ?> />
776
+ <label for="delete_options_subscriptions-no" class="switch-label switch-label-on">
777
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
778
+ </label>
779
+ <span class="switch-selection"></span>
780
+ </div>
781
+
782
+ <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" >
783
+
784
+ </div>
785
+ </div>
786
+ </div>
787
+
788
+ <div class="form-group row">
789
+ <div class="col-sm-9 offset-sm-1">
790
+ <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
791
+ <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
792
+ </button>
793
+ </div>
794
+ </div>
795
+
796
+ <?php wp_nonce_field( 'stcr_save_options_nonce', 'stcr_save_options_nonce' ); ?>
797
+
798
+ </form>
799
+ </div>
800
+
801
+ <div class="col-md-3">
802
+ <div class="card card-font-size">
803
+ <div class="card-body">
804
+ <p>
805
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
806
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
807
+ </p>
808
+ <p>
809
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
810
+ </p>
811
+ </div>
812
+ </div>
813
+ </div>
814
+
815
+ </div>
816
+ </div>
817
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
818
+ <?php
819
+ //global $wp_subscribe_reloaded;
820
+ // Tell WP that we are going to use a resource.
821
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
822
+ // Includes the Panel JS resource file as well as the JS text domain translations.
823
+ //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-subs-options", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
824
+ // Enqueue the JS File
825
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
826
+
827
+ ?>
options/stcr_support.php CHANGED
@@ -1,57 +1,57 @@
1
- <?php
2
- // Options
3
-
4
- // Avoid direct access to this piece of code
5
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
- header( 'Location: /' );
7
- exit;
8
- }
9
-
10
-
11
- ?>
12
- <div class="container-fluid">
13
- <div class="mt-3"></div>
14
- <div class="row">
15
- <div class="col-sm-9">
16
- <div class="card card-font-size card-no-max-width">
17
- <div class="card-body">
18
- <div class="card-text">
19
-
20
- <h5><?php _e( "You can help", 'subscribe-to-comments-reloaded' ) ?></h5>
21
- <p><?php _e( "Please consider blogging about my plugin with a link to the plugin's page. Please let your readers know what makes your blog better. You can also contribute donating your time: do not hesitate to send me bug reports, your localization files, ideas on how to improve <strong>Subscribe to Comments Reloaded</strong> and so on. Whatever you do, thanks for using my plugin!", 'subscribe-to-comments-reloaded' ) ?></p>
22
-
23
- <h5><?php _e( "Subscribe to the Beta testers", 'subscribe-to-comments-reloaded' ) ?></h5>
24
- <p><?php _e( "Before a new Update we release a Beta version so that our current users can give us feedback if they find a bug, If you want to join the tester list you can add your email <a href='http://eepurl.com/biCk1b' target='_blank'>here</a>", 'subscribe-to-comments-reloaded' ) ?></h5></p>
25
-
26
- <h5><?php _e( "Vote and show your appreciation", 'subscribe-to-comments-reloaded' ) ?></h5>
27
- <p><?php _e( 'Tell other people if <strong>Subscribe to Comments Reloaded</strong> works for you and how good it is. <a href="http://wordpress.org/extend/plugins/subscribe-to-comments-reloaded/">Rate it</a> on its Plugin Directory page.', 'subscribe-to-comments-reloaded' ) ?></p>
28
-
29
- <h5><?php _e( "Did you find a Bug on the plugin?", 'subscribe-to-comments-reloaded' ) ?></h5>
30
- <p><?php _e( 'Please report any bug on the <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/new?title=Bug%20Report:%20%3Cshort%20description%3E&labels=bug" target="_blank">GitHub</a> Page rather than on the WordPress Support page.', 'subscribe-to-comments-reloaded' ) ?>
31
- </p>
32
- <div class="alert alert-info" role="alert">
33
- <strong>Heads up!</strong>
34
- <p><?php printf( __( 'The options on the WordPress forum at very limited to share media information, so I urge you to use GitHub to report any issue, you will get a better and faster experience than in WordPress. And you can use <a href="%s" target="_blank" >Markdown syntax</a>.', 'subscribe-to-comments-reloaded' ), "https://guides.github.com/features/mastering-markdown/" ); ?></p>
35
- </div>
36
- </div>
37
- </div>
38
-
39
- </div>
40
- </div>
41
-
42
- <div class="col-md-3">
43
- <div class="card card-font-size">
44
- <div class="card-body">
45
- <p>
46
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
47
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
48
- </p>
49
- <p>
50
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
51
- </p>
52
- </div>
53
- </div>
54
- </div>
55
-
56
- </div>
57
- </div>
1
+ <?php
2
+ // Options
3
+
4
+ // Avoid direct access to this piece of code
5
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
6
+ header( 'Location: /' );
7
+ exit;
8
+ }
9
+
10
+
11
+ ?>
12
+ <div class="container-fluid">
13
+ <div class="mt-3"></div>
14
+ <div class="row">
15
+ <div class="col-sm-9">
16
+ <div class="card card-font-size card-no-max-width">
17
+ <div class="card-body">
18
+ <div class="card-text">
19
+
20
+ <h5><?php _e( "You can help", 'subscribe-to-comments-reloaded' ) ?></h5>
21
+ <p><?php _e( "Please consider blogging about my plugin with a link to the plugin's page. Please let your readers know what makes your blog better. You can also contribute donating your time: do not hesitate to send me bug reports, your localization files, ideas on how to improve <strong>Subscribe to Comments Reloaded</strong> and so on. Whatever you do, thanks for using my plugin!", 'subscribe-to-comments-reloaded' ) ?></p>
22
+
23
+ <h5><?php _e( "Subscribe to the Beta testers", 'subscribe-to-comments-reloaded' ) ?></h5>
24
+ <p><?php _e( "Before a new Update we release a Beta version so that our current users can give us feedback if they find a bug, If you want to join the tester list you can add your email <a href='http://eepurl.com/biCk1b' target='_blank'>here</a>", 'subscribe-to-comments-reloaded' ) ?></h5></p>
25
+
26
+ <h5><?php _e( "Vote and show your appreciation", 'subscribe-to-comments-reloaded' ) ?></h5>
27
+ <p><?php _e( 'Tell other people if <strong>Subscribe to Comments Reloaded</strong> works for you and how good it is. <a href="http://wordpress.org/extend/plugins/subscribe-to-comments-reloaded/">Rate it</a> on its Plugin Directory page.', 'subscribe-to-comments-reloaded' ) ?></p>
28
+
29
+ <h5><?php _e( "Did you find a Bug on the plugin?", 'subscribe-to-comments-reloaded' ) ?></h5>
30
+ <p><?php _e( 'Please report any bug on the <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/new?title=Bug%20Report:%20%3Cshort%20description%3E&labels=bug" target="_blank">GitHub</a> Page rather than on the WordPress Support page.', 'subscribe-to-comments-reloaded' ) ?>
31
+ </p>
32
+ <div class="alert alert-info" role="alert">
33
+ <strong>Heads up!</strong>
34
+ <p><?php printf( __( 'The options on the WordPress forum at very limited to share media information, so I urge you to use GitHub to report any issue, you will get a better and faster experience than in WordPress. And you can use <a href="%s" target="_blank" >Markdown syntax</a>.', 'subscribe-to-comments-reloaded' ), "https://guides.github.com/features/mastering-markdown/" ); ?></p>
35
+ </div>
36
+ </div>
37
+ </div>
38
+
39
+ </div>
40
+ </div>
41
+
42
+ <div class="col-md-3">
43
+ <div class="card card-font-size">
44
+ <div class="card-body">
45
+ <p>
46
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
47
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
48
+ </p>
49
+ <p>
50
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
51
+ </p>
52
+ </div>
53
+ </div>
54
+ </div>
55
+
56
+ </div>
57
+ </div>
options/stcr_system.php CHANGED
@@ -1,764 +1,790 @@
1
- <?php
2
- /**
3
- * Displays WP-admin -> StCR -> StCR System
4
- */
5
-
6
- // Avoid direct access to this piece of code
7
- if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
8
- header( 'Location: /' );
9
- exit;
10
- }
11
-
12
- global $wpdb;
13
-
14
- $options = array(
15
- "enable_log_data" => "yesno",
16
- "auto_clean_log_data" => "yesno",
17
- "auto_clean_log_frecuency" => "text"
18
- );
19
-
20
- $stcr_options = $wpdb->get_results('SELECT * FROM '. $wpdb->prefix . 'options WHERE option_name LIKE "subscribe_reloaded%"');
21
-
22
- $stcr_options_str = "";
23
- $stcr_options_array = array();
24
- $stcr_system_information = array();
25
-
26
- foreach ($stcr_options as $option) {
27
- $stcr_options_str .= "{$option->option_name}: {$option->option_value}\n";
28
- $stcr_options_array[$option->option_name] = $option->option_value;
29
- }
30
-
31
- $stcr_options_array["custom_post_types"] = implode( "| ", get_post_types( '', 'names' ) );
32
- $stcr_options_array["permalink_structure"] = get_option('permalink_structure');
33
-
34
- // Setup the auto purge for the download report.
35
- // // Schedule the auto purge for the log file.
36
- if ( ! wp_next_scheduled( '_cron_subscribe_reloaded_system_report_file_purge' ) ) {
37
- wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
38
- // Let us bind the schedule event with our desire action.
39
- wp_schedule_event( time() + 15, "daily", '_cron_subscribe_reloaded_system_report_file_purge' );
40
- }
41
-
42
- // Updating options
43
- if ( array_key_exists( "purge_log", $_POST ) ) {
44
- // Check that the log file exits
45
- $plugin_dir = plugin_dir_path( __DIR__ );
46
- $file_name = "log.txt";
47
- $message_type = "";
48
- $message = "";
49
- $file_path = $plugin_dir . "utils/" . $file_name;
50
-
51
- if( file_exists( $file_path ) && is_writable( $plugin_dir ) )
52
- {
53
- // unlink the file
54
- if( unlink($file_path) )
55
- {
56
- // show success message.
57
- $message = __( 'The log file has been successfully deleted.', 'subscribe-to-comments-reloaded' );
58
- $message_type = "notice-success";
59
- }
60
- else
61
- {
62
- $message = __( 'Can\'t delete the log file, check the file permissions.', 'subscribe-to-comments-reloaded' );
63
- $message_type = "notice-warning";
64
- }
65
- }
66
- else
67
- {
68
- $message = __( 'The log file does not exists.', 'subscribe-to-comments-reloaded' );
69
- $message_type = "notice-warning";
70
- }
71
- echo "<div class='notice $message_type'><p>";
72
- echo $message;
73
- // echo "<br><pre>$file_path$file_name</pre>";
74
- echo "</p></div>\n";
75
- }
76
- else {
77
- // echo "<pre>Option selected ";
78
- // print_r($_POST['options']);
79
- // echo "</pre>";
80
- // Update options
81
- if( isset( $_POST['options'] ) ) { // Update options
82
-
83
- $faulty_fields = array();
84
-
85
- foreach ( $_POST['options'] as $option => $value )
86
- {
87
- // echo $option . '<br>';
88
-
89
- if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
90
- {
91
- array_push( $faulty_fields, $option );
92
- }
93
-
94
- if ( $option === "auto_clean_log_data" && $value === "yes" )
95
- {
96
- // // Schedule the auto purge for the log file.
97
- if ( ! wp_next_scheduled( '_cron_log_file_purge' ) ) {
98
- $log_purger_recurrence = get_option( "subscribe_reloaded_auto_clean_log_frecuency" );
99
- wp_clear_scheduled_hook( '_cron_log_file_purge' );
100
- // Let us bind the schedule event with our desire action.
101
- wp_schedule_event( time() + 15, $log_purger_recurrence, '_cron_log_file_purge' );
102
- }
103
- }
104
- elseif ( $option === "auto_clean_log_data" && $value === "no" )
105
- {
106
- // Delete a Schedule event
107
- wp_clear_scheduled_hook( '_cron_log_file_purge' );
108
- }
109
- }
110
-
111
- // Display an alert in the admin interface if something went wrong
112
- echo '<div class="updated"><p>';
113
- if ( sizeof( $faulty_fields ) == 0 ) {
114
- _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
115
- } else {
116
- _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
117
- // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
118
- }
119
- echo "</p></div>";
120
- }
121
- }
122
- ?>
123
- <link href="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.css" rel="stylesheet"/>
124
- <style type="text/css">
125
- .system-error {
126
- color: #dc3545;
127
- }
128
-
129
- .system-success{
130
- color: #7cc575;
131
- }
132
- </style>
133
-
134
-
135
- <div class="container-fluid">
136
- <div class="mt-3"></div>
137
- <div class="row">
138
- <div class="col-sm-9">
139
- <form action="" method="post">
140
-
141
- <div class="form-group row" style="margin-bottom: 0;">
142
- <label for="enable_log_data" class="col-sm-3 col-form-label text-right"><?php _e( 'Enable Log Information', 'subscribe-to-comments-reloaded' ) ?></label>
143
- <div class="col-sm-7">
144
- <div class="switch">
145
- <input type="radio" class="switch-input" name="options[enable_log_data]"
146
- value="yes" id="enable_log_data-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_log_data' ) == 'yes' ) ? ' checked' : ''; ?> />
147
- <label for="enable_log_data-yes" class="switch-label switch-label-off">
148
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
149
- </label>
150
- <input type="radio" class="switch-input" name="options[enable_log_data]" value="no" id="enable_log_data-no"
151
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_log_data' ) == 'no' ) ? ' checked' : ''; ?> />
152
- <label for="enable_log_data-no" class="switch-label switch-label-on">
153
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
154
- </label>
155
- <span class="switch-selection"></span>
156
- </div>
157
-
158
- <div class="helpDescription subsOptDescriptions"
159
- data-content="<?php _e( "If enabled, will log information of the plugin. Helpful for debugging purposes.<p>The file is stored under the path <code>Plugins Dir>subscribe-to-comments-reloaded>utils>log.txt</code></code></p>", 'subscribe-to-comments-reloaded' ); ?>"
160
- data-placement="right"
161
- aria-label="<?php _e( "If enabled, will log information of the plugin. Helpful for debugging purposes.", 'subscribe-to-comments-reloaded' ); ?>">
162
- <i class="fas fa-question-circle"></i>
163
- </div>
164
- </div>
165
- </div>
166
-
167
- <div class="form-group row" style="margin-bottom: 0;">
168
- <label for="auto_clean_log_data" class="col-sm-3 col-form-label text-right"><?php _e( 'Enable Auto clean log data', 'subscribe-to-comments-reloaded' ) ?></label>
169
- <div class="col-sm-7">
170
- <div class="switch">
171
- <input type="radio" class="switch-input" name="options[auto_clean_log_data]"
172
- value="yes" id="auto_clean_log_data-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_data' ) == 'yes' ) ? ' checked' : ''; ?> />
173
- <label for="auto_clean_log_data-yes" class="switch-label switch-label-off">
174
- <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
175
- </label>
176
- <input type="radio" class="switch-input" name="options[auto_clean_log_data]" value="no" id="auto_clean_log_data-no"
177
- <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_data' ) == 'no' ) ? ' checked' : ''; ?> />
178
- <label for="auto_clean_log_data-no" class="switch-label switch-label-on">
179
- <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
180
- </label>
181
- <span class="switch-selection"></span>
182
- </div>
183
-
184
- <select class="auto_clean_log_frecuency form-control form-control-select" name="options[auto_clean_log_frecuency]">
185
- <option value="hourly" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_frecuency' ) === 'hourly' ) ? "selected='selected'" : ''; ?>><?php _e( 'Hourly', 'subscribe-to-comments-reloaded' ); ?></option>
186
- <option value="twicedaily" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_frecuency' ) === 'twicedaily' ) ? "selected='selected'" : ''; ?>><?php _e( 'Twice Daily', 'subscribe-to-comments-reloaded' ); ?></option>
187
- <option value="daily" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_frecuency' ) === 'daily' ) ? "selected='selected'" : ''; ?>><?php _e( 'Daily', 'subscribe-to-comments-reloaded' ); ?></option>
188
- </select>
189
-
190
- <div class="helpDescription subsOptDescriptions"
191
- data-content="<?php _e( "If enabled, StCR will auto clean your information according to the frequency that you defined on the dropdown.", 'subscribe-to-comments-reloaded' ); ?>"
192
- data-placement="right"
193
- aria-label="<?php _e( "If enabled, StCR will auto clean your information according to the frequency that you defined on the dropdown.", 'subscribe-to-comments-reloaded' ); ?>">
194
- <i class="fas fa-question-circle"></i>
195
- </div>
196
- </div>
197
- </div>
198
-
199
- <div class="form-group row">
200
- <label for="purge_log" class="col-sm-3 col-form-label text-right">
201
- <?php _e( 'Clean Up Log Archive', 'subscribe-to-comments-reloaded' ) ?></label>
202
- <div class="col-sm-7">
203
-
204
- <span style="font-size: 0.9rem;"><?php _e(
205
- "If you want to clean up the log archive please click the following button",
206
- 'subscribe-to-comments-reloaded'
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
-
214
- <div class="form-group row">
215
- <label for="generate_system_info" class="col-sm-3 col-form-label text-right">
216
- <?php _e( 'Download System Info File', 'subscribe-to-comments-reloaded' ) ?></label>
217
- <div class="col-sm-7">
218
- <a class="download_report btn btn-download subscribe-form-button" href="#">
219
- <?php _e( 'Download', 'subscribe-to-comments-reloaded' ); ?>
220
- </a>
221
- </div>
222
- </div>
223
-
224
- <div class="form-group row">
225
- <div class="col-sm-9 offset-sm-3">
226
- <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
227
- <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
228
- </button>
229
- </div>
230
- </div>
231
-
232
- <h4><?php _e( 'System Information', 'subscribe-to-comments-reloaded' ) ?></h4><br>
233
-
234
- <!-- Plugin Info -->
235
- <?php
236
- // get the total number of subscribers and subscriptions
237
- $total_subscribers = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}subscribe_reloaded_subscribers");
238
- $total_subscriptions = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}postmeta where meta_key LIKE '_stcr@_%'");
239
- ?>
240
- <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
241
- <thead style="background-color: #4688d2; color: #ffffff;">
242
- <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Plugin Info', 'subscribe-to-comments-reloaded' ) ?></th>
243
- </thead>
244
- <tbody>
245
- <tr>
246
- <td class="text-left"><?php _e( 'Subscribers', 'subscribe-toc-omments-reloaded' ); ?></td>
247
- <td class="text-left"><?php echo $total_subscribers; ?></td>
248
- </tr>
249
- <tr>
250
- <td class="text-left"><?php _e( 'Subscriptions', 'subscribe-toc-omments-reloaded' ); ?></td>
251
- <td class="text-left"><?php echo $total_subscriptions; ?></td>
252
- </tr>
253
- </tbody>
254
- </table>
255
-
256
- <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
257
- <thead style="background-color: #4688d2; color: #ffffff;">
258
- <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'WordPress Environment', 'subscribe-to-comments-reloaded' ) ?></th>
259
- </thead>
260
- <?php
261
-
262
- $memory = $wp_subscribe_reloaded->stcr->utils->to_num_ini_notation( WP_MEMORY_LIMIT );
263
- $memoryValue = '';
264
- $wpDebug = 'No';
265
- $wpCron = 'No';
266
- $wpHome = get_option( 'home' );
267
- $wpsiteurl = get_option( 'siteurl' );
268
- $wpVersion = get_bloginfo( 'version' );
269
- $wpMultisite = is_multisite();
270
- $wpLanguage = get_locale();
271
- $wpPermalink = esc_html( get_option( 'permalink_structure' ) );
272
- $wpTablePrefix = esc_html( $wpdb->prefix );
273
- $wpTablePrefixLength = strlen( $wpdb->prefix );
274
- $wpTablePrefixStatus = $wpTablePrefixLength > 16 ? esc_html( 'Error: Too long', 'subscribe-to-comments-reloaded' ) : esc_html( 'Acceptable', 'subscribe-to-comments-reloaded' );
275
- $wpRegisteredPostStatuses = esc_html( implode( ', ', get_post_stati() ) );
276
-
277
- $stcr_system_information['Wordpress Environment']["Home URL"] = $wpHome;
278
- $stcr_system_information['Wordpress Environment']["Site URL"] = $wpsiteurl;
279
- $stcr_system_information['Wordpress Environment']["WordPress Version"] = $wpVersion;
280
- $stcr_system_information['Wordpress Environment']["Multisite"] = $wpMultisite;
281
- $stcr_system_information['Wordpress Environment']["Language"] = $wpLanguage;
282
- $stcr_system_information['Wordpress Environment']["Permalink Structure"] = $wpPermalink;
283
- $stcr_system_information['Wordpress Environment']["Table Prefix"] = $wpTablePrefix;
284
- $stcr_system_information['Wordpress Environment']["Table Prefix Length"] = $wpTablePrefixLength;
285
- $stcr_system_information['Wordpress Environment']["Table Prefix Status"] = $wpTablePrefixStatus;
286
- $stcr_system_information['Wordpress Environment']["Registered Post Statuses"] = $wpRegisteredPostStatuses;
287
-
288
-
289
-
290
- if ( function_exists( 'memory_get_usage' ) ) {
291
- $system_memory = $wp_subscribe_reloaded->stcr->utils->to_num_ini_notation( @ini_get( 'memory_limit' ) );
292
- $memory = max( $memory, $system_memory );
293
- }
294
-
295
- if ( $memory < 67108864 ) {
296
- $memoryValue = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend setting memory to at least 64 MB. See: %s', 'subscribe-to-comments-reloaded' ), size_format( $memory ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . __( 'Increasing memory allocated to PHP', 'subscribe-to-comments-reloaded' ) . '</a>' ) . '</div>';
297
- $stcr_system_information['Wordpress Environment']["Memory Limit"] = "Memory under 64MB";
298
- }
299
- else {
300
- $memoryValue = '<div class="system-success">' . size_format( $memory ) . '</div>';
301
- $stcr_system_information['Wordpress Environment']["Memory Limit"] = size_format( $memory );
302
- }
303
- // Check if Debug is Enable
304
- if ( defined( 'WP_DEBUG' ) && WP_DEBUG )
305
- {
306
- $wpDebug = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
307
- $stcr_system_information['Wordpress Environment']["WP Debug Mode"] = true;
308
- }
309
- else
310
- {
311
- $wpDebug = '<div>'. $wpDebug .'</div>';
312
- $stcr_system_information['Wordpress Environment']["WP Debug Mode"] = false;
313
- }
314
- // Check if WP Cron is Enable
315
- if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON )
316
- {
317
- $wpCron = '<div>'. $wpCron .'</div>';
318
- $stcr_system_information['Wordpress Environment']["WP Cron"] = true;
319
- }
320
- else
321
- {
322
- $wpCron = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
323
- $stcr_system_information['Wordpress Environment']["WP Cron"] = false;
324
- }
325
-
326
- $wordpressEnvironment = array(
327
- 1 => array(
328
- __( "Home URL", 'subscribe-to-comments-reloaded' ),
329
- $wpHome
330
- ),
331
- 2 => array(
332
- __( "Site URL", 'subscribe-to-comments-reloaded' ),
333
- $wpsiteurl
334
- ),
335
- 3 => array(
336
- __( "WordPress Version", 'subscribe-to-comments-reloaded' ),
337
- $wpVersion
338
- ),
339
- 4 => array(
340
- "Multisite",
341
- $wpMultisite ? '<span class="dashicons dashicons-yes"></span>' : 'No'
342
- ),
343
- 5 => array(
344
- __( "Memory Limit", 'subscribe-to-comments-reloaded' ),
345
- $memoryValue
346
- ),
347
- 6 => array(
348
- __( "WP Debug Mode", 'subscribe-to-comments-reloaded' ),
349
- $wpDebug
350
- ),
351
- 7 => array(
352
- __( "WP Cron", 'subscribe-to-comments-reloaded' ),
353
- $wpCron
354
- ),
355
- 8 => array(
356
- __( "Language", 'subscribe-to-comments-reloaded' ),
357
- $wpLanguage
358
- ),
359
- 9 => array(
360
- __( "Permalink Structure", 'subscribe-to-comments-reloaded' ),
361
- $wpPermalink
362
- ),
363
- 10 => array(
364
- __( "Table Prefix", 'subscribe-to-comments-reloaded' ),
365
- $wpTablePrefix
366
- ),
367
- 11 => array(
368
- __( "Table Prefix Length", 'subscribe-to-comments-reloaded' ),
369
- $wpTablePrefixLength
370
- ),
371
- 12 => array(
372
- __( "Table Prefix Status", 'subscribe-to-comments-reloaded' ),
373
- $wpTablePrefixStatus
374
- ),
375
- 13 => array(
376
- __( "Registered Post Statuses", 'subscribe-to-comments-reloaded' ),
377
- $wpRegisteredPostStatuses
378
- )
379
- );
380
- ?>
381
- <tbody>
382
- <?php
383
- foreach ( $wordpressEnvironment as $key => $opt )
384
- {
385
- echo "<tr>";
386
- echo "<td class='text-left' style='min-width: 50px;'>{$opt[0]}</td>";
387
- echo "<td class='text-left'>{$opt[1]}</td>";
388
- echo "</tr>";
389
- }
390
- ?>
391
- </tbody>
392
- </table>
393
-
394
- <!-- Server Environment -->
395
- <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
396
- <thead style="background-color: #4688d2; color: #ffffff;">
397
- <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Server Environment', 'subscribe-to-comments-reloaded' ) ?></th>
398
- </thead>
399
- <?php
400
-
401
- $tlsCheck = false;
402
- $tlsCheckValue = __( 'Cannot Evaluate', 'subscribe-to-comments-reloaded' );
403
- $tlsRating = __( 'Not Available', 'subscribe-to-comments-reloaded' );
404
- $phpVersion = __( 'Not Available', 'subscribe-to-comments-reloaded' );
405
- $cURLVersion = __( 'Not Available', 'subscribe-to-comments-reloaded' );
406
- $MySQLSVersion = __( 'Not Available', 'subscribe-to-comments-reloaded' );
407
- $defaultTimezone = __( 'Not Available', 'subscribe-to-comments-reloaded' );
408
- $serverInfo = esc_html( $_SERVER['SERVER_SOFTWARE'] );
409
- $maxPostSize = size_format( $wp_subscribe_reloaded->stcr->utils->to_num_ini_notation( ini_get( 'post_max_size' ) ) );
410
-
411
- // Get the SSL status.
412
- if ( ini_get( 'allow_url_fopen' ) ) {
413
- $tlsCheck = file_get_contents( 'https://www.howsmyssl.com/a/check' );
414
- }
415
-
416
- if ( false !== $tlsCheck )
417
- {
418
- $tlsCheck = json_decode( $tlsCheck );
419
- /* translators: %s: SSL connection response */
420
- $tlsCheckValue = sprintf( __( 'Connection uses %s', 'subscribe-to-comments-reloaded' ), esc_html( $tlsCheck->tls_version ) );
421
- }
422
- $stcr_system_information['Server Environment']["TLS Connection"] = $tlsCheckValue;
423
- // Check TSL Rating
424
- if ( false !== $tlsCheck )
425
- {
426
- $tlsRating = property_exists( $tlsCheck, 'rating' ) ? $tlsCheck->rating : $tlsCheck->tls_version;
427
- }
428
- $stcr_system_information['Server Environment']["TLS Rating"] = $tlsRating;
429
- $stcr_system_information['Server Environment']["Server Info"] = $serverInfo;
430
- // Check the PHP Version
431
- if ( function_exists( 'phpversion' ) )
432
- {
433
- $phpVersion = phpversion();
434
-
435
- if ( version_compare( $phpVersion, '5.6', '<' ) )
436
- {
437
- $phpVersion = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum PHP version of 5.6. See: %s', 'subscribe-to-comments-reloaded' ), esc_html( $phpVersion ), '<a href="http://subscribe-reloaded.com/about/" target="_blank">' . __( 'PHP Requirements in StCR', 'subscribe-to-comments-reloaded' ) . '</a>' ) . '</div>';
438
- $stcr_system_information['Server Environment']["PHP Version"] = sprintf( '%s - We recommend a minimum PHP version of 5.6. See: %s', esc_html( $phpVersion ), '<a href="http://subscribe-reloaded.com/about/" target="_blank">PHP Requirements in StCR</a>' );
439
- }
440
- else
441
- {
442
- $phpVersion = '<div class="system-success">' . esc_html( $phpVersion ) . '</div>';
443
- $stcr_system_information['Server Environment']["PHP Version"] = phpversion();
444
- }
445
- }
446
- else
447
- {
448
- $phpVersion = __( "Couldn't determine PHP version because the function phpversion() doesn't exist.", 'subscribe-to-comments-reloaded' );
449
- $stcr_system_information['Server Environment']["PHP Version"] = "Couldn't determine PHP version because the function phpversion() doesn't exist.";
450
- }
451
-
452
- $stcr_system_information['Server Environment']["PHP Post Max Size"] = $maxPostSize;
453
- $stcr_system_information['Server Environment']["PHP Max Execution Time"] = ini_get( 'max_execution_time' );
454
- $stcr_system_information['Server Environment']["PHP Max Input Vars"] = ini_get( 'max_input_vars' );
455
- $stcr_system_information['Server Environment']["PHP Max Upload Size"] = size_format( wp_max_upload_size() );
456
-
457
- // Check the cURL Version
458
- if ( function_exists( 'curl_version' ) )
459
- {
460
- $cURLVersion = curl_version();
461
- $cURLVersionNumber = $cURLVersion['version'];
462
- $cURLSSLVersion = $cURLVersion['ssl_version'];
463
-
464
- if ( version_compare( $cURLVersionNumber, '7.40', '<' ) )
465
- {
466
- $cURLVersion = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum cURL version of 7.40.', 'subscribe-to-comments-reloaded' ), esc_html( $cURLVersionNumber . ', ' . $cURLSSLVersion ) ) . '</div>';
467
- $stcr_system_information['Server Environment']["cURL Version"] = sprintf('%s - We recommend a minimum cURL version of 7.40.', esc_html( $cURLVersionNumber . ', ' . $cURLSSLVersion ) );
468
- }
469
- else
470
- {
471
- $cURLVersion = '<div class="system-success">' . esc_html( $cURLVersionNumber ) . '</div>';
472
- $stcr_system_information['Server Environment']["cURL Version"] = $cURLVersion;
473
- }
474
- }
475
- else
476
- {
477
- $cURLVersion = '&ndash;';
478
- $stcr_system_information['Server Environment']["cURL Version"] = 'cURL is not available';
479
- }
480
-
481
- // check MySQL version
482
- global $wp_version, $required_mysql_version;
483
- if ( version_compare( $wpdb->db_version(), $required_mysql_version, '<' ) ) {
484
- $MySQLSVersion = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ) . '</div>';
485
- $stcr_system_information['Server Environment']["MySQL Version"] = $wpdb->db_version();
486
- } else {
487
- $MySQLSVersion = '<div class="system-success">' . $wpdb->db_version() . '</div>';
488
- $stcr_system_information['Server Environment']["MySQL Version"] = $wpdb->db_version();
489
- }
490
-
491
- // Get the Timezone
492
- $defaultTimezone = date_default_timezone_get();
493
-
494
- if ( 'UTC' !== $defaultTimezone )
495
- {
496
- $defaultTimezone = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'subscribe-to-comments-reloaded' ), $defaultTimezone ) . '</div>';
497
- $stcr_system_information['Server Environment']["Default Timezone is UTC"] = sprintf('Default timezone is %s - it should be UTC', $defaultTimezone );
498
- }
499
- else
500
- {
501
- $defaultTimezone = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
502
- $stcr_system_information['Server Environment']["Default Timezone is UTC"] = "Yes";
503
- }
504
- // DOMDocument
505
- $DOMDocument = __( 'Not Available', 'subscribe-to-comments-reloaded' );
506
- if ( class_exists( 'DOMDocument' ) )
507
- {
508
- $DOMDocument = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
509
- $stcr_system_information['Server Environment']["DOMDocument"] = "Yes";
510
- }
511
- else {
512
- $DOMDocument = sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'subscribe-to-comments-reloaded' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' );
513
- $stcr_system_information['Server Environment']["DOMDocument"] = sprintf( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' );
514
- }
515
- // Check gzip
516
- $gzip = __( 'Not Available', 'subscribe-to-comments-reloaded' );
517
- if ( is_callable( 'gzopen' ) )
518
- {
519
- $gzip = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
520
- $stcr_system_information['Server Environment']["gzip"] = "Yes";
521
- }
522
- else {
523
- $gzip = sprintf( __( 'Your server does not support the %s function - this is used for file compression and decompression.', 'subscribe-to-comments-reloaded' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' );
524
- $stcr_system_information['Server Environment']["gzip"] = sprintf( 'Your server does not support the %s function - this is used for file compression and decompression.', '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' );
525
- }// Check GD
526
- $gd = __( 'Not Available', 'subscribe-to-comments-reloaded' );
527
- if ( extension_loaded( 'gd' ) && function_exists( 'gd_info' ) )
528
- {
529
- $gd = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
530
- $stcr_system_information['Server Environment']["GD Graphics Library"] = "Yes";
531
- }
532
- else {
533
- $gd = '<div class="system-error"><span class="dashicons dashicons-no"></span></div>';
534
- $stcr_system_information['Server Environment']["GD Graphics Library"] = "No";
535
- }
536
-
537
- // Define array of values
538
- $serverEnvironment = array(
539
- 1 => array(
540
- __( "TLS Connection", 'subscribe-to-comments-reloaded' ),
541
- $tlsCheckValue
542
- ),
543
- 2 => array(
544
- __( "TLS Rating", 'subscribe-to-comments-reloaded' ),
545
- $tlsRating
546
- ),
547
- 3 => array(
548
- __( "Server Info", 'subscribe-to-comments-reloaded' ),
549
- $serverInfo
550
- ),
551
- 4 => array(
552
- __( "PHP Version", 'subscribe-to-comments-reloaded' ),
553
- $phpVersion
554
- ),
555
- 5 => array(
556
- __( "PHP Post Max Size", 'subscribe-to-comments-reloaded' ),
557
- $maxPostSize
558
- ),
559
- 6 => array(
560
- __( "PHP Max Execution Time", 'subscribe-to-comments-reloaded' ),
561
- ini_get( 'max_execution_time' )
562
- ),
563
- 7 => array(
564
- __( "PHP Max Input Vars", 'subscribe-to-comments-reloaded' ),
565
- ini_get( 'max_input_vars' )
566
- ),
567
- 8 => array(
568
- __( "PHP Max Upload Size", 'subscribe-to-comments-reloaded' ),
569
- size_format( wp_max_upload_size() )
570
- ),
571
- 9 => array(
572
- __( "cURL Version", 'subscribe-to-comments-reloaded' ),
573
- $cURLVersion
574
- ),
575
- 10 => array(
576
- __( "MySQL Version", 'subscribe-to-comments-reloaded' ),
577
- $MySQLSVersion
578
- ),
579
- 11 => array(
580
- __( "Default Timezone is UTC", 'subscribe-to-comments-reloaded' ),
581
- $defaultTimezone
582
- ),
583
- 12 => array(
584
- __( "DOMDocument", 'subscribe-to-comments-reloaded' ),
585
- $DOMDocument
586
- ),
587
- 13 => array(
588
- __( "gzip", 'subscribe-to-comments-reloaded' ),
589
- $gzip
590
- ),
591
- 14 => array(
592
- __( "GD Graphics Library", 'subscribe-to-comments-reloaded' ),
593
- $gd
594
- )
595
- );
596
- ?>
597
- <tbody>
598
- <?php
599
- foreach ( $serverEnvironment as $key => $opt )
600
- {
601
- echo "<tr>";
602
- echo "<td class='text-left' style='min-width: 50px;'>{$opt[0]}</td>";
603
- echo "<td class='text-left'>{$opt[1]}</td>";
604
- echo "</tr>";
605
- }
606
- ?>
607
- </tbody>
608
- </table>
609
- <?php
610
- $plugins = $wp_subscribe_reloaded->stcr->utils->stcr_get_plugins();
611
- $installed_plugins = array();
612
- ?>
613
- <!-- Active Plugins -->
614
- <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
615
- <thead style="background-color: #4688d2; color: #ffffff;">
616
- <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Active Plugins', 'subscribe-to-comments-reloaded' ) ?></th>
617
- </thead>
618
-
619
- <tbody>
620
- <?php
621
-
622
- foreach ( $plugins as $plugin_data )
623
- {
624
- // Filter only the Active plugins
625
- if ('active' !== $plugin_data['Status'] )
626
- {
627
- continue;
628
- }
629
-
630
- $plugin_name = $plugin_data['Name'];
631
- $author_name = $plugin_data['Author'];
632
-
633
- $installed_plugins[] = array(
634
- "plugin-name" => $plugin_name,
635
- "plugin-author" => $author_name
636
- );
637
-
638
- // Link the plugin name to the plugin URL if available.
639
- if ( ! empty( $plugin_data['PluginURI'] ) ) {
640
- $plugin_name = sprintf(
641
- '<a href="%s" title="%s">%s</a>',
642
- esc_url( $plugin_data['PluginURI'] ),
643
- esc_attr__( 'Visit plugin homepage', 'subscribe-to-comments-reloaded' ),
644
- $plugin_name
645
- );
646
- }
647
- // Link the author name to the author URL if available.
648
- if ( ! empty( $plugin_data['AuthorURI'] ) ) {
649
- $author_name = sprintf(
650
- '<a href="%s" title="%s">%s</a>',
651
- esc_url( $plugin_data['AuthorURI'] ),
652
- esc_attr__( 'Visit author homepage', 'subscribe-to-comments-reloaded' ),
653
- $author_name
654
- );
655
-
656
- $author_name = sprintf( _x( 'by %s', 'by author', 'subscribe-to-comments-reloaded' ),
657
- wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ) . ' &ndash; '
658
- . esc_html( $plugin_data['Version'] );
659
- }
660
- echo "<tr>";
661
- echo "<td class='text-left' style='min-width: 50px;'>{$plugin_name}</td>";
662
- echo "<td class='text-left'>{$author_name}</td>";
663
- echo "</tr>";
664
- $stcr_system_information['WordPress Active Plugins'][$plugin_data['Name']] = $plugin_data;
665
- }
666
-
667
- ?>
668
- </tbody>
669
- </table>
670
- <!-- Inactive Plugins -->
671
- <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
672
- <thead style="background-color: #4688d2; color: #ffffff;">
673
- <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Inactive Plugins', 'subscribe-to-comments-reloaded' ) ?></th>
674
- </thead>
675
-
676
- <tbody>
677
- <?php
678
-
679
- foreach ( $plugins as $plugin_data )
680
- {
681
- // Filter only the Inactive plugins
682
- if ('inactive' !== $plugin_data['Status'] )
683
- {
684
- continue;
685
- }
686
-
687
- $plugin_name = $plugin_data['Name'];
688
- $author_name = $plugin_data['Author'];
689
-
690
- $installed_plugins[] = array(
691
- "plugin-name" => $plugin_name,
692
- "plugin-author" => $author_name
693
- );
694
-
695
- // Link the plugin name to the plugin URL if available.
696
- if ( ! empty( $plugin_data['PluginURI'] ) ) {
697
- $plugin_name = sprintf(
698
- '<a href="%s" title="%s">%s</a>',
699
- esc_url( $plugin_data['PluginURI'] ),
700
- esc_attr__( 'Visit plugin homepage', 'subscribe-to-comments-reloaded' ),
701
- $plugin_name
702
- );
703
- }
704
- // Link the author name to the author URL if available.
705
- if ( ! empty( $plugin_data['AuthorURI'] ) ) {
706
- $author_name = sprintf(
707
- '<a href="%s" title="%s">%s</a>',
708
- esc_url( $plugin_data['AuthorURI'] ),
709
- esc_attr__( 'Visit author homepage', 'subscribe-to-comments-reloaded' ),
710
- $author_name
711
- );
712
-
713
- $author_name = sprintf( _x( 'by %s', 'by author', 'subscribe-to-comments-reloaded' ),
714
- wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ) . ' &ndash; '
715
- . esc_html( $plugin_data['Version'] );
716
- }
717
- echo "<tr>";
718
- echo "<td class='text-left' style='min-width: 50px;'>{$plugin_name}</td>";
719
- echo "<td class='text-left'>{$author_name}</td>";
720
- echo "</tr>";
721
- $stcr_system_information['WordPress Inactive Plugins'][$plugin_data['Name']] = $plugin_data;
722
- }
723
- ?>
724
- </tbody>
725
- </table>
726
-
727
- </form>
728
-
729
- <form name="stcr_sysinfo_form" class="stcr-hidden" action="<?php echo esc_url( admin_url( 'admin.php?page=stcr_system' ) ); ?>" method="post">
730
- <input type="hidden" name="stcr_sysinfo_action" value="download_sysinfo" />
731
- <textarea name="stcr_sysinfo" readonly><?php echo serialize( $stcr_system_information ); ?></textarea>
732
- </form>
733
-
734
- </div>
735
-
736
- <div class="col-md-3">
737
- <div class="card card-font-size">
738
- <div class="card-body">
739
- <p>
740
- Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
741
- <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/rate.png" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
742
- </p>
743
- <p>
744
- <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
745
- </p>
746
- </div>
747
- </div>
748
- </div>
749
-
750
- </div>
751
- </div>
752
- <script type="text/javascript" src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/vendor/webui-popover/dist/jquery.webui-popover.min.js"></script>
753
- <?php
754
- //global $wp_subscribe_reloaded;
755
- // Tell WP that we are going to use a resource.
756
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-system-info", "stcr_system.js", "includes/js/admin");
757
- $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
758
- // Includes the Panel JS resource file as well as the JS text domain translations.
759
- //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-system-info", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
760
- // Enqueue the JS File
761
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-system-info" );
762
- $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
763
-
764
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Displays WP-admin -> StCR -> StCR System
4
+ */
5
+
6
+ // Avoid direct access to this piece of code
7
+ if ( ! function_exists( 'is_admin' ) || ! is_admin() ) {
8
+ header( 'Location: /' );
9
+ exit;
10
+ }
11
+
12
+ global $wpdb;
13
+
14
+ $options = array(
15
+ "enable_log_data" => "yesno",
16
+ "auto_clean_log_data" => "yesno",
17
+ "auto_clean_log_frecuency" => "text"
18
+ );
19
+
20
+ $stcr_options = $wpdb->get_results('SELECT * FROM '. $wpdb->prefix . 'options WHERE option_name LIKE "subscribe_reloaded%"');
21
+
22
+ $stcr_options_str = "";
23
+ $stcr_options_array = array();
24
+ $stcr_system_information = array();
25
+
26
+ foreach ($stcr_options as $option) {
27
+ $stcr_options_str .= "{$option->option_name}: {$option->option_value}\n";
28
+ $stcr_options_array[$option->option_name] = $option->option_value;
29
+ }
30
+
31
+ $stcr_options_array["custom_post_types"] = implode( "| ", get_post_types( '', 'names' ) );
32
+ $stcr_options_array["permalink_structure"] = get_option('permalink_structure');
33
+
34
+ // Setup the auto purge for the download report.
35
+ // // Schedule the auto purge for the log file.
36
+ if ( ! wp_next_scheduled( '_cron_subscribe_reloaded_system_report_file_purge' ) ) {
37
+ wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
38
+ // Let us bind the schedule event with our desire action.
39
+ wp_schedule_event( time() + 15, "daily", '_cron_subscribe_reloaded_system_report_file_purge' );
40
+ }
41
+
42
+ // Updating options
43
+ if ( array_key_exists( "purge_log", $_POST ) ) {
44
+
45
+ if ( empty( $_POST['stcr_purge_log_nonce'] ) ) {
46
+ return;
47
+ }
48
+
49
+ if ( ! wp_verify_nonce( $_POST['stcr_purge_log_nonce'], 'stcr_purge_log_nonce' ) ) {
50
+ return;
51
+ }
52
+
53
+ if ( ! current_user_can( 'manage_options' ) ) {
54
+ return;
55
+ }
56
+
57
+ // Check that the log file exits
58
+ $plugin_dir = plugin_dir_path( __DIR__ );
59
+ $file_name = "log.txt";
60
+ $message_type = "";
61
+ $message = "";
62
+ $file_path = $plugin_dir . "utils/" . $file_name;
63
+
64
+ if( file_exists( $file_path ) && is_writable( $plugin_dir ) )
65
+ {
66
+ // unlink the file
67
+ if( unlink($file_path) )
68
+ {
69
+ // show success message.
70
+ $message = __( 'The log file has been successfully deleted.', 'subscribe-to-comments-reloaded' );
71
+ $message_type = "notice-success";
72
+ }
73
+ else
74
+ {
75
+ $message = __( 'Can\'t delete the log file, check the file permissions.', 'subscribe-to-comments-reloaded' );
76
+ $message_type = "notice-warning";
77
+ }
78
+ }
79
+ else
80
+ {
81
+ $message = __( 'The log file does not exists.', 'subscribe-to-comments-reloaded' );
82
+ $message_type = "notice-warning";
83
+ }
84
+ echo "<div class='notice $message_type'><p>";
85
+ echo $message;
86
+ // echo "<br><pre>$file_path$file_name</pre>";
87
+ echo "</p></div>\n";
88
+ }
89
+ else {
90
+
91
+ if( isset( $_POST['options'] ) ) { // Update options
92
+
93
+ if ( empty( $_POST['stcr_save_system_nonce'] ) ) {
94
+ return;
95
+ }
96
+
97
+ if ( ! wp_verify_nonce( $_POST['stcr_save_system_nonce'], 'stcr_save_system_nonce' ) ) {
98
+ return;
99
+ }
100
+
101
+ if ( ! current_user_can( 'manage_options' ) ) {
102
+ return;
103
+ }
104
+
105
+ $faulty_fields = array();
106
+
107
+ foreach ( $_POST['options'] as $option => $value )
108
+ {
109
+ // echo $option . '<br>';
110
+
111
+ if ( ! $wp_subscribe_reloaded->stcr->utils->stcr_update_menu_options( $option, $value, $options[$option] ) )
112
+ {
113
+ array_push( $faulty_fields, $option );
114
+ }
115
+
116
+ if ( $option === "auto_clean_log_data" && $value === "yes" )
117
+ {
118
+ // // Schedule the auto purge for the log file.
119
+ if ( ! wp_next_scheduled( '_cron_log_file_purge' ) ) {
120
+ $log_purger_recurrence = get_option( "subscribe_reloaded_auto_clean_log_frecuency" );
121
+ wp_clear_scheduled_hook( '_cron_log_file_purge' );
122
+ // Let us bind the schedule event with our desire action.
123
+ wp_schedule_event( time() + 15, $log_purger_recurrence, '_cron_log_file_purge' );
124
+ }
125
+ }
126
+ elseif ( $option === "auto_clean_log_data" && $value === "no" )
127
+ {
128
+ // Delete a Schedule event
129
+ wp_clear_scheduled_hook( '_cron_log_file_purge' );
130
+ }
131
+ }
132
+
133
+ // Display an alert in the admin interface if something went wrong
134
+ echo '<div class="updated"><p>';
135
+ if ( sizeof( $faulty_fields ) == 0 ) {
136
+ _e( 'Your settings have been successfully updated.', 'subscribe-to-comments-reloaded' );
137
+ } else {
138
+ _e( 'There was an error updating the options.', 'subscribe-to-comments-reloaded' );
139
+ // echo ' <strong>' . substr( $faulty_fields, 0, - 2 ) . '</strong>';
140
+ }
141
+ echo "</p></div>";
142
+ }
143
+ }
144
+ ?>
145
+ <link href="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.css', STCR_PLUGIN_FILE ) ); ?>" rel="stylesheet"/>
146
+ <style type="text/css">
147
+ .system-error {
148
+ color: #dc3545;
149
+ }
150
+
151
+ .system-success{
152
+ color: #7cc575;
153
+ }
154
+ </style>
155
+
156
+
157
+ <div class="container-fluid">
158
+ <div class="mt-3"></div>
159
+ <div class="row">
160
+ <div class="col-sm-9">
161
+ <form action="" method="post">
162
+
163
+ <div class="form-group row" style="margin-bottom: 0;">
164
+ <label for="enable_log_data" class="col-sm-3 col-form-label text-right"><?php _e( 'Enable Log Information', 'subscribe-to-comments-reloaded' ) ?></label>
165
+ <div class="col-sm-7">
166
+ <div class="switch">
167
+ <input type="radio" class="switch-input" name="options[enable_log_data]"
168
+ value="yes" id="enable_log_data-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_log_data' ) == 'yes' ) ? ' checked' : ''; ?> />
169
+ <label for="enable_log_data-yes" class="switch-label switch-label-off">
170
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
171
+ </label>
172
+ <input type="radio" class="switch-input" name="options[enable_log_data]" value="no" id="enable_log_data-no"
173
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'enable_log_data' ) == 'no' ) ? ' checked' : ''; ?> />
174
+ <label for="enable_log_data-no" class="switch-label switch-label-on">
175
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
176
+ </label>
177
+ <span class="switch-selection"></span>
178
+ </div>
179
+
180
+ <div class="helpDescription subsOptDescriptions"
181
+ data-content="<?php _e( "If enabled, will log information of the plugin. Helpful for debugging purposes.<p>The file is stored under the path <code>Plugins Dir>subscribe-to-comments-reloaded>utils>log.txt</code></code></p>", 'subscribe-to-comments-reloaded' ); ?>"
182
+ data-placement="right"
183
+ aria-label="<?php _e( "If enabled, will log information of the plugin. Helpful for debugging purposes.", 'subscribe-to-comments-reloaded' ); ?>">
184
+ <i class="fas fa-question-circle"></i>
185
+ </div>
186
+ </div>
187
+ </div>
188
+
189
+ <div class="form-group row" style="margin-bottom: 0;">
190
+ <label for="auto_clean_log_data" class="col-sm-3 col-form-label text-right"><?php _e( 'Enable Auto clean log data', 'subscribe-to-comments-reloaded' ) ?></label>
191
+ <div class="col-sm-7">
192
+ <div class="switch">
193
+ <input type="radio" class="switch-input" name="options[auto_clean_log_data]"
194
+ value="yes" id="auto_clean_log_data-yes" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_data' ) == 'yes' ) ? ' checked' : ''; ?> />
195
+ <label for="auto_clean_log_data-yes" class="switch-label switch-label-off">
196
+ <?php _e( 'Yes', 'subscribe-to-comments-reloaded' ) ?>
197
+ </label>
198
+ <input type="radio" class="switch-input" name="options[auto_clean_log_data]" value="no" id="auto_clean_log_data-no"
199
+ <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_data' ) == 'no' ) ? ' checked' : ''; ?> />
200
+ <label for="auto_clean_log_data-no" class="switch-label switch-label-on">
201
+ <?php _e( 'No', 'subscribe-to-comments-reloaded' ) ?>
202
+ </label>
203
+ <span class="switch-selection"></span>
204
+ </div>
205
+
206
+ <select class="auto_clean_log_frecuency form-control form-control-select" name="options[auto_clean_log_frecuency]">
207
+ <option value="hourly" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_frecuency' ) === 'hourly' ) ? "selected='selected'" : ''; ?>><?php _e( 'Hourly', 'subscribe-to-comments-reloaded' ); ?></option>
208
+ <option value="twicedaily" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_frecuency' ) === 'twicedaily' ) ? "selected='selected'" : ''; ?>><?php _e( 'Twice Daily', 'subscribe-to-comments-reloaded' ); ?></option>
209
+ <option value="daily" <?php echo ( $wp_subscribe_reloaded->stcr->utils->stcr_get_menu_options( 'auto_clean_log_frecuency' ) === 'daily' ) ? "selected='selected'" : ''; ?>><?php _e( 'Daily', 'subscribe-to-comments-reloaded' ); ?></option>
210
+ </select>
211
+
212
+ <div class="helpDescription subsOptDescriptions"
213
+ data-content="<?php _e( "If enabled, StCR will auto clean your information according to the frequency that you defined on the dropdown.", 'subscribe-to-comments-reloaded' ); ?>"
214
+ data-placement="right"
215
+ aria-label="<?php _e( "If enabled, StCR will auto clean your information according to the frequency that you defined on the dropdown.", 'subscribe-to-comments-reloaded' ); ?>">
216
+ <i class="fas fa-question-circle"></i>
217
+ </div>
218
+ </div>
219
+ </div>
220
+
221
+ <div class="form-group row">
222
+ <label for="purge_log" class="col-sm-3 col-form-label text-right">
223
+ <?php _e( 'Clean Up Log Archive', 'subscribe-to-comments-reloaded' ) ?></label>
224
+ <div class="col-sm-7">
225
+
226
+ <span style="font-size: 0.9rem;"><?php _e(
227
+ "If you want to clean up the log archive please click the following button",
228
+ 'subscribe-to-comments-reloaded'
229
+ ); ?>
230
+ </span>
231
+
232
+ <?php wp_nonce_field( 'stcr_purge_log_nonce', 'stcr_purge_log_nonce' ); ?>
233
+ <input type='submit' id="purge_log" value='<?php esc_attr_e( 'Clean' ); ?>' class='btn btn-secondary subscribe-form-button' name='purge_log' >
234
+ </div>
235
+ </div>
236
+
237
+ <div class="form-group row">
238
+ <label for="generate_system_info" class="col-sm-3 col-form-label text-right">
239
+ <?php _e( 'Download System Info File', 'subscribe-to-comments-reloaded' ) ?></label>
240
+ <div class="col-sm-7">
241
+ <a class="download_report btn btn-download subscribe-form-button" href="#">
242
+ <?php _e( 'Download', 'subscribe-to-comments-reloaded' ); ?>
243
+ </a>
244
+ </div>
245
+ </div>
246
+
247
+ <div class="form-group row">
248
+ <div class="col-sm-9 offset-sm-3">
249
+ <button type="submit" class="btn btn-primary subscribe-form-button" name="Submit">
250
+ <?php _e( 'Save Changes', 'subscribe-to-comments-reloaded' ) ?>
251
+ </button>
252
+ </div>
253
+ </div>
254
+
255
+ <h4><?php _e( 'System Information', 'subscribe-to-comments-reloaded' ) ?></h4><br>
256
+
257
+ <!-- Plugin Info -->
258
+ <?php
259
+ // get the total number of subscribers and subscriptions
260
+ $total_subscribers = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}subscribe_reloaded_subscribers");
261
+ $total_subscriptions = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}postmeta where meta_key LIKE '_stcr@_%'");
262
+ ?>
263
+ <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
264
+ <thead style="background-color: #4688d2; color: #ffffff;">
265
+ <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Plugin Info', 'subscribe-to-comments-reloaded' ) ?></th>
266
+ </thead>
267
+ <tbody>
268
+ <tr>
269
+ <td class="text-left"><?php _e( 'Subscribers', 'subscribe-toc-omments-reloaded' ); ?></td>
270
+ <td class="text-left"><?php echo $total_subscribers; ?></td>
271
+ </tr>
272
+ <tr>
273
+ <td class="text-left"><?php _e( 'Subscriptions', 'subscribe-toc-omments-reloaded' ); ?></td>
274
+ <td class="text-left"><?php echo $total_subscriptions; ?></td>
275
+ </tr>
276
+ </tbody>
277
+ </table>
278
+
279
+ <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
280
+ <thead style="background-color: #4688d2; color: #ffffff;">
281
+ <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'WordPress Environment', 'subscribe-to-comments-reloaded' ) ?></th>
282
+ </thead>
283
+ <?php
284
+
285
+ $memory = $wp_subscribe_reloaded->stcr->utils->to_num_ini_notation( WP_MEMORY_LIMIT );
286
+ $memoryValue = '';
287
+ $wpDebug = 'No';
288
+ $wpCron = 'No';
289
+ $wpHome = get_option( 'home' );
290
+ $wpsiteurl = get_option( 'siteurl' );
291
+ $wpVersion = get_bloginfo( 'version' );
292
+ $wpMultisite = is_multisite();
293
+ $wpLanguage = get_locale();
294
+ $wpPermalink = esc_html( get_option( 'permalink_structure' ) );
295
+ $wpTablePrefix = esc_html( $wpdb->prefix );
296
+ $wpTablePrefixLength = strlen( $wpdb->prefix );
297
+ $wpTablePrefixStatus = $wpTablePrefixLength > 16 ? esc_html( 'Error: Too long', 'subscribe-to-comments-reloaded' ) : esc_html( 'Acceptable', 'subscribe-to-comments-reloaded' );
298
+ $wpRegisteredPostStatuses = esc_html( implode( ', ', get_post_stati() ) );
299
+
300
+ $stcr_system_information['Wordpress Environment']["Home URL"] = $wpHome;
301
+ $stcr_system_information['Wordpress Environment']["Site URL"] = $wpsiteurl;
302
+ $stcr_system_information['Wordpress Environment']["WordPress Version"] = $wpVersion;
303
+ $stcr_system_information['Wordpress Environment']["Multisite"] = $wpMultisite;
304
+ $stcr_system_information['Wordpress Environment']["Language"] = $wpLanguage;
305
+ $stcr_system_information['Wordpress Environment']["Permalink Structure"] = $wpPermalink;
306
+ $stcr_system_information['Wordpress Environment']["Table Prefix"] = $wpTablePrefix;
307
+ $stcr_system_information['Wordpress Environment']["Table Prefix Length"] = $wpTablePrefixLength;
308
+ $stcr_system_information['Wordpress Environment']["Table Prefix Status"] = $wpTablePrefixStatus;
309
+ $stcr_system_information['Wordpress Environment']["Registered Post Statuses"] = $wpRegisteredPostStatuses;
310
+
311
+
312
+
313
+ if ( function_exists( 'memory_get_usage' ) ) {
314
+ $system_memory = $wp_subscribe_reloaded->stcr->utils->to_num_ini_notation( @ini_get( 'memory_limit' ) );
315
+ $memory = max( $memory, $system_memory );
316
+ }
317
+
318
+ if ( $memory < 67108864 ) {
319
+ $memoryValue = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend setting memory to at least 64 MB. See: %s', 'subscribe-to-comments-reloaded' ), size_format( $memory ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . __( 'Increasing memory allocated to PHP', 'subscribe-to-comments-reloaded' ) . '</a>' ) . '</div>';
320
+ $stcr_system_information['Wordpress Environment']["Memory Limit"] = "Memory under 64MB";
321
+ }
322
+ else {
323
+ $memoryValue = '<div class="system-success">' . size_format( $memory ) . '</div>';
324
+ $stcr_system_information['Wordpress Environment']["Memory Limit"] = size_format( $memory );
325
+ }
326
+ // Check if Debug is Enable
327
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG )
328
+ {
329
+ $wpDebug = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
330
+ $stcr_system_information['Wordpress Environment']["WP Debug Mode"] = true;
331
+ }
332
+ else
333
+ {
334
+ $wpDebug = '<div>'. $wpDebug .'</div>';
335
+ $stcr_system_information['Wordpress Environment']["WP Debug Mode"] = false;
336
+ }
337
+ // Check if WP Cron is Enable
338
+ if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON )
339
+ {
340
+ $wpCron = '<div>'. $wpCron .'</div>';
341
+ $stcr_system_information['Wordpress Environment']["WP Cron"] = true;
342
+ }
343
+ else
344
+ {
345
+ $wpCron = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
346
+ $stcr_system_information['Wordpress Environment']["WP Cron"] = false;
347
+ }
348
+
349
+ $wordpressEnvironment = array(
350
+ 1 => array(
351
+ __( "Home URL", 'subscribe-to-comments-reloaded' ),
352
+ $wpHome
353
+ ),
354
+ 2 => array(
355
+ __( "Site URL", 'subscribe-to-comments-reloaded' ),
356
+ $wpsiteurl
357
+ ),
358
+ 3 => array(
359
+ __( "WordPress Version", 'subscribe-to-comments-reloaded' ),
360
+ $wpVersion
361
+ ),
362
+ 4 => array(
363
+ "Multisite",
364
+ $wpMultisite ? '<span class="dashicons dashicons-yes"></span>' : 'No'
365
+ ),
366
+ 5 => array(
367
+ __( "Memory Limit", 'subscribe-to-comments-reloaded' ),
368
+ $memoryValue
369
+ ),
370
+ 6 => array(
371
+ __( "WP Debug Mode", 'subscribe-to-comments-reloaded' ),
372
+ $wpDebug
373
+ ),
374
+ 7 => array(
375
+ __( "WP Cron", 'subscribe-to-comments-reloaded' ),
376
+ $wpCron
377
+ ),
378
+ 8 => array(
379
+ __( "Language", 'subscribe-to-comments-reloaded' ),
380
+ $wpLanguage
381
+ ),
382
+ 9 => array(
383
+ __( "Permalink Structure", 'subscribe-to-comments-reloaded' ),
384
+ $wpPermalink
385
+ ),
386
+ 10 => array(
387
+ __( "Table Prefix", 'subscribe-to-comments-reloaded' ),
388
+ $wpTablePrefix
389
+ ),
390
+ 11 => array(
391
+ __( "Table Prefix Length", 'subscribe-to-comments-reloaded' ),
392
+ $wpTablePrefixLength
393
+ ),
394
+ 12 => array(
395
+ __( "Table Prefix Status", 'subscribe-to-comments-reloaded' ),
396
+ $wpTablePrefixStatus
397
+ ),
398
+ 13 => array(
399
+ __( "Registered Post Statuses", 'subscribe-to-comments-reloaded' ),
400
+ $wpRegisteredPostStatuses
401
+ )
402
+ );
403
+ ?>
404
+ <tbody>
405
+ <?php
406
+ foreach ( $wordpressEnvironment as $key => $opt )
407
+ {
408
+ echo "<tr>";
409
+ echo "<td class='text-left' style='min-width: 50px;'>{$opt[0]}</td>";
410
+ echo "<td class='text-left'>{$opt[1]}</td>";
411
+ echo "</tr>";
412
+ }
413
+ ?>
414
+ </tbody>
415
+ </table>
416
+
417
+ <!-- Server Environment -->
418
+ <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
419
+ <thead style="background-color: #4688d2; color: #ffffff;">
420
+ <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Server Environment', 'subscribe-to-comments-reloaded' ) ?></th>
421
+ </thead>
422
+ <?php
423
+
424
+ $tlsCheck = false;
425
+ $tlsCheckValue = __( 'Cannot Evaluate', 'subscribe-to-comments-reloaded' );
426
+ $tlsRating = __( 'Not Available', 'subscribe-to-comments-reloaded' );
427
+ $phpVersion = __( 'Not Available', 'subscribe-to-comments-reloaded' );
428
+ $cURLVersion = __( 'Not Available', 'subscribe-to-comments-reloaded' );
429
+ $MySQLSVersion = __( 'Not Available', 'subscribe-to-comments-reloaded' );
430
+ $defaultTimezone = __( 'Not Available', 'subscribe-to-comments-reloaded' );
431
+ $serverInfo = esc_html( $_SERVER['SERVER_SOFTWARE'] );
432
+ $maxPostSize = size_format( $wp_subscribe_reloaded->stcr->utils->to_num_ini_notation( ini_get( 'post_max_size' ) ) );
433
+
434
+ // Get the SSL status.
435
+ if ( ini_get( 'allow_url_fopen' ) ) {
436
+ $tlsCheck = file_get_contents( 'https://www.howsmyssl.com/a/check' );
437
+ }
438
+
439
+ if ( false !== $tlsCheck )
440
+ {
441
+ $tlsCheck = json_decode( $tlsCheck );
442
+ /* translators: %s: SSL connection response */
443
+ $tlsCheckValue = sprintf( __( 'Connection uses %s', 'subscribe-to-comments-reloaded' ), esc_html( $tlsCheck->tls_version ) );
444
+ }
445
+ $stcr_system_information['Server Environment']["TLS Connection"] = $tlsCheckValue;
446
+ // Check TSL Rating
447
+ if ( false !== $tlsCheck )
448
+ {
449
+ $tlsRating = property_exists( $tlsCheck, 'rating' ) ? $tlsCheck->rating : $tlsCheck->tls_version;
450
+ }
451
+ $stcr_system_information['Server Environment']["TLS Rating"] = $tlsRating;
452
+ $stcr_system_information['Server Environment']["Server Info"] = $serverInfo;
453
+ // Check the PHP Version
454
+ if ( function_exists( 'phpversion' ) )
455
+ {
456
+ $phpVersion = phpversion();
457
+
458
+ if ( version_compare( $phpVersion, '5.6', '<' ) )
459
+ {
460
+ $phpVersion = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum PHP version of 5.6. See: %s', 'subscribe-to-comments-reloaded' ), esc_html( $phpVersion ), '<a href="http://subscribe-reloaded.com/about/" target="_blank">' . __( 'PHP Requirements in StCR', 'subscribe-to-comments-reloaded' ) . '</a>' ) . '</div>';
461
+ $stcr_system_information['Server Environment']["PHP Version"] = sprintf( '%s - We recommend a minimum PHP version of 5.6. See: %s', esc_html( $phpVersion ), '<a href="http://subscribe-reloaded.com/about/" target="_blank">PHP Requirements in StCR</a>' );
462
+ }
463
+ else
464
+ {
465
+ $phpVersion = '<div class="system-success">' . esc_html( $phpVersion ) . '</div>';
466
+ $stcr_system_information['Server Environment']["PHP Version"] = phpversion();
467
+ }
468
+ }
469
+ else
470
+ {
471
+ $phpVersion = __( "Couldn't determine PHP version because the function phpversion() doesn't exist.", 'subscribe-to-comments-reloaded' );
472
+ $stcr_system_information['Server Environment']["PHP Version"] = "Couldn't determine PHP version because the function phpversion() doesn't exist.";
473
+ }
474
+
475
+ $stcr_system_information['Server Environment']["PHP Post Max Size"] = $maxPostSize;
476
+ $stcr_system_information['Server Environment']["PHP Max Execution Time"] = ini_get( 'max_execution_time' );
477
+ $stcr_system_information['Server Environment']["PHP Max Input Vars"] = ini_get( 'max_input_vars' );
478
+ $stcr_system_information['Server Environment']["PHP Max Upload Size"] = size_format( wp_max_upload_size() );
479
+
480
+ // Check the cURL Version
481
+ if ( function_exists( 'curl_version' ) )
482
+ {
483
+ $cURLVersion = curl_version();
484
+ $cURLVersionNumber = $cURLVersion['version'];
485
+ $cURLSSLVersion = $cURLVersion['ssl_version'];
486
+
487
+ if ( version_compare( $cURLVersionNumber, '7.40', '<' ) )
488
+ {
489
+ $cURLVersion = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s - We recommend a minimum cURL version of 7.40.', 'subscribe-to-comments-reloaded' ), esc_html( $cURLVersionNumber . ', ' . $cURLSSLVersion ) ) . '</div>';
490
+ $stcr_system_information['Server Environment']["cURL Version"] = sprintf('%s - We recommend a minimum cURL version of 7.40.', esc_html( $cURLVersionNumber . ', ' . $cURLSSLVersion ) );
491
+ }
492
+ else
493
+ {
494
+ $cURLVersion = '<div class="system-success">' . esc_html( $cURLVersionNumber ) . '</div>';
495
+ $stcr_system_information['Server Environment']["cURL Version"] = $cURLVersion;
496
+ }
497
+ }
498
+ else
499
+ {
500
+ $cURLVersion = '&ndash;';
501
+ $stcr_system_information['Server Environment']["cURL Version"] = 'cURL is not available';
502
+ }
503
+
504
+ // check MySQL version
505
+ global $wp_version, $required_mysql_version;
506
+ if ( version_compare( $wpdb->db_version(), $required_mysql_version, '<' ) ) {
507
+ $MySQLSVersion = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ) . '</div>';
508
+ $stcr_system_information['Server Environment']["MySQL Version"] = $wpdb->db_version();
509
+ } else {
510
+ $MySQLSVersion = '<div class="system-success">' . $wpdb->db_version() . '</div>';
511
+ $stcr_system_information['Server Environment']["MySQL Version"] = $wpdb->db_version();
512
+ }
513
+
514
+ // Get the Timezone
515
+ $defaultTimezone = date_default_timezone_get();
516
+
517
+ if ( 'UTC' !== $defaultTimezone )
518
+ {
519
+ $defaultTimezone = '<div class="system-error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'subscribe-to-comments-reloaded' ), $defaultTimezone ) . '</div>';
520
+ $stcr_system_information['Server Environment']["Default Timezone is UTC"] = sprintf('Default timezone is %s - it should be UTC', $defaultTimezone );
521
+ }
522
+ else
523
+ {
524
+ $defaultTimezone = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
525
+ $stcr_system_information['Server Environment']["Default Timezone is UTC"] = "Yes";
526
+ }
527
+ // DOMDocument
528
+ $DOMDocument = __( 'Not Available', 'subscribe-to-comments-reloaded' );
529
+ if ( class_exists( 'DOMDocument' ) )
530
+ {
531
+ $DOMDocument = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
532
+ $stcr_system_information['Server Environment']["DOMDocument"] = "Yes";
533
+ }
534
+ else {
535
+ $DOMDocument = sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'subscribe-to-comments-reloaded' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' );
536
+ $stcr_system_information['Server Environment']["DOMDocument"] = sprintf( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' );
537
+ }
538
+ // Check gzip
539
+ $gzip = __( 'Not Available', 'subscribe-to-comments-reloaded' );
540
+ if ( is_callable( 'gzopen' ) )
541
+ {
542
+ $gzip = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
543
+ $stcr_system_information['Server Environment']["gzip"] = "Yes";
544
+ }
545
+ else {
546
+ $gzip = sprintf( __( 'Your server does not support the %s function - this is used for file compression and decompression.', 'subscribe-to-comments-reloaded' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' );
547
+ $stcr_system_information['Server Environment']["gzip"] = sprintf( 'Your server does not support the %s function - this is used for file compression and decompression.', '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' );
548
+ }// Check GD
549
+ $gd = __( 'Not Available', 'subscribe-to-comments-reloaded' );
550
+ if ( extension_loaded( 'gd' ) && function_exists( 'gd_info' ) )
551
+ {
552
+ $gd = '<div class="system-success"><span class="dashicons dashicons-yes"></span></div>';
553
+ $stcr_system_information['Server Environment']["GD Graphics Library"] = "Yes";
554
+ }
555
+ else {
556
+ $gd = '<div class="system-error"><span class="dashicons dashicons-no"></span></div>';
557
+ $stcr_system_information['Server Environment']["GD Graphics Library"] = "No";
558
+ }
559
+
560
+ // Define array of values
561
+ $serverEnvironment = array(
562
+ 1 => array(
563
+ __( "TLS Connection", 'subscribe-to-comments-reloaded' ),
564
+ $tlsCheckValue
565
+ ),
566
+ 2 => array(
567
+ __( "TLS Rating", 'subscribe-to-comments-reloaded' ),
568
+ $tlsRating
569
+ ),
570
+ 3 => array(
571
+ __( "Server Info", 'subscribe-to-comments-reloaded' ),
572
+ $serverInfo
573
+ ),
574
+ 4 => array(
575
+ __( "PHP Version", 'subscribe-to-comments-reloaded' ),
576
+ $phpVersion
577
+ ),
578
+ 5 => array(
579
+ __( "PHP Post Max Size", 'subscribe-to-comments-reloaded' ),
580
+ $maxPostSize
581
+ ),
582
+ 6 => array(
583
+ __( "PHP Max Execution Time", 'subscribe-to-comments-reloaded' ),
584
+ ini_get( 'max_execution_time' )
585
+ ),
586
+ 7 => array(
587
+ __( "PHP Max Input Vars", 'subscribe-to-comments-reloaded' ),
588
+ ini_get( 'max_input_vars' )
589
+ ),
590
+ 8 => array(
591
+ __( "PHP Max Upload Size", 'subscribe-to-comments-reloaded' ),
592
+ size_format( wp_max_upload_size() )
593
+ ),
594
+ 9 => array(
595
+ __( "cURL Version", 'subscribe-to-comments-reloaded' ),
596
+ $cURLVersion
597
+ ),
598
+ 10 => array(
599
+ __( "MySQL Version", 'subscribe-to-comments-reloaded' ),
600
+ $MySQLSVersion
601
+ ),
602
+ 11 => array(
603
+ __( "Default Timezone is UTC", 'subscribe-to-comments-reloaded' ),
604
+ $defaultTimezone
605
+ ),
606
+ 12 => array(
607
+ __( "DOMDocument", 'subscribe-to-comments-reloaded' ),
608
+ $DOMDocument
609
+ ),
610
+ 13 => array(
611
+ __( "gzip", 'subscribe-to-comments-reloaded' ),
612
+ $gzip
613
+ ),
614
+ 14 => array(
615
+ __( "GD Graphics Library", 'subscribe-to-comments-reloaded' ),
616
+ $gd
617
+ )
618
+ );
619
+ ?>
620
+ <tbody>
621
+ <?php
622
+ foreach ( $serverEnvironment as $key => $opt )
623
+ {
624
+ echo "<tr>";
625
+ echo "<td class='text-left' style='min-width: 50px;'>{$opt[0]}</td>";
626
+ echo "<td class='text-left'>{$opt[1]}</td>";
627
+ echo "</tr>";
628
+ }
629
+ ?>
630
+ </tbody>
631
+ </table>
632
+ <?php
633
+ $plugins = $wp_subscribe_reloaded->stcr->utils->stcr_get_plugins();
634
+ $installed_plugins = array();
635
+ ?>
636
+ <!-- Active Plugins -->
637
+ <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
638
+ <thead style="background-color: #4688d2; color: #ffffff;">
639
+ <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Active Plugins', 'subscribe-to-comments-reloaded' ) ?></th>
640
+ </thead>
641
+
642
+ <tbody>
643
+ <?php
644
+
645
+ foreach ( $plugins as $plugin_data )
646
+ {
647
+ // Filter only the Active plugins
648
+ if ('active' !== $plugin_data['Status'] )
649
+ {
650
+ continue;
651
+ }
652
+
653
+ $plugin_name = $plugin_data['Name'];
654
+ $author_name = $plugin_data['Author'];
655
+
656
+ $installed_plugins[] = array(
657
+ "plugin-name" => $plugin_name,
658
+ "plugin-author" => $author_name
659
+ );
660
+
661
+ // Link the plugin name to the plugin URL if available.
662
+ if ( ! empty( $plugin_data['PluginURI'] ) ) {
663
+ $plugin_name = sprintf(
664
+ '<a href="%s" title="%s">%s</a>',
665
+ esc_url( $plugin_data['PluginURI'] ),
666
+ esc_attr__( 'Visit plugin homepage', 'subscribe-to-comments-reloaded' ),
667
+ $plugin_name
668
+ );
669
+ }
670
+ // Link the author name to the author URL if available.
671
+ if ( ! empty( $plugin_data['AuthorURI'] ) ) {
672
+ $author_name = sprintf(
673
+ '<a href="%s" title="%s">%s</a>',
674
+ esc_url( $plugin_data['AuthorURI'] ),
675
+ esc_attr__( 'Visit author homepage', 'subscribe-to-comments-reloaded' ),
676
+ $author_name
677
+ );
678
+
679
+ $author_name = sprintf( _x( 'by %s', 'by author', 'subscribe-to-comments-reloaded' ),
680
+ wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ) . ' &ndash; '
681
+ . esc_html( $plugin_data['Version'] );
682
+ }
683
+ echo "<tr>";
684
+ echo "<td class='text-left' style='min-width: 50px;'>{$plugin_name}</td>";
685
+ echo "<td class='text-left'>{$author_name}</td>";
686
+ echo "</tr>";
687
+ $stcr_system_information['WordPress Active Plugins'][$plugin_data['Name']] = $plugin_data;
688
+ }
689
+
690
+ ?>
691
+ </tbody>
692
+ </table>
693
+ <!-- Inactive Plugins -->
694
+ <table class="table table-sm table-hover table-striped system-info-table" style="font-size: 0.8em">
695
+ <thead style="background-color: #4688d2; color: #ffffff;">
696
+ <th style="textalilfe" class="text-left" colspan="2"><?php _e( 'Inactive Plugins', 'subscribe-to-comments-reloaded' ) ?></th>
697
+ </thead>
698
+
699
+ <tbody>
700
+ <?php
701
+
702
+ foreach ( $plugins as $plugin_data )
703
+ {
704
+ // Filter only the Inactive plugins
705
+ if ('inactive' !== $plugin_data['Status'] )
706
+ {
707
+ continue;
708
+ }
709
+
710
+ $plugin_name = $plugin_data['Name'];
711
+ $author_name = $plugin_data['Author'];
712
+
713
+ $installed_plugins[] = array(
714
+ "plugin-name" => $plugin_name,
715
+ "plugin-author" => $author_name
716
+ );
717
+
718
+ // Link the plugin name to the plugin URL if available.
719
+ if ( ! empty( $plugin_data['PluginURI'] ) ) {
720
+ $plugin_name = sprintf(
721
+ '<a href="%s" title="%s">%s</a>',
722
+ esc_url( $plugin_data['PluginURI'] ),
723
+ esc_attr__( 'Visit plugin homepage', 'subscribe-to-comments-reloaded' ),
724
+ $plugin_name
725
+ );
726
+ }
727
+ // Link the author name to the author URL if available.
728
+ if ( ! empty( $plugin_data['AuthorURI'] ) ) {
729
+ $author_name = sprintf(
730
+ '<a href="%s" title="%s">%s</a>',
731
+ esc_url( $plugin_data['AuthorURI'] ),
732
+ esc_attr__( 'Visit author homepage', 'subscribe-to-comments-reloaded' ),
733
+ $author_name
734
+ );
735
+
736
+ $author_name = sprintf( _x( 'by %s', 'by author', 'subscribe-to-comments-reloaded' ),
737
+ wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ) . ' &ndash; '
738
+ . esc_html( $plugin_data['Version'] );
739
+ }
740
+ echo "<tr>";
741
+ echo "<td class='text-left' style='min-width: 50px;'>{$plugin_name}</td>";
742
+ echo "<td class='text-left'>{$author_name}</td>";
743
+ echo "</tr>";
744
+ $stcr_system_information['WordPress Inactive Plugins'][$plugin_data['Name']] = $plugin_data;
745
+ }
746
+ ?>
747
+ </tbody>
748
+ </table>
749
+
750
+ <?php wp_nonce_field( 'stcr_save_system_nonce', 'stcr_save_system_nonce' ); ?>
751
+
752
+ </form>
753
+
754
+ <form name="stcr_sysinfo_form" class="stcr-hidden" action="<?php echo esc_url( admin_url( 'admin.php?page=stcr_system' ) ); ?>" method="post">
755
+ <input type="hidden" name="stcr_sysinfo_action" value="download_sysinfo" />
756
+ <textarea name="stcr_sysinfo" readonly><?php echo serialize( $stcr_system_information ); ?></textarea>
757
+ <?php wp_nonce_field( 'stcr_download_sysinfo_nonce', 'stcr_download_sysinfo_nonce' ); ?>
758
+ </form>
759
+
760
+ </div>
761
+
762
+ <div class="col-md-3">
763
+ <div class="card card-font-size">
764
+ <div class="card-body">
765
+ <p>
766
+ Thank you for using Subscribe to Comments Reloaded. You can Support the plugin by rating it
767
+ <a href="https://wordpress.org/support/plugin/subscribe-to-comments-reloaded/reviews/#new-post" target="_blank"><img src="<?php echo esc_url( plugins_url( '/images/rate.png', STCR_PLUGIN_FILE ) ); ?>" alt="Rate Subscribe to Comments Reloaded" style="vertical-align: sub;" /></a>
768
+ </p>
769
+ <p>
770
+ <i class="fas fa-bug"></i> Having issues? Please <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues/" target="_blank">create a ticket</a>
771
+ </p>
772
+ </div>
773
+ </div>
774
+ </div>
775
+
776
+ </div>
777
+ </div>
778
+ <script type="text/javascript" src="<?php echo esc_url( plugins_url( '/vendor/webui-popover/dist/jquery.webui-popover.min.js', STCR_PLUGIN_FILE ) ); ?>"></script>
779
+ <?php
780
+ //global $wp_subscribe_reloaded;
781
+ // Tell WP that we are going to use a resource.
782
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-system-info", "stcr_system.js", "includes/js/admin");
783
+ $wp_subscribe_reloaded->stcr->utils->register_script_to_wp( "stcr-subs-options", "subs_options.js", "includes/js/admin");
784
+ // Includes the Panel JS resource file as well as the JS text domain translations.
785
+ //$wp_subscribe_reloaded->stcr->stcr_i18n->stcr_localize_script( "stcr-system-info", "stcr_i18n", $wp_subscribe_reloaded->stcr->stcr_i18n->get_js_subs_translation() );
786
+ // Enqueue the JS File
787
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-system-info" );
788
+ $wp_subscribe_reloaded->stcr->utils->enqueue_script_to_wp( "stcr-subs-options" );
789
+
790
+ ?>
readme.txt CHANGED
@@ -6,8 +6,8 @@ Plugin URI: http://subscribe-reloaded.com/
6
  Requires at least: 4.0
7
  Requires PHP: 5.6
8
  Requires MySQL: 5.6
9
- Tested up to: 5.8
10
- Stable tag: 211130
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -95,6 +95,14 @@ Just go to the Options Panel and click the generate button. By generating a new
95
  7. Manage the subscriptions on the Frontend Side.
96
 
97
  == Changelog ==
 
 
 
 
 
 
 
 
98
  = v211130 =
99
  * **Fix** Removed custom error handler (thanks to JakeQZ for bringing the issue to our attention)
100
  * **Fix** Processing form submission in subscribe.php is now stopped in case "subscribe without commenting" is enabled
6
  Requires at least: 4.0
7
  Requires PHP: 5.6
8
  Requires MySQL: 5.6
9
+ Tested up to: 5.9
10
+ Stable tag: 220502
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
95
  7. Manage the subscriptions on the Frontend Side.
96
 
97
  == Changelog ==
98
+ = v220502 =
99
+ * **Important** Security fixes
100
+ * **New** Option to set for which post types the subscription will be available
101
+ * **New** Option to define blacklisted emails (that won't be allowed to subscribe). Option located in WP Admin > StCR > Options.
102
+ * **Improvement** reCaptcha v3 now available
103
+ * **Fix** General code improvements
104
+ * **Fix** Issue with "comment-subscriptions" page showing a 404 error
105
+
106
  = v211130 =
107
  * **Fix** Removed custom error handler (thanks to JakeQZ for bringing the issue to our attention)
108
  * **Fix** Processing form submission in subscribe.php is now stopped in case "subscribe without commenting" is enabled
subscribe-to-comments-reloaded.php CHANGED
@@ -1,82 +1,87 @@
1
- <?php
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: 211130
6
- * Author: WPKube
7
- * Author URI: http://wpkube.com/
8
- * License: GPL-2.0+
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- * Text Domain: subscribe-to-comments-reloaded
11
- * Domain Path: /langs
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() {
53
- require_once dirname(__FILE__).'/utils/stcr_manage.php';
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() {
64
- require_once dirname(__FILE__).'/utils/stcr_manage.php';
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
- }
 
 
 
 
 
1
+ <?php
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: 220502
6
+ * Author: WPKube
7
+ * Author URI: http://wpkube.com/
8
+ * License: GPL-2.0+
9
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ * Text Domain: subscribe-to-comments-reloaded
11
+ * Domain Path: /langs
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
+ // Define the main plugin constant file.
23
+ if ( ! defined( 'STCR_PLUGIN_FILE' ) ) {
24
+ define( 'STCR_PLUGIN_FILE', __FILE__ );
25
+ }
26
+
27
+ require_once dirname( STCR_PLUGIN_FILE ) . '/wp_subscribe_reloaded.php';
28
+
29
+ if( ! class_exists( '\\'.__NAMESPACE__.'\\stcr_subscribe_reloaded' ) ) {
30
+
31
+ /**
32
+ * Main plugin class
33
+ *
34
+ * @since 150720
35
+ */
36
+ class stcr_subscribe_reloaded {
37
+
38
+ const CLASSNAME = __CLASS__; // http://www.garfieldtech.com/blog/class-constants-php54
39
+
40
+ public $stcr = null;
41
+
42
+ /**
43
+ * Constructor
44
+ *
45
+ * @since 150720
46
+ */
47
+ function __construct() {
48
+ $this->stcr = new wp_subscribe_reloaded();
49
+ $this->stcr->set_user_cookie();
50
+ }
51
+
52
+ /**
53
+ * This will trigger the activate function located on utils/stcr_manage.php
54
+ *
55
+ * @since 150720
56
+ */
57
+ static function activate() {
58
+ require_once dirname( STCR_PLUGIN_FILE ) . '/utils/stcr_manage.php';
59
+ $_stcra = new stcr_manage();
60
+ $_stcra->activate();
61
+ }
62
+
63
+ /**
64
+ * This will trigger the deactivate function located on utils/stcr_manage.php
65
+ *
66
+ * @since 150720
67
+ */
68
+ static function deactivate() {
69
+ require_once dirname( STCR_PLUGIN_FILE ) . '/utils/stcr_manage.php';
70
+ $_stcrd = new stcr_manage();
71
+ $_stcrd->deactivate();
72
+ }
73
+
74
+ }
75
+
76
+ // plugin activation
77
+ register_activation_hook( STCR_PLUGIN_FILE, array( \stcr\stcr_subscribe_reloaded::CLASSNAME , 'activate' ) );
78
+
79
+ // plugin deactivation
80
+ register_deactivation_hook( STCR_PLUGIN_FILE, array( \stcr\stcr_subscribe_reloaded::CLASSNAME , 'deactivate' ) );
81
+
82
+ // instantiate stcr_subscribe_reloaded class
83
+ if ( ! isset( $GLOBALS['wp_subscribe_reloaded'] ) ) {
84
+ $GLOBALS['wp_subscribe_reloaded'] = new stcr_subscribe_reloaded();
85
+ }
86
+
87
+ }
templates/key_expired.php CHANGED
@@ -1,86 +1,92 @@
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
- $error_message = __( "Woohaa the link to manage your subscriptions has expired, don't worry, just enter your email below and a new link will be send.", 'subscribe-to-comments-reloaded');
9
-
10
- global $wp_subscribe_reloaded;
11
- ob_start();
12
-
13
- if ( isset( $_POST[ 'sre' ] ) && trim( $_POST[ 'sre' ] ) !== "" ) {
14
- $email = esc_attr( $_POST[ 'sre' ] );
15
- $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]' ) ), ENT_QUOTES, 'UTF-8' );
16
- $page_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_content', '' ) ), ENT_QUOTES, 'UTF-8' );
17
- $email_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_email_content', '' ) ), ENT_QUOTES, 'UTF-8' );
18
- $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
19
- $one_click_unsubscribe_link = $manager_link;
20
-
21
- if ( function_exists( 'qtrans_convertURL' ) ) {
22
- $manager_link = qtrans_convertURL( $manager_link );
23
- }
24
-
25
- $clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
26
- $subscriber_salt = $wp_subscribe_reloaded->stcr->utils->generate_temp_key( $clean_email );
27
-
28
- $manager_link .= ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?';
29
- $manager_link .= "srek=" . $wp_subscribe_reloaded->stcr->utils->get_subscriber_key($clean_email) . "&srk=$subscriber_salt&amp;srsrc=e";
30
- $one_click_unsubscribe_link .= ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?';
31
- $one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' ) . "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=$subscriber_salt" . "&sra=u" . "&srp=";
32
-
33
- // Replace tags with their actual values
34
- $subject = str_replace( '[blog_name]', get_bloginfo( 'name' ), $subject );
35
- // Setup the fronted page message
36
- $page_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $page_message );
37
- // Setup the email message
38
- $email_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $email_message );
39
- $email_message = str_replace( '[manager_link]', $manager_link, $email_message );
40
- $email_message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $email_message );
41
-
42
- if ( get_option( 'subscribe_reloaded_enable_html_emails', 'yes' ) == 'yes' ) {
43
- $email_message = wpautop( $email_message );
44
- }
45
-
46
- // QTranslate support
47
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
48
- $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
49
- $page_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $page_message );
50
- $email_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $email_message );
51
- }
52
- // Prepare email settings
53
- $email_settings = array(
54
- 'subject' => $subject,
55
- 'message' => $email_message,
56
- 'toEmail' => $clean_email
57
- );
58
- $wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
59
- echo wpautop( $page_message );
60
- }
61
- else
62
- {
63
- $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
64
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
65
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
66
- }
67
- ?>
68
- <p><?php echo wpautop( $error_message ); ?></p>
69
- <form action="<?php
70
- $url = $_SERVER[ 'REQUEST_URI' ];
71
- $url = preg_replace('/sre=\w+&|&key\_expired=\d+/', '', $url );
72
- echo esc_url( $url . "&key_expired=1" );
73
- ?>" name="sub-form" method="post">
74
- <fieldset style="border:0">
75
- <p><label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
76
- <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] ) : ''; ?>" size="22" onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue" />
77
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
78
- </p>
79
- </fieldset>
80
- </form>
81
- <?php
82
- }
83
- $output = ob_get_contents();
84
- ob_end_clean();
85
- return $output;
86
- ?>
 
 
 
 
 
 
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
+ $error_message = __( "Woohaa the link to manage your subscriptions has expired, don't worry, just enter your email below and a new link will be send.", 'subscribe-to-comments-reloaded');
9
+
10
+ global $wp_subscribe_reloaded;
11
+ ob_start();
12
+
13
+ if ( isset( $_POST[ 'sre' ] ) && trim( $_POST[ 'sre' ] ) !== "" ) {
14
+ $email = esc_attr( $_POST[ 'sre' ] );
15
+ $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]' ) ), ENT_QUOTES, 'UTF-8' );
16
+ $page_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_content', '' ) ), ENT_QUOTES, 'UTF-8' );
17
+ $email_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_email_content', '' ) ), ENT_QUOTES, 'UTF-8' );
18
+ $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
19
+ $one_click_unsubscribe_link = $manager_link;
20
+
21
+ if ( function_exists( 'qtrans_convertURL' ) ) {
22
+ $manager_link = qtrans_convertURL( $manager_link );
23
+ }
24
+
25
+ $clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
26
+ $subscriber_salt = $wp_subscribe_reloaded->stcr->utils->generate_temp_key( $clean_email );
27
+
28
+ $manager_link .= ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?';
29
+ $manager_link .= "srek=" . $wp_subscribe_reloaded->stcr->utils->get_subscriber_key($clean_email) . "&srk=$subscriber_salt&amp;srsrc=e";
30
+ $one_click_unsubscribe_link .= ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?';
31
+ $one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' ) . "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=$subscriber_salt" . "&sra=u" . "&srp=";
32
+
33
+ // Replace tags with their actual values
34
+ $subject = str_replace( '[blog_name]', get_bloginfo( 'name' ), $subject );
35
+ // Setup the fronted page message
36
+ $page_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $page_message );
37
+ // Setup the email message
38
+ $email_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $email_message );
39
+ $email_message = str_replace( '[manager_link]', $manager_link, $email_message );
40
+ $email_message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $email_message );
41
+
42
+ if ( get_option( 'subscribe_reloaded_enable_html_emails', 'yes' ) == 'yes' ) {
43
+ $email_message = wpautop( $email_message );
44
+ }
45
+
46
+ // QTranslate support
47
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
48
+ $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
49
+ $page_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $page_message );
50
+ $email_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $email_message );
51
+ }
52
+ // Prepare email settings
53
+ $email_settings = array(
54
+ 'subject' => $subject,
55
+ 'message' => $email_message,
56
+ 'toEmail' => $clean_email
57
+ );
58
+ $has_blacklist_email = $this->utils->blacklisted_emails( $clean_email );
59
+ // Send the confirmation email only if the email
60
+ // address is not in blacklist email list.
61
+ if ( $has_blacklist_email ) {
62
+ $wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
63
+ }
64
+
65
+ echo wpautop( $page_message );
66
+ }
67
+ else
68
+ {
69
+ $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
70
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
71
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
72
+ }
73
+ ?>
74
+ <p><?php echo wpautop( $error_message ); ?></p>
75
+ <form action="<?php
76
+ $url = $_SERVER[ 'REQUEST_URI' ];
77
+ $url = preg_replace('/sre=\w+&|&key\_expired=\d+/', '', $url );
78
+ echo esc_url( $url . "&key_expired=1" );
79
+ ?>" name="sub-form" method="post">
80
+ <fieldset style="border:0">
81
+ <p><label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
82
+ <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] ) : ''; ?>" size="22" onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue" />
83
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
84
+ </p>
85
+ </fieldset>
86
+ </form>
87
+ <?php
88
+ }
89
+ $output = ob_get_contents();
90
+ ob_end_clean();
91
+ return $output;
92
+ ?>
templates/request-management-link.php CHANGED
@@ -1,275 +1,331 @@
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
12
- $post_permalink = null;
13
- $current_user_email = null; // Comes from wp_subscribe-to-comments-reloaded\subscribe_reloaded_manage()
14
- $ID = $target_post;
15
- $valid_all = true;
16
- $valid_email = true;
17
- $valid_challenge = true;
18
-
19
- // google recaptcha
20
- $valid_captcha = true;
21
- $captcha_output = '';
22
- $use_captcha = get_option( 'subscribe_reloaded_use_captcha', 'no' );
23
- $captcha_site_key = get_option( 'subscribe_reloaded_captcha_site_key', '' );
24
- $captcha_secret_key = get_option( 'subscribe_reloaded_captcha_secret_key', '' );
25
-
26
- // google recaptcha confirm
27
- if ( $use_captcha == 'yes' ) {
28
- $captcha_output .= '<div class="g-recaptcha" data-sitekey="' . $captcha_site_key . '"></div>';
29
- if ( isset( $_POST['g-recaptcha-response'] ) ) {
30
- $captcha = $_POST['g-recaptcha-response'];
31
- $captcha_result = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
32
- 'method' => 'POST',
33
- 'body' => array(
34
- 'secret' => $captcha_secret_key,
35
- 'response' => $captcha,
36
- )
37
- ));
38
- if ( is_wp_error( $captcha_result ) ) {
39
- $valid_captcha = false;
40
- } else {
41
- $captcha_response = json_decode( $captcha_result['body'], true );
42
- if ( ! $captcha_response['success'] ) {
43
- $valid_captcha = false;
44
- }
45
- }
46
- } else {
47
- $valid_captcha = false;
48
- }
49
- }
50
-
51
- // get email if user known
52
- if ( isset( $current_user ) && $current_user->ID > 0 ) {
53
- $current_user_email = $current_user->data->user_email;
54
- }
55
-
56
- // post permalink supplied with $_GET
57
- if ( array_key_exists('post_permalink', $_GET ) ) {
58
- if ( ! empty( $_GET['post_permalink'] ) ) {
59
- $post_permalink = $_GET['post_permalink'];
60
- }
61
- }
62
-
63
- // challenge question
64
- $challenge_question_state = get_option( 'subscribe_reloaded_use_challenge_question', 'no' );
65
- $challenge_question = get_option( 'subscribe_reloaded_challenge_question', 'What is 1 + 2?' );
66
- $challenge_answer = get_option( 'subscribe_reloaded_challenge_answer', '3' );
67
-
68
- // start output buffering
69
- ob_start();
70
-
71
- // email address supplied
72
- if ( ! empty( $email ) ) {
73
-
74
- // check email validity
75
- $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
76
-
77
- // check challenge question validity
78
- if ( $challenge_question_state == 'yes' ) {
79
- $challenge_user_answer = sanitize_text_field( $_POST['subscribe_reloaded_challenge'] );
80
- if ( $challenge_answer != $challenge_user_answer ) {
81
- $valid_challenge = false;
82
- $valid_all = false;
83
- }
84
- }
85
-
86
- // email is invalid
87
- if ( $stcr_post_email === false ) {
88
- $valid_email = false;
89
- $valid_all = false;
90
- }
91
-
92
- // email is not subscribed
93
- if ( ! $wp_subscribe_reloaded->stcr->utils->get_subscriber_key( $stcr_post_email ) ) {
94
- $valid_email = false;
95
- $valid_all = false;
96
- }
97
-
98
- // captcha is not valid
99
- if ( ! $valid_captcha ) {
100
- $valid_all = false;
101
- }
102
-
103
- if ( $valid_all ) {
104
-
105
- // Send management link
106
- $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]' ) ), ENT_QUOTES, 'UTF-8' );
107
- $page_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_content', '' ) ), ENT_QUOTES, 'UTF-8' );
108
- $email_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_email_content', '' ) ), ENT_QUOTES, 'UTF-8' );
109
- $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
110
- $one_click_unsubscribe_link = $manager_link;
111
- if ( function_exists( 'qtrans_convertURL' ) ) {
112
- $manager_link = qtrans_convertURL( $manager_link );
113
- }
114
-
115
- $clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
116
- $subscriber_salt = $wp_subscribe_reloaded->stcr->utils->generate_temp_key( $clean_email );
117
-
118
- $manager_link .= ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?';
119
- $manager_link .= "srek=" . $wp_subscribe_reloaded->stcr->utils->get_subscriber_key($clean_email) . "&srk=$subscriber_salt&amp;srsrc=e&post_permalink=" . esc_url( $post_permalink );
120
- $one_click_unsubscribe_link .= ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?';
121
- $one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' )
122
- . "srek=" . esc_attr( $this->utils->get_subscriber_key( $clean_email ) )
123
- . "&srk=$subscriber_salt" . "&sra=u;srsrc=e" . "&srp=";
124
-
125
- // Replace tags with their actual values
126
- $subject = str_replace( '[blog_name]', get_bloginfo( 'name' ), $subject );
127
- $page_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $page_message );
128
- $email_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $email_message );
129
- $email_message = str_replace( '[manager_link]', $manager_link, $email_message );
130
- $email_message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $email_message );
131
-
132
- if ( get_option( 'subscribe_reloaded_enable_html_emails', 'yes' ) == 'yes' ) {
133
- $email_message = wpautop( $email_message );
134
- }
135
-
136
- // QTranslate support
137
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
138
- $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
139
- $page_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $page_message );
140
- $email_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $email_message );
141
- }
142
-
143
- // Prepare email settings
144
- $email_settings = array(
145
- 'subject' => $subject,
146
- 'message' => $email_message,
147
- 'toEmail' => $clean_email
148
- );
149
-
150
- $wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
151
-
152
- echo wpautop( $page_message );
153
-
154
- }
155
-
156
- // email address not supplied
157
- } else {
158
-
159
- $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
160
-
161
- // get email address
162
- $email = '';
163
- if ( isset($current_user_email) ) {
164
- $email = $current_user_email;
165
- } else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] )) {
166
- $email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
167
- } else {
168
- $email = '';
169
- }
170
-
171
- // qTrans compatibility
172
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
173
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
174
- }
175
-
176
- ?>
177
- <p><?php echo wpautop( $message ); ?></p>
178
- <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
179
- <fieldset style="border:0">
180
- <?php if ( $challenge_question_state == 'yes' ) : ?>
181
- <p>
182
- <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
183
- <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
184
- </p>
185
- <p>
186
- <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
187
- <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
188
- </p>
189
- <p>
190
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
191
- </p>
192
- <?php echo $captcha_output; ?>
193
- <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
194
- <?php else : ?>
195
- <p>
196
- <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
197
- <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
198
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
199
- </p>
200
- <?php echo $captcha_output; ?>
201
- <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
202
- <?php endif; ?>
203
-
204
- </fieldset>
205
- </form>
206
- <?php
207
-
208
- if ( isset( $post_permalink ) ) {
209
- echo '<p id="subscribe-reloaded-update-p">
210
- <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>
211
- </p>';
212
- }
213
-
214
- }
215
-
216
- // email invalid
217
- if( ! $valid_all ) {
218
-
219
- $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
220
-
221
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
222
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
223
- }
224
-
225
- ?>
226
- <p><?php echo wpautop( $message ); ?></p>
227
- <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
228
- <fieldset style="border:0">
229
-
230
- <?php if ( $challenge_question_state == 'yes' ) : ?>
231
- <p>
232
- <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
233
- <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
234
- </p>
235
- <p>
236
- <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
237
- <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
238
- </p>
239
- <p>
240
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
241
- </p>
242
- <?php echo $captcha_output; ?>
243
- <p class="notice-email-error" style='color: #f55252;font-weight:bold;'></p>
244
- <?php else : ?>
245
- <p>
246
- <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
247
- <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
248
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
249
- </p>
250
- <?php echo $captcha_output; ?>
251
- <p class="notice-email-error" style='color: #f55252;font-weight:bold;'></p>
252
- <?php endif; ?>
253
-
254
- <?php if ( ! $valid_email ) : ?>
255
- <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>
256
- <?php endif; ?>
257
-
258
- <?php if ( ! $valid_challenge ) : ?>
259
- <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
260
- <?php endif; ?>
261
-
262
- <?php if ( ! $valid_captcha ) : ?>
263
- <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
264
- <?php endif; ?>
265
-
266
- </fieldset>
267
- </form>
268
- <?php
269
- }
270
-
271
- // stop output buffer and pass it back
272
- $output = ob_get_contents();
273
- ob_end_clean();
274
- return $output;
275
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
12
+ $post_permalink = null;
13
+ $current_user_email = null; // Comes from wp_subscribe-to-comments-reloaded\subscribe_reloaded_manage()
14
+ $ID = $target_post;
15
+ $valid_all = true;
16
+ $valid_email = true;
17
+ $valid_challenge = true;
18
+
19
+ // google recaptcha
20
+ $valid_captcha = true;
21
+ $captcha_output = '';
22
+ $use_captcha = get_option( 'subscribe_reloaded_use_captcha', 'no' );
23
+ $captcha_site_key = get_option( 'subscribe_reloaded_captcha_site_key', '' );
24
+ $captcha_secret_key = get_option( 'subscribe_reloaded_captcha_secret_key', '' );
25
+ $recaptcha_version = get_option( 'subscribe_reloaded_recaptcha_version', 'v2' );
26
+
27
+ // google recaptcha confirm
28
+ if ( $use_captcha == 'yes' ) {
29
+ $captcha_output .= '<div class="g-recaptcha" data-sitekey="' . $captcha_site_key . '"></div>';
30
+ if ( 'v2' == $recaptcha_version ) {
31
+ if ( isset( $_POST['g-recaptcha-response'] ) ) {
32
+ $captcha = $_POST['g-recaptcha-response'];
33
+ $captcha_result = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
34
+ 'method' => 'POST',
35
+ 'body' => array(
36
+ 'secret' => $captcha_secret_key,
37
+ 'response' => $captcha,
38
+ )
39
+ ));
40
+ if ( is_wp_error( $captcha_result ) ) {
41
+ $valid_captcha = false;
42
+ } else {
43
+ $captcha_response = json_decode( $captcha_result['body'], true );
44
+ if ( ! $captcha_response['success'] ) {
45
+ $valid_captcha = false;
46
+ }
47
+ }
48
+ }
49
+ } elseif ( 'v3' == $recaptcha_version ) {
50
+ if ( isset( $_POST['token'] ) ) {
51
+ $captcha = $_POST['token'];
52
+ $action = $_POST['action'];
53
+
54
+ $captcha_result = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
55
+ 'method' => 'POST',
56
+ 'body' => array(
57
+ 'secret' => $recaptcha_secret_key,
58
+ 'response' => $captcha,
59
+ )
60
+ ));
61
+ if ( is_wp_error( $captcha_result ) ) {
62
+ $valid_captcha = false;
63
+ } else {
64
+ $captcha_response = json_decode( $captcha_result['body'], true );
65
+ if ( ! $captcha_response['success'] || ! $captcha_response['action'] == $action || $captcha_response['score'] < 0.5 ) {
66
+ $valid_captcha = false;
67
+ }
68
+ }
69
+ }
70
+ } else {
71
+ $valid_captcha = false;
72
+ }
73
+ }
74
+
75
+ // get email if user known
76
+ if ( isset( $current_user ) && $current_user->ID > 0 ) {
77
+ $current_user_email = $current_user->data->user_email;
78
+ }
79
+
80
+ // post permalink supplied with $_GET
81
+ if ( array_key_exists('post_permalink', $_GET ) ) {
82
+ if ( ! empty( $_GET['post_permalink'] ) ) {
83
+ $post_permalink = $_GET['post_permalink'];
84
+ }
85
+ }
86
+
87
+ // challenge question
88
+ $challenge_question_state = get_option( 'subscribe_reloaded_use_challenge_question', 'no' );
89
+ $challenge_question = get_option( 'subscribe_reloaded_challenge_question', 'What is 1 + 2?' );
90
+ $challenge_answer = get_option( 'subscribe_reloaded_challenge_answer', '3' );
91
+
92
+ // start output buffering
93
+ ob_start();
94
+
95
+ // email address supplied
96
+ if ( ! empty( $email ) ) {
97
+
98
+ // check email validity
99
+ $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
100
+
101
+ // check challenge question validity
102
+ if ( $challenge_question_state == 'yes' ) {
103
+ $challenge_user_answer = sanitize_text_field( $_POST['subscribe_reloaded_challenge'] );
104
+ if ( $challenge_answer != $challenge_user_answer ) {
105
+ $valid_challenge = false;
106
+ $valid_all = false;
107
+ }
108
+ }
109
+
110
+ // email is invalid
111
+ if ( $stcr_post_email === false ) {
112
+ $valid_email = false;
113
+ $valid_all = false;
114
+ }
115
+
116
+ // email is not subscribed
117
+ if ( ! $wp_subscribe_reloaded->stcr->utils->get_subscriber_key( $stcr_post_email ) ) {
118
+ $valid_email = false;
119
+ $valid_all = false;
120
+ }
121
+
122
+ // captcha is not valid
123
+ if ( ! $valid_captcha ) {
124
+ $valid_all = false;
125
+ }
126
+
127
+ if ( $valid_all ) {
128
+
129
+ // Send management link
130
+ $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]' ) ), ENT_QUOTES, 'UTF-8' );
131
+ $page_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_content', '' ) ), ENT_QUOTES, 'UTF-8' );
132
+ $email_message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_management_email_content', '' ) ), ENT_QUOTES, 'UTF-8' );
133
+ $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
134
+ $one_click_unsubscribe_link = $manager_link;
135
+ if ( function_exists( 'qtrans_convertURL' ) ) {
136
+ $manager_link = qtrans_convertURL( $manager_link );
137
+ }
138
+
139
+ $clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
140
+ $subscriber_salt = $wp_subscribe_reloaded->stcr->utils->generate_temp_key( $clean_email );
141
+
142
+ $manager_link .= ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?';
143
+ $manager_link .= "srek=" . $wp_subscribe_reloaded->stcr->utils->get_subscriber_key($clean_email) . "&srk=$subscriber_salt&amp;srsrc=e&post_permalink=" . esc_url( $post_permalink );
144
+ $one_click_unsubscribe_link .= ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?';
145
+ $one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' )
146
+ . "srek=" . esc_attr( $this->utils->get_subscriber_key( $clean_email ) )
147
+ . "&srk=$subscriber_salt" . "&sra=u;srsrc=e" . "&srp=";
148
+
149
+ // Replace tags with their actual values
150
+ $subject = str_replace( '[blog_name]', get_bloginfo( 'name' ), $subject );
151
+ $page_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $page_message );
152
+ $email_message = str_replace( '[blog_name]', get_bloginfo( 'name' ), $email_message );
153
+ $email_message = str_replace( '[manager_link]', $manager_link, $email_message );
154
+ $email_message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $email_message );
155
+
156
+ if ( get_option( 'subscribe_reloaded_enable_html_emails', 'yes' ) == 'yes' ) {
157
+ $email_message = wpautop( $email_message );
158
+ }
159
+
160
+ // QTranslate support
161
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
162
+ $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
163
+ $page_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $page_message );
164
+ $email_message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $email_message );
165
+ }
166
+
167
+ // Prepare email settings
168
+ $email_settings = array(
169
+ 'subject' => $subject,
170
+ 'message' => $email_message,
171
+ 'toEmail' => $clean_email
172
+ );
173
+
174
+ $has_blacklist_email = $this->utils->blacklisted_emails( $clean_email );
175
+ // Send the confirmation email only if the email
176
+ // address is not in blacklist email list.
177
+ if ( $has_blacklist_email ) {
178
+ $wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
179
+ }
180
+
181
+ echo wpautop( $page_message );
182
+
183
+ }
184
+
185
+ // email address not supplied
186
+ } else {
187
+
188
+ $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
189
+
190
+ // get email address
191
+ $email = '';
192
+ if ( isset($current_user_email) ) {
193
+ $email = $current_user_email;
194
+ } else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] )) {
195
+ $email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
196
+ } else {
197
+ $email = '';
198
+ }
199
+
200
+ // qTrans compatibility
201
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
202
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
203
+ }
204
+
205
+ ?>
206
+ <p><?php echo wpautop( $message ); ?></p>
207
+ <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
208
+ <fieldset style="border:0">
209
+ <?php if ( $challenge_question_state == 'yes' ) : ?>
210
+ <p>
211
+ <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
212
+ <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
213
+ </p>
214
+ <p>
215
+ <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
216
+ <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
217
+ </p>
218
+ <p>
219
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
220
+ </p>
221
+ <?php echo $captcha_output; ?>
222
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
223
+ <?php else : ?>
224
+ <p>
225
+ <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
226
+ <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
227
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
228
+ </p>
229
+ <?php echo $captcha_output; ?>
230
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
231
+ <?php endif; ?>
232
+
233
+ </fieldset>
234
+ </form>
235
+ <?php
236
+
237
+ if ( isset( $post_permalink ) ) {
238
+ echo '<p id="subscribe-reloaded-update-p">
239
+ <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>
240
+ </p>';
241
+ }
242
+
243
+ }
244
+
245
+ if ( $use_captcha == 'yes' && $valid_captcha && 'v3' == $recaptcha_version ) {
246
+ ?>
247
+ <div class="stcr-recaptcha">
248
+ <script src="https://www.google.com/recaptcha/api.js?render=<?php echo esc_attr( $captcha_site_key ); ?>"></script>
249
+ <script>
250
+ jQuery(document).ready(function(){
251
+ jQuery('form.sub-form').on( 'submit', function(event) {
252
+
253
+ event.preventDefault();
254
+ var stcrForm = jQuery(this);
255
+ var stcrEmail = jQuery(this).find('#subscribe_reloaded_email').val();
256
+
257
+ grecaptcha.ready(function() {
258
+ grecaptcha.execute('<?php echo esc_attr( $captcha_site_key ); ?>', {action: 'management_link'}).then(function(token) {
259
+ stcrForm.prepend('<input type="hidden" name="token" value="' + token + '">');
260
+ stcrForm.prepend('<input type="hidden" name="action" value="management_link">');
261
+ stcrForm.unbind('submit').submit();
262
+ });
263
+ });
264
+
265
+ });
266
+ });
267
+ </script>
268
+ </div>
269
+ <?php
270
+ }
271
+
272
+ // email invalid
273
+ if( ! $valid_all ) {
274
+
275
+ $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_request_mgmt_link' ) ), ENT_QUOTES, 'UTF-8' );
276
+
277
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
278
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
279
+ }
280
+
281
+ ?>
282
+ <p><?php echo wpautop( $message ); ?></p>
283
+ <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
284
+ <fieldset style="border:0">
285
+
286
+ <?php if ( $challenge_question_state == 'yes' ) : ?>
287
+ <p>
288
+ <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
289
+ <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
290
+ </p>
291
+ <p>
292
+ <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
293
+ <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
294
+ </p>
295
+ <p>
296
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
297
+ </p>
298
+ <?php echo $captcha_output; ?>
299
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold;'></p>
300
+ <?php else : ?>
301
+ <p>
302
+ <label for="subscribe_reloaded_email"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
303
+ <input id='subscribe_reloaded_email' type="email" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
304
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php _e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
305
+ </p>
306
+ <?php echo $captcha_output; ?>
307
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold;'></p>
308
+ <?php endif; ?>
309
+
310
+ <?php if ( ! $valid_email ) : ?>
311
+ <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>
312
+ <?php endif; ?>
313
+
314
+ <?php if ( ! $valid_challenge ) : ?>
315
+ <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
316
+ <?php endif; ?>
317
+
318
+ <?php if ( ! $valid_captcha ) : ?>
319
+ <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
320
+ <?php endif; ?>
321
+
322
+ </fieldset>
323
+ </form>
324
+ <?php
325
+ }
326
+
327
+ // stop output buffer and pass it back
328
+ $output = ob_get_contents();
329
+ ob_end_clean();
330
+ return $output;
331
+ ?>
templates/subscribe.php CHANGED
@@ -1,287 +1,343 @@
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
- $current_user_email = null; // Comes from wp_subscribe-to-comments-reloaded\subscribe_reloaded_manage()
12
- $valid_all = true;
13
- $valid_email = true;
14
- $valid_challenge = true;
15
-
16
- // google recaptcha
17
- $valid_captcha = true;
18
- $captcha_output = '';
19
- $use_captcha = get_option( 'subscribe_reloaded_use_captcha', 'no' );
20
- $captcha_site_key = get_option( 'subscribe_reloaded_captcha_site_key', '' );
21
- $captcha_secret_key = get_option( 'subscribe_reloaded_captcha_secret_key', '' );
22
-
23
- if ( get_option( 'subscribe_reloaded_allow_subscribe_without_comment', 'yes' ) != 'yes' ) {
24
- exit;
25
- }
26
-
27
- // google recaptcha confirm
28
- if ( $use_captcha == 'yes' ) {
29
- $captcha_output .= '<div class="g-recaptcha" data-sitekey="' . $captcha_site_key . '"></div>';
30
- if ( isset( $_POST['g-recaptcha-response'] ) ) {
31
- $captcha = $_POST['g-recaptcha-response'];
32
- $captcha_result = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
33
- 'method' => 'POST',
34
- 'body' => array(
35
- 'secret' => $captcha_secret_key,
36
- 'response' => $captcha,
37
- )
38
- ));
39
- if ( is_wp_error( $captcha_result ) ) {
40
- $valid_captcha = false;
41
- } else {
42
- $captcha_response = json_decode( $captcha_result['body'], true );
43
- if ( ! $captcha_response['success'] ) {
44
- $valid_captcha = false;
45
- }
46
- }
47
- } else {
48
- $valid_captcha = false;
49
- }
50
- }
51
-
52
- // get user email
53
- if ( isset($current_user) && $current_user->ID > 0 ) {
54
- $current_user_email = $current_user->data->user_email;
55
- }
56
-
57
- // get post permalink
58
- $post_permalink = get_permalink( $post_ID );
59
-
60
- // challenge question
61
- $challenge_question_state = get_option( 'subscribe_reloaded_use_challenge_question', 'no' );
62
- $challenge_question = get_option( 'subscribe_reloaded_challenge_question', 'What is 1 + 2?' );
63
- $challenge_answer = get_option( 'subscribe_reloaded_challenge_answer', '3' );
64
-
65
- // start output buffer
66
- ob_start();
67
-
68
- // email address supplied
69
- if ( ! empty( $email ) ) {
70
-
71
- // check email validity
72
- $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
73
-
74
- // check challenge question validity
75
- if ( $challenge_question_state == 'yes' ) {
76
- $challenge_user_answer = sanitize_text_field( $_POST['subscribe_reloaded_challenge'] );
77
- if ( $challenge_answer != $challenge_user_answer ) {
78
- $valid_challenge = false;
79
- $valid_all = false;
80
- }
81
- }
82
-
83
- // email is invalid
84
- if ( $stcr_post_email === false ) {
85
- $valid_email = false;
86
- $valid_all = false;
87
- }
88
-
89
- // captcha is not valid
90
- if ( ! $valid_captcha ) {
91
- $valid_all = false;
92
- }
93
-
94
- // email is valid
95
- if ( $valid_all ) {
96
-
97
- // Use Akismet, if available, to check this user is legit
98
- if ( function_exists( 'akismet_http_post' ) ) {
99
-
100
- global $akismet_api_host, $akismet_api_port;
101
-
102
- $akismet_query_string = "user_ip={$_SERVER['REMOTE_ADDR']}";
103
- $akismet_query_string .= "&user_agent=" . esc_url( stripslashes( $_SERVER['HTTP_USER_AGENT'] ) );
104
- $akismet_query_string .= "&blog=" . esc_url( get_option( 'home' ) );
105
- $akismet_query_string .= "&blog_lang=" . get_locale();
106
- $akismet_query_string .= "&blog_charset=" . get_option( 'blog_charset' );
107
- $akismet_query_string .= "&permalink=".esc_url( $post_permalink );
108
- $akismet_query_string .= "&comment_author_email=" . esc_url( sanitize_email( $email ) );
109
-
110
- $akismet_response = akismet_http_post( $akismet_query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
111
-
112
- // If this is considered SPAM, we stop here
113
- if ( $akismet_response[1] == 'true' ) {
114
- ob_end_clean();
115
- return '';
116
- }
117
-
118
- }
119
-
120
- // sanitize email address
121
- $clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
122
-
123
- // notify the administrator about the new subscription
124
- if ( get_option( 'subscribe_reloaded_enable_admin_messages' ) == 'yes' ) {
125
-
126
- $from_name = stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) );
127
- $from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
128
-
129
- $subject = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title";
130
- $message = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title\n" . __( 'User:', 'subscribe-to-comments-reloaded' ) . " $clean_email";
131
-
132
- $email_settings = array(
133
- 'subject' => $subject,
134
- 'message' => $message,
135
- 'toEmail' => get_bloginfo( 'admin_email' )
136
- );
137
-
138
- $wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
139
-
140
- }
141
-
142
- // double check, send confirmation email
143
- if ( get_option( 'subscribe_reloaded_enable_double_check' ) == 'yes' && ! $wp_subscribe_reloaded->stcr->is_user_subscribed( $post_ID, $clean_email, 'C' ) ) {
144
- $wp_subscribe_reloaded->stcr->add_subscription( $post_ID, $clean_email, 'YC' );
145
- $wp_subscribe_reloaded->stcr->confirmation_email( $post_ID, $clean_email );
146
- $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed_dci' ) ), ENT_QUOTES, 'UTF-8' );
147
-
148
- // not double check, add subscription
149
- } else {
150
- $this->add_subscription( $post_ID, $clean_email, 'Y' );
151
- $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed' ) ), ENT_QUOTES, 'UTF-8' );
152
- }
153
-
154
- // new subscription message
155
- $message = str_replace( '[post_permalink]', $post_permalink, $message );
156
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
157
- $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
158
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
159
- } else {
160
- $message = str_replace( '[post_title]', $target_post->post_title, $message );
161
- }
162
-
163
- echo wpautop( $message );
164
-
165
- }
166
-
167
- // no email address supplied
168
- } else {
169
-
170
- // email value for input field
171
- if ( isset( $current_user_email ) ) {
172
- $email = $current_user_email;
173
- } else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] )) {
174
- $email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
175
- } else {
176
- $email = '';
177
- }
178
-
179
- // output message for subscribing without commenting
180
- $message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
181
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
182
- $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
183
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
184
- } else {
185
- $message = str_replace( '[post_title]', $target_post->post_title, $message );
186
- }
187
- echo '<p>' . $message . '</p>';
188
-
189
- // output the form
190
-
191
-
192
- ?>
193
- <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]); ?>" method="post" name="sub-form">
194
- <fieldset style="border:0">
195
- <div>
196
- <?php if ( $challenge_question_state == 'yes' ) : ?>
197
- <p>
198
- <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
199
- <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
200
- </p>
201
- <p>
202
- <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
203
- <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
204
- </p>
205
- <p>
206
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
207
- </p>
208
- <?php echo $captcha_output; ?>
209
- <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
210
- <?php else : ?>
211
- <p>
212
- <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
213
- <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
214
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
215
- </p>
216
- <?php echo $captcha_output; ?>
217
- <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
218
- <?php endif; ?>
219
- </div>
220
- </fieldset>
221
- </form>
222
- <?php
223
-
224
- }
225
-
226
- // invalid email
227
- if ( ! $valid_all ) {
228
-
229
- // message for subscribing without commenting
230
- $message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
231
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
232
- $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
233
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
234
- } else {
235
- $message = str_replace( '[post_title]', esc_html( $target_post->post_title ), $message );
236
- }
237
- echo '<p>' . $message . '</p>';
238
-
239
- ?>
240
- <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
241
- <fieldset style="border:0">
242
-
243
- <?php if ( $challenge_question_state == 'yes' ) : ?>
244
- <p>
245
- <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
246
- <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
247
- </p>
248
- <p>
249
- <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
250
- <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
251
- </p>
252
- <p>
253
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
254
- </p>
255
- <?php echo $captcha_output; ?>
256
- <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
257
- <?php else : ?>
258
- <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
259
- <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
260
- <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
261
- <?php echo $captcha_output; ?>
262
- <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
263
- <?php endif; ?>
264
-
265
- <?php if ( ! $valid_email ) : ?>
266
- <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>
267
- <?php endif; ?>
268
-
269
- <?php if ( ! $valid_challenge ) : ?>
270
- <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
271
- <?php endif; ?>
272
-
273
- <?php if ( ! $valid_captcha ) : ?>
274
- <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
275
- <?php endif; ?>
276
-
277
- </fieldset>
278
- </form>
279
- <?php
280
-
281
- }
282
-
283
- // stop output buffer and pass it back
284
- $output = ob_get_contents();
285
- ob_end_clean();
286
- return $output;
287
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $current_user_email = null; // Comes from wp_subscribe-to-comments-reloaded\subscribe_reloaded_manage()
12
+ $valid_all = true;
13
+ $valid_email = true;
14
+ $valid_challenge = true;
15
+
16
+ // google recaptcha
17
+ $valid_captcha = true;
18
+ $captcha_output = '';
19
+ $use_captcha = get_option( 'subscribe_reloaded_use_captcha', 'no' );
20
+ $captcha_site_key = get_option( 'subscribe_reloaded_captcha_site_key', '' );
21
+ $captcha_secret_key = get_option( 'subscribe_reloaded_captcha_secret_key', '' );
22
+ $recaptcha_version = get_option( 'subscribe_reloaded_recaptcha_version', 'v2' );
23
+
24
+ if ( get_option( 'subscribe_reloaded_allow_subscribe_without_comment', 'yes' ) != 'yes' ) {
25
+ exit;
26
+ }
27
+
28
+ // google recaptcha confirm
29
+ if ( $use_captcha == 'yes' ) {
30
+ $captcha_output .= '<div class="g-recaptcha" data-sitekey="' . $captcha_site_key . '"></div>';
31
+ if ( 'v2' == $recaptcha_version ) {
32
+ if ( isset( $_POST['g-recaptcha-response'] ) ) {
33
+ $captcha = $_POST['g-recaptcha-response'];
34
+ $captcha_result = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
35
+ 'method' => 'POST',
36
+ 'body' => array(
37
+ 'secret' => $captcha_secret_key,
38
+ 'response' => $captcha,
39
+ )
40
+ ));
41
+ if ( is_wp_error( $captcha_result ) ) {
42
+ $valid_captcha = false;
43
+ } else {
44
+ $captcha_response = json_decode( $captcha_result['body'], true );
45
+ if ( ! $captcha_response['success'] ) {
46
+ $valid_captcha = false;
47
+ }
48
+ }
49
+ }
50
+ } elseif ( 'v3' == $recaptcha_version ) {
51
+ if ( isset( $_POST['token'] ) ) {
52
+ $captcha = $_POST['token'];
53
+ $action = $_POST['action'];
54
+
55
+ $captcha_result = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
56
+ 'method' => 'POST',
57
+ 'body' => array(
58
+ 'secret' => $recaptcha_secret_key,
59
+ 'response' => $captcha,
60
+ )
61
+ ));
62
+ if ( is_wp_error( $captcha_result ) ) {
63
+ $valid_captcha = false;
64
+ } else {
65
+ $captcha_response = json_decode( $captcha_result['body'], true );
66
+ if ( ! $captcha_response['success'] || ! $captcha_response['action'] == $action || $captcha_response['score'] < 0.5 ) {
67
+ $valid_captcha = false;
68
+ }
69
+ }
70
+ }
71
+ } else {
72
+ $valid_captcha = false;
73
+ }
74
+ }
75
+
76
+ // get user email
77
+ if ( isset($current_user) && $current_user->ID > 0 ) {
78
+ $current_user_email = $current_user->data->user_email;
79
+ }
80
+
81
+ // get post permalink
82
+ $post_permalink = get_permalink( $post_ID );
83
+
84
+ // challenge question
85
+ $challenge_question_state = get_option( 'subscribe_reloaded_use_challenge_question', 'no' );
86
+ $challenge_question = get_option( 'subscribe_reloaded_challenge_question', 'What is 1 + 2?' );
87
+ $challenge_answer = get_option( 'subscribe_reloaded_challenge_answer', '3' );
88
+
89
+ // start output buffer
90
+ ob_start();
91
+
92
+ // email address supplied
93
+ if ( ! empty( $email ) ) {
94
+
95
+ // check email validity
96
+ $stcr_post_email = $wp_subscribe_reloaded->stcr->utils->check_valid_email( $email );
97
+
98
+ // check challenge question validity
99
+ if ( $challenge_question_state == 'yes' ) {
100
+ $challenge_user_answer = sanitize_text_field( $_POST['subscribe_reloaded_challenge'] );
101
+ if ( $challenge_answer != $challenge_user_answer ) {
102
+ $valid_challenge = false;
103
+ $valid_all = false;
104
+ }
105
+ }
106
+
107
+ // email is invalid
108
+ if ( $stcr_post_email === false ) {
109
+ $valid_email = false;
110
+ $valid_all = false;
111
+ }
112
+
113
+ // captcha is not valid
114
+ if ( ! $valid_captcha ) {
115
+ $valid_all = false;
116
+ }
117
+
118
+ // email is valid
119
+ if ( $valid_all ) {
120
+
121
+ // Use Akismet, if available, to check this user is legit
122
+ if ( function_exists( 'akismet_http_post' ) ) {
123
+
124
+ global $akismet_api_host, $akismet_api_port;
125
+
126
+ $akismet_query_string = "user_ip={$_SERVER['REMOTE_ADDR']}";
127
+ $akismet_query_string .= "&user_agent=" . esc_url( stripslashes( $_SERVER['HTTP_USER_AGENT'] ) );
128
+ $akismet_query_string .= "&blog=" . esc_url( get_option( 'home' ) );
129
+ $akismet_query_string .= "&blog_lang=" . get_locale();
130
+ $akismet_query_string .= "&blog_charset=" . get_option( 'blog_charset' );
131
+ $akismet_query_string .= "&permalink=".esc_url( $post_permalink );
132
+ $akismet_query_string .= "&comment_author_email=" . esc_url( sanitize_email( $email ) );
133
+
134
+ $akismet_response = akismet_http_post( $akismet_query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
135
+
136
+ // If this is considered SPAM, we stop here
137
+ if ( $akismet_response[1] == 'true' ) {
138
+ ob_end_clean();
139
+ return '';
140
+ }
141
+
142
+ }
143
+
144
+ // sanitize email address
145
+ $clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email( $email );
146
+
147
+ // notify the administrator about the new subscription
148
+ if ( get_option( 'subscribe_reloaded_enable_admin_messages' ) == 'yes' ) {
149
+
150
+ $from_name = stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) );
151
+ $from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
152
+
153
+ $subject = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title";
154
+ $message = __( 'New subscription to', 'subscribe-to-comments-reloaded' ) . " $target_post->post_title\n" . __( 'User:', 'subscribe-to-comments-reloaded' ) . " $clean_email";
155
+
156
+ $email_settings = array(
157
+ 'subject' => $subject,
158
+ 'message' => $message,
159
+ 'toEmail' => get_bloginfo( 'admin_email' )
160
+ );
161
+
162
+ $has_blacklist_email = $this->utils->blacklisted_emails( $clean_email );
163
+ // Send the confirmation email only if the email
164
+ // address is not in blacklist email list.
165
+ if ( $has_blacklist_email ) {
166
+ $wp_subscribe_reloaded->stcr->utils->send_email( $email_settings );
167
+ }
168
+
169
+ }
170
+
171
+ // double check, send confirmation email
172
+ if ( get_option( 'subscribe_reloaded_enable_double_check' ) == 'yes' && ! $wp_subscribe_reloaded->stcr->is_user_subscribed( $post_ID, $clean_email, 'C' ) ) {
173
+ $wp_subscribe_reloaded->stcr->add_subscription( $post_ID, $clean_email, 'YC' );
174
+ $wp_subscribe_reloaded->stcr->confirmation_email( $post_ID, $clean_email );
175
+ $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed_dci' ) ), ENT_QUOTES, 'UTF-8' );
176
+
177
+ // not double check, add subscription
178
+ } else {
179
+ $this->add_subscription( $post_ID, $clean_email, 'Y' );
180
+ $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscription_confirmed' ) ), ENT_QUOTES, 'UTF-8' );
181
+ }
182
+
183
+ // new subscription message
184
+ $message = str_replace( '[post_permalink]', $post_permalink, $message );
185
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
186
+ $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
187
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
188
+ } else {
189
+ $message = str_replace( '[post_title]', $target_post->post_title, $message );
190
+ }
191
+
192
+ echo wpautop( $message );
193
+
194
+ }
195
+
196
+ // no email address supplied
197
+ } else {
198
+
199
+ // email value for input field
200
+ if ( isset( $current_user_email ) ) {
201
+ $email = $current_user_email;
202
+ } else if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] )) {
203
+ $email = sanitize_email( $_COOKIE['comment_author_email_' . COOKIEHASH] );
204
+ } else {
205
+ $email = '';
206
+ }
207
+
208
+ // output message for subscribing without commenting
209
+ $message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
210
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
211
+ $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
212
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
213
+ } else {
214
+ $message = str_replace( '[post_title]', $target_post->post_title, $message );
215
+ }
216
+ echo '<p>' . $message . '</p>';
217
+
218
+ // output the form
219
+
220
+
221
+ ?>
222
+ <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]); ?>" method="post" name="sub-form">
223
+ <fieldset style="border:0">
224
+ <div>
225
+ <?php if ( $challenge_question_state == 'yes' ) : ?>
226
+ <p>
227
+ <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
228
+ <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
229
+ </p>
230
+ <p>
231
+ <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
232
+ <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
233
+ </p>
234
+ <p>
235
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
236
+ </p>
237
+ <?php echo $captcha_output; ?>
238
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
239
+ <?php else : ?>
240
+ <p>
241
+ <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
242
+ <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
243
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
244
+ </p>
245
+ <?php echo $captcha_output; ?>
246
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
247
+ <?php endif; ?>
248
+ </div>
249
+ </fieldset>
250
+ </form>
251
+ <?php
252
+
253
+ }
254
+
255
+ if ( $use_captcha == 'yes' && $valid_captcha && 'v3' == $recaptcha_version ) {
256
+ ?>
257
+ <div class="stcr-recaptcha">
258
+ <script src="https://www.google.com/recaptcha/api.js?render=<?php echo esc_attr( $captcha_site_key ); ?>"></script>
259
+ <script>
260
+ jQuery(document).ready(function(){
261
+ jQuery('form.sub-form').on( 'submit', function(event) {
262
+
263
+ event.preventDefault();
264
+ var stcrForm = jQuery(this);
265
+ var stcrEmail = jQuery(this).find('#sre').val();
266
+
267
+ grecaptcha.ready(function() {
268
+ grecaptcha.execute('<?php echo esc_attr( $captcha_site_key ); ?>', {action: 'subscribe'}).then(function(token) {
269
+ stcrForm.prepend('<input type="hidden" name="token" value="' + token + '">');
270
+ stcrForm.prepend('<input type="hidden" name="action" value="subscribe">');
271
+ stcrForm.unbind('submit').submit();
272
+ });
273
+ });
274
+
275
+ });
276
+ });
277
+ </script>
278
+ </div>
279
+ <?php
280
+ }
281
+
282
+ // invalid email
283
+ if ( ! $valid_all ) {
284
+
285
+ // message for subscribing without commenting
286
+ $message = str_replace( '[post_permalink]', $post_permalink, html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribe_without_commenting' ) ), ENT_QUOTES, 'UTF-8' ) );
287
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
288
+ $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $target_post->post_title ), $message );
289
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
290
+ } else {
291
+ $message = str_replace( '[post_title]', esc_html( $target_post->post_title ), $message );
292
+ }
293
+ echo '<p>' . $message . '</p>';
294
+
295
+ ?>
296
+ <form action="<?php echo esc_url( $_SERVER[ 'REQUEST_URI' ]);?>" method="post" name="sub-form">
297
+ <fieldset style="border:0">
298
+
299
+ <?php if ( $challenge_question_state == 'yes' ) : ?>
300
+ <p>
301
+ <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
302
+ <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
303
+ </p>
304
+ <p>
305
+ <label for="subscribe-reloaded-challenge"><?php echo $challenge_question; ?></label>
306
+ <input id="subscribe-reloaded-challenge" type="text" class="subscribe-form-field" name="subscribe_reloaded_challenge" />
307
+ </p>
308
+ <p>
309
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
310
+ </p>
311
+ <?php echo $captcha_output; ?>
312
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
313
+ <?php else : ?>
314
+ <label for="sre"><?php _e( 'Email', 'subscribe-to-comments-reloaded' ) ?></label>
315
+ <input id='sre' type="text" class="subscribe-form-field" name="sre" value="<?php echo esc_attr( $email ); ?>" size="22" required />
316
+ <input name="submit" type="submit" class="subscribe-form-button" value="<?php esc_attr_e( 'Send', 'subscribe-to-comments-reloaded' ) ?>" />
317
+ <?php echo $captcha_output; ?>
318
+ <p class="notice-email-error" style='color: #f55252;font-weight:bold; display: none;'></p>
319
+ <?php endif; ?>
320
+
321
+ <?php if ( ! $valid_email ) : ?>
322
+ <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>
323
+ <?php endif; ?>
324
+
325
+ <?php if ( ! $valid_challenge ) : ?>
326
+ <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
327
+ <?php endif; ?>
328
+
329
+ <?php if ( ! $valid_captcha ) : ?>
330
+ <p style='color: #f55252;font-weight:bold;'><i class="fa fa-exclamation-triangle"></i> <?php _e("Challenge answer is not correct", 'subscribe-to-comments-reloaded') ?></p>
331
+ <?php endif; ?>
332
+
333
+ </fieldset>
334
+ </form>
335
+ <?php
336
+
337
+ }
338
+
339
+ // stop output buffer and pass it back
340
+ $output = ob_get_contents();
341
+ ob_end_clean();
342
+ return $output;
343
+ ?>
utils/stcr_manage.php CHANGED
@@ -1,754 +1,773 @@
1
- <?php
2
- /**
3
- * Class with management functions for Subscribe to Comments Reloaded
4
- * @author reedyseth
5
- * @since 16-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
- require_once dirname(__FILE__).'/stcr_utils.php';
16
- require_once dirname(__FILE__).'/stcr_upgrade.php';
17
-
18
- if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_manage') )
19
- {
20
- class stcr_manage {
21
-
22
- public $current_version = VERSION;
23
- public $utils = null;
24
- public $upgrade = null;
25
- public $db_version = null;
26
- public $fresh_install = false;
27
-
28
- public function __construct() {
29
- $this->upgrade = new stcr_upgrade();
30
- $this->utils = new stcr_utils();
31
- $this->db_version = get_option( 'subscribe_reloaded_version' );
32
- if ( ! get_option( 'subscribe_reloaded_fresh_install' )
33
- || get_option( 'subscribe_reloaded_fresh_install' ) == 'yes')
34
- {
35
- $this->fresh_install = true;
36
- }
37
- else
38
- {
39
- $this->fresh_install = false;
40
- update_option('subscribe_reloaded_fresh_install', 'no');
41
- }
42
- // Schedule the autopurge hook
43
- if ( ! wp_next_scheduled( '_cron_subscribe_reloaded_purge' ) ) {
44
- wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
45
- // Let us bind the schedule event with our desire action.
46
- wp_schedule_event( time() + 15, 'daily', '_cron_subscribe_reloaded_purge' );
47
- }
48
-
49
- }
50
-
51
- /**
52
- * Search for a new version of code for a possible update
53
- */
54
- public function stcr_admin_init() {
55
-
56
- // Add Authors to custom posts types
57
- if ( get_option( 'subscribe_reloaded_notify_authors' ) === 'yes' ) {
58
- // Retrieve custom post types
59
- $gpt_args = array('_builtin' => false);
60
- $post_types = get_post_types( $gpt_args );
61
- foreach ($post_types as $post_type_name) {
62
- // Add author subscription in every post type
63
- add_action( 'publish_' . $post_type_name , array( $this, 'subscribe_post_author' ) );
64
- }
65
- }
66
- }
67
-
68
- public function admin_notices() {
69
- $notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
70
- $nonce = null;
71
-
72
- if ( $notices ) {
73
- // Add JS script
74
- wp_enqueue_script( 'stcr-admin-js' );
75
- wp_enqueue_style( 'stcr-admin-style' );
76
-
77
- foreach ( $notices as $name => $noticeData ) {
78
- if( $noticeData['status'] == 'unread' ) {
79
- $nonce = wp_create_nonce( $name );
80
- // Set the a fresh nonce
81
- $this->utils->stcr_update_admin_notice_status( $name, 'unread', $nonce );
82
- echo "<div class='notice is-dismissible stcr-dismiss-notice {$noticeData['type']}' data-nonce='{$nonce}|{$name}'>";
83
- echo $noticeData['message'];
84
- echo "</div>";
85
- }
86
- }
87
- update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
88
- }
89
- }
90
-
91
- /**
92
- * Support for WP MU network activations (experimental)
93
- */
94
- public function new_blog( $_blog_id ) {
95
- switch_to_blog( $_blog_id );
96
- $this->_activate();
97
- restore_current_blog();
98
- }
99
- // end new_blog
100
-
101
- public function sendConfirmationEMail( $info ) {
102
- // Retrieve the information about the new comment
103
- $this->confirmation_email( $info->comment_post_ID, $info->comment_author_email );
104
- }
105
-
106
- /**
107
- * Sends a message to confirm a subscription
108
- */
109
- public function confirmation_email( $_post_ID = 0, $_email = '' ) {
110
- // Retrieve the options from the database
111
- $from_name = stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) );
112
- $from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
113
- $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_double_check_subject', 'Please confirm your subscribtion to [post_title]' ) ), ENT_COMPAT, 'UTF-8' );
114
- $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_double_check_content', '' ) ), ENT_COMPAT, 'UTF-8' );
115
- $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
116
- if ( function_exists( 'qtrans_convertURL' ) ) {
117
- $manager_link = qtrans_convertURL( $manager_link );
118
- }
119
-
120
- $clean_email = $this->utils->clean_email( $_email );
121
- $subscriber_salt = $this->utils->generate_temp_key( $clean_email );
122
-
123
- $this->utils->add_user_subscriber_table( $clean_email );
124
-
125
- $post = get_post( $_post_ID );
126
- $post_permalink = get_permalink( $_post_ID );
127
-
128
- $manager_link .= ( ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?' ) . "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=" . $subscriber_salt;
129
- $confirm_link = "$manager_link&srp=$_post_ID&sra=c&srsrc=e&confirmation_email=y&post_permalink=" . esc_url( $post_permalink );
130
-
131
-
132
- // Replace tags with their actual values
133
- $subject = str_replace( '[post_title]', $post->post_title, $subject );
134
-
135
- $message = str_replace( '[post_permalink]', $post_permalink, $message );
136
- $message = str_replace( '[confirm_link]', $confirm_link, $message );
137
- $message = str_replace( '[manager_link]', $manager_link, $message );
138
-
139
- // QTranslate support
140
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
141
- $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
142
- $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $post->post_title ), $message );
143
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
144
- } else {
145
- $message = str_replace( '[post_title]', $post->post_title, $message );
146
- }
147
- $message = apply_filters( 'stcr_confirmation_email_message', $message, $_post_ID, $clean_email );
148
-
149
- // Prepare email settings
150
- $email_settings = array(
151
- 'subject' => $subject,
152
- 'message' => $message,
153
- 'toEmail' => $clean_email,
154
- 'XPostId' => $_post_ID
155
- );
156
- $this->utils->send_email( $email_settings );
157
- }
158
- // end confirmation_email
159
-
160
- /**
161
- * Support for WP MU network activations (experimental)
162
- */
163
- public function activate() {
164
- global $wpdb;
165
-
166
- if ( function_exists( 'is_multisite' ) && is_multisite() && isset( $_GET['networkwide'] ) && ( $_GET['networkwide'] == 1 ) ) {
167
- $blogids = $wpdb->get_col(
168
- $wpdb->prepare(
169
- "
170
- SELECT blog_id
171
- FROM $wpdb->blogs
172
- WHERE site_id = %d
173
- AND deleted = 0
174
- AND spam = 0", $wpdb->siteid
175
- )
176
- );
177
-
178
- foreach ( $blogids as $blog_id ) {
179
- switch_to_blog( $blog_id );
180
- $this->_activate();
181
- }
182
- restore_current_blog();
183
- } else {
184
- $this->_activate();
185
- }
186
- }
187
- // end activate
188
- /**
189
- * Adds the options to the database and imports the data from other plugins
190
- */
191
- public function _activate() {
192
- // Load localization files
193
- // load_plugin_textdomain( 'subscribe-to-comments-reloaded', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
194
- // Upgrade rountine
195
- $this->upgrade();
196
-
197
- delete_option('subscribe_reloaded_unique_key');
198
-
199
- $this->utils->create_options();
200
- }
201
- /**
202
- * Performs some clean-up maintenance (disable cron job).
203
- */
204
- public function deactivate() {
205
- global $wpdb;
206
- if ( function_exists( 'is_multisite' ) && is_multisite() && isset( $_GET['networkwide'] ) && ( $_GET['networkwide'] == 1 ) ) {
207
- $blogids = $wpdb->get_col(
208
- $wpdb->prepare(
209
- "
210
- SELECT blog_id
211
- FROM $wpdb->blogs
212
- WHERE site_id = %d
213
- AND deleted = 0
214
- AND spam = 0", $wpdb->siteid
215
- )
216
- );
217
-
218
- foreach ( $blogids as $blog_id ) {
219
- switch_to_blog( $blog_id );
220
- wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
221
- wp_clear_scheduled_hook( '_cron_log_file_purge' );
222
- wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
223
-
224
- }
225
- restore_current_blog();
226
- } else {
227
- wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
228
- wp_clear_scheduled_hook( '_cron_log_file_purge' );
229
- wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
230
- }
231
- }
232
-
233
- // end deactivate
234
-
235
- public function maybe_update()
236
- {
237
- $int_db_version = str_replace('.','', $this->db_version) ;
238
- $int_curr_version = str_replace('.','', $this->current_version) ;
239
-
240
- if ( empty ( $int_db_version ) || (int) $int_db_version < (int) $int_curr_version ) {
241
- // // Do whatever upgrades needed here.
242
- // $this->_activate();
243
- // Send the current version to display the appropiate message
244
- // The notification will only be visible once there is an update not a activation.
245
- $this->upgrade->upgrade_notification( $this->current_version, $this->db_version, $this->fresh_install );
246
- $this->upgrade();
247
- update_option( 'subscribe_reloaded_version', $this->current_version );
248
- }
249
- }
250
-
251
- private function upgrade()
252
- {
253
- // Import data from the WP Comment Subscriptions plugin, if needed
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.
264
- // $this->upgrade->_import_crn_data();
265
-
266
- // Starting from version 2.0 StCR uses Wordpress' tables to store the information about subscriptions
267
- $this->upgrade->_update_db();
268
-
269
- // Since there are some users with the database corrupted due to encoding stuff we need to sanitize
270
- // their information
271
- $this->upgrade->_sanitize_db_information( $this->fresh_install );
272
- // Create a new table if not exists to manage the subscribers safer
273
- // First Check if the subscribers table is created.
274
- if ( ! get_option( 'subscribe_reloaded_subscriber_table' ) || get_option( 'subscribe_reloaded_subscriber_table' ) == 'no') {
275
- $this->upgrade->_create_subscriber_table( $this->fresh_install );
276
- }
277
- // Apply Patches
278
- $this->upgrade->apply_patches();
279
- }
280
-
281
- /**
282
- * Remove the log file created by StCR
283
- * @since 05-Apr-2017
284
- */
285
- public function log_file_purge()
286
- {
287
- $plugin_dir = plugin_dir_path( __DIR__ );
288
- $file_name = "log.txt";
289
- $file_path = $plugin_dir . "utils/" . $file_name;
290
-
291
- if( file_exists( $file_path ) && is_writable( $plugin_dir ) )
292
- {
293
- // unlink the file
294
- unlink($file_path);
295
- }
296
- }
297
- /**
298
- * Removes old entries from the database
299
- */
300
- public function subscribe_reloaded_purge() {
301
- global $wpdb;
302
-
303
- if ( ( $autopurge_interval = intval( get_option( 'subscribe_reloaded_purge_days', 0 ) ) ) <= 0 ) {
304
- return true;
305
- }
306
-
307
- // First retrieve the emails to be deleted
308
- $emailsToPurge = "SELECT DISTINCT REPLACE(meta_key, '_stcr@_', '') AS email FROM $wpdb->postmeta
309
- WHERE meta_key LIKE '\_stcr@\_%'
310
- AND STR_TO_DATE(meta_value, '%Y-%m-%d %H:%i:%s') <= DATE_SUB(NOW(),
311
- INTERVAL $autopurge_interval DAY) AND meta_value LIKE '%C'";
312
-
313
- $emails = $wpdb->get_results( $emailsToPurge, OBJECT );
314
- // Now if there are emails go ahead and delete them
315
- if ( ! empty( $emails ) && is_array( $emails ) ) {
316
- foreach( $emails as $row ) {
317
- $this->utils->remove_user_subscriber_table($row->email);
318
- }
319
- }
320
- // Delete old entries on the post_meta table
321
- $wpdb->query(
322
- "
323
- DELETE FROM $wpdb->postmeta
324
- WHERE meta_key LIKE '\_stcr@\_%'
325
- AND STR_TO_DATE(meta_value, '%Y-%m-%d %H:%i:%s') <= DATE_SUB(NOW(), INTERVAL $autopurge_interval DAY) AND meta_value LIKE '%C'"
326
- );
327
- }
328
- // end subscribe_reloaded_purge
329
- /**
330
- * Finds all links in text and wraps them with an HTML anchor tag
331
- *
332
- * @param unknown $text
333
- *
334
- * @return string Text with all links wrapped in HTML anchor tags
335
- *
336
- */
337
- public function htmlify_message_links( $text ) {
338
- return preg_replace( '!(((f|ht)tp(s)?://)[-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $text );
339
- }
340
-
341
- /**
342
- * Adds a new entry in the admin menu, to manage this plugin's options
343
- */
344
- public function add_config_menu( $_s ) {
345
-
346
- if ( current_user_can( 'manage_options' ) ) {
347
-
348
- $page_title = "Subscribe to Comments Reloaded";
349
- $menu_title = "StCR";
350
- $capability = "manage_options";
351
- $function = "";
352
- $icon_url = "dashicons-email";
353
- $position = 26;
354
- $parent_slug= "stcr_manage_subscriptions";
355
- add_menu_page( $page_title, $menu_title, $capability, $parent_slug, $function, $icon_url, $position );
356
-
357
- add_submenu_page( $parent_slug ,
358
- __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ),
359
- __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ),
360
- $capability,
361
- "stcr_manage_subscriptions",
362
- array( $this, "stcr_option_manage_subscriptions") );
363
- add_submenu_page( $parent_slug ,
364
- __( 'Comment Form', 'subscribe-to-comments-reloaded' ),
365
- __( 'Comment Form', 'subscribe-to-comments-reloaded' ),
366
- $capability,
367
- "stcr_comment_form",
368
- array( $this, "stcr_option_comment_form" ) );
369
- add_submenu_page( $parent_slug ,
370
- __( 'Management Page', 'subscribe-to-comments-reloaded' ),
371
- __( 'Management Page', 'subscribe-to-comments-reloaded' ),
372
- $capability,
373
- "stcr_management_page",
374
- array( $this, "stcr_option_management_page" ) );
375
- add_submenu_page( $parent_slug ,
376
- __( 'Notifications', 'subscribe-to-comments-reloaded' ),
377
- __( 'Notifications', 'subscribe-to-comments-reloaded' ),
378
- $capability,
379
- "stcr_notifications",
380
- array( $this, "stcr_option_notifications" ) );
381
- add_submenu_page( $parent_slug ,
382
- __( 'Options', 'subscribe-to-comments-reloaded' ),
383
- __( 'Options', 'subscribe-to-comments-reloaded' ),
384
- $capability,
385
- "stcr_options",
386
- array( $this, "stcr_option_options" ) );
387
- // @since 160316
388
- // Using this page requires to list a cool table, on this case will be the WP_List_Table,
389
- // since this requires much effort this is pointe to go to the pro version. NO ETA avaiable.
390
- //
391
- // add_submenu_page( $parent_slug ,
392
- // __( 'Subscribers Emails', 'subscribe-to-comments-reloaded' ),
393
- // __( 'Subscribers Emails', 'subscribe-to-comments-reloaded' ),
394
- // $capability,
395
- // "stcr_subscribers_emails",
396
- // array( $this, "stcr_option_subscribers_emails" ) );
397
-
398
- add_submenu_page( $parent_slug ,
399
- __( 'Support', 'subscribe-to-comments-reloaded' ),
400
- __( 'Support', 'subscribe-to-comments-reloaded' ),
401
- $capability,
402
- "stcr_support",
403
- array( $this, "stcr_option_support" ) );
404
- // add_submenu_page( $parent_slug ,
405
- // __( 'Donate', 'subscribe-to-comments-reloaded' ),
406
- // __( 'Donate', 'subscribe-to-comments-reloaded' ),
407
- // $capability,
408
- // "stcr_donate",
409
- // array( $this, "stcr_option_donate" ) );
410
- add_submenu_page( $parent_slug ,
411
- __( 'StCR System', 'subscribe-to-comments-reloaded' ),
412
- __( 'StCR System', 'subscribe-to-comments-reloaded' ),
413
- $capability,
414
- "stcr_system",
415
- array( $this, "stcr_option_system" ) );
416
- }
417
-
418
- return $_s;
419
- }
420
- // end add_config_menu
421
-
422
- /**
423
- * Dispaly the stcr_option_manage_subscriptions template
424
- * @since 160316
425
- * @author reedyseth
426
- */
427
- public function stcr_option_manage_subscriptions()
428
- {
429
- //must check that the user has the required capability
430
- if (!current_user_can('manage_options'))
431
- {
432
- wp_die( __('You do not have sufficient permissions to access this page.') );
433
- }
434
-
435
- $this->add_options_stylesheet();
436
- global $wp_subscribe_reloaded;
437
-
438
- // echo 'New Page Settings';
439
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php" ) )
440
- {
441
- // What panel to display
442
- $current_panel = 2;
443
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php";
444
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_manage_subscriptions.php" ) )
445
- {
446
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_manage_subscriptions.php";
447
- }
448
- }
449
- }
450
- /**
451
- * Dispaly the stcr_option_comment_form template
452
- * @since 160316
453
- * @author reedyseth
454
- */
455
- public function stcr_option_comment_form()
456
- {
457
- //must check that the user has the required capability
458
- if (!current_user_can('manage_options'))
459
- {
460
- wp_die( __('You do not have sufficient permissions to access this page.') );
461
- }
462
-
463
- $this->add_options_stylesheet();
464
-
465
- // echo 'New Page Settings';
466
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php" ) )
467
- {
468
- // What panel to display
469
- $current_panel = 2;
470
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php";
471
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_comment_form.php" ) )
472
- {
473
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_comment_form.php";
474
- }
475
- }
476
- }
477
- /**
478
- * Dispaly the stcr_option_management_page template
479
- * @since 160316
480
- * @author reedyseth
481
- */
482
- public function stcr_option_management_page()
483
- {
484
- //must check that the user has the required capability
485
- if (!current_user_can('manage_options'))
486
- {
487
- wp_die( __('You do not have sufficient permissions to access this page.') );
488
- }
489
-
490
- $this->add_options_stylesheet();
491
-
492
- // echo 'New Page Settings';
493
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php" ) )
494
- {
495
- // What panel to display
496
- $current_panel = 2;
497
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php";
498
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_management_page.php" ) )
499
- {
500
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_management_page.php";
501
- }
502
- }
503
- }
504
- /**
505
- * Dispaly the stcr_option_notifications template
506
- * @since 160316
507
- * @author reedyseth
508
- */
509
- public function stcr_option_notifications()
510
- {
511
- //must check that the user has the required capability
512
- if (!current_user_can('manage_options'))
513
- {
514
- wp_die( __('You do not have sufficient permissions to access this page.') );
515
- }
516
-
517
- $this->add_options_stylesheet();
518
-
519
- // echo 'New Page Settings';
520
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php" ) )
521
- {
522
- // What panel to display
523
- $current_panel = 2;
524
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php";
525
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_notifications.php" ) )
526
- {
527
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_notifications.php";
528
- }
529
- }
530
- }
531
- /**
532
- * Dispaly the stcr_option_options template
533
- * @since 160316
534
- * @author reedyseth
535
- */
536
- public function stcr_option_options()
537
- {
538
- //must check that the user has the required capability
539
- if (!current_user_can('manage_options'))
540
- {
541
- wp_die( __('You do not have sufficient permissions to access this page.') );
542
- }
543
-
544
- $this->add_options_stylesheet();
545
-
546
- // echo 'New Page Settings';
547
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php" ) )
548
- {
549
- // What panel to display
550
- $current_panel = 2;
551
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php";
552
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_options.php" ) )
553
- {
554
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_options.php";
555
- }
556
- }
557
- }
558
- /**
559
- * Dispaly the stcr_option_support template
560
- * @since 160316
561
- * @author reedyseth
562
- */
563
- public function stcr_option_support()
564
- {
565
- //must check that the user has the required capability
566
- if (!current_user_can('manage_options'))
567
- {
568
- wp_die( __('You do not have sufficient permissions to access this page.') );
569
- }
570
-
571
- $this->add_options_stylesheet();
572
-
573
- // echo 'New Page Settings';
574
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php" ) )
575
- {
576
- // What panel to display
577
- $current_panel = 2;
578
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php";
579
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_support.php" ) )
580
- {
581
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_support.php";
582
- }
583
- }
584
- }
585
-
586
-
587
- /**
588
- * Dispaly the stcr_option_donate template
589
- * @since 160524
590
- * @author reedyseth
591
- */
592
- public function stcr_option_system()
593
- {
594
- //must check that the user has the required capability
595
- if (!current_user_can('manage_options'))
596
- {
597
- wp_die( __('You do not have sufficient permissions to access this page.') );
598
- }
599
-
600
- $this->add_options_stylesheet();
601
-
602
- // echo 'New Page Settings';
603
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php" ) )
604
- {
605
- // What panel to display
606
- $current_panel = 2;
607
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/index.php";
608
- if ( is_readable( WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_system.php" ) )
609
- {
610
- require_once WP_PLUGIN_DIR . "/subscribe-to-comments-reloaded/options/stcr_system.php";
611
- }
612
- }
613
- }
614
-
615
- /**
616
- * Download system information file
617
- *
618
- * @since 190325
619
- * @return void
620
- */
621
- function sysinfo_download() {
622
-
623
- if ( ! isset( $_POST['stcr_sysinfo_action'] ) ) {
624
- return;
625
- }
626
-
627
- if ( $_POST['stcr_sysinfo_action'] != 'download_sysinfo' ) {
628
- return;
629
- }
630
-
631
- if ( ! current_user_can( 'manage_options' ) ) {
632
- return;
633
- }
634
-
635
- nocache_headers();
636
-
637
- header( 'Content-Type: text/plain' );
638
- header( 'Content-Disposition: attachment; filename="stcr-sysinfo.txt"' );
639
-
640
- echo stripslashes( $_POST['stcr_sysinfo'] );
641
-
642
- exit;
643
-
644
- }
645
-
646
- /**
647
- * Adds a custom stylesheet file to the admin interface
648
- */
649
- public function add_options_stylesheet() {
650
- $stylesheet_url = plugins_url( 'subscribe-to-comments-reloaded/style.css' );
651
- wp_register_style( 'subscribe-to-comments', $stylesheet_url );
652
- wp_enqueue_style( 'subscribe-to-comments' );
653
- }
654
-
655
- public function add_post_comments_stylesheet() {
656
- $stylesheet_url = plugins_url( 'subscribe-to-comments-reloaded/post-and-comments.css' );
657
- wp_register_style( 'subscribe-to-comments', $stylesheet_url );
658
- wp_enqueue_style( 'subscribe-to-comments' );
659
- }
660
- // end add_stylesheet
661
-
662
- /**
663
- * Adds custom HTML code to the HEAD section of the management page
664
- */
665
- public function add_custom_header_meta() {
666
- $a = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_custom_header_meta', '' ) ), ENT_QUOTES, 'UTF-8' );
667
- echo $a;
668
- }
669
- // end add_custom_header_meta
670
-
671
- /**
672
- * Adds a new column header to the Edit Comments panel
673
- */
674
- public function add_column_header( $_columns ) {
675
- $image_url = plugins_url( 'subscribe-to-comments-reloaded/images' );
676
- $image_tooltip = __( 'Subscriptions', 'subscribe-to-comments-reloaded' );
677
- $_columns['subscribe-reloaded'] = "<span class='hidden'>" . $image_tooltip . "</span><img src='$image_url/subscribe-to-comments-small.png' width='17' height='12' alt='" . $image_tooltip . "' title='" . $image_tooltip . "' />";
678
-
679
- return $_columns;
680
- }
681
- // end add_comment_column_header
682
-
683
- /**
684
- * Adds a new column to the Edit Comments panel
685
- */
686
- public function add_comment_column( $_column_name ) {
687
- if ( 'subscribe-reloaded' != $_column_name ) {
688
- return;
689
- }
690
-
691
- global $comment;
692
- $subscription = $this->get_subscriptions(
693
- array(
694
- 'post_id',
695
- 'email'
696
- ), array(
697
- 'equals',
698
- 'equals'
699
- ), array(
700
- $comment->comment_post_ID,
701
- $comment->comment_author_email
702
- ), 'dt', 'DESC', 0, 1
703
- );
704
- if ( count( $subscription ) == 0 ) {
705
- echo '<a href="admin.php?page=stcr_manage_subscriptions&subscribepanel=1&amp;sra=add-subscription&amp;srp=' . $comment->comment_post_ID . '&amp;sre=' . urlencode( $comment->comment_author_email ) . '">' . __( 'No', 'subscribe-to-comments-reloaded' ) . '</a>';
706
- } else {
707
- echo '<a href="admin.php?page=stcr_manage_subscriptions&subscribepanel=1&amp;srf=email&amp;srt=equals&amp;srv=' . urlencode( $comment->comment_author_email ) . '">' . $subscription[0]->status . '</a>';
708
- }
709
- }
710
- // end add_column
711
-
712
- /**
713
- * Adds a new column to the Posts management panel
714
- */
715
- public function add_post_column( $_column_name ) {
716
- if ( 'subscribe-reloaded' != $_column_name ) {
717
- return;
718
- }
719
-
720
- global $post;
721
- echo '<a href="admin.php?page=stcr_manage_subscriptions&subscribepanel=1&amp;srf=post_id&amp;srt=equals&amp;srv=' . $post->ID . '">' . count( $this->get_subscriptions( 'post_id', 'equals', $post->ID ) ) . '</a>';
722
- }
723
- // end add_column
724
-
725
- /**
726
- * Returns the URL of the management page as a shortcode
727
- */
728
- public function subscribe_url_shortcode() {
729
- global $post;
730
- $user_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '' );
731
- if ( function_exists( 'qtrans_convertURL' ) ) {
732
- $user_link = qtrans_convertURL( $user_link );
733
- }
734
- if ( strpos( $user_link, '?' ) !== false ) {
735
- return "$user_link&amp;srp=$post->ID&amp;sra=s";
736
- } else {
737
- return "$user_link?srp=$post->ID&amp;sra=s";
738
- }
739
- }
740
- // end subscribe_url_shortcode
741
-
742
- /**
743
- * Exclude subscriptions on post duplication
744
- *
745
- * @since 200625
746
- */
747
- public function duplicate_post_exclude_subs( $exclude ) {
748
-
749
- return array_merge( $exclude, array( '_stcr' ) );
750
-
751
- }
752
-
753
- }
754
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class with management functions for Subscribe to Comments Reloaded
4
+ * @author reedyseth
5
+ * @since 16-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
+ require_once dirname(__FILE__).'/stcr_utils.php';
16
+ require_once dirname(__FILE__).'/stcr_upgrade.php';
17
+
18
+ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_manage') )
19
+ {
20
+ class stcr_manage {
21
+
22
+ public $current_version = VERSION;
23
+ public $utils = null;
24
+ public $upgrade = null;
25
+ public $db_version = null;
26
+ public $fresh_install = false;
27
+
28
+ public function __construct() {
29
+ $this->upgrade = new stcr_upgrade();
30
+ $this->utils = new stcr_utils();
31
+ $this->db_version = get_option( 'subscribe_reloaded_version' );
32
+ if ( ! get_option( 'subscribe_reloaded_fresh_install' )
33
+ || get_option( 'subscribe_reloaded_fresh_install' ) == 'yes')
34
+ {
35
+ $this->fresh_install = true;
36
+ }
37
+ else
38
+ {
39
+ $this->fresh_install = false;
40
+ update_option('subscribe_reloaded_fresh_install', 'no');
41
+ }
42
+ // Schedule the autopurge hook
43
+ if ( ! wp_next_scheduled( '_cron_subscribe_reloaded_purge' ) ) {
44
+ wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
45
+ // Let us bind the schedule event with our desire action.
46
+ wp_schedule_event( time() + 15, 'daily', '_cron_subscribe_reloaded_purge' );
47
+ }
48
+
49
+ }
50
+
51
+ /**
52
+ * Search for a new version of code for a possible update
53
+ */
54
+ public function stcr_admin_init() {
55
+
56
+ // Add Authors to custom posts types
57
+ if ( get_option( 'subscribe_reloaded_notify_authors' ) === 'yes' ) {
58
+ // Retrieve custom post types
59
+ $gpt_args = array('_builtin' => false);
60
+ $post_types = get_post_types( $gpt_args );
61
+ foreach ($post_types as $post_type_name) {
62
+ // Add author subscription in every post type
63
+ add_action( 'publish_' . $post_type_name , array( $this, 'subscribe_post_author' ) );
64
+ }
65
+ }
66
+ }
67
+
68
+ public function admin_notices() {
69
+ $notices = get_option( 'subscribe_reloaded_deferred_admin_notices' );
70
+ $nonce = null;
71
+
72
+ if ( $notices ) {
73
+ // Add JS script
74
+ wp_enqueue_script( 'stcr-admin-js' );
75
+ wp_enqueue_style( 'stcr-admin-style' );
76
+
77
+ foreach ( $notices as $name => $noticeData ) {
78
+ if( $noticeData['status'] == 'unread' ) {
79
+ $nonce = wp_create_nonce( $name );
80
+ // Set the a fresh nonce
81
+ $this->utils->stcr_update_admin_notice_status( $name, 'unread', $nonce );
82
+ echo "<div class='notice is-dismissible stcr-dismiss-notice {$noticeData['type']}' data-nonce='{$nonce}|{$name}'>";
83
+ echo $noticeData['message'];
84
+ echo "</div>";
85
+ }
86
+ }
87
+ update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Support for WP MU network activations (experimental)
93
+ */
94
+ public function new_blog( $_blog_id ) {
95
+ switch_to_blog( $_blog_id );
96
+ $this->_activate();
97
+ restore_current_blog();
98
+ }
99
+ // end new_blog
100
+
101
+ public function sendConfirmationEMail( $info ) {
102
+ // Retrieve the information about the new comment.
103
+ $this->confirmation_email( $info->comment_post_ID, $info->comment_author_email );
104
+ }
105
+
106
+ /**
107
+ * Sends a message to confirm a subscription
108
+ */
109
+ public function confirmation_email( $_post_ID = 0, $_email = '' ) {
110
+ $has_blacklist_email = $this->utils->blacklisted_emails( $_email );
111
+ // Do not proceed on sending the confirmation email if the email
112
+ // address is in blacklist email list.
113
+ if ( false === $has_blacklist_email ) {
114
+ return;
115
+ }
116
+
117
+ // Retrieve the options from the database
118
+ $from_name = stripslashes( get_option( 'subscribe_reloaded_from_name', 'admin' ) );
119
+ $from_email = get_option( 'subscribe_reloaded_from_email', get_bloginfo( 'admin_email' ) );
120
+ $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_double_check_subject', 'Please confirm your subscribtion to [post_title]' ) ), ENT_COMPAT, 'UTF-8' );
121
+ $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_double_check_content', '' ) ), ENT_COMPAT, 'UTF-8' );
122
+ $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
123
+ if ( function_exists( 'qtrans_convertURL' ) ) {
124
+ $manager_link = qtrans_convertURL( $manager_link );
125
+ }
126
+
127
+ $clean_email = $this->utils->clean_email( $_email );
128
+ $subscriber_salt = $this->utils->generate_temp_key( $clean_email );
129
+
130
+ $this->utils->add_user_subscriber_table( $clean_email );
131
+
132
+ $post = get_post( $_post_ID );
133
+ $post_permalink = get_permalink( $_post_ID );
134
+
135
+ $manager_link .= ( ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?' ) . "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=" . $subscriber_salt;
136
+ $confirm_link = "$manager_link&srp=$_post_ID&sra=c&srsrc=e&confirmation_email=y&post_permalink=" . esc_url( $post_permalink );
137
+
138
+
139
+ // Replace tags with their actual values
140
+ $subject = str_replace( '[post_title]', $post->post_title, $subject );
141
+
142
+ $message = str_replace( '[post_permalink]', $post_permalink, $message );
143
+ $message = str_replace( '[confirm_link]', $confirm_link, $message );
144
+ $message = str_replace( '[manager_link]', $manager_link, $message );
145
+
146
+ // QTranslate support
147
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
148
+ $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
149
+ $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $post->post_title ), $message );
150
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
151
+ } else {
152
+ $message = str_replace( '[post_title]', $post->post_title, $message );
153
+ }
154
+ $message = apply_filters( 'stcr_confirmation_email_message', $message, $_post_ID, $clean_email );
155
+
156
+ // Prepare email settings
157
+ $email_settings = array(
158
+ 'subject' => $subject,
159
+ 'message' => $message,
160
+ 'toEmail' => $clean_email,
161
+ 'XPostId' => $_post_ID
162
+ );
163
+ $this->utils->send_email( $email_settings );
164
+ }
165
+ // end confirmation_email
166
+
167
+ /**
168
+ * Support for WP MU network activations (experimental)
169
+ */
170
+ public function activate() {
171
+ global $wpdb;
172
+
173
+ if ( function_exists( 'is_multisite' ) && is_multisite() && isset( $_GET['networkwide'] ) && ( $_GET['networkwide'] == 1 ) ) {
174
+ $blogids = $wpdb->get_col(
175
+ $wpdb->prepare(
176
+ "
177
+ SELECT blog_id
178
+ FROM $wpdb->blogs
179
+ WHERE site_id = %d
180
+ AND deleted = 0
181
+ AND spam = 0", $wpdb->siteid
182
+ )
183
+ );
184
+
185
+ foreach ( $blogids as $blog_id ) {
186
+ switch_to_blog( $blog_id );
187
+ $this->_activate();
188
+ }
189
+ restore_current_blog();
190
+ } else {
191
+ $this->_activate();
192
+ }
193
+ }
194
+ // end activate
195
+ /**
196
+ * Adds the options to the database and imports the data from other plugins
197
+ */
198
+ public function _activate() {
199
+ // Load localization files
200
+ // load_plugin_textdomain( 'subscribe-to-comments-reloaded', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
201
+ // Upgrade rountine
202
+ $this->upgrade();
203
+
204
+ delete_option('subscribe_reloaded_unique_key');
205
+
206
+ $this->utils->create_options();
207
+ }
208
+ /**
209
+ * Performs some clean-up maintenance (disable cron job).
210
+ */
211
+ public function deactivate() {
212
+ global $wpdb;
213
+ if ( function_exists( 'is_multisite' ) && is_multisite() && isset( $_GET['networkwide'] ) && ( $_GET['networkwide'] == 1 ) ) {
214
+ $blogids = $wpdb->get_col(
215
+ $wpdb->prepare(
216
+ "
217
+ SELECT blog_id
218
+ FROM $wpdb->blogs
219
+ WHERE site_id = %d
220
+ AND deleted = 0
221
+ AND spam = 0", $wpdb->siteid
222
+ )
223
+ );
224
+
225
+ foreach ( $blogids as $blog_id ) {
226
+ switch_to_blog( $blog_id );
227
+ wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
228
+ wp_clear_scheduled_hook( '_cron_log_file_purge' );
229
+ wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
230
+
231
+ }
232
+ restore_current_blog();
233
+ } else {
234
+ wp_clear_scheduled_hook( '_cron_subscribe_reloaded_purge' );
235
+ wp_clear_scheduled_hook( '_cron_log_file_purge' );
236
+ wp_clear_scheduled_hook( '_cron_subscribe_reloaded_system_report_file_purge' );
237
+ }
238
+ }
239
+
240
+ // end deactivate
241
+
242
+ public function maybe_update()
243
+ {
244
+ $int_db_version = str_replace('.','', $this->db_version) ;
245
+ $int_curr_version = str_replace('.','', $this->current_version) ;
246
+
247
+ if ( empty ( $int_db_version ) || (int) $int_db_version < (int) $int_curr_version ) {
248
+ // // Do whatever upgrades needed here.
249
+ // $this->_activate();
250
+ // Send the current version to display the appropiate message
251
+ // The notification will only be visible once there is an update not a activation.
252
+ $this->upgrade->upgrade_notification( $this->current_version, $this->db_version, $this->fresh_install );
253
+ $this->upgrade();
254
+ update_option( 'subscribe_reloaded_version', $this->current_version );
255
+ }
256
+ }
257
+
258
+ private function upgrade()
259
+ {
260
+ // Import data from the WP Comment Subscriptions plugin, if needed
261
+ $this->upgrade->_import_wpcs_data();
262
+
263
+ // Import data from Subscribe to Comments & Co., if needed
264
+ $this->upgrade->_import_stc_data();
265
+
266
+ // Import data from Subscribe to Comments by Mark Jaquith
267
+ $this->upgrade->_import_stc_mj_data();
268
+
269
+ // Import data from Comment Reply Notification, if needed
270
+ // Function deprecated and not in use anymore.
271
+ // $this->upgrade->_import_crn_data();
272
+
273
+ // Starting from version 2.0 StCR uses Wordpress' tables to store the information about subscriptions
274
+ $this->upgrade->_update_db();
275
+
276
+ // Since there are some users with the database corrupted due to encoding stuff we need to sanitize
277
+ // their information
278
+ $this->upgrade->_sanitize_db_information( $this->fresh_install );
279
+ // Create a new table if not exists to manage the subscribers safer
280
+ // First Check if the subscribers table is created.
281
+ if ( ! get_option( 'subscribe_reloaded_subscriber_table' ) || get_option( 'subscribe_reloaded_subscriber_table' ) == 'no') {
282
+ $this->upgrade->_create_subscriber_table( $this->fresh_install );
283
+ }
284
+ // Apply Patches
285
+ $this->upgrade->apply_patches();
286
+
287
+ // Migrate/Add new plugin options on version upgrade.
288
+ $this->upgrade->email_blacklist_post_types_recaptcha();
289
+ }
290
+
291
+ /**
292
+ * Remove the log file created by StCR
293
+ * @since 05-Apr-2017
294
+ */
295
+ public function log_file_purge()
296
+ {
297
+ $plugin_dir = plugin_dir_path( __DIR__ );
298
+ $file_name = "log.txt";
299
+ $file_path = $plugin_dir . "utils/" . $file_name;
300
+
301
+ if( file_exists( $file_path ) && is_writable( $plugin_dir ) )
302
+ {
303
+ // unlink the file
304
+ unlink($file_path);
305
+ }
306
+ }
307
+ /**
308
+ * Removes old entries from the database
309
+ */
310
+ public function subscribe_reloaded_purge() {
311
+ global $wpdb;
312
+
313
+ if ( ( $autopurge_interval = intval( get_option( 'subscribe_reloaded_purge_days', 0 ) ) ) <= 0 ) {
314
+ return true;
315
+ }
316
+
317
+ // First retrieve the emails to be deleted
318
+ $emailsToPurge = "SELECT DISTINCT REPLACE(meta_key, '_stcr@_', '') AS email FROM $wpdb->postmeta
319
+ WHERE meta_key LIKE '\_stcr@\_%'
320
+ AND STR_TO_DATE(meta_value, '%Y-%m-%d %H:%i:%s') <= DATE_SUB(NOW(),
321
+ INTERVAL $autopurge_interval DAY) AND meta_value LIKE '%C'";
322
+
323
+ $emails = $wpdb->get_results( $emailsToPurge, OBJECT );
324
+ // Now if there are emails go ahead and delete them
325
+ if ( ! empty( $emails ) && is_array( $emails ) ) {
326
+ foreach( $emails as $row ) {
327
+ $this->utils->remove_user_subscriber_table($row->email);
328
+ }
329
+ }
330
+ // Delete old entries on the post_meta table
331
+ $wpdb->query(
332
+ "
333
+ DELETE FROM $wpdb->postmeta
334
+ WHERE meta_key LIKE '\_stcr@\_%'
335
+ AND STR_TO_DATE(meta_value, '%Y-%m-%d %H:%i:%s') <= DATE_SUB(NOW(), INTERVAL $autopurge_interval DAY) AND meta_value LIKE '%C'"
336
+ );
337
+ }
338
+ // end subscribe_reloaded_purge
339
+ /**
340
+ * Finds all links in text and wraps them with an HTML anchor tag
341
+ *
342
+ * @param unknown $text
343
+ *
344
+ * @return string Text with all links wrapped in HTML anchor tags
345
+ *
346
+ */
347
+ public function htmlify_message_links( $text ) {
348
+ return preg_replace( '!(((f|ht)tp(s)?://)[-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $text );
349
+ }
350
+
351
+ /**
352
+ * Adds a new entry in the admin menu, to manage this plugin's options
353
+ */
354
+ public function add_config_menu( $_s ) {
355
+
356
+ if ( current_user_can( 'manage_options' ) ) {
357
+
358
+ $page_title = "Subscribe to Comments Reloaded";
359
+ $menu_title = "StCR";
360
+ $capability = "manage_options";
361
+ $moderate_capability = 'manage_options';
362
+ $function = "";
363
+ $icon_url = "dashicons-email";
364
+ $position = 26;
365
+ $parent_slug= "stcr_manage_subscriptions";
366
+ add_menu_page( $page_title, $menu_title, $moderate_capability, $parent_slug, $function, $icon_url, $position );
367
+
368
+ add_submenu_page( $parent_slug ,
369
+ __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ),
370
+ __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ),
371
+ $moderate_capability,
372
+ "stcr_manage_subscriptions",
373
+ array( $this, "stcr_option_manage_subscriptions") );
374
+ add_submenu_page( $parent_slug ,
375
+ __( 'Comment Form', 'subscribe-to-comments-reloaded' ),
376
+ __( 'Comment Form', 'subscribe-to-comments-reloaded' ),
377
+ $capability,
378
+ "stcr_comment_form",
379
+ array( $this, "stcr_option_comment_form" ) );
380
+ add_submenu_page( $parent_slug ,
381
+ __( 'Management Page', 'subscribe-to-comments-reloaded' ),
382
+ __( 'Management Page', 'subscribe-to-comments-reloaded' ),
383
+ $capability,
384
+ "stcr_management_page",
385
+ array( $this, "stcr_option_management_page" ) );
386
+ add_submenu_page( $parent_slug ,
387
+ __( 'Notifications', 'subscribe-to-comments-reloaded' ),
388
+ __( 'Notifications', 'subscribe-to-comments-reloaded' ),
389
+ $capability,
390
+ "stcr_notifications",
391
+ array( $this, "stcr_option_notifications" ) );
392
+ add_submenu_page( $parent_slug ,
393
+ __( 'Options', 'subscribe-to-comments-reloaded' ),
394
+ __( 'Options', 'subscribe-to-comments-reloaded' ),
395
+ $capability,
396
+ "stcr_options",
397
+ array( $this, "stcr_option_options" ) );
398
+ // @since 160316
399
+ // Using this page requires to list a cool table, on this case will be the WP_List_Table,
400
+ // since this requires much effort this is pointe to go to the pro version. NO ETA avaiable.
401
+ //
402
+ // add_submenu_page( $parent_slug ,
403
+ // __( 'Subscribers Emails', 'subscribe-to-comments-reloaded' ),
404
+ // __( 'Subscribers Emails', 'subscribe-to-comments-reloaded' ),
405
+ // $capability,
406
+ // "stcr_subscribers_emails",
407
+ // array( $this, "stcr_option_subscribers_emails" ) );
408
+
409
+ add_submenu_page( $parent_slug ,
410
+ __( 'Support', 'subscribe-to-comments-reloaded' ),
411
+ __( 'Support', 'subscribe-to-comments-reloaded' ),
412
+ $capability,
413
+ "stcr_support",
414
+ array( $this, "stcr_option_support" ) );
415
+ // add_submenu_page( $parent_slug ,
416
+ // __( 'Donate', 'subscribe-to-comments-reloaded' ),
417
+ // __( 'Donate', 'subscribe-to-comments-reloaded' ),
418
+ // $capability,
419
+ // "stcr_donate",
420
+ // array( $this, "stcr_option_donate" ) );
421
+ add_submenu_page( $parent_slug ,
422
+ __( 'StCR System', 'subscribe-to-comments-reloaded' ),
423
+ __( 'StCR System', 'subscribe-to-comments-reloaded' ),
424
+ $capability,
425
+ "stcr_system",
426
+ array( $this, "stcr_option_system" ) );
427
+ }
428
+
429
+ return $_s;
430
+ }
431
+ // end add_config_menu
432
+
433
+ /**
434
+ * Dispaly the stcr_option_manage_subscriptions template
435
+ * @since 160316
436
+ * @author reedyseth
437
+ */
438
+ public function stcr_option_manage_subscriptions()
439
+ {
440
+ //must check that the user has the required capability
441
+ if (!current_user_can('manage_options'))
442
+ {
443
+ wp_die( __('You do not have sufficient permissions to access this page.') );
444
+ }
445
+
446
+ $this->add_options_stylesheet();
447
+ global $wp_subscribe_reloaded;
448
+
449
+ // echo 'New Page Settings';
450
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php' ) )
451
+ {
452
+ // What panel to display
453
+ $current_panel = 2;
454
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php';
455
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_manage_subscriptions.php' ) )
456
+ {
457
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_manage_subscriptions.php';
458
+ }
459
+ }
460
+ }
461
+ /**
462
+ * Dispaly the stcr_option_comment_form template
463
+ * @since 160316
464
+ * @author reedyseth
465
+ */
466
+ public function stcr_option_comment_form()
467
+ {
468
+ //must check that the user has the required capability
469
+ if (!current_user_can('manage_options'))
470
+ {
471
+ wp_die( __('You do not have sufficient permissions to access this page.') );
472
+ }
473
+
474
+ $this->add_options_stylesheet();
475
+
476
+ // echo 'New Page Settings';
477
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php' ) )
478
+ {
479
+ // What panel to display
480
+ $current_panel = 2;
481
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php';
482
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_comment_form.php' ) )
483
+ {
484
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_comment_form.php';
485
+ }
486
+ }
487
+ }
488
+ /**
489
+ * Dispaly the stcr_option_management_page template
490
+ * @since 160316
491
+ * @author reedyseth
492
+ */
493
+ public function stcr_option_management_page()
494
+ {
495
+ //must check that the user has the required capability
496
+ if (!current_user_can('manage_options'))
497
+ {
498
+ wp_die( __('You do not have sufficient permissions to access this page.') );
499
+ }
500
+
501
+ $this->add_options_stylesheet();
502
+
503
+ // echo 'New Page Settings';
504
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php' ) )
505
+ {
506
+ // What panel to display
507
+ $current_panel = 2;
508
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php';
509
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_management_page.php' ) )
510
+ {
511
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_management_page.php';
512
+ }
513
+ }
514
+ }
515
+ /**
516
+ * Dispaly the stcr_option_notifications template
517
+ * @since 160316
518
+ * @author reedyseth
519
+ */
520
+ public function stcr_option_notifications()
521
+ {
522
+ //must check that the user has the required capability
523
+ if (!current_user_can('manage_options'))
524
+ {
525
+ wp_die( __('You do not have sufficient permissions to access this page.') );
526
+ }
527
+
528
+ $this->add_options_stylesheet();
529
+
530
+ // echo 'New Page Settings';
531
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php' ) )
532
+ {
533
+ // What panel to display
534
+ $current_panel = 2;
535
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php';
536
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_notifications.php' ) )
537
+ {
538
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_notifications.php';
539
+ }
540
+ }
541
+ }
542
+ /**
543
+ * Dispaly the stcr_option_options template
544
+ * @since 160316
545
+ * @author reedyseth
546
+ */
547
+ public function stcr_option_options()
548
+ {
549
+ //must check that the user has the required capability
550
+ if (!current_user_can('manage_options'))
551
+ {
552
+ wp_die( __('You do not have sufficient permissions to access this page.') );
553
+ }
554
+
555
+ $this->add_options_stylesheet();
556
+
557
+ // echo 'New Page Settings';
558
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php' ) )
559
+ {
560
+ // What panel to display
561
+ $current_panel = 2;
562
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php';
563
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_options.php' ) )
564
+ {
565
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_options.php';
566
+ }
567
+ }
568
+ }
569
+ /**
570
+ * Dispaly the stcr_option_support template
571
+ * @since 160316
572
+ * @author reedyseth
573
+ */
574
+ public function stcr_option_support()
575
+ {
576
+ //must check that the user has the required capability
577
+ if (!current_user_can('manage_options'))
578
+ {
579
+ wp_die( __('You do not have sufficient permissions to access this page.') );
580
+ }
581
+
582
+ $this->add_options_stylesheet();
583
+
584
+ // echo 'New Page Settings';
585
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php' ) )
586
+ {
587
+ // What panel to display
588
+ $current_panel = 2;
589
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php';
590
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_support.php' ) )
591
+ {
592
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_support.php';
593
+ }
594
+ }
595
+ }
596
+
597
+
598
+ /**
599
+ * Dispaly the stcr_option_donate template
600
+ * @since 160524
601
+ * @author reedyseth
602
+ */
603
+ public function stcr_option_system()
604
+ {
605
+ //must check that the user has the required capability
606
+ if (!current_user_can('manage_options'))
607
+ {
608
+ wp_die( __('You do not have sufficient permissions to access this page.') );
609
+ }
610
+
611
+ $this->add_options_stylesheet();
612
+
613
+ // echo 'New Page Settings';
614
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php' ) )
615
+ {
616
+ // What panel to display
617
+ $current_panel = 2;
618
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/index.php';
619
+ if ( is_readable( trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_system.php' ) )
620
+ {
621
+ require_once trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'options/stcr_system.php';
622
+ }
623
+ }
624
+ }
625
+
626
+ /**
627
+ * Download system information file
628
+ *
629
+ * @since 190325
630
+ * @return void
631
+ */
632
+ function sysinfo_download() {
633
+
634
+ if ( ! isset( $_POST['stcr_sysinfo_action'] ) ) {
635
+ return;
636
+ }
637
+
638
+ if ( $_POST['stcr_sysinfo_action'] != 'download_sysinfo' ) {
639
+ return;
640
+ }
641
+
642
+ if ( empty( $_POST['stcr_download_sysinfo_nonce'] ) ) {
643
+ return;
644
+ }
645
+
646
+ if ( ! wp_verify_nonce( $_POST['stcr_download_sysinfo_nonce'], 'stcr_download_sysinfo_nonce' ) ) {
647
+ return;
648
+ }
649
+
650
+ if ( ! current_user_can( 'manage_options' ) ) {
651
+ return;
652
+ }
653
+
654
+ nocache_headers();
655
+
656
+ header( 'Content-Type: text/plain' );
657
+ header( 'Content-Disposition: attachment; filename="stcr-sysinfo.txt"' );
658
+
659
+ echo stripslashes( $_POST['stcr_sysinfo'] );
660
+
661
+ exit;
662
+
663
+ }
664
+
665
+ /**
666
+ * Adds a custom stylesheet file to the admin interface
667
+ */
668
+ public function add_options_stylesheet() {
669
+ $stylesheet_url = plugins_url( '/style.css', STCR_PLUGIN_FILE );
670
+ wp_register_style( 'subscribe-to-comments', $stylesheet_url );
671
+ wp_enqueue_style( 'subscribe-to-comments' );
672
+ }
673
+
674
+ public function add_post_comments_stylesheet() {
675
+ $stylesheet_url = plugins_url( '/post-and-comments.css', STCR_PLUGIN_FILE );
676
+ wp_register_style( 'subscribe-to-comments', $stylesheet_url );
677
+ wp_enqueue_style( 'subscribe-to-comments' );
678
+ }
679
+ // end add_stylesheet
680
+
681
+ /**
682
+ * Adds custom HTML code to the HEAD section of the management page
683
+ */
684
+ public function add_custom_header_meta() {
685
+ $a = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_custom_header_meta', '' ) ), ENT_QUOTES, 'UTF-8' );
686
+ echo $a;
687
+ }
688
+ // end add_custom_header_meta
689
+
690
+ /**
691
+ * Adds a new column header to the Edit Comments panel
692
+ */
693
+ public function add_column_header( $_columns ) {
694
+ $image_url = plugins_url( '/images', STCR_PLUGIN_FILE );
695
+ $image_tooltip = __( 'Subscriptions', 'subscribe-to-comments-reloaded' );
696
+ $_columns['subscribe-reloaded'] = "<span class='hidden'>" . $image_tooltip . "</span><img src='$image_url/subscribe-to-comments-small.png' width='17' height='12' alt='" . $image_tooltip . "' title='" . $image_tooltip . "' />";
697
+
698
+ return $_columns;
699
+ }
700
+ // end add_comment_column_header
701
+
702
+ /**
703
+ * Adds a new column to the Edit Comments panel
704
+ */
705
+ public function add_comment_column( $_column_name ) {
706
+ if ( 'subscribe-reloaded' != $_column_name ) {
707
+ return;
708
+ }
709
+
710
+ global $comment;
711
+ $subscription = $this->get_subscriptions(
712
+ array(
713
+ 'post_id',
714
+ 'email'
715
+ ), array(
716
+ 'equals',
717
+ 'equals'
718
+ ), array(
719
+ $comment->comment_post_ID,
720
+ $comment->comment_author_email
721
+ ), 'dt', 'DESC', 0, 1
722
+ );
723
+ if ( count( $subscription ) == 0 ) {
724
+ echo '<a href="admin.php?page=stcr_manage_subscriptions&subscribepanel=1&amp;sra=add-subscription&amp;srp=' . $comment->comment_post_ID . '&amp;sre=' . urlencode( $comment->comment_author_email ) . '">' . __( 'No', 'subscribe-to-comments-reloaded' ) . '</a>';
725
+ } else {
726
+ echo '<a href="admin.php?page=stcr_manage_subscriptions&subscribepanel=1&amp;srf=email&amp;srt=equals&amp;srv=' . urlencode( $comment->comment_author_email ) . '">' . $subscription[0]->status . '</a>';
727
+ }
728
+ }
729
+ // end add_column
730
+
731
+ /**
732
+ * Adds a new column to the Posts management panel
733
+ */
734
+ public function add_post_column( $_column_name ) {
735
+ if ( 'subscribe-reloaded' != $_column_name ) {
736
+ return;
737
+ }
738
+
739
+ global $post;
740
+ echo '<a href="admin.php?page=stcr_manage_subscriptions&subscribepanel=1&amp;srf=post_id&amp;srt=equals&amp;srv=' . $post->ID . '">' . count( $this->get_subscriptions( 'post_id', 'equals', $post->ID ) ) . '</a>';
741
+ }
742
+ // end add_column
743
+
744
+ /**
745
+ * Returns the URL of the management page as a shortcode
746
+ */
747
+ public function subscribe_url_shortcode() {
748
+ global $post;
749
+ $user_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '' );
750
+ if ( function_exists( 'qtrans_convertURL' ) ) {
751
+ $user_link = qtrans_convertURL( $user_link );
752
+ }
753
+ if ( strpos( $user_link, '?' ) !== false ) {
754
+ return "$user_link&amp;srp=$post->ID&amp;sra=s";
755
+ } else {
756
+ return "$user_link?srp=$post->ID&amp;sra=s";
757
+ }
758
+ }
759
+ // end subscribe_url_shortcode
760
+
761
+ /**
762
+ * Exclude subscriptions on post duplication
763
+ *
764
+ * @since 200625
765
+ */
766
+ public function duplicate_post_exclude_subs( $exclude ) {
767
+
768
+ return array_merge( $exclude, array( '_stcr' ) );
769
+
770
+ }
771
+
772
+ }
773
+ }
utils/stcr_upgrade.php CHANGED
@@ -1,761 +1,819 @@
1
- <?php
2
- /**
3
- * Class with utility functions to upgrade 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_upgrade') ) {
16
- class stcr_upgrade extends stcr_utils {
17
-
18
- private $_stcr_charset = null;
19
- private $_stcr_collate = null;
20
- private $_db_collate = null;
21
-
22
- public function __construct()
23
- {
24
- $this->_stcr_charset = 'utf8';
25
- $this->_stcr_collate = 'utf8_unicode_ci';
26
- $this->_db_collate = "DEFAULT CHARSET={$this->_stcr_charset} COLLATE={$this->_stcr_collate}";
27
- }
28
-
29
- public function apply_patches()
30
- {
31
- $this->patch_collation();
32
- }
33
-
34
- public function _create_subscriber_table( $_fresh_install ) {
35
- global $wpdb;
36
- $errorMsg = '';
37
-
38
- // If the update option is set to false
39
- $stcr_opt_subscriber_table = get_option('subscribe_reloaded_subscriber_table');
40
-
41
- if ( $_fresh_install || ( ! $stcr_opt_subscriber_table || $stcr_opt_subscriber_table == 'no' ) ) {
42
- // Creation of table and subscribers.
43
- $sqlCreateTable = " CREATE TABLE " . $wpdb->prefix . "subscribe_reloaded_subscribers (
44
- stcr_id int(11) NOT NULL AUTO_INCREMENT,
45
- subscriber_email varchar(100) NOT NULL,
46
- salt int(15) NOT NULL,
47
- subscriber_unique_id varchar(50) NULL,
48
- add_date timestamp NOT NULL DEFAULT NOW(),
49
- PRIMARY KEY (stcr_id),
50
- UNIQUE KEY uk_subscriber_email (subscriber_email))
51
- ENGINE = InnoDB
52
- $this->_db_collate";
53
-
54
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
55
- // dbDelta Will create or update the table safety
56
- // Ref: https://codex.wordpress.org/Creating_Tables_with_Plugins
57
- $result = dbDelta( $sqlCreateTable );
58
- $retrieveNumberOfSubscribers = "SELECT COUNT(subscriber_email) FROM " . $wpdb->prefix . "subscribe_reloaded_subscribers";
59
- $numSubscribers = $wpdb->get_var( $retrieveNumberOfSubscribers );
60
- // If subscribers not found then the create routine.
61
- if ( $numSubscribers == 0 ) {
62
- // Get list of emails to be imported.
63
- $retrieveEmails = "SELECT DISTINCT REPLACE(meta_key, '_stcr@_', '') AS email FROM " . $wpdb->postmeta
64
- . " WHERE meta_key LIKE '\_stcr@\_%'";
65
- $emails = $wpdb->get_results( $retrieveEmails, OBJECT );
66
- // insert the records on the new table.
67
- foreach ( $emails as $email ) {
68
- // Insert email
69
- $OK = $this->add_user_subscriber_table( $email->email );
70
- if ( ! $OK) {
71
- $notices = get_option( 'subscribe_reloaded_deferred_admin_notices', array() );
72
- $notices[] = '<div class="error"><h3>' . __( 'Important Notice', 'subscribe-to-comments-reloaded' ) . '</h3>' .
73
- '<p>The creation of of the table <strong>' . $wpdb->prefix . 'subscribe_reloaded_subscribers</strong> failed</p></div>';
74
- update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
75
- break 1;
76
- }
77
- }
78
-
79
- if( ! $_fresh_install )
80
- {
81
- $this->stcr_create_admin_notice(
82
- 'notify_create_subscriber_table',
83
- 'unread',
84
- '<p><strong>Subscribe to Comments Reloaded:</strong> The creation of table <code>' . $wpdb->prefix . 'subscribe_reloaded_subscribers</code> was successful.</p>'.
85
- '<p>This new table will help to add your subscribers email addresses more safely and prevent Google PII violations.'
86
- . '<a class="dismiss" href="#">Dismiss. </a>'
87
- . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">'
88
- . '</p>',
89
- 'updated'
90
- );
91
- }
92
- update_option('subscribe_reloaded_subscriber_table', 'yes');
93
- }
94
- }
95
- }
96
-
97
- public function _sanitize_db_information( $_fresh_install ) {
98
- global $wpdb;
99
-
100
- if ( ( ! get_option( "subscribe_reloaded_data_sanitized" )
101
- || get_option( "subscribe_reloaded_data_sanitized" ) == "no" )
102
- && ! $_fresh_install ) {
103
- $stcr_data = $wpdb->get_results(
104
- " SELECT * FROM $wpdb->options WHERE option_name like 'subscribe_reloaded%'
105
- ORDER BY option_name", OBJECT
106
- );
107
- $sctr_data_array_size = sizeof( $stcr_data );
108
- // Lets make sure that there is not another subscription with the same compose key
109
- foreach ( $stcr_data as $row ) {
110
- if ( $row->option_name != 'subscribe_reloaded_deferred_admin_notices' ) {
111
- $optionValue = $row->option_value;
112
- $optionValue = html_entity_decode( stripslashes( $optionValue ), ENT_QUOTES, 'UTF-8' );
113
- $optionValue = esc_attr( $optionValue );
114
- update_option( $row->option_name, $optionValue );
115
- }
116
- }
117
- $this->stcr_create_admin_notice(
118
- 'notify_update_sanitize_db_options',
119
- 'unread',
120
- '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> The information in your database has been sanitized to prevent the raw html messages. <a class="dismiss" href="#">Dismiss. </a>'
121
- . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">' , 'subscribe-to-comments-reloaded' )
122
- . '</p>',
123
- 'updated'
124
- );
125
- update_option( "subscribe_reloaded_data_sanitized", "yes" );
126
- }
127
- } // end _sanitize_db_information
128
-
129
- /**
130
- * Copies the information from the stand-alone table to WP's core table
131
- */
132
- public function _update_db() {
133
- global $wpdb;
134
- $stcr_table = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}subscribe_reloaded'" );
135
-
136
- // Perform the import only if the target table does not contain any subscriptions
137
- $count_postmeta_rows = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
138
- if ( ! empty( $stcr_table ) && $count_postmeta_rows == 0 ) {
139
- $wpdb->query(
140
- "
141
- INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
142
- SELECT post_ID, CONCAT('_stcr@_', email), CONCAT(dt, '|Y')
143
- FROM {$wpdb->prefix}subscribe_reloaded
144
- WHERE email LIKE '%@%.%' AND status = 'Y'
145
- GROUP BY email, post_ID"
146
- );
147
- }
148
- }
149
- // end _update_db
150
-
151
- /**
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
-
163
- if ( ! empty( $result ) && is_array( $result ) && $count_postmeta_rows == 0 ) {
164
- $wpdb->query(
165
- "
166
- INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
167
- SELECT comment_post_ID, CONCAT('_stcr@_', comment_author_email), CONCAT(comment_date, '|Y')
168
- FROM $wpdb->comments
169
- WHERE comment_author_email LIKE '%@%.%' AND comment_subscribe = 'Y'
170
- GROUP BY comment_post_ID, comment_author_email"
171
- );
172
- $this->stcr_create_admin_notice(
173
- 'notify_import_stc_data',
174
- 'unread',
175
- '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> Comment subscription data from the <strong>Subscribe to Comments</strong> plugin 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>' .
176
- '<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>' .
177
- '<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.'
178
- . '<a class="dismiss" href="#">Dismiss. </a>'
179
- . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">', 'subscribe-to-comments-reloaded' ) . '</p>',
180
- 'updated'
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
- *
254
- * @deprecated
255
- * @since 13-May-2014
256
- */
257
- public function _import_crn_data() {
258
- global $wpdb;
259
- $crn_data_count = null;
260
- $subscriptions_to_import = array();
261
- $commentMailColumn = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->comments LIKE 'comment_mail_notify' " );
262
- if ( empty( $commentMailColumn ) ) {
263
- $crn_data_count = 0;
264
- } else {
265
- // Import the information collected by Subscribe to Comments, if needed
266
- $crn_data_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_mail_notify = 1" );
267
- }
268
-
269
- if ( $crn_data_count > 0 ) { // if $crn_data_count is 0 there is no Comment Reply
270
- // plugin installed and therefore no comment_mail_notify
271
- // column.
272
- // Since we know that there are subscriptions Retrieve all of them from COMMENT_REPLY_NOTIFICATION
273
- $crn_data = $wpdb->get_results(
274
- " SELECT comment_post_ID, comment_author_email"
275
- . " FROM wp_comments WHERE comment_mail_notify = '1'"
276
- . " GROUP BY comment_author_email"
277
- , OBJECT
278
- );
279
- $stcr_data = $wpdb->get_results(
280
- " SELECT post_id, SUBSTRING(meta_key,8) AS email"
281
- . " FROM wp_postmeta WHERE meta_key LIKE '_stcr@_%'"
282
- , ARRAY_N
283
- );
284
- $sctr_data_array_size = sizeof( $stcr_data );
285
- // Lets make sure that there is not another subscription with the same compose key
286
- foreach ( $crn_data as $row ) {
287
- // Search the specific compose key in the array
288
- for ( $i = 0; $i < $sctr_data_array_size; $i ++ ) {
289
- $post_id_in_stcr = in_array( $row->comment_post_ID, $stcr_data[$i] );
290
- $email_in_stcr = in_array( $row->comment_author_email, $stcr_data[$i] );
291
- // validate with an If
292
- if ( $post_id_in_stcr && $email_in_stcr ) {
293
- // If the same compose key is in StCR search for the next value.
294
- continue 2; // the next subscription.
295
- }
296
- }
297
- // 2) Until this point the compose key is not on StCR so is safe to import.
298
- $OK = $wpdb->insert(
299
- $wpdb->postmeta,
300
- array(
301
- "post_id" => $row->comment_post_ID,
302
- "meta_key" => "_stcr@_" . $row->comment_author_email,
303
- "meta_value" => current_time( "mysql" ) . "|R"
304
- ),
305
- array(
306
- "%d",
307
- "%s",
308
- "%s"
309
- )
310
- );
311
-
312
- }
313
- $this->stcr_create_admin_notice(
314
- 'notify_import_comment_reply',
315
- 'unread',
316
- '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> Comment subscription data from the <strong>Comment Reply Notification</strong> plugin was detected and automatically imported into <strong>Subscribe to Comments Reloaded</strong>.', 'subscribe-to-comments-reloaded' ) . ( is_plugin_active( 'comment-reply-notification/comment-reply-notification.php' ) ? __( ' It is recommended that you now <strong>deactivate</strong> Comment Reply Notification to prevent confusion between the two plugins.', 'subscribe-to-comments-reloaded' ) : '' ) . '</p>' .
317
- '<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.'
318
- . '<a class="dismiss" href="#">Dismiss. </a>'
319
- . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">', 'subscribe-to-comments-reloaded' ) . '</p>',
320
- 'updated'
321
- );
322
- }
323
- }
324
- // end _import_crn_data
325
- /**
326
- * Imports options and subscription data created with the WP Comment Subscriptions plugin
327
- */
328
- public function _import_wpcs_data() {
329
- global $wpdb;
330
-
331
- // Import the information collected by WP Comment Subscriptions, if needed
332
- $wpcs_data_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_wpcs@\_%'" );
333
-
334
- // Perform the import only if the target table does not contain any subscriptions
335
- $count_postmeta_rows = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
336
-
337
- if ( ! empty( $wpcs_data_count ) && $count_postmeta_rows == 0 ) {
338
- $wpdb->query(
339
- "
340
- INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
341
- SELECT post_id, REPLACE(meta_key, '_wpcs@_', '_stcr@_') meta_key, meta_value
342
- FROM $wpdb->postmeta
343
- WHERE meta_key LIKE '%_wpcs@_%'"
344
- );
345
-
346
- if ( $option = get_option( 'wp_comment_subscriptions_manager_page' ) ) {
347
- add_option( 'subscribe_reloaded_manager_page', $option );
348
- }
349
- if ( $option = get_option( 'wp_comment_subscriptions_show_subscription_box' ) ) {
350
- add_option( 'subscribe_reloaded_show_subscription_box', $option );
351
- }
352
- if ( $option = get_option( 'wp_comment_subscriptions_checked_by_default' ) ) {
353
- add_option( 'subscribe_reloaded_checked_by_default', $option );
354
- }
355
- if ( $option = get_option( 'wp_comment_subscriptions_enable_advanced_subscriptions' ) ) {
356
- add_option( 'subscribe_reloaded_enable_advanced_subscriptions', $option );
357
- }
358
- if ( $option = get_option( 'wp_comment_subscriptions_checkbox_inline_style' ) ) {
359
- add_option( 'subscribe_reloaded_checkbox_inline_style', $option );
360
- }
361
- if ( $option = get_option( 'wp_comment_subscriptions_checkbox_html' ) ) {
362
- add_option( 'subscribe_reloaded_checkbox_html', $option );
363
- }
364
- if ( $option = get_option( 'wp_comment_subscriptions_checkbox_label' ) ) {
365
- add_option( 'subscribe_reloaded_checkbox_label', $option );
366
- }
367
- if ( $option = get_option( 'wp_comment_subscriptions_subscribed_label' ) ) {
368
- add_option( 'subscribe_reloaded_subscribed_label', $option );
369
- }
370
- if ( $option = get_option( 'wp_comment_subscriptions_subscribed_waiting_label' ) ) {
371
- add_option( 'subscribe_reloaded_subscribed_waiting_label', $option );
372
- }
373
- if ( $option = get_option( 'wp_comment_subscriptions_author_label' ) ) {
374
- add_option( 'subscribe_reloaded_author_label', $option );
375
- }
376
- if ( $option = get_option( 'wp_comment_subscriptions_htmlify_message_links' ) ) {
377
- add_option( 'subscribe_reloaded_htmlify_message_links', $option );
378
- }
379
-
380
- if ( $option = get_option( 'wp_comment_subscriptions_manager_page_enabled' ) ) {
381
- add_option( 'subscribe_reloaded_manager_page_enabled', $option );
382
- }
383
- if ( $option = get_option( 'wp_comment_subscriptions_manager_page_title' ) ) {
384
- add_option( 'subscribe_reloaded_manager_page_title', $option );
385
- }
386
- if ( $option = get_option( 'wp_comment_subscriptions_custom_header_meta' ) ) {
387
- add_option( 'subscribe_reloaded_custom_header_meta', $option );
388
- }
389
- if ( $option = get_option( 'wp_comment_subscriptions_request_mgmt_link' ) ) {
390
- add_option( 'subscribe_reloaded_request_mgmt_link', $option );
391
- }
392
- if ( $option = get_option( 'wp_comment_subscriptions_request_mgmt_link_thankyou' ) ) {
393
- add_option( 'subscribe_reloaded_request_mgmt_link_thankyou', $option );
394
- }
395
- if ( $option = get_option( 'wp_comment_subscriptions_subscribe_without_commenting' ) ) {
396
- add_option( 'subscribe_reloaded_subscribe_without_commenting', $option );
397
- }
398
- if ( $option = get_option( 'wp_comment_subscriptions_subscription_confirmed' ) ) {
399
- add_option( 'subscribe_reloaded_subscription_confirmed', $option );
400
- }
401
- if ( $option = get_option( 'wp_comment_subscriptions_subscription_confirmed_dci' ) ) {
402
- add_option( 'subscribe_reloaded_subscription_confirmed_dci', $option );
403
- }
404
- if ( $option = get_option( 'wp_comment_subscriptions_author_text' ) ) {
405
- add_option( 'subscribe_reloaded_author_text', $option );
406
- }
407
- if ( $option = get_option( 'wp_comment_subscriptions_user_text' ) ) {
408
- add_option( 'subscribe_reloaded_user_text', $option );
409
- }
410
-
411
- if ( $option = get_option( 'wp_comment_subscriptions_from_name' ) ) {
412
- add_option( 'subscribe_reloaded_from_name', $option );
413
- }
414
- if ( $option = get_option( 'wp_comment_subscriptions_from_email' ) ) {
415
- add_option( 'subscribe_reloaded_from_email', $option );
416
- }
417
- if ( $option = get_option( 'wp_comment_subscriptions_notification_subject' ) ) {
418
- add_option( 'subscribe_reloaded_notification_subject', $option );
419
- }
420
- if ( $option = get_option( 'wp_comment_subscriptions_notification_content' ) ) {
421
- add_option( 'subscribe_reloaded_notification_content', $option );
422
- }
423
- if ( $option = get_option( 'wp_comment_subscriptions_double_check_subject' ) ) {
424
- add_option( 'subscribe_reloaded_double_check_subject', $option );
425
- }
426
- if ( $option = get_option( 'wp_comment_subscriptions_double_check_content' ) ) {
427
- add_option( 'subscribe_reloaded_double_check_content', $option );
428
- }
429
- if ( $option = get_option( 'wp_comment_subscriptions_management_subject' ) ) {
430
- add_option( 'subscribe_reloaded_management_subject', $option );
431
- }
432
- if ( $option = get_option( 'wp_comment_subscriptions_management_content' ) ) {
433
- add_option( 'subscribe_reloaded_management_content', $option );
434
- }
435
-
436
- if ( $option = get_option( 'wp_comment_subscriptions_purge_days' ) ) {
437
- add_option( 'subscribe_reloaded_purge_days', $option );
438
- }
439
- if ( $option = get_option( 'wp_comment_subscriptions_enable_double_check' ) ) {
440
- add_option( 'subscribe_reloaded_enable_double_check', $option );
441
- }
442
- if ( $option = get_option( 'wp_comment_subscriptions_notify_authors' ) ) {
443
- add_option( 'subscribe_reloaded_notify_authors', $option );
444
- }
445
- if ( $option = get_option( 'wp_comment_subscriptions_enable_html_emails' ) ) {
446
- add_option( 'subscribe_reloaded_enable_html_emails', $option );
447
- }
448
- if ( $option = get_option( 'wp_comment_subscriptions_process_trackbacks' ) ) {
449
- add_option( 'subscribe_reloaded_process_trackbacks', $option );
450
- }
451
- if ( $option = get_option( 'wp_comment_subscriptions_enable_admin_messages' ) ) {
452
- add_option( 'subscribe_reloaded_enable_admin_messages', $option );
453
- }
454
- if ( $option = get_option( 'wp_comment_subscriptions_admin_subscribe' ) ) {
455
- add_option( 'subscribe_reloaded_admin_subscribe', $option );
456
- }
457
- if ( $option = get_option( 'wp_comment_subscriptions_admin_bcc' ) ) {
458
- add_option( 'subscribe_reloaded_admin_bcc', $option );
459
- }
460
- if ( $option = get_option( 'wp_comment_subscriptions_only_for_posts' ) ) {
461
- add_option( 'subscribe_reloaded_only_for_posts', $option );
462
- }
463
- $this->stcr_create_admin_notice(
464
- 'notify_import_wpcs_data',
465
- 'unread',
466
- '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> Plugin options and comment subscription data from the <strong>WP Comment Subscriptions</strong> plugin were detected and automatically imported into <strong>Subscribe to Comments Reloaded</strong>.', 'subscribe-to-comments-reloaded' ) . ( is_plugin_active( 'wp-comment-subscriptions/wp-comment-subscriptions.php' ) ? __( ' It is recommended that you now <strong>deactivate</strong> WP Comment Subscriptions to prevent confusion between the two plugins.', 'subscribe-to-comments-reloaded' ) : '' ) . '</p>' .
467
- '<p>' . __( 'If you have subscription data from another plugin (such as Subscribe to Comments or 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>' .
468
- '<p>' . __( '<strong>Note:</strong> If you were previously using the <code>wp_comment_subscriptions_show()</code> function or the <code>[wpcs-subscribe-url]</code> shortcode, you\'ll need to replace those with <code>subscribe_reloaded_show()</code> and <code>[subscribe-url]</code> respectively.', 'subscribe-to-comments-reloaded' ) . '</p>' .
469
- '<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.'
470
- . '<a class="dismiss" href="#">Dismiss. </a>'
471
- . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">', 'subscribe-to-comments-reloaded' ) . '</p>',
472
- 'updated'
473
- );
474
- }
475
- }
476
- // end _import_wpcs_data
477
- public function upgrade_notification( $_version, $_db_version, $_fresh_install ) {
478
-
479
- $options_link = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
480
- $system_link = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_system' ), __( 'Log Settings', 'subscribe-to-comments-reloaded' ) );
481
-
482
- if( ! $_fresh_install ) {
483
-
484
- switch ($_version) {
485
- case '160106':
486
- $this->stcr_create_admin_notice(
487
- 'notify_update_' . $_version,
488
- 'unread',
489
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160106.', 'subscribe-to-comments-reloaded') . '</p>' .
490
- '<p>' . __('This version includes many changes and fixes to improve your experience with the plugin, including One Click Unsubscribe, Rich Text Editor to create HTML email templates, Subscription Checkbox position, and more!', 'subscribe-to-comments-reloaded') . '</p>' .
491
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
492
- . '<a class="dismiss" href="#">Dismiss. </a>'
493
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
494
- 'updated'
495
- );
496
- // Update the HTML emails option
497
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
498
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
499
- break;
500
- case '160115':
501
- $this->stcr_create_admin_notice(
502
- 'notify_update_' . $_version,
503
- 'unread',
504
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160115.', 'subscribe-to-comments-reloaded') . '</p>' .
505
- '<p>' . __('This version includes fixes to broken links while managing your subscriptions', 'subscribe-to-comments-reloaded') . '</p>' .
506
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
507
- . '<a class="dismiss" href="#">Dismiss. </a>'
508
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
509
- 'updated'
510
- );
511
- // Update the HTML emails option
512
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
513
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
514
- break;
515
- case '160831':
516
- $this->stcr_create_admin_notice(
517
- 'notify_update_' . $_version,
518
- 'unread',
519
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160831', 'subscribe-to-comments-reloaded') . '</p>' .
520
- '<p>' . __('This version includes fixes to many bugs and also new features, ', 'subscribe-to-comments-reloaded') . '</p>' .
521
- '<ul>' .
522
- '<li>' . __("<strong>New Feature</strong> Add new option to set the Reply To email address. This will help the subscribers to use the Reply option in their email agents.", 'subscribe-to-comments-reloaded') . '</li>'.
523
- '<li>' . __("<strong>New Feature</strong> Improve the Admin Menu for StCR. Replace the StCR menu on the Settings Menu for a new Menu with sub menus for the pages.", 'subscribe-to-comments-reloaded') . '</li>'.
524
- '<li>' . __("<strong>New Feature</strong> Safely Uninstall option to Delete the plugin without loosing your subscriptions. You can use this option also for reset all the settings, see the FAQ.", 'subscribe-to-comments-reloaded') . '</li>'.
525
- '<li>' . __("<strong>New Feature</strong> Now the WordPress Authors can use the <strong>Subscribe authors</strong> option to autor subscribe to a Custom Post Type.", 'subscribe-to-comments-reloaded') . '</li>'.
526
- '<li>' . __("<strong>New Feature</strong> A new field was added under the notification options to and the management link only by email and not to display it on the request link page.", 'subscribe-to-comments-reloaded') . '</li>'.
527
- '</ul>' .
528
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
529
- . '<a class="dismiss" href="#">Dismiss. </a>'
530
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
531
- 'updated'
532
- );
533
- // Update the HTML emails option
534
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
535
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
536
- break;
537
- case '160902':
538
- $this->stcr_create_admin_notice(
539
- 'notify_update_' . $_version,
540
- 'unread',
541
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160902', 'subscribe-to-comments-reloaded') . '</p>' .
542
- '<p>' . __('This version includes fixes to many bugs and also new features, ', 'subscribe-to-comments-reloaded') . '</p>' .
543
- '<ul>' .
544
- '<li>' . __("<strong>Fix update</strong> this version Fixes some issue trigger by the previous 160831 version.", 'subscribe-to-comments-reloaded') . '</li>'.
545
- '<li>' . __("<strong>New Feature</strong> Add new option to set the Reply To email address. This will help the subscribers to use the Reply option in their email agents.", 'subscribe-to-comments-reloaded') . '</li>'.
546
- '<li>' . __("<strong>New Feature</strong> Improve the Admin Menu for StCR. Replace the StCR menu on the Settings Menu for a new Menu with sub menus for the pages.", 'subscribe-to-comments-reloaded') . '</li>'.
547
- '<li>' . __("<strong>New Feature</strong> Safely Uninstall option to Delete the plugin without loosing your subscriptions. You can use this option also for reset all the settings, see the FAQ.", 'subscribe-to-comments-reloaded') . '</li>'.
548
- '<li>' . __("<strong>New Feature</strong> Now the WordPress Authors can use the <strong>Subscribe authors</strong> option to autor subscribe to a Custom Post Type.", 'subscribe-to-comments-reloaded') . '</li>'.
549
- '<li>' . __("<strong>New Feature</strong> A new field was added under the notification options to and the management link only by email and not to display it on the request link page.", 'subscribe-to-comments-reloaded') . '</li>'.
550
- '</ul>' .
551
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
552
- . '<a class="dismiss" href="#">Dismiss. </a>'
553
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
554
- 'updated'
555
- );
556
- // Update the HTML emails option
557
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
558
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
559
- break;
560
- case '160915':
561
- $options_link = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
562
- $this->stcr_create_admin_notice(
563
- 'notify_update_' . $_version,
564
- 'unread',
565
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160915', 'subscribe-to-comments-reloaded') . '</p>' .
566
- '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
567
- '<ul>' .
568
- '<li>' . __("<strong>Fix</strong> StCR checkbox position issues with some WordPress themes, Go to the {$options_link} to activate it.", 'subscribe-to-comments-reloaded') . '</li>'.
569
- '<li>' . __("<strong>Change</strong> the radio buttons in the management page for a dropdown.", 'subscribe-to-comments-reloaded') . '</li>'.
570
- '<li>' . __("<strong>Improve</strong> Email validation for empty values and using a regex.", 'subscribe-to-comments-reloaded') . '</li>'.
571
- '</ul>' .
572
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
573
- . '<a class="dismiss" href="#">Dismiss. </a>'
574
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
575
- 'updated'
576
- );
577
- // Update the HTML emails option
578
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
579
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
580
- break;
581
- case '170428':
582
- $this->stcr_create_admin_notice(
583
- 'notify_update_' . $_version,
584
- 'unread',
585
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
586
- '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
587
-
588
- '<ul>' .
589
- '<li>' . __("<strong>Fix</strong> Wrong confirmation link when the double check option is enable.", 'subscribe-to-comments-reloaded') . '</li>'.
590
- '<li>' . __("<strong>Improve</strong> Manage subscription page. Take a look ;).", 'subscribe-to-comments-reloaded') . '</li>'.
591
- '<li>' . __("<strong>Improve</strong> Log file manipulation. Now you can control how the log behaves, take a look at the {$system_link}.", 'subscribe-to-comments-reloaded') . '</li>'.
592
- '</ul>' .
593
-
594
- '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
595
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
596
- . '<a class="dismiss" href="#">Dismiss. </a>'
597
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
598
- 'updated'
599
- );
600
- // Update the HTML emails option
601
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
602
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
603
- break;
604
- case '170607':
605
- $this->stcr_create_admin_notice(
606
- 'notify_update_' . $_version,
607
- 'unread',
608
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
609
- '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
610
-
611
- '<ul>' .
612
- '<li>' . __("<strong>Fix Critical Bug</strong> This version fix a critical bug on fresh installation regarding a database table creation.", 'subscribe-to-comments-reloaded') . '</li>'.
613
- '<li>' . __("<strong>Add</strong> Option to control the inclusion of the style Font Awesome.", 'subscribe-to-comments-reloaded') . '</li>'.
614
- '</ul>' .
615
-
616
- '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
617
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
618
- . '<a class="dismiss" href="#">Dismiss. </a>'
619
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
620
- 'updated'
621
- );
622
- // Update the HTML emails option
623
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
624
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
625
- break;
626
- case '180212':
627
- $this->stcr_create_admin_notice(
628
- 'notify_update_' . $_version,
629
- 'unread',
630
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
631
- '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
632
-
633
- '<ul>' .
634
- '<li>' . __("<strong>Security Patch</strong> This version add a patch for some security issues.", 'subscribe-to-comments-reloaded') . '</li>'.
635
- '<li>' . __("<strong>Add</strong> Option to reset all the plugin options", 'subscribe-to-comments-reloaded') . '</li>'.
636
- '<li>' . __("<strong>Fix</strong> issue regarding database collations", 'subscribe-to-comments-reloaded') . '</li>'.
637
- '</ul>' .
638
-
639
- '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
640
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
641
- . '<a class="dismiss" href="#">Dismiss. </a>'
642
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
643
- 'updated'
644
- );
645
- // Update the HTML emails option
646
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
647
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
648
- break;
649
- case '180225':
650
- $this->stcr_create_admin_notice(
651
- 'notify_update_' . $_version,
652
- 'unread',
653
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
654
- '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
655
- '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
656
- '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
657
- . '<a class="dismiss" href="#">Dismiss. </a>'
658
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
659
- 'updated'
660
- );
661
- // Update the HTML emails option
662
- update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
663
- update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
664
- break;
665
- case '190117':
666
- $this->stcr_create_admin_notice(
667
- 'notify_update_' . $_version,
668
- 'unread',
669
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
670
- '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
671
- '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
672
- '<p>' . __('You might need to clear you cache !!', 'subscribe-to-comments-reloaded') . '</p>' .
673
- '<p>' . __('Please visit the <a href="http://subscribe-reloaded.com/update/stcr-release-version-'.$_version.'/" target="_blank">Release Post</a> for a complete list of changes and guide about the new version.'
674
- . '<a class="dismiss" href="#">Dismiss. </a>'
675
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
676
- 'updated'
677
- );
678
- break;
679
- case '190214':
680
- $this->stcr_create_admin_notice(
681
- 'notify_update_' . $_version,
682
- 'unread',
683
- '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
684
- '<p>' . __('This version includes fixes., ', 'subscribe-to-comments-reloaded') . '</p>' .
685
- '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
686
- '<p>' . __('You might need to clear you cache !!', 'subscribe-to-comments-reloaded') . '</p>' .
687
- '<p>' . __('Please visit the <a href="http://subscribe-reloaded.com/update/stcr-release-version-'.$_version.'/" target="_blank">Release Post</a> for a complete list of changes and guide about the new version.'
688
- . '<a class="dismiss" href="#">Dismiss. </a>'
689
- . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
690
- 'updated'
691
- );
692
- break;
693
- }
694
- }
695
- }
696
-
697
- private function patch_collation()
698
- {
699
- global $wpdb;
700
- $wp_postmeta_table_data = $wpdb->get_results( 'SHOW TABLE STATUS LIKE \''. $wpdb->prefix .'postmeta\'' );
701
- $wp_stcr_subs_table_data = $wpdb->get_results( 'SHOW TABLE STATUS LIKE \''. $wpdb->prefix .'subscribe_reloaded_subscribers\'' );
702
- $wp_postmeta_collation_data = $wpdb->get_results( 'SHOW COLLATION' );
703
-
704
- $wp_postmeta_collation = $wp_postmeta_table_data[0]->Collation;
705
- $wp_stcr_subs_collation = $wp_stcr_subs_table_data[0]->Collation;
706
- // Check Collation
707
- if( $wp_postmeta_collation !== $wp_stcr_subs_collation )
708
- {
709
- // Get database collations
710
- $database_collations = $wpdb->get_results( 'SHOW COLLATION' );
711
- $collations = array();
712
-
713
- if( ! empty($database_collations))
714
- {
715
- foreach ( $database_collations as $collation)
716
- {
717
- $collations[$collation->Collation] = $collation->Charset;
718
- }
719
- //$collations = array_unique($collations, SORT_STRING);
720
- }
721
- // Update subscribe_reloaded_subscribers table collation
722
- $new_charset = $collations[$wp_postmeta_collation];
723
- $new_collation = $wp_postmeta_collation;
724
- $sql = 'ALTER TABLE '. $wpdb->prefix .'subscribe_reloaded_subscribers CONVERT TO CHARACTER SET '. $new_charset .' COLLATE '. $new_collation;
725
- $result = $wpdb->query( $sql );
726
-
727
- if( $result !== false ) // Query executed without any error.
728
- {
729
- // Update subscribe_reloaded_subscribers columns collation
730
- $sql = 'ALTER TABLE '. $wpdb->prefix .'subscribe_reloaded_subscribers CHANGE subscriber_email subscriber_email VARCHAR(100) CHARACTER SET '. $new_charset .' COLLATE '. $new_collation .' NOT NULL';
731
- $result = $wpdb->query( $sql );
732
-
733
- if( $result !== false ) // Query executed without any error.
734
- {
735
- $sql = 'ALTER TABLE '. $wpdb->prefix .'subscribe_reloaded_subscribers CHANGE subscriber_unique_id subscriber_unique_id VARCHAR(50) CHARACTER SET '. $new_charset .' COLLATE '. $new_collation .' NOT NULL';
736
- $result = $wpdb->query( $sql );
737
-
738
- if( $result === false ) // Query executed without any error.
739
- {
740
- // Log query execution.
741
- $this->stcr_logger("Error while updating the collation for the subscribe_reloaded_subscribers COLUMN subscriber_unique_id.");
742
- $this->stcr_logger("\nDatabase Error: \" $wpdb->last_error \"\n");
743
- }
744
- }
745
- else
746
- {
747
- // Log query execution.
748
- $this->stcr_logger("Error while updating the collation for the subscribe_reloaded_subscribers table COLUMN subscriber_email");
749
- $this->stcr_logger("\nDatabase Error: \" $wpdb->last_error \"\n");
750
- }
751
- }
752
- else
753
- {
754
- // Log query execution.
755
- $this->stcr_logger("Error while updating the collation for the subscribe_reloaded_subscribers table");
756
- $this->stcr_logger("\nDatabase Error: \" $wpdb->last_error \"\n");
757
- }
758
- }
759
- }
760
- }
761
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class with utility functions to upgrade 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_upgrade') ) {
16
+ class stcr_upgrade extends stcr_utils {
17
+
18
+ private $_stcr_charset = null;
19
+ private $_stcr_collate = null;
20
+ private $_db_collate = null;
21
+
22
+ public function __construct()
23
+ {
24
+ $this->_stcr_charset = 'utf8';
25
+ $this->_stcr_collate = 'utf8_unicode_ci';
26
+ $this->_db_collate = "DEFAULT CHARSET={$this->_stcr_charset} COLLATE={$this->_stcr_collate}";
27
+ }
28
+
29
+ public function apply_patches()
30
+ {
31
+ $this->patch_collation();
32
+ }
33
+
34
+ public function _create_subscriber_table( $_fresh_install ) {
35
+ global $wpdb;
36
+ $errorMsg = '';
37
+
38
+ // If the update option is set to false
39
+ $stcr_opt_subscriber_table = get_option('subscribe_reloaded_subscriber_table');
40
+
41
+ if ( $_fresh_install || ( ! $stcr_opt_subscriber_table || $stcr_opt_subscriber_table == 'no' ) ) {
42
+ // Creation of table and subscribers.
43
+ $sqlCreateTable = " CREATE TABLE " . $wpdb->prefix . "subscribe_reloaded_subscribers (
44
+ stcr_id int(11) NOT NULL AUTO_INCREMENT,
45
+ subscriber_email varchar(100) NOT NULL,
46
+ salt int(15) NOT NULL,
47
+ subscriber_unique_id varchar(50) NULL,
48
+ add_date timestamp NOT NULL DEFAULT NOW(),
49
+ PRIMARY KEY (stcr_id),
50
+ UNIQUE KEY uk_subscriber_email (subscriber_email))
51
+ ENGINE = InnoDB
52
+ $this->_db_collate";
53
+
54
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
55
+ // dbDelta Will create or update the table safety
56
+ // Ref: https://codex.wordpress.org/Creating_Tables_with_Plugins
57
+ $result = dbDelta( $sqlCreateTable );
58
+ $retrieveNumberOfSubscribers = "SELECT COUNT(subscriber_email) FROM " . $wpdb->prefix . "subscribe_reloaded_subscribers";
59
+ $numSubscribers = $wpdb->get_var( $retrieveNumberOfSubscribers );
60
+ // If subscribers not found then the create routine.
61
+ if ( $numSubscribers == 0 ) {
62
+ // Get list of emails to be imported.
63
+ $retrieveEmails = "SELECT DISTINCT REPLACE(meta_key, '_stcr@_', '') AS email FROM " . $wpdb->postmeta
64
+ . " WHERE meta_key LIKE '\_stcr@\_%'";
65
+ $emails = $wpdb->get_results( $retrieveEmails, OBJECT );
66
+ // insert the records on the new table.
67
+ foreach ( $emails as $email ) {
68
+ // Insert email
69
+ $OK = $this->add_user_subscriber_table( $email->email );
70
+ if ( ! $OK) {
71
+ $notices = get_option( 'subscribe_reloaded_deferred_admin_notices', array() );
72
+ $notices[] = '<div class="error"><h3>' . __( 'Important Notice', 'subscribe-to-comments-reloaded' ) . '</h3>' .
73
+ '<p>The creation of of the table <strong>' . $wpdb->prefix . 'subscribe_reloaded_subscribers</strong> failed</p></div>';
74
+ update_option( 'subscribe_reloaded_deferred_admin_notices', $notices );
75
+ break 1;
76
+ }
77
+ }
78
+
79
+ if( ! $_fresh_install )
80
+ {
81
+ $this->stcr_create_admin_notice(
82
+ 'notify_create_subscriber_table',
83
+ 'unread',
84
+ '<p><strong>Subscribe to Comments Reloaded:</strong> The creation of table <code>' . $wpdb->prefix . 'subscribe_reloaded_subscribers</code> was successful.</p>'.
85
+ '<p>This new table will help to add your subscribers email addresses more safely and prevent Google PII violations.'
86
+ . '<a class="dismiss" href="#">Dismiss. </a>'
87
+ . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">'
88
+ . '</p>',
89
+ 'updated'
90
+ );
91
+ }
92
+ update_option('subscribe_reloaded_subscriber_table', 'yes');
93
+ }
94
+ }
95
+ }
96
+
97
+ public function _sanitize_db_information( $_fresh_install ) {
98
+ global $wpdb;
99
+
100
+ if ( ( ! get_option( "subscribe_reloaded_data_sanitized" )
101
+ || get_option( "subscribe_reloaded_data_sanitized" ) == "no" )
102
+ && ! $_fresh_install ) {
103
+ $stcr_data = $wpdb->get_results(
104
+ " SELECT * FROM $wpdb->options WHERE option_name like 'subscribe_reloaded%'
105
+ ORDER BY option_name", OBJECT
106
+ );
107
+ $sctr_data_array_size = sizeof( $stcr_data );
108
+ // Lets make sure that there is not another subscription with the same compose key
109
+ foreach ( $stcr_data as $row ) {
110
+ if ( $row->option_name != 'subscribe_reloaded_deferred_admin_notices' ) {
111
+ $optionValue = $row->option_value;
112
+ $optionValue = html_entity_decode( stripslashes( $optionValue ), ENT_QUOTES, 'UTF-8' );
113
+ $optionValue = esc_attr( $optionValue );
114
+ update_option( $row->option_name, $optionValue );
115
+ }
116
+ }
117
+ $this->stcr_create_admin_notice(
118
+ 'notify_update_sanitize_db_options',
119
+ 'unread',
120
+ '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> The information in your database has been sanitized to prevent the raw html messages. <a class="dismiss" href="#">Dismiss. </a>'
121
+ . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">' , 'subscribe-to-comments-reloaded' )
122
+ . '</p>',
123
+ 'updated'
124
+ );
125
+ update_option( "subscribe_reloaded_data_sanitized", "yes" );
126
+ }
127
+ } // end _sanitize_db_information
128
+
129
+ /**
130
+ * Copies the information from the stand-alone table to WP's core table
131
+ */
132
+ public function _update_db() {
133
+ global $wpdb;
134
+ $stcr_table = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}subscribe_reloaded'" );
135
+
136
+ // Perform the import only if the target table does not contain any subscriptions
137
+ $count_postmeta_rows = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
138
+ if ( ! empty( $stcr_table ) && $count_postmeta_rows == 0 ) {
139
+ $wpdb->query(
140
+ "
141
+ INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
142
+ SELECT post_ID, CONCAT('_stcr@_', email), CONCAT(dt, '|Y')
143
+ FROM {$wpdb->prefix}subscribe_reloaded
144
+ WHERE email LIKE '%@%.%' AND status = 'Y'
145
+ GROUP BY email, post_ID"
146
+ );
147
+ }
148
+ }
149
+ // end _update_db
150
+
151
+ /**
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
+
163
+ if ( ! empty( $result ) && is_array( $result ) && $count_postmeta_rows == 0 ) {
164
+ $wpdb->query(
165
+ "
166
+ INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
167
+ SELECT comment_post_ID, CONCAT('_stcr@_', comment_author_email), CONCAT(comment_date, '|Y')
168
+ FROM $wpdb->comments
169
+ WHERE comment_author_email LIKE '%@%.%' AND comment_subscribe = 'Y'
170
+ GROUP BY comment_post_ID, comment_author_email"
171
+ );
172
+ $this->stcr_create_admin_notice(
173
+ 'notify_import_stc_data',
174
+ 'unread',
175
+ '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> Comment subscription data from the <strong>Subscribe to Comments</strong> plugin 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>' .
176
+ '<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>' .
177
+ '<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.'
178
+ . '<a class="dismiss" href="#">Dismiss. </a>'
179
+ . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">', 'subscribe-to-comments-reloaded' ) . '</p>',
180
+ 'updated'
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
+ *
254
+ * @deprecated
255
+ * @since 13-May-2014
256
+ */
257
+ public function _import_crn_data() {
258
+ global $wpdb;
259
+ $crn_data_count = null;
260
+ $subscriptions_to_import = array();
261
+ $commentMailColumn = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->comments LIKE 'comment_mail_notify' " );
262
+ if ( empty( $commentMailColumn ) ) {
263
+ $crn_data_count = 0;
264
+ } else {
265
+ // Import the information collected by Subscribe to Comments, if needed
266
+ $crn_data_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_mail_notify = 1" );
267
+ }
268
+
269
+ if ( $crn_data_count > 0 ) { // if $crn_data_count is 0 there is no Comment Reply
270
+ // plugin installed and therefore no comment_mail_notify
271
+ // column.
272
+ // Since we know that there are subscriptions Retrieve all of them from COMMENT_REPLY_NOTIFICATION
273
+ $crn_data = $wpdb->get_results(
274
+ " SELECT comment_post_ID, comment_author_email"
275
+ . " FROM wp_comments WHERE comment_mail_notify = '1'"
276
+ . " GROUP BY comment_author_email"
277
+ , OBJECT
278
+ );
279
+ $stcr_data = $wpdb->get_results(
280
+ " SELECT post_id, SUBSTRING(meta_key,8) AS email"
281
+ . " FROM wp_postmeta WHERE meta_key LIKE '_stcr@_%'"
282
+ , ARRAY_N
283
+ );
284
+ $sctr_data_array_size = sizeof( $stcr_data );
285
+ // Lets make sure that there is not another subscription with the same compose key
286
+ foreach ( $crn_data as $row ) {
287
+ // Search the specific compose key in the array
288
+ for ( $i = 0; $i < $sctr_data_array_size; $i ++ ) {
289
+ $post_id_in_stcr = in_array( $row->comment_post_ID, $stcr_data[$i] );
290
+ $email_in_stcr = in_array( $row->comment_author_email, $stcr_data[$i] );
291
+ // validate with an If
292
+ if ( $post_id_in_stcr && $email_in_stcr ) {
293
+ // If the same compose key is in StCR search for the next value.
294
+ continue 2; // the next subscription.
295
+ }
296
+ }
297
+ // 2) Until this point the compose key is not on StCR so is safe to import.
298
+ $OK = $wpdb->insert(
299
+ $wpdb->postmeta,
300
+ array(
301
+ "post_id" => $row->comment_post_ID,
302
+ "meta_key" => "_stcr@_" . $row->comment_author_email,
303
+ "meta_value" => current_time( "mysql" ) . "|R"
304
+ ),
305
+ array(
306
+ "%d",
307
+ "%s",
308
+ "%s"
309
+ )
310
+ );
311
+
312
+ }
313
+ $this->stcr_create_admin_notice(
314
+ 'notify_import_comment_reply',
315
+ 'unread',
316
+ '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> Comment subscription data from the <strong>Comment Reply Notification</strong> plugin was detected and automatically imported into <strong>Subscribe to Comments Reloaded</strong>.', 'subscribe-to-comments-reloaded' ) . ( is_plugin_active( 'comment-reply-notification/comment-reply-notification.php' ) ? __( ' It is recommended that you now <strong>deactivate</strong> Comment Reply Notification to prevent confusion between the two plugins.', 'subscribe-to-comments-reloaded' ) : '' ) . '</p>' .
317
+ '<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.'
318
+ . '<a class="dismiss" href="#">Dismiss. </a>'
319
+ . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">', 'subscribe-to-comments-reloaded' ) . '</p>',
320
+ 'updated'
321
+ );
322
+ }
323
+ }
324
+ // end _import_crn_data
325
+ /**
326
+ * Imports options and subscription data created with the WP Comment Subscriptions plugin
327
+ */
328
+ public function _import_wpcs_data() {
329
+ global $wpdb;
330
+
331
+ // Import the information collected by WP Comment Subscriptions, if needed
332
+ $wpcs_data_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_wpcs@\_%'" );
333
+
334
+ // Perform the import only if the target table does not contain any subscriptions
335
+ $count_postmeta_rows = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%'" );
336
+
337
+ if ( ! empty( $wpcs_data_count ) && $count_postmeta_rows == 0 ) {
338
+ $wpdb->query(
339
+ "
340
+ INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
341
+ SELECT post_id, REPLACE(meta_key, '_wpcs@_', '_stcr@_') meta_key, meta_value
342
+ FROM $wpdb->postmeta
343
+ WHERE meta_key LIKE '%_wpcs@_%'"
344
+ );
345
+
346
+ if ( $option = get_option( 'wp_comment_subscriptions_manager_page' ) ) {
347
+ add_option( 'subscribe_reloaded_manager_page', $option );
348
+ }
349
+ if ( $option = get_option( 'wp_comment_subscriptions_show_subscription_box' ) ) {
350
+ add_option( 'subscribe_reloaded_show_subscription_box', $option );
351
+ }
352
+ if ( $option = get_option( 'wp_comment_subscriptions_checked_by_default' ) ) {
353
+ add_option( 'subscribe_reloaded_checked_by_default', $option );
354
+ }
355
+ if ( $option = get_option( 'wp_comment_subscriptions_enable_advanced_subscriptions' ) ) {
356
+ add_option( 'subscribe_reloaded_enable_advanced_subscriptions', $option );
357
+ }
358
+ if ( $option = get_option( 'wp_comment_subscriptions_checkbox_inline_style' ) ) {
359
+ add_option( 'subscribe_reloaded_checkbox_inline_style', $option );
360
+ }
361
+ if ( $option = get_option( 'wp_comment_subscriptions_checkbox_html' ) ) {
362
+ add_option( 'subscribe_reloaded_checkbox_html', $option );
363
+ }
364
+ if ( $option = get_option( 'wp_comment_subscriptions_checkbox_label' ) ) {
365
+ add_option( 'subscribe_reloaded_checkbox_label', $option );
366
+ }
367
+ if ( $option = get_option( 'wp_comment_subscriptions_subscribed_label' ) ) {
368
+ add_option( 'subscribe_reloaded_subscribed_label', $option );
369
+ }
370
+ if ( $option = get_option( 'wp_comment_subscriptions_subscribed_waiting_label' ) ) {
371
+ add_option( 'subscribe_reloaded_subscribed_waiting_label', $option );
372
+ }
373
+ if ( $option = get_option( 'wp_comment_subscriptions_author_label' ) ) {
374
+ add_option( 'subscribe_reloaded_author_label', $option );
375
+ }
376
+ if ( $option = get_option( 'wp_comment_subscriptions_htmlify_message_links' ) ) {
377
+ add_option( 'subscribe_reloaded_htmlify_message_links', $option );
378
+ }
379
+
380
+ if ( $option = get_option( 'wp_comment_subscriptions_manager_page_enabled' ) ) {
381
+ add_option( 'subscribe_reloaded_manager_page_enabled', $option );
382
+ }
383
+ if ( $option = get_option( 'wp_comment_subscriptions_manager_page_title' ) ) {
384
+ add_option( 'subscribe_reloaded_manager_page_title', $option );
385
+ }
386
+ if ( $option = get_option( 'wp_comment_subscriptions_custom_header_meta' ) ) {
387
+ add_option( 'subscribe_reloaded_custom_header_meta', $option );
388
+ }
389
+ if ( $option = get_option( 'wp_comment_subscriptions_request_mgmt_link' ) ) {
390
+ add_option( 'subscribe_reloaded_request_mgmt_link', $option );
391
+ }
392
+ if ( $option = get_option( 'wp_comment_subscriptions_request_mgmt_link_thankyou' ) ) {
393
+ add_option( 'subscribe_reloaded_request_mgmt_link_thankyou', $option );
394
+ }
395
+ if ( $option = get_option( 'wp_comment_subscriptions_subscribe_without_commenting' ) ) {
396
+ add_option( 'subscribe_reloaded_subscribe_without_commenting', $option );
397
+ }
398
+ if ( $option = get_option( 'wp_comment_subscriptions_subscription_confirmed' ) ) {
399
+ add_option( 'subscribe_reloaded_subscription_confirmed', $option );
400
+ }
401
+ if ( $option = get_option( 'wp_comment_subscriptions_subscription_confirmed_dci' ) ) {
402
+ add_option( 'subscribe_reloaded_subscription_confirmed_dci', $option );
403
+ }
404
+ if ( $option = get_option( 'wp_comment_subscriptions_author_text' ) ) {
405
+ add_option( 'subscribe_reloaded_author_text', $option );
406
+ }
407
+ if ( $option = get_option( 'wp_comment_subscriptions_user_text' ) ) {
408
+ add_option( 'subscribe_reloaded_user_text', $option );
409
+ }
410
+
411
+ if ( $option = get_option( 'wp_comment_subscriptions_from_name' ) ) {
412
+ add_option( 'subscribe_reloaded_from_name', $option );
413
+ }
414
+ if ( $option = get_option( 'wp_comment_subscriptions_from_email' ) ) {
415
+ add_option( 'subscribe_reloaded_from_email', $option );
416
+ }
417
+ if ( $option = get_option( 'wp_comment_subscriptions_notification_subject' ) ) {
418
+ add_option( 'subscribe_reloaded_notification_subject', $option );
419
+ }
420
+ if ( $option = get_option( 'wp_comment_subscriptions_notification_content' ) ) {
421
+ add_option( 'subscribe_reloaded_notification_content', $option );
422
+ }
423
+ if ( $option = get_option( 'wp_comment_subscriptions_double_check_subject' ) ) {
424
+ add_option( 'subscribe_reloaded_double_check_subject', $option );
425
+ }
426
+ if ( $option = get_option( 'wp_comment_subscriptions_double_check_content' ) ) {
427
+ add_option( 'subscribe_reloaded_double_check_content', $option );
428
+ }
429
+ if ( $option = get_option( 'wp_comment_subscriptions_management_subject' ) ) {
430
+ add_option( 'subscribe_reloaded_management_subject', $option );
431
+ }
432
+ if ( $option = get_option( 'wp_comment_subscriptions_management_content' ) ) {
433
+ add_option( 'subscribe_reloaded_management_content', $option );
434
+ }
435
+
436
+ if ( $option = get_option( 'wp_comment_subscriptions_purge_days' ) ) {
437
+ add_option( 'subscribe_reloaded_purge_days', $option );
438
+ }
439
+ if ( $option = get_option( 'wp_comment_subscriptions_enable_double_check' ) ) {
440
+ add_option( 'subscribe_reloaded_enable_double_check', $option );
441
+ }
442
+ if ( $option = get_option( 'wp_comment_subscriptions_notify_authors' ) ) {
443
+ add_option( 'subscribe_reloaded_notify_authors', $option );
444
+ }
445
+ if ( $option = get_option( 'wp_comment_subscriptions_enable_html_emails' ) ) {
446
+ add_option( 'subscribe_reloaded_enable_html_emails', $option );
447
+ }
448
+ if ( $option = get_option( 'wp_comment_subscriptions_process_trackbacks' ) ) {
449
+ add_option( 'subscribe_reloaded_process_trackbacks', $option );
450
+ }
451
+ if ( $option = get_option( 'wp_comment_subscriptions_enable_admin_messages' ) ) {
452
+ add_option( 'subscribe_reloaded_enable_admin_messages', $option );
453
+ }
454
+ if ( $option = get_option( 'wp_comment_subscriptions_admin_subscribe' ) ) {
455
+ add_option( 'subscribe_reloaded_admin_subscribe', $option );
456
+ }
457
+ if ( $option = get_option( 'wp_comment_subscriptions_admin_bcc' ) ) {
458
+ add_option( 'subscribe_reloaded_admin_bcc', $option );
459
+ }
460
+ if ( $option = get_option( 'wp_comment_subscriptions_only_for_posts' ) ) {
461
+ add_option( 'subscribe_reloaded_only_for_posts', $option );
462
+ }
463
+ $this->stcr_create_admin_notice(
464
+ 'notify_import_wpcs_data',
465
+ 'unread',
466
+ '<p>' . __( '<strong>Subscribe to Comments Reloaded:</strong> Plugin options and comment subscription data from the <strong>WP Comment Subscriptions</strong> plugin were detected and automatically imported into <strong>Subscribe to Comments Reloaded</strong>.', 'subscribe-to-comments-reloaded' ) . ( is_plugin_active( 'wp-comment-subscriptions/wp-comment-subscriptions.php' ) ? __( ' It is recommended that you now <strong>deactivate</strong> WP Comment Subscriptions to prevent confusion between the two plugins.', 'subscribe-to-comments-reloaded' ) : '' ) . '</p>' .
467
+ '<p>' . __( 'If you have subscription data from another plugin (such as Subscribe to Comments or 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>' .
468
+ '<p>' . __( '<strong>Note:</strong> If you were previously using the <code>wp_comment_subscriptions_show()</code> function or the <code>[wpcs-subscribe-url]</code> shortcode, you\'ll need to replace those with <code>subscribe_reloaded_show()</code> and <code>[subscribe-url]</code> respectively.', 'subscribe-to-comments-reloaded' ) . '</p>' .
469
+ '<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.'
470
+ . '<a class="dismiss" href="#">Dismiss. </a>'
471
+ . '<img class="stcr-loading-animation" src="'. esc_url( admin_url() . '/images/loading.gif'). '" alt="Working...">', 'subscribe-to-comments-reloaded' ) . '</p>',
472
+ 'updated'
473
+ );
474
+ }
475
+ }
476
+ // end _import_wpcs_data
477
+ public function upgrade_notification( $_version, $_db_version, $_fresh_install ) {
478
+
479
+ $options_link = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
480
+ $system_link = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_system' ), __( 'Log Settings', 'subscribe-to-comments-reloaded' ) );
481
+
482
+ if( ! $_fresh_install ) {
483
+
484
+ switch ($_version) {
485
+ case '160106':
486
+ $this->stcr_create_admin_notice(
487
+ 'notify_update_' . $_version,
488
+ 'unread',
489
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160106.', 'subscribe-to-comments-reloaded') . '</p>' .
490
+ '<p>' . __('This version includes many changes and fixes to improve your experience with the plugin, including One Click Unsubscribe, Rich Text Editor to create HTML email templates, Subscription Checkbox position, and more!', 'subscribe-to-comments-reloaded') . '</p>' .
491
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
492
+ . '<a class="dismiss" href="#">Dismiss. </a>'
493
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
494
+ 'updated'
495
+ );
496
+ // Update the HTML emails option
497
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
498
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
499
+ break;
500
+ case '160115':
501
+ $this->stcr_create_admin_notice(
502
+ 'notify_update_' . $_version,
503
+ 'unread',
504
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160115.', 'subscribe-to-comments-reloaded') . '</p>' .
505
+ '<p>' . __('This version includes fixes to broken links while managing your subscriptions', 'subscribe-to-comments-reloaded') . '</p>' .
506
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
507
+ . '<a class="dismiss" href="#">Dismiss. </a>'
508
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
509
+ 'updated'
510
+ );
511
+ // Update the HTML emails option
512
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
513
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
514
+ break;
515
+ case '160831':
516
+ $this->stcr_create_admin_notice(
517
+ 'notify_update_' . $_version,
518
+ 'unread',
519
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160831', 'subscribe-to-comments-reloaded') . '</p>' .
520
+ '<p>' . __('This version includes fixes to many bugs and also new features, ', 'subscribe-to-comments-reloaded') . '</p>' .
521
+ '<ul>' .
522
+ '<li>' . __("<strong>New Feature</strong> Add new option to set the Reply To email address. This will help the subscribers to use the Reply option in their email agents.", 'subscribe-to-comments-reloaded') . '</li>'.
523
+ '<li>' . __("<strong>New Feature</strong> Improve the Admin Menu for StCR. Replace the StCR menu on the Settings Menu for a new Menu with sub menus for the pages.", 'subscribe-to-comments-reloaded') . '</li>'.
524
+ '<li>' . __("<strong>New Feature</strong> Safely Uninstall option to Delete the plugin without loosing your subscriptions. You can use this option also for reset all the settings, see the FAQ.", 'subscribe-to-comments-reloaded') . '</li>'.
525
+ '<li>' . __("<strong>New Feature</strong> Now the WordPress Authors can use the <strong>Subscribe authors</strong> option to autor subscribe to a Custom Post Type.", 'subscribe-to-comments-reloaded') . '</li>'.
526
+ '<li>' . __("<strong>New Feature</strong> A new field was added under the notification options to and the management link only by email and not to display it on the request link page.", 'subscribe-to-comments-reloaded') . '</li>'.
527
+ '</ul>' .
528
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
529
+ . '<a class="dismiss" href="#">Dismiss. </a>'
530
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
531
+ 'updated'
532
+ );
533
+ // Update the HTML emails option
534
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
535
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
536
+ break;
537
+ case '160902':
538
+ $this->stcr_create_admin_notice(
539
+ 'notify_update_' . $_version,
540
+ 'unread',
541
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160902', 'subscribe-to-comments-reloaded') . '</p>' .
542
+ '<p>' . __('This version includes fixes to many bugs and also new features, ', 'subscribe-to-comments-reloaded') . '</p>' .
543
+ '<ul>' .
544
+ '<li>' . __("<strong>Fix update</strong> this version Fixes some issue trigger by the previous 160831 version.", 'subscribe-to-comments-reloaded') . '</li>'.
545
+ '<li>' . __("<strong>New Feature</strong> Add new option to set the Reply To email address. This will help the subscribers to use the Reply option in their email agents.", 'subscribe-to-comments-reloaded') . '</li>'.
546
+ '<li>' . __("<strong>New Feature</strong> Improve the Admin Menu for StCR. Replace the StCR menu on the Settings Menu for a new Menu with sub menus for the pages.", 'subscribe-to-comments-reloaded') . '</li>'.
547
+ '<li>' . __("<strong>New Feature</strong> Safely Uninstall option to Delete the plugin without loosing your subscriptions. You can use this option also for reset all the settings, see the FAQ.", 'subscribe-to-comments-reloaded') . '</li>'.
548
+ '<li>' . __("<strong>New Feature</strong> Now the WordPress Authors can use the <strong>Subscribe authors</strong> option to autor subscribe to a Custom Post Type.", 'subscribe-to-comments-reloaded') . '</li>'.
549
+ '<li>' . __("<strong>New Feature</strong> A new field was added under the notification options to and the management link only by email and not to display it on the request link page.", 'subscribe-to-comments-reloaded') . '</li>'.
550
+ '</ul>' .
551
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
552
+ . '<a class="dismiss" href="#">Dismiss. </a>'
553
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
554
+ 'updated'
555
+ );
556
+ // Update the HTML emails option
557
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
558
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
559
+ break;
560
+ case '160915':
561
+ $options_link = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
562
+ $this->stcr_create_admin_notice(
563
+ 'notify_update_' . $_version,
564
+ 'unread',
565
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version 160915', 'subscribe-to-comments-reloaded') . '</p>' .
566
+ '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
567
+ '<ul>' .
568
+ '<li>' . __("<strong>Fix</strong> StCR checkbox position issues with some WordPress themes, Go to the {$options_link} to activate it.", 'subscribe-to-comments-reloaded') . '</li>'.
569
+ '<li>' . __("<strong>Change</strong> the radio buttons in the management page for a dropdown.", 'subscribe-to-comments-reloaded') . '</li>'.
570
+ '<li>' . __("<strong>Improve</strong> Email validation for empty values and using a regex.", 'subscribe-to-comments-reloaded') . '</li>'.
571
+ '</ul>' .
572
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
573
+ . '<a class="dismiss" href="#">Dismiss. </a>'
574
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Working...">', 'subscribe-to-comments-reloaded') . '</p>',
575
+ 'updated'
576
+ );
577
+ // Update the HTML emails option
578
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
579
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
580
+ break;
581
+ case '170428':
582
+ $this->stcr_create_admin_notice(
583
+ 'notify_update_' . $_version,
584
+ 'unread',
585
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
586
+ '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
587
+
588
+ '<ul>' .
589
+ '<li>' . __("<strong>Fix</strong> Wrong confirmation link when the double check option is enable.", 'subscribe-to-comments-reloaded') . '</li>'.
590
+ '<li>' . __("<strong>Improve</strong> Manage subscription page. Take a look ;).", 'subscribe-to-comments-reloaded') . '</li>'.
591
+ '<li>' . __("<strong>Improve</strong> Log file manipulation. Now you can control how the log behaves, take a look at the {$system_link}.", 'subscribe-to-comments-reloaded') . '</li>'.
592
+ '</ul>' .
593
+
594
+ '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
595
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
596
+ . '<a class="dismiss" href="#">Dismiss. </a>'
597
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
598
+ 'updated'
599
+ );
600
+ // Update the HTML emails option
601
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
602
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
603
+ break;
604
+ case '170607':
605
+ $this->stcr_create_admin_notice(
606
+ 'notify_update_' . $_version,
607
+ 'unread',
608
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
609
+ '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
610
+
611
+ '<ul>' .
612
+ '<li>' . __("<strong>Fix Critical Bug</strong> This version fix a critical bug on fresh installation regarding a database table creation.", 'subscribe-to-comments-reloaded') . '</li>'.
613
+ '<li>' . __("<strong>Add</strong> Option to control the inclusion of the style Font Awesome.", 'subscribe-to-comments-reloaded') . '</li>'.
614
+ '</ul>' .
615
+
616
+ '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
617
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
618
+ . '<a class="dismiss" href="#">Dismiss. </a>'
619
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
620
+ 'updated'
621
+ );
622
+ // Update the HTML emails option
623
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
624
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
625
+ break;
626
+ case '180212':
627
+ $this->stcr_create_admin_notice(
628
+ 'notify_update_' . $_version,
629
+ 'unread',
630
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
631
+ '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
632
+
633
+ '<ul>' .
634
+ '<li>' . __("<strong>Security Patch</strong> This version add a patch for some security issues.", 'subscribe-to-comments-reloaded') . '</li>'.
635
+ '<li>' . __("<strong>Add</strong> Option to reset all the plugin options", 'subscribe-to-comments-reloaded') . '</li>'.
636
+ '<li>' . __("<strong>Fix</strong> issue regarding database collations", 'subscribe-to-comments-reloaded') . '</li>'.
637
+ '</ul>' .
638
+
639
+ '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
640
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
641
+ . '<a class="dismiss" href="#">Dismiss. </a>'
642
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
643
+ 'updated'
644
+ );
645
+ // Update the HTML emails option
646
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
647
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
648
+ break;
649
+ case '180225':
650
+ $this->stcr_create_admin_notice(
651
+ 'notify_update_' . $_version,
652
+ 'unread',
653
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
654
+ '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
655
+ '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
656
+ '<p>' . __('Please visit the <a href="https://wordpress.org/plugins/subscribe-to-comments-reloaded/changelog/" target="_blank">Changelog</a> for a complete list of changes.'
657
+ . '<a class="dismiss" href="#">Dismiss. </a>'
658
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
659
+ 'updated'
660
+ );
661
+ // Update the HTML emails option
662
+ update_option( 'subscribe_reloaded_htmlify_message_links', 'no' );
663
+ update_option( 'subscribe_reloaded_enable_html_emails', 'yes' );
664
+ break;
665
+ case '190117':
666
+ $this->stcr_create_admin_notice(
667
+ 'notify_update_' . $_version,
668
+ 'unread',
669
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
670
+ '<p>' . __('This version includes fixes and improvements, ', 'subscribe-to-comments-reloaded') . '</p>' .
671
+ '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
672
+ '<p>' . __('You might need to clear you cache !!', 'subscribe-to-comments-reloaded') . '</p>' .
673
+ '<p>' . __('Please visit the <a href="http://subscribe-reloaded.com/update/stcr-release-version-'.$_version.'/" target="_blank">Release Post</a> for a complete list of changes and guide about the new version.'
674
+ . '<a class="dismiss" href="#">Dismiss. </a>'
675
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
676
+ 'updated'
677
+ );
678
+ break;
679
+ case '190214':
680
+ $this->stcr_create_admin_notice(
681
+ 'notify_update_' . $_version,
682
+ 'unread',
683
+ '<p>' . __('<strong>Subscribe to Comments Reloaded</strong> has been updated to version ' . $_version, 'subscribe-to-comments-reloaded') . '</p>' .
684
+ '<p>' . __('This version includes fixes., ', 'subscribe-to-comments-reloaded') . '</p>' .
685
+ '<p>' . __('If you find a bug or an issue you can report it <a href="https://github.com/stcr/subscribe-to-comments-reloaded/issues" target="_blank">here</a>.', 'subscribe-to-comments-reloaded') . '</p>' .
686
+ '<p>' . __('You might need to clear you cache !!', 'subscribe-to-comments-reloaded') . '</p>' .
687
+ '<p>' . __('Please visit the <a href="http://subscribe-reloaded.com/update/stcr-release-version-'.$_version.'/" target="_blank">Release Post</a> for a complete list of changes and guide about the new version.'
688
+ . '<a class="dismiss" href="#">Dismiss. </a>'
689
+ . '<img class="stcr-loading-animation" src="' . esc_url(admin_url() . '/images/loading.gif') . '" alt="Dismissing Message">', 'subscribe-to-comments-reloaded') . '</p>',
690
+ 'updated'
691
+ );
692
+ break;
693
+ }
694
+ }
695
+ }
696
+
697
+ /**
698
+ * Migrate/Add new plugin options on version upgrade.
699
+ */
700
+ public function email_blacklist_post_types_recaptcha() {
701
+
702
+ // Return if already migrated.
703
+ if ( get_option( 'subscribe_reloaded_email_blacklist_post_types_recaptcha_migrated' ) ) {
704
+ return;
705
+ }
706
+
707
+ // For blacklist email.
708
+ update_option( 'subscribe_reloaded_blacklisted_emails', '' );
709
+
710
+ // For recaptcha version.
711
+ update_option( 'subscribe_reloaded_recaptcha_version', 'v2' );
712
+
713
+ // Migrate the Enable only on blog posts option to newly used options.
714
+ add_action( 'admin_init', array( $this, 'migrate_post_type_support' ) );
715
+
716
+ // Update the option.
717
+ update_option( 'subscribe_reloaded_email_blacklist_post_types_recaptcha_migrated', true );
718
+
719
+ }
720
+
721
+ /**
722
+ * Migrate the Enable only on blog posts option to newly used options.
723
+ */
724
+ public function migrate_post_type_support() {
725
+
726
+ // Get the old data of Enable only on blog posts from database.
727
+ $only_for_posts = get_option( 'subscribe_reloaded_only_for_posts', 'no' );
728
+ if ( 'yes' == $only_for_posts ) {
729
+ $post_type_supports[] = 'post';
730
+ } else {
731
+ $post_type_supports = array();
732
+ $args = array(
733
+ '_builtin' => false,
734
+ 'public' => true,
735
+ );
736
+ $post_types = get_post_types( $args );
737
+ $default_post_types = array(
738
+ 'post',
739
+ 'page',
740
+ );
741
+ $post_types = array_merge( $default_post_types, $post_types );
742
+ foreach ( $post_types as $post_type ) {
743
+ $post_type_supports[] = $post_type;
744
+ }
745
+ }
746
+
747
+ // Update the new option for the same Enable only on blog posts option with new way.
748
+ update_option( 'subscribe_reloaded_post_type_supports', $post_type_supports );
749
+
750
+ // Old key is required no more now.
751
+ delete_option( 'subscribe_reloaded_only_for_posts' );
752
+
753
+ }
754
+
755
+ private function patch_collation()
756
+ {
757
+ global $wpdb;
758
+ $wp_postmeta_table_data = $wpdb->get_results( 'SHOW TABLE STATUS LIKE \''. $wpdb->prefix .'postmeta\'' );
759
+ $wp_stcr_subs_table_data = $wpdb->get_results( 'SHOW TABLE STATUS LIKE \''. $wpdb->prefix .'subscribe_reloaded_subscribers\'' );
760
+ $wp_postmeta_collation_data = $wpdb->get_results( 'SHOW COLLATION' );
761
+
762
+ $wp_postmeta_collation = $wp_postmeta_table_data[0]->Collation;
763
+ $wp_stcr_subs_collation = $wp_stcr_subs_table_data[0]->Collation;
764
+ // Check Collation
765
+ if( $wp_postmeta_collation !== $wp_stcr_subs_collation )
766
+ {
767
+ // Get database collations
768
+ $database_collations = $wpdb->get_results( 'SHOW COLLATION' );
769
+ $collations = array();
770
+
771
+ if( ! empty($database_collations))
772
+ {
773
+ foreach ( $database_collations as $collation)
774
+ {
775
+ $collations[$collation->Collation] = $collation->Charset;
776
+ }
777
+ //$collations = array_unique($collations, SORT_STRING);
778
+ }
779
+ // Update subscribe_reloaded_subscribers table collation
780
+ $new_charset = $collations[$wp_postmeta_collation];
781
+ $new_collation = $wp_postmeta_collation;
782
+ $sql = 'ALTER TABLE '. $wpdb->prefix .'subscribe_reloaded_subscribers CONVERT TO CHARACTER SET '. $new_charset .' COLLATE '. $new_collation;
783
+ $result = $wpdb->query( $sql );
784
+
785
+ if( $result !== false ) // Query executed without any error.
786
+ {
787
+ // Update subscribe_reloaded_subscribers columns collation
788
+ $sql = 'ALTER TABLE '. $wpdb->prefix .'subscribe_reloaded_subscribers CHANGE subscriber_email subscriber_email VARCHAR(100) CHARACTER SET '. $new_charset .' COLLATE '. $new_collation .' NOT NULL';
789
+ $result = $wpdb->query( $sql );
790
+
791
+ if( $result !== false ) // Query executed without any error.
792
+ {
793
+ $sql = 'ALTER TABLE '. $wpdb->prefix .'subscribe_reloaded_subscribers CHANGE subscriber_unique_id subscriber_unique_id VARCHAR(50) CHARACTER SET '. $new_charset .' COLLATE '. $new_collation .' NOT NULL';
794
+ $result = $wpdb->query( $sql );
795
+
796
+ if( $result === false ) // Query executed without any error.
797
+ {
798
+ // Log query execution.
799
+ $this->stcr_logger("Error while updating the collation for the subscribe_reloaded_subscribers COLUMN subscriber_unique_id.");
800
+ $this->stcr_logger("\nDatabase Error: \" $wpdb->last_error \"\n");
801
+ }
802
+ }
803
+ else
804
+ {
805
+ // Log query execution.
806
+ $this->stcr_logger("Error while updating the collation for the subscribe_reloaded_subscribers table COLUMN subscriber_email");
807
+ $this->stcr_logger("\nDatabase Error: \" $wpdb->last_error \"\n");
808
+ }
809
+ }
810
+ else
811
+ {
812
+ // Log query execution.
813
+ $this->stcr_logger("Error while updating the collation for the subscribe_reloaded_subscribers table");
814
+ $this->stcr_logger("\nDatabase Error: \" $wpdb->last_error \"\n");
815
+ }
816
+ }
817
+ }
818
+ }
819
+ }
utils/stcr_utils.php CHANGED
@@ -20,7 +20,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
20
 
21
  public function __construct()
22
  {
23
-
24
  }
25
 
26
  public function __destruct()
@@ -89,9 +89,10 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
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
 
@@ -268,7 +269,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
268
  * Creates the HTML structure to properly handle HTML messages
269
  */
270
  public function wrap_html_message( $_message = '', $_subject = '' ) {
271
-
272
  global $wp_locale;
273
 
274
  // HTML emails
@@ -289,7 +290,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
289
  $body = "<body>$_message</body>";
290
  return $html . $head . $body . "</html>";
291
  }
292
-
293
  // Plain text emails
294
  } else {
295
 
@@ -303,7 +304,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
303
  * Returns an email address where some possible 'offending' strings have been removed
304
  */
305
  public function clean_email( $_email ) {
306
-
307
  if ( is_array( $_email) || is_object( $_email ) ) {
308
  return;
309
  }
@@ -318,8 +319,8 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
318
  "/mime\-version\:/i"
319
  );
320
 
321
- return sanitize_email( stripslashes( strip_tags( preg_replace( $offending_strings, '', $_email ) ) ) );
322
-
323
  }
324
  // end clean_email
325
 
@@ -391,8 +392,29 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
391
  add_option( 'subscribe_reloaded_enable_font_awesome', 'yes', '', 'yes' );
392
  add_option( 'subscribe_reloaded_delete_options_subscriptions', 'no', '', 'no' );
393
  add_option( 'subscribe_reloaded_date_format', 'd M Y', '', 'no' );
394
- add_option( 'subscribe_reloaded_only_for_posts', 'no', '', 'yes' );
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  }
397
  /**
398
  * @since 08-February-2018
@@ -537,8 +559,8 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
537
  public function register_admin_scripts( $hook ) {
538
 
539
  // paths
540
- $stcr_admin_js = plugins_url( 'subscribe-to-comments-reloaded/includes/js/stcr-admin.js' );
541
- $stcr_admin_css = plugins_url( 'subscribe-to-comments-reloaded/includes/css/stcr-admin-style.css' );
542
 
543
  // register scripts
544
  wp_register_script('stcr-admin-js', $stcr_admin_js, array( 'jquery' ) );
@@ -548,7 +570,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
548
 
549
  // check if we're on our pages
550
  if ( strpos( $hook, 'stcr' ) !== false ) {
551
-
552
  // enqueue scripts
553
  wp_enqueue_script('stcr-admin-js');
554
 
@@ -578,7 +600,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
578
  */
579
  public function register_script_to_wp( $handle, $script_name, $path_add = "" )
580
  {
581
- $js_resource = plugins_url( SLUG . "/$path_add/$script_name" );
582
  wp_register_script( $handle, $js_resource );
583
  }
584
  /**includes/js/admin
@@ -596,8 +618,8 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
596
  * @author reedyseth
597
  */
598
  public function register_plugin_scripts() {
599
-
600
- $stcr_font_awesome_css = plugins_url( 'subscribe-to-comments-reloaded/includes/css/font-awesome.min.css' );
601
  // Font Awesome
602
  if ( get_option( 'subscribe_reloaded_enable_font_awesome' ) == "yes" ) {
603
  wp_register_style( 'stcr-font-awesome', $stcr_font_awesome_css );
@@ -606,7 +628,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
606
 
607
  // google recaptcha
608
  if ( get_option( 'subscribe_reloaded_use_captcha', 'no' ) == 'yes' ) {
609
-
610
  // management page permalink
611
  $manager_page_permalink = get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
612
  if ( function_exists( 'qtrans_convertURL' ) ) {
@@ -617,7 +639,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
617
  if ( empty( $manager_page_permalink ) ) {
618
  $manager_page_permalink = '/comment-subscriptions/';
619
  }
620
-
621
  // remove the ending slash so both variations (with and without slash) work in the strpos check below
622
  $manager_page_permalink = rtrim( $manager_page_permalink, '/' );
623
 
@@ -680,8 +702,8 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
680
  else
681
  {
682
  $value = get_option( 'subscribe_reloaded_' . $_option, $_default );
683
- $value = html_entity_decode( stripslashes( $value ), ENT_QUOTES, 'UTF-8' );
684
- $value = stripslashes( $value );
685
  // Set the cache value
686
  $this->menu_opts_cache[$_option] = $value;
687
  }
@@ -760,7 +782,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
760
  }
761
 
762
  // Prevent XSS/CSRF attacks
763
- $_value = trim( stripslashes( $_value ) );
764
 
765
  switch ( $_type ) {
766
  case 'yesno':
@@ -787,6 +809,18 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
787
  case 'url':
788
  update_option( 'subscribe_reloaded_' . $_option, esc_url( $_value ) );
789
 
 
 
 
 
 
 
 
 
 
 
 
 
790
  break;
791
  default:
792
  update_option( 'subscribe_reloaded_' . $_option, esc_attr( $_value ) );
@@ -848,7 +882,7 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
848
 
849
  return;
850
  }
851
-
852
  /**
853
  * Update a StCR notification status
854
  *
@@ -899,7 +933,36 @@ if( ! class_exists('\\'.__NAMESPACE__.'\\stcr_utils') )
899
 
900
  fclose($file);
901
  }
902
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
903
  }
904
  }
905
- }
20
 
21
  public function __construct()
22
  {
23
+
24
  }
25
 
26
  public function __destruct()
89
  public function remove_user_subscriber_table($_email) {
90
  global $wpdb;
91
 
92
+ $OK = $wpdb->query( $wpdb->prepare(
93
+ "DELETE FROM " . $wpdb->prefix . "subscribe_reloaded_subscribers WHERE subscriber_email = %s",
94
+ $_email
95
+ ));
96
  return $OK === false || $OK == 0 || empty( $OK ) ? false : $OK;
97
  }
98
 
269
  * Creates the HTML structure to properly handle HTML messages
270
  */
271
  public function wrap_html_message( $_message = '', $_subject = '' ) {
272
+
273
  global $wp_locale;
274
 
275
  // HTML emails
290
  $body = "<body>$_message</body>";
291
  return $html . $head . $body . "</html>";
292
  }
293
+
294
  // Plain text emails
295
  } else {
296
 
304
  * Returns an email address where some possible 'offending' strings have been removed
305
  */
306
  public function clean_email( $_email ) {
307
+
308
  if ( is_array( $_email) || is_object( $_email ) ) {
309
  return;
310
  }
319
  "/mime\-version\:/i"
320
  );
321
 
322
+ return sanitize_email( stripslashes( strip_tags( preg_replace( $offending_strings, '', strtolower( $_email ) ) ) ) );
323
+
324
  }
325
  // end clean_email
326
 
392
  add_option( 'subscribe_reloaded_enable_font_awesome', 'yes', '', 'yes' );
393
  add_option( 'subscribe_reloaded_delete_options_subscriptions', 'no', '', 'no' );
394
  add_option( 'subscribe_reloaded_date_format', 'd M Y', '', 'no' );
 
395
 
396
+ // For blacklist email.
397
+ add_option( 'subscribe_reloaded_blacklisted_emails', '', '', 'yes' );
398
+
399
+ // For recaptcha version.
400
+ add_option( 'subscribe_reloaded_recaptcha_version', 'v2', '', 'yes' );
401
+
402
+ // For post type support.
403
+ $post_type_supports = array();
404
+ $args = array(
405
+ '_builtin' => false,
406
+ 'public' => true,
407
+ );
408
+ $post_types = get_post_types( $args );
409
+ $default_post_types = array(
410
+ 'post',
411
+ 'page',
412
+ );
413
+ $post_types = array_merge( $default_post_types, $post_types );
414
+ foreach ( $post_types as $post_type ) {
415
+ $post_type_supports[] = $post_type;
416
+ }
417
+ add_option( 'subscribe_reloaded_post_type_supports', $post_type_supports, '', 'yes' );
418
  }
419
  /**
420
  * @since 08-February-2018
559
  public function register_admin_scripts( $hook ) {
560
 
561
  // paths
562
+ $stcr_admin_js = plugins_url( '/includes/js/stcr-admin.js', STCR_PLUGIN_FILE );
563
+ $stcr_admin_css = plugins_url( '/includes/css/stcr-admin-style.css', STCR_PLUGIN_FILE );
564
 
565
  // register scripts
566
  wp_register_script('stcr-admin-js', $stcr_admin_js, array( 'jquery' ) );
570
 
571
  // check if we're on our pages
572
  if ( strpos( $hook, 'stcr' ) !== false ) {
573
+
574
  // enqueue scripts
575
  wp_enqueue_script('stcr-admin-js');
576
 
600
  */
601
  public function register_script_to_wp( $handle, $script_name, $path_add = "" )
602
  {
603
+ $js_resource = plugins_url( "/$path_add/$script_name", STCR_PLUGIN_FILE );
604
  wp_register_script( $handle, $js_resource );
605
  }
606
  /**includes/js/admin
618
  * @author reedyseth
619
  */
620
  public function register_plugin_scripts() {
621
+
622
+ $stcr_font_awesome_css = plugins_url( '/includes/css/font-awesome.min.css', STCR_PLUGIN_FILE );
623
  // Font Awesome
624
  if ( get_option( 'subscribe_reloaded_enable_font_awesome' ) == "yes" ) {
625
  wp_register_style( 'stcr-font-awesome', $stcr_font_awesome_css );
628
 
629
  // google recaptcha
630
  if ( get_option( 'subscribe_reloaded_use_captcha', 'no' ) == 'yes' ) {
631
+
632
  // management page permalink
633
  $manager_page_permalink = get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
634
  if ( function_exists( 'qtrans_convertURL' ) ) {
639
  if ( empty( $manager_page_permalink ) ) {
640
  $manager_page_permalink = '/comment-subscriptions/';
641
  }
642
+
643
  // remove the ending slash so both variations (with and without slash) work in the strpos check below
644
  $manager_page_permalink = rtrim( $manager_page_permalink, '/' );
645
 
702
  else
703
  {
704
  $value = get_option( 'subscribe_reloaded_' . $_option, $_default );
705
+ $value = ( ! is_array( $value ) ) ? html_entity_decode( stripslashes( $value ), ENT_QUOTES, 'UTF-8' ) : wp_unslash( $value );
706
+ $value = ( ! is_array( $value ) ) ? stripslashes( $value ) : wp_unslash( $value );
707
  // Set the cache value
708
  $this->menu_opts_cache[$_option] = $value;
709
  }
782
  }
783
 
784
  // Prevent XSS/CSRF attacks
785
+ $_value = ( 'multicheck' !== $_type ) ? trim( stripslashes( $_value ) ) : wp_unslash( $_value );
786
 
787
  switch ( $_type ) {
788
  case 'yesno':
809
  case 'url':
810
  update_option( 'subscribe_reloaded_' . $_option, esc_url( $_value ) );
811
 
812
+ break;
813
+ case 'textarea':
814
+ update_option( 'subscribe_reloaded_' . $_option, wp_kses_post( $_value ) );
815
+
816
+ break;
817
+ case 'multicheck':
818
+ update_option( 'subscribe_reloaded_' . $_option, wp_unslash( $_value ) );
819
+
820
+ break;
821
+ case 'select':
822
+ update_option( 'subscribe_reloaded_' . $_option, sanitize_key( $_value ) );
823
+
824
  break;
825
  default:
826
  update_option( 'subscribe_reloaded_' . $_option, esc_attr( $_value ) );
882
 
883
  return;
884
  }
885
+
886
  /**
887
  * Update a StCR notification status
888
  *
933
 
934
  fclose($file);
935
  }
936
+
937
+ }
938
+
939
+ /**
940
+ * Function to check if the commenter email address is blacklisted or not.
941
+ *
942
+ * @param string $email_to_check The commentor's email address.
943
+ *
944
+ * @return bool
945
+ */
946
+ public function blacklisted_emails( $email_to_check = '' ) {
947
+
948
+ // If the emails is blacklisted then, do not proceed to send the subscription confirmation email.
949
+ $blacklisted_emails = get_option( 'subscribe_reloaded_blacklisted_emails', '' );
950
+ $email_blacklist = ! empty( $blacklisted_emails ) ? explode( ',', $blacklisted_emails ) : false;
951
+
952
+ if ( is_array( $email_blacklist ) ) {
953
+ foreach ( $email_blacklist as $blacklist_item ) {
954
+ $blacklisted_items = trim( $blacklist_item );
955
+
956
+ if ( ! empty( trim( $blacklisted_items ) ) ) {
957
+ if ( is_email( $email_to_check ) === is_email( $blacklisted_items ) ) {
958
+ return false;
959
+ }
960
+ }
961
+ }
962
+ }
963
+
964
+ return true;
965
+
966
  }
967
  }
968
+ }
wp_subscribe_reloaded.php CHANGED
@@ -1,1746 +1,1780 @@
1
- <?php
2
- namespace stcr;
3
-
4
- // Avoid direct access to this piece of code
5
- if ( ! function_exists( 'add_action' ) ) {
6
- header( 'Location: /' );
7
- exit;
8
- }
9
-
10
- // globals
11
- define( __NAMESPACE__.'\\VERSION','211130' );
12
- define( __NAMESPACE__.'\\DEVELOPMENT', false );
13
- define( __NAMESPACE__.'\\SLUG', "subscribe-to-comments-reloaded" );
14
-
15
- // load files
16
- require_once dirname(__FILE__).'/utils/stcr_manage.php';
17
- require_once dirname(__FILE__).'/classes/stcr_i18n.php';
18
- require_once dirname(__FILE__).'/utils/functions.php';
19
-
20
- // Main plugin class
21
- if( ! class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded') ) {
22
-
23
- /**
24
- * Main plugin class
25
- *
26
- * __construct ( Constructor )
27
- * add_test_subscriptions ( Adds subscriptions for testing purposes )
28
- * define_wp_hooks ( Define the WordPress Hooks that will be used by the plugin. )
29
- * display_admin_header ( Display admin header menu )
30
- * subscribe_reloaded_load_plugin_textdomain ( Load localization files )
31
- * plugin_settings_link ( Add Settings link to plugin on plugins page )
32
- * _get_comment_object ( Retrieves the comment information from the database )
33
- * new_comment_posted ( Takes the appropriate action, when a new comment is posted )
34
- * is_double_check_enabled ( Is double check ( subscriptions need to be confirmed ) enabled )
35
- * comment_status_changed ( Actions when comments status changes ( approve/unapprove/spam/trash ) )
36
- * comment_deleted ( Actions when comment is deleted )
37
- * subscribe_post_author ( Subscribe the post author )
38
- * subscribe_reloaded_manage ( Displays the appropriate management page )
39
- * is_author ( Checks if current logged in user is the author )
40
- * is_user_subscribed ( Checks if a given email address is subscribed to a post )
41
- * add_subscription ( Adds a new subscription )
42
- * delete_subscriptions ( Deletes one or more subscriptions from the database )
43
- * retrieve_user_subscriptions ( Retries user subscriptions by post ID )
44
- * update_subscription_status ( Updates the status of an existing subscription )
45
- * update_subscription_email ( Updates the email address of an existing subscription )
46
- * get_subscriptions ( Retrieves a list of emails subscribed to a specific post )
47
- * notify_user ( Sends the notification message to a given user )
48
- * subscribe_reloaded_show ( Displays the checkbox to allow visitors to subscribe )
49
- * set_user_cookie ( Set a cookie if the user just subscribed without commenting )
50
- * management_page_sc ( Management page shortcode )
51
- * comment_content_prepend ( Add custom content before comment content )
52
- */
53
- class wp_subscribe_reloaded extends stcr_manage {
54
-
55
- public $stcr_i18n;
56
-
57
- /**
58
- * Constructor
59
- */
60
- public function __construct() {
61
-
62
- // run parent constructor.
63
- parent::__construct();
64
-
65
- $this->salt = defined( 'NONCE_KEY' ) ? NONCE_KEY : 'please create a unique key in your wp-config.php';
66
-
67
- // show the checkbox - You can manually override this by adding the corresponding function in your template
68
- if ( get_option( 'subscribe_reloaded_show_subscription_box' ) === 'yes' ) {
69
-
70
- if ( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
71
- add_action( 'comment_form', array($this, 'subscribe_reloaded_show'), 5, 0 );
72
- } else {
73
- add_filter( 'comment_form_submit_field', array($this, 'subscribe_reloaded_show'), 5, 1 );
74
- }
75
-
76
- // when users must be logged in to comment and current visitor is not logged in
77
- add_action( 'comment_form_must_log_in_after', array($this, 'subscribe_reloaded_show'), 5, 0 );
78
-
79
- }
80
-
81
- $this->maybe_update();
82
-
83
- // define WordPress hooks the plugin uses
84
- $this->define_wp_hooks();
85
-
86
- // localization
87
- $this->stcr_i18n = new stcr_i18n();
88
-
89
- // add subscriptions for tests
90
- if ( DEVELOPMENT ) {
91
- $this->add_test_subscriptions( 1000, 18,'Y', 'dev', 30);
92
- }
93
-
94
- // management page shortcode
95
- add_shortcode( 'stcr_management_page', array( $this, 'management_page_sc' ) );
96
-
97
- }
98
-
99
- /**
100
- * Adds subscriptions for testing purposes
101
- *
102
- * @since 190705
103
- */
104
- public function add_test_subscriptions( $iterations, $post_id, $status = 'Y', $email_prefix = 'dev', $last_id_subs = 0 ) {
105
- for ( $i = $last_id_subs+1; $i <= $iterations; $i++) {
106
- $this->add_subscription( $post_id, "{$email_prefix}_{$i}" . time() . "@dev.com", $status );
107
- }
108
- }
109
-
110
- /**
111
- * Define the WordPress Hooks that will be used by the plugin.
112
- *
113
- * @since 180302
114
- */
115
- public function define_wp_hooks() {
116
-
117
- // new comment posted
118
- add_action( 'comment_post', array( $this, 'new_comment_posted' ), 12, 2 );
119
-
120
- // add hook for the subscribe_reloaded_purge, define on the constructure so that the hook is read on time.
121
- add_action('_cron_subscribe_reloaded_purge', array($this, 'subscribe_reloaded_purge'), 10 );
122
- add_action('_cron_log_file_purge', array($this, 'log_file_purge'), 10 );
123
-
124
- // load text domain
125
- add_action( 'plugins_loaded', array( $this, 'subscribe_reloaded_load_plugin_textdomain' ) );
126
-
127
- // front end
128
- if ( ! is_admin() ) {
129
-
130
- // management page permalink
131
- $manager_page_permalink = get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
132
- if ( function_exists( 'qtrans_convertURL' ) ) {
133
- $manager_page_permalink = qtrans_convertURL( $manager_page_permalink );
134
- }
135
-
136
- // management page permalink fallback
137
- if ( empty( $manager_page_permalink ) ) {
138
- $manager_page_permalink = '/comment-subscriptions/';
139
- }
140
-
141
- // remove the ending slash so both variations (with and without slash) work in the strpos check below
142
- $manager_page_permalink = rtrim( $manager_page_permalink, '/' );
143
-
144
- // if we are on the management page, filter the_posts
145
- if ( ( strpos( $_SERVER["REQUEST_URI"], $manager_page_permalink ) !== false ) ) {
146
-
147
- $request_uri = $_SERVER['REQUEST_URI'];
148
- $request_uri_arr = explode( $manager_page_permalink, $request_uri );
149
-
150
- // don't show management page if a "child page"
151
- if ( empty( $request_uri_arr[1] ) || $request_uri_arr[1] == '/' || strpos( $request_uri_arr[1], '/?' ) === 0 ) {
152
- add_filter( 'the_posts', array( $this, 'subscribe_reloaded_manage' ), 10, 2 );
153
- }
154
-
155
- }
156
-
157
- // filter to add custom output before comment content
158
- add_filter( 'comment_text', array( $this, 'comment_content_prepend' ), 10, 2 );
159
-
160
- // script to move the subscription form
161
- add_action( 'wp_footer', array( $this, 'move_form_with_js' ), 20 );
162
-
163
- // enqueue scripts
164
- $this->utils->hook_plugin_scripts();
165
-
166
- // wp admin
167
- } else {
168
-
169
- // hook for WPMU - new blog created
170
- add_action( 'wpmu_new_blog', array( $this, 'new_blog' ), 10, 1 );
171
-
172
- // remove subscriptions for post that is being deleted
173
- add_action( 'delete_post', array( $this, 'delete_subscriptions' ), 10, 2 );
174
-
175
- // remove subscriptions when a comment is deleted or status changed
176
- add_action( 'deleted_comment', array( $this, 'comment_deleted' ) );
177
- add_action( 'wp_set_comment_status', array( $this, 'comment_status_changed' ) );
178
-
179
- // new columns in post/comment tables ( WP admin > Posts and WP admin > Comments )
180
- add_filter( 'manage_edit-comments_columns', array( $this, 'add_column_header' ) );
181
- add_filter( 'manage_posts_columns', array( $this, 'add_column_header' ) );
182
- add_action( 'manage_comments_custom_column', array( $this, 'add_comment_column' ) );
183
- add_action( 'manage_posts_custom_column', array( $this, 'add_post_column' ) );
184
-
185
- // Add appropriate entries in the admin menu
186
- add_action( 'admin_menu', array( $this, 'add_config_menu' ) );
187
- add_action( 'admin_print_styles-edit-comments.php', array( $this, 'add_post_comments_stylesheet' ) );
188
- add_action( 'admin_print_styles-edit.php', array( $this, 'add_post_comments_stylesheet' ) );
189
-
190
- // admin header
191
- add_action( 'in_admin_header', array( $this, 'display_admin_header' ), 100 );
192
-
193
- // admin init
194
- add_action( 'admin_init', array( $this, 'stcr_admin_init' ) );
195
-
196
- // admin notices
197
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
198
-
199
- // shortcodes to use the management URL sitewide
200
- add_shortcode( 'subscribe-url', array( $this, 'subscribe_url_shortcode' ) );
201
-
202
- // action links for listing on WP admin > Plugins
203
- add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
204
-
205
- // subscribe post authors, if auto subscribe for authors enabled
206
- if ( get_option( 'subscribe_reloaded_notify_authors' ) === 'yes' ) {
207
- add_action( 'publish_post', array( $this, 'subscribe_post_author' ) );
208
- }
209
-
210
- // enqueue scripts
211
- $this->utils->hook_admin_scripts();
212
-
213
- // ajax for admin notices ( mark as read )
214
- $this->utils->stcr_create_ajax_notices();
215
-
216
- // download system information file
217
- add_action( 'admin_init', array( $this, 'sysinfo_download' ) );
218
-
219
- // exclude subscriptions on post duplication
220
- add_filter( 'duplicate_post_blacklist_filter', array( $this, 'duplicate_post_exclude_subs' ) );
221
-
222
- }
223
-
224
- }
225
-
226
- /**
227
- * Display the admin header menu
228
- *
229
- * @since 190705 Cleanup
230
- */
231
- public function display_admin_header () {
232
-
233
- global $wp_locale;
234
-
235
- $slug = 'stcr_manage_subscriptions';
236
- $current_page = isset( $_GET['page'] ) ? $_GET['page'] : '';
237
-
238
- // define the menu items
239
- $array_pages = array(
240
- 'stcr_manage_subscriptions' => __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ),
241
- 'stcr_comment_form' => __( 'Comment Form', 'subscribe-to-comments-reloaded' ),
242
- 'stcr_management_page' => __( 'Management Page', 'subscribe-to-comments-reloaded' ),
243
- 'stcr_notifications' => __( 'Notifications', 'subscribe-to-comments-reloaded' ),
244
- 'stcr_options' => __( 'Options', 'subscribe-to-comments-reloaded' ),
245
- 'stcr_support' => __( 'Support', 'subscribe-to-comments-reloaded' ),
246
- 'stcr_system' => __( 'Options', 'subscribe-to-comments-reloaded' )
247
- );
248
-
249
- // do not proceed if not on a STCR admin page
250
- if ( ! array_key_exists( $current_page, $array_pages) ) {
251
- return;
252
- }
253
-
254
- ?>
255
-
256
- <nav class="navbar navbar-expand-lg navbar-light bg-light <?php echo $wp_locale->text_direction ?>">
257
-
258
- <a class="navbar-brand"><img src="<?php echo plugins_url(); ?>/subscribe-to-comments-reloaded/images/stcr-logo-150.png" alt="" width="25" height="19"></a>
259
-
260
- <div class="collapse navbar-collapse">
261
-
262
- <ul class="navbar-nav">
263
-
264
- <?php
265
-
266
- // go through each stcr admin page
267
- foreach ( $array_pages as $page => $page_desc ) :
268
-
269
- // skip strc_system because it's added as part of stcr_options
270
- if ( $page == 'stcr_system' ) continue;
271
-
272
- ?><li class="<?php echo $page == 'stcr_options' ? 'dropdown' : ''; ?>"><?php
273
-
274
- // dropdrown for options menu item
275
- if ( $page == 'stcr_options' ) :
276
-
277
- ?>
278
- <a
279
- class="nav-link dropdown-toggle <?php echo ( $current_page == $page || $current_page == 'stcr_system' ? ' stcr-active-tab' : '' ); ?>"
280
- style="padding: 5px 12px 0 0;"
281
- href="#"
282
- id="navbarDropdown"
283
- role="button"
284
- data-toggle="dropdown"
285
- aria-haspopup="true"
286
- aria-expanded="false">
287
- <?php echo $page_desc; ?>
288
- </a>
289
- <div class="dropdown-menu" aria-labelledby="navbarDropdown">
290
- <a class="dropdown-item" href="admin.php?page=<?php echo $page; ?>"><?php echo __('StCR Options', 'subscribe-to-comments-reloaded'); ?></a>
291
- <div class="dropdown-divider"></div>
292
- <a class="dropdown-item" href="admin.php?page=stcr_system"><?php echo __('StCR System', 'subscribe-to-comments-reloaded'); ?></a>
293
- </div>
294
- <?php
295
-
296
- // regular menu items
297
- else :
298
-
299
- ?>
300
- <a
301
- class="navbar-brand <?php echo ( $current_page == $page ) ? ' stcr-active-tab' : ''; ?>"
302
- href="admin.php?page=<?php echo $page; ?>">
303
- <?php echo $page_desc; ?>
304
- </a>
305
- <?php
306
-
307
- endif;
308
-
309
- ?></li><?php
310
-
311
- endforeach;
312
-
313
- ?>
314
-
315
- </ul><!-- .navbar-nav -->
316
-
317
- </div><!-- .navbar-collapse -->
318
-
319
- </nav><!-- .navbar -->
320
- <?php
321
-
322
- }
323
-
324
- /**
325
- * Load localization files
326
- *
327
- * @since 190705 cleanup
328
- */
329
- function subscribe_reloaded_load_plugin_textdomain() {
330
-
331
- load_plugin_textdomain( 'subscribe-to-comments-reloaded', FALSE, SLUG . '/langs/' );
332
-
333
- }
334
-
335
- /**
336
- * Add Settings link to plugin on plugins page
337
- *
338
- * @since 190705 cleanup
339
- */
340
- public function plugin_settings_link( $links, $file ) {
341
-
342
- if ( $file == 'subscribe-to-comments-reloaded/subscribe-to-comments-reloaded.php' ) {
343
- $links['settings'] = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
344
- }
345
-
346
- return $links;
347
-
348
- }
349
-
350
- /**
351
- * Retrieves the comment information from the database
352
- *
353
- * @since 190705 cleanup
354
- */
355
- public function _get_comment_object( $_comment_ID ) {
356
-
357
- global $wpdb;
358
-
359
- return $wpdb->get_row(
360
- $wpdb->prepare(
361
- "SELECT comment_post_ID, comment_author_email, comment_approved, comment_type, comment_parent
362
- FROM $wpdb->comments
363
- WHERE comment_ID = %d
364
- LIMIT 1", $_comment_ID
365
- ), OBJECT
366
- );
367
-
368
- }
369
-
370
- /**
371
- * Takes the appropriate action, when a new comment is posted
372
- *
373
- * @since 190705 cleanup
374
- */
375
- public function new_comment_posted( $_comment_ID = 0, $_comment_status = 0 ) {
376
-
377
- // get information about the comment
378
- $info = $this->_get_comment_object( $_comment_ID );
379
-
380
- // return if no info found or comment marked as spam
381
- if ( empty( $info ) || $info->comment_approved == 'spam' ) {
382
- return $_comment_ID;
383
- }
384
-
385
- // return if subscriptions disabled for this post
386
- $is_disabled = get_post_meta( $info->comment_post_ID, 'stcr_disable_subscriptions', true );
387
- if ( ! empty( $is_disabled ) ) {
388
- return $_comment_ID;
389
- }
390
-
391
- // return if trackback/pingback ( if set not to notify on those )
392
- if ( ( get_option( 'subscribe_reloaded_process_trackbacks', 'no' ) == 'no' ) && ( $info->comment_type == 'trackback' || $info->comment_type == 'pingback' ) ) {
393
- return $_comment_ID;
394
- }
395
-
396
- // process the subscription
397
- if ( ! empty( $_POST['subscribe-reloaded'] ) && ! empty( $info->comment_author_email ) ) {
398
-
399
- // check if subscription type is valid
400
- if ( in_array( $_POST['subscribe-reloaded'], array( 'replies', 'digest', 'yes' ) ) ) {
401
-
402
- // get subscription type
403
- switch ($_POST['subscribe-reloaded']) {
404
- case 'replies':
405
- $status = 'R';
406
- break;
407
- case 'digest':
408
- $status = 'D';
409
- break;
410
- default:
411
- $status = 'Y';
412
- break;
413
- }
414
-
415
- // if not already subscribed
416
- if ( ! $this->is_user_subscribed($info->comment_post_ID, $info->comment_author_email)) {
417
-
418
- // if double check enabled, send confirmation email and append C to status
419
- if ( $this->is_double_check_enabled($info) ) {
420
- $this->sendConfirmationEMail($info);
421
- $status = "{$status}C";
422
- }
423
-
424
- // add the subscription
425
- $this->add_subscription($info->comment_post_ID, $info->comment_author_email, $status);
426
-
427
- // return ( do not proceed with sending notifications ) if comment held for moderation
428
- if ( $info->comment_approved == 0 ) {
429
- return $_comment_ID;
430
- }
431
-
432
- }
433
-
434
- }
435
-
436
- }
437
-
438
- // if comment approved, notify subscribed users about the comment
439
- if ( $info->comment_approved == 1 ) {
440
-
441
- // get all subscriptions
442
- $subscriptions = $this->get_subscriptions(
443
- array(
444
- 'post_id',
445
- 'status'
446
- ),
447
- array(
448
- 'equals',
449
- 'equals'
450
- ),
451
- array(
452
- $info->comment_post_ID,
453
- 'Y'
454
- )
455
- );
456
-
457
- // is this a reply to an existing comment?
458
- if ( ! empty( $info->comment_parent ) ) {
459
-
460
- // merge subscriptions
461
- $subscriptions = array_merge(
462
- $subscriptions,
463
- $this->get_subscriptions(
464
- 'parent',
465
- 'equals',
466
- array(
467
- $info->comment_parent,
468
- $info->comment_post_ID
469
- )
470
- )
471
- );
472
-
473
- }
474
-
475
- // post author info
476
- $post_author_id = get_post_field( 'post_author', $info->comment_post_ID );
477
- $post_author_data = get_userdata( $post_author_id );
478
- $post_author_email = $post_author_data->user_email;
479
- $post_author_notified = false;
480
-
481
- // notify subscribers
482
- foreach ( $subscriptions as $a_subscription ) {
483
-
484
- // skip comment author
485
- if ( $a_subscription->email != $info->comment_author_email ) {
486
-
487
- // notify the user
488
- $this->notify_user( $info->comment_post_ID, $a_subscription->email, $_comment_ID );
489
-
490
- // post author notified?
491
- if ( $a_subscription->email == $post_author_email ) {
492
- $post_author_notified = true;
493
- }
494
-
495
- }
496
-
497
- }
498
-
499
- // notify author
500
- if ( ! $post_author_notified && get_option( 'subscribe_reloaded_notify_authors', 'no' ) == 'yes' ) {
501
-
502
- // send email to author unless the author made the comment
503
- if ( $info->comment_author_email != $post_author_email ) {
504
- $this->notify_user( $info->comment_post_ID, $post_author_email, $_comment_ID );
505
- }
506
-
507
- }
508
-
509
- }
510
-
511
- // that's all, return
512
- return $_comment_ID;
513
-
514
- }
515
-
516
- /**
517
- * Is double check ( subscriptions need to be confirmed ) enabled
518
- *
519
- * @since 190705
520
- */
521
- public function is_double_check_enabled( $info ) {
522
-
523
- $is_subscribe_to_post = false;
524
- $is_user_logged_in = is_user_logged_in();
525
- $is_option_enabled = false;
526
- if ( get_option( 'subscribe_reloaded_enable_double_check', 'no' ) == 'yes' ) {
527
- $is_option_enabled = true;
528
- }
529
-
530
- $approved_subscriptions = $this->get_subscriptions(
531
- array(
532
- 'status',
533
- 'email'
534
- ),
535
- array(
536
- 'equals',
537
- 'equals'
538
- ), array(
539
- 'Y',
540
- $info->comment_author_email
541
- )
542
- );
543
-
544
- // check if the user is already subscribed to the requested Post ID
545
- foreach ( $approved_subscriptions as $subscription ) {
546
- if ( $info->comment_post_ID == $subscription->post_id ) {
547
- $is_subscribe_to_post = true;
548
- }
549
- }
550
-
551
- // option enabled AND user not logged in AND not already subscribed
552
- if ( $is_option_enabled && ! $is_user_logged_in && ( ! $is_subscribe_to_post || empty( $approved_subscriptions ) ) ) {
553
- return true;
554
- } else {
555
- return false;
556
- }
557
-
558
- }
559
-
560
- /**
561
- * Actions when comments status changes ( approve/unapprove/spam/trash )
562
- *
563
- * @since 190705 cleanup
564
- */
565
- public function comment_status_changed( $_comment_ID = 0, $_comment_status = 0 ) {
566
-
567
- // get information about the comment
568
- $info = $this->_get_comment_object( $_comment_ID );
569
-
570
- // return, no information found
571
- if ( empty( $info ) ) {
572
- return $_comment_ID;
573
- }
574
-
575
- // go through the types of statuses
576
- switch ( $info->comment_approved ) {
577
-
578
- // unapproved
579
- case '0':
580
-
581
- $this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, 'C' );
582
- break;
583
-
584
- // approved
585
- case '1':
586
-
587
- $this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, '-C' );
588
-
589
- // get subscriptions
590
- $subscriptions = $this->get_subscriptions(
591
- array(
592
- 'post_id',
593
- 'status'
594
- ), array(
595
- 'equals',
596
- 'equals'
597
- ), array(
598
- $info->comment_post_ID,
599
- 'Y'
600
- )
601
- );
602
-
603
- if ( ! empty( $info->comment_parent ) ) {
604
-
605
- $subscriptions = array_merge(
606
- $subscriptions, $this->get_subscriptions(
607
- 'parent',
608
- 'equals',
609
- array(
610
- $info->comment_parent,
611
- $info->comment_post_ID
612
- )
613
- )
614
- );
615
-
616
- }
617
-
618
- // go through subscriptions and notify subscribers
619
- foreach ( $subscriptions as $a_subscription ) {
620
-
621
- // skip the comment author
622
- if ( $a_subscription->email != $info->comment_author_email ) {
623
- $this->notify_user( $info->comment_post_ID, $a_subscription->email, $_comment_ID );
624
- }
625
-
626
- }
627
-
628
- break;
629
-
630
- case 'trash':
631
-
632
- case 'spam':
633
-
634
- // perform the same actions as if it were deleted
635
- $this->comment_deleted( $_comment_ID );
636
- break;
637
-
638
- default:
639
- break;
640
-
641
- }
642
-
643
- // return
644
- return $_comment_ID;
645
-
646
- }
647
-
648
- /**
649
- * Actions when comment is deleted
650
- *
651
- * @since 190705 cleanup
652
- */
653
- public function comment_deleted( $_comment_ID ) {
654
-
655
- global $wpdb;
656
-
657
- // get information about the comments
658
- $info = $this->_get_comment_object( $_comment_ID );
659
-
660
- // return, no information found
661
- if ( empty( $info ) ) {
662
- return $_comment_ID;
663
- }
664
-
665
- // how many comments does the author have on this post
666
- $count_approved_comments = $wpdb->get_var(
667
- "SELECT COUNT(*)
668
- FROM $wpdb->comments
669
- WHERE comment_post_ID = '$info->comment_post_ID'
670
- AND comment_author_email = '$info->comment_author_email'
671
- AND comment_approved = 1"
672
- );
673
-
674
- // if author has no comments left on this post, remove his subscription
675
- if ( intval( $count_approved_comments ) == 0 ) {
676
- $this->delete_subscriptions( $info->comment_post_ID, $info->comment_author_email );
677
- }
678
-
679
- // return
680
- return $_comment_ID;
681
- }
682
-
683
- /**
684
- * Subscribe the post author
685
- *
686
- * @since 190705 cleanup
687
- */
688
- public function subscribe_post_author( $_post_ID ) {
689
-
690
- $new_post = get_post( $_post_ID );
691
- $author_email = get_the_author_meta( 'user_email', $new_post->post_author );
692
-
693
- if ( ! empty( $author_email ) ) {
694
- $this->add_subscription( $_post_ID, $author_email, 'Y' );
695
- }
696
-
697
- }
698
-
699
- /**
700
- * Displays the appropriate management page
701
- *
702
- * @since 190705 cleanup
703
- */
704
- public function subscribe_reloaded_manage( $_posts = '', $_query = '' ) {
705
-
706
- // vars
707
- global $current_user;
708
- $stcr_unique_key = get_option( 'subscribe_reloaded_unique_key' );
709
- $date = date_i18n( 'Y-m-d H:i:s' );
710
- $error_exits = false;
711
- $email = '';
712
- $virtual_page_enabled = get_option( 'subscribe_reloaded_manager_page_enabled', 'yes' );
713
-
714
- // if something exists at this URL and virtual page disabled, abort mission
715
- if ( ! empty( $_posts ) && $virtual_page_enabled == 'no' ) {
716
- return $_posts;
717
- }
718
-
719
- // make sure we don't call the code below twice on non-virtual page
720
- if ( $virtual_page_enabled == 'no' && ! in_the_loop() ) {
721
- return;
722
- }
723
-
724
- try {
725
-
726
- // get post ID
727
- $post_ID = !empty($_POST['srp']) ? intval($_POST['srp']) : (!empty($_GET['srp']) ? intval($_GET['srp']) : 0);
728
-
729
- // does a post with that ID exist
730
- $target_post = get_post($post_ID);
731
- if ( ( $post_ID > 0 ) && ! is_object($target_post) ) {
732
- return $_posts;
733
- }
734
-
735
- // vars
736
- $action = !empty($_POST['sra']) ? $_POST['sra'] : (!empty($_GET['sra']) ? $_GET['sra'] : 0);
737
- $key = !empty($_POST['srk']) ? $_POST['srk'] : (!empty($_GET['srk']) ? $_GET['srk'] : 0);
738
-
739
- $sre = !empty($_POST['sre']) ? $_POST['sre'] : (!empty($_GET['sre']) ? $_GET['sre'] : '');
740
- if ( is_user_logged_in() ) {
741
- $sre = $current_user->data->user_email;
742
- }
743
-
744
- $srek = !empty($_POST['srek']) ? $_POST['srek'] : (!empty($_GET['srek']) ? $_GET['srek'] : '');
745
- $link_source = !empty($_POST['srsrc']) ? $_POST['srsrc'] : (!empty($_GET['srsrc']) ? $_GET['srsrc'] : '');
746
- $key_expired = !empty($_POST['key_expired']) ? $_POST['key_expired'] : (!empty($_GET['key_expired']) ? $_GET['key_expired'] : '0');
747
-
748
- // check if the current subscriber has valid email using the $srek key.
749
- $email_by_key = $this->utils->get_subscriber_email_by_key($srek);
750
-
751
- // stop if invalid SRE key
752
- if ( ! $email_by_key && ! empty( $srek ) ) {
753
-
754
- $this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find an email with the SRE key: ( $srek )\n");
755
- $email = '';
756
-
757
- // valid key, proceed
758
- } else {
759
-
760
- if ( ! $email_by_key && empty( $sre ) ) {
761
- $email = '';
762
- } else if ( $email_by_key && ! empty( $email_by_key ) ) {
763
- $email = $email_by_key;
764
- } else if ( ! empty( $sre ) ) {
765
- $email = $this->utils->check_valid_email( $sre );
766
- } else {
767
- $email = '';
768
- }
769
-
770
- }
771
-
772
- // comes from the comment form.
773
- if ($link_source == 'f') {
774
-
775
- // Check for a valid SRK key, until this point we know the email is correct but the $key has expired/change
776
- // or is wrong, in that case display the request management page template
777
- if ($email !== "" && $key !== 0 && $stcr_unique_key !== $key || $key_expired == "1") {
778
- if ($key_expired == "1") {
779
- $error_exits = true;
780
- } else {
781
- $this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
782
- $error_exits = true;
783
- }
784
- }
785
-
786
- // comes from email link
787
- } else if ($link_source == 'e') {
788
-
789
- if ($email !== "" && $key !== 0 && !$this->utils->_is_valid_key($key, $email) || $key_expired == "1") {
790
- if ($key_expired == "1") {
791
- $error_exits = true;
792
- } else {
793
- $this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
794
- $error_exits = true;
795
- }
796
- }
797
-
798
- }
799
-
800
- // error found, show message
801
- if ($error_exits) {
802
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/key_expired.php';
803
-
804
- // all fine, proceed
805
- } else {
806
-
807
- // subscribe without commenting
808
- if (
809
- !empty($action) &&
810
- ($action == 's') &&
811
- ($post_ID > 0) &&
812
- $key_expired != "1"
813
- ) {
814
-
815
- if ( get_option( 'subscribe_reloaded_allow_subscribe_without_comment', 'yes' ) == 'yes' ) {
816
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/subscribe.php';
817
- } else {
818
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/not-allowed.php';
819
- }
820
-
821
- // post author
822
- } elseif (
823
- ($post_ID > 0) &&
824
- $this->is_author($target_post->post_author)
825
- ) {
826
-
827
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/author.php';
828
-
829
- // confirm subscription
830
- } elseif (
831
- ($post_ID > 0) &&
832
- !empty($email) &&
833
- !empty($key) &&
834
- !empty($action) &&
835
- $this->utils->_is_valid_key($key, $email) &&
836
- $this->is_user_subscribed($post_ID, $email, 'C') &&
837
- ($action == 'c') &&
838
- $key_expired != "1"
839
- ) {
840
-
841
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/confirm.php';
842
-
843
- // unsubscribe
844
- } elseif (
845
- ($post_ID > 0) &&
846
- !empty($email) &&
847
- !empty($key) &&
848
- !empty($action) &&
849
- $this->utils->_is_valid_key($key, $email) &&
850
- ($action == 'u') &&
851
- $key_expired != "1"
852
- ) {
853
-
854
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/one-click-unsubscribe.php';
855
-
856
- // user management page
857
- } elseif (
858
- !empty($email) &&
859
- ($key !== 0 && $this->utils->_is_valid_key($key, $email) || (!empty($current_user->data->user_email) && ($current_user->data->user_email === $email && current_user_can('read'))))
860
- ) {
861
-
862
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/user.php';
863
-
864
- // wrong request
865
- } elseif (
866
- !empty($email) &&
867
- ($key === 0 && (!empty($current_user->data->user_email) && ($current_user->data->user_email !== $email)))
868
- ) {
869
-
870
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/wrong-request.php';
871
-
872
- }
873
-
874
- // request management link
875
- if (empty($include_post_content)) {
876
-
877
- if ( get_option( 'subscribe_reloaded_allow_request_management_link', 'yes' ) == 'yes' ) {
878
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/request-management-link.php';
879
- } else {
880
- $include_post_content = include WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/templates/not-allowed.php';
881
- }
882
-
883
- }
884
-
885
- }
886
-
887
- global $wp_query;
888
-
889
- // management page title
890
- $manager_page_title = html_entity_decode(get_option('subscribe_reloaded_manager_page_title', 'Manage subscriptions'), ENT_QUOTES, 'UTF-8');
891
- if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
892
- $manager_page_title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($manager_page_title);
893
- } else {
894
- $manager_page_title = $manager_page_title;
895
- }
896
-
897
- // fake posts
898
- $posts[] =
899
- (object)array(
900
- 'ID' => '9999999',
901
- 'post_autToggle hor' => '1',
902
- 'post_date' => '2001-01-01 11:38:56',
903
- 'post_date_gmt' => '2001-01-01 00:38:56',
904
- 'post_content' => $include_post_content,
905
- 'post_title' => $manager_page_title,
906
- 'post_excerpt' => '',
907
- 'post_status' => 'publish',
908
- 'comment_status' => 'closed',
909
- 'ping_status' => 'closed',
910
- 'post_password' => '',
911
- 'to_ping' => '',
912
- 'pinged' => '',
913
- 'post_modified' => '2001-01-01 11:00:01',
914
- 'post_modified_gmt' => '2001-01-01 00:00:01',
915
- 'post_content_filtered' => '',
916
- 'post_parent' => '0',
917
- 'menu_order' => '0',
918
- 'post_type' => 'page',
919
- 'post_mime_type' => '',
920
- 'post_category' => '0',
921
- 'comment_count' => '0',
922
- 'filter' => 'raw',
923
- 'guid' => get_bloginfo('url') . '/?page_id=9999999',
924
- 'post_name' => get_bloginfo('url') . '/?page_id=9999999',
925
- 'ancestors' => array()
926
- );
927
-
928
- // Make WP believe this is a real page, with no comments attached
929
- $wp_query->is_page = true;
930
- $wp_query->is_single = false;
931
- $wp_query->is_home = false;
932
- $wp_query->comments = false;
933
-
934
- // Discard 404 errors thrown by other checks
935
- unset($wp_query->query["error"]);
936
- $wp_query->query_vars["error"] = "";
937
- $wp_query->is_404 = false;
938
-
939
- // Seems like WP adds its own HTML formatting code to the content, we don't need that here
940
- remove_filter('the_content', 'wpautop');
941
-
942
- // Look like the plugin is call twice and therefor subscribe to the "the_posts" filter again so we need to
943
- // tell to WordPress to not register again.
944
- remove_filter("the_posts", array($this, "subscribe_reloaded_manage"));
945
- add_action('wp_head', array($this, 'add_custom_header_meta'));
946
-
947
- // log the error
948
- } catch(\Exception $ex) {
949
-
950
- $this->utils->stcr_logger( "\n [ERROR][$date] - $ex->getMessage()\n" );
951
- $this->utils->stcr_logger( "\n [ERROR][$date] - $ex->getTraceAsString()\n" );
952
-
953
- }
954
-
955
- // return filtered posts
956
- return $posts;
957
-
958
- }
959
-
960
- /**
961
- * Checks if current logged in user is the author
962
- *
963
- * @since 190705 cleanup
964
- */
965
- public function is_author( $_post_author ) {
966
-
967
- global $current_user;
968
- return ! empty( $current_user ) && ( ( $_post_author == $current_user->ID ) || current_user_can( 'manage_options' ) );
969
-
970
- }
971
-
972
- /**
973
- * Checks if a given email address is subscribed to a post
974
- *
975
- * @since 190705 cleanup
976
- */
977
- public function is_user_subscribed( $_post_ID = 0, $_email = '', $_status = '' ) {
978
-
979
- global $current_user;
980
-
981
- // return, no info about email available
982
- if ( ( empty( $current_user->user_email ) && empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) && empty( $_email ) ) || empty( $_post_ID ) ) {
983
- return false;
984
- }
985
-
986
- $operator = ( $_status != '' ) ? 'equals' : 'contains';
987
-
988
- // get subscriptions
989
- $subscriptions = $this->get_subscriptions(
990
- array(
991
- 'post_id',
992
- 'status'
993
- ),
994
- array(
995
- 'equals',
996
- $operator
997
- ), array(
998
- $_post_ID,
999
- $_status
1000
- )
1001
- );
1002
-
1003
- // if email not supplied, tried to get it
1004
- if ( empty( $_email ) ) {
1005
- $user_email = ! empty( $current_user->user_email ) ? $current_user->user_email : ( ! empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ? stripslashes( esc_attr( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) : '#undefined#' );
1006
-
1007
- // if supplied, use it
1008
- } else {
1009
- $user_email = $_email;
1010
- }
1011
-
1012
- // go through all subscriptions and return true if the email is found
1013
- foreach ( $subscriptions as $a_subscription ) {
1014
- if ( $user_email == $a_subscription->email ) {
1015
- return true;
1016
- }
1017
- }
1018
-
1019
- // return false, the email is not subscribed
1020
- return false;
1021
-
1022
- }
1023
-
1024
- /**
1025
- * Adds a new subscription
1026
- *
1027
- * @since 190705 cleanup
1028
- */
1029
- public function add_subscription( $_post_id = 0, $_email = '', $_status = 'Y' ) {
1030
-
1031
- global $wpdb;
1032
-
1033
- // does the post exist?
1034
- $target_post = get_post( $_post_id );
1035
- if ( ( $_post_id > 0 ) && ! is_object( $target_post ) ) {
1036
- return;
1037
- }
1038
-
1039
- // return if status incorrect
1040
- if ( ! in_array( $_status, array( 'Y', 'YC', 'R', 'RC', 'C', '-C' ) ) || empty( $_status ) ) {
1041
- return;
1042
- }
1043
-
1044
- // using Wordpress local time
1045
- $dt = date_i18n( 'Y-m-d H:i:s' );
1046
-
1047
- // sanitize email
1048
- $clean_email = $this->utils->clean_email( $_email );
1049
-
1050
- // insert subscriber into postmeta
1051
- $wpdb->query( $wpdb->prepare(
1052
- "INSERT IGNORE INTO $wpdb->postmeta (post_id, meta_key, meta_value)
1053
- SELECT %d, %s, %s
1054
- FROM DUAL
1055
- WHERE NOT EXISTS (
1056
- SELECT post_id
1057
- FROM $wpdb->postmeta
1058
- WHERE post_id = %d
1059
- AND meta_key = %s
1060
- LIMIT 0,1
1061
- )", $_post_id, "_stcr@_$clean_email", "$dt|$_status", $_post_id, "_stcr@_$clean_email"
1062
- ));
1063
-
1064
- // Insert user into subscribe_reloaded_subscribers table
1065
- // TODO: Only on this section the user should be added to the subscribers table. On the send confirmation email is repeating this method.
1066
- $OK = $this->utils->add_user_subscriber_table( $clean_email );
1067
-
1068
- }
1069
-
1070
- /**
1071
- * Deletes one or more subscriptions from the database
1072
- *
1073
- * @since 190705 cleanup
1074
- */
1075
- public function delete_subscriptions( $_post_id = 0, $_email = '' ) {
1076
-
1077
- // related to wp 5.5 delete_post coming with 2nd parameter of WP Post object
1078
- if ( is_object( $_email ) ) {
1079
- $_email = '';
1080
- }
1081
-
1082
- global $wpdb;
1083
-
1084
- $has_subscriptions = false;
1085
-
1086
- // no post ID supplied, return 0
1087
- if ( empty( $_post_id ) ) {
1088
- return 0;
1089
- }
1090
-
1091
- // generate search for the DB query
1092
- $posts_where = '';
1093
- if ( ! is_array( $_post_id ) ) {
1094
- $posts_where = "post_id = " . intval( $_post_id );
1095
- } else {
1096
- foreach ( $_post_id as $a_post_id ) {
1097
- $posts_where .= "post_id = '" . intval( $a_post_id ) . "' OR ";
1098
- }
1099
- $posts_where = substr( $posts_where, 0, - 4 );
1100
- }
1101
-
1102
- // if email supplied, add it to the search for the DB query
1103
- if ( ! empty( $_email ) ) {
1104
- $emails_where = '';
1105
- if ( ! is_array( $_email ) ) {
1106
- $emails_where = "meta_key = '_stcr@_" . $this->utils->clean_email( $_email ) . "'";
1107
- $has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $_email );
1108
- if ( $has_subscriptions === false) {
1109
- $this->utils->remove_user_subscriber_table( $_email );
1110
- }
1111
- } else {
1112
- foreach ( $_email as $a_email ) {
1113
- $emails_where .= "meta_key = '_stcr@_" . $this->utils->clean_email( $a_email ) . "' OR ";
1114
- // Deletion on every email on the subscribers table.
1115
- $has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $a_email );
1116
- if ( $has_subscriptions === false ) {
1117
- $this->utils->remove_user_subscriber_table( $a_email );
1118
- }
1119
- }
1120
-
1121
- $emails_where = substr( $emails_where, 0, - 4 );
1122
- }
1123
-
1124
- // remove subscription from DB
1125
- return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE ($posts_where) AND ($emails_where)" );
1126
-
1127
- } else {
1128
-
1129
- // remove all subscriptions for specific post from DB
1130
- return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%' AND ($posts_where)" );
1131
-
1132
- }
1133
-
1134
- }
1135
-
1136
- /**
1137
- * The function must search for subscription by a given post id.
1138
- *
1139
- * @param $_post_id The post ID to search
1140
- * @param $_email The user email, use to search the subscriptions.
1141
- * @param bool $in If set to true the search will return the subscription information, if false then it
1142
- * should retrieve all the subscriptions but not the given.
1143
- *
1144
- * @return bool|object If $in is true then it could return the subscription or false, false means not found,
1145
- * if $in is false the it could return the subscriptions or false, false means not found
1146
- */
1147
- public function retrieve_user_subscriptions( $_post_id, $_email, $in = false ) {
1148
-
1149
- global $wpdb;
1150
-
1151
- $meta_key = '_stcr@_';
1152
- $in_values = '';
1153
-
1154
- // single post
1155
- if( ! is_array( $_post_id ) ){
1156
-
1157
- if ( ! $in ) {
1158
- $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id <> %d AND meta_key = %s";
1159
- } else if ( $in ) {
1160
- $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s";
1161
- }
1162
-
1163
- $result = $wpdb->get_results( $wpdb->prepare( $retrieve_subscriptions, $_post_id, $meta_key.$_email ), OBJECT );
1164
-
1165
- // array of posts
1166
- } else {
1167
-
1168
- $in_values = implode( ',', $_post_id );
1169
-
1170
- if ( ! $in ) {
1171
- $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id NOT IN ($in_values) AND meta_key = %s";
1172
- } else if ( $in ) {
1173
- $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id IN ($in_values) AND meta_key = %s";
1174
- }
1175
-
1176
- $result = $wpdb->get_results($wpdb->prepare( $retrieve_subscriptions, $meta_key.$_email ), OBJECT);
1177
-
1178
- }
1179
-
1180
- return $result === false || $result == 0 || empty( $result ) ? false : $result;
1181
-
1182
- }
1183
-
1184
- /**
1185
- * Updates the status of an existing subscription
1186
- *
1187
- * @since 190705 cleanup
1188
- */
1189
- public function update_subscription_status( $_post_id = 0, $_email = '', $_new_status = 'C' ) {
1190
-
1191
- global $wpdb;
1192
-
1193
- // if not a valid status, return
1194
- if ( empty( $_new_status ) || ! in_array( $_new_status, array( 'Y', 'R', 'C', '-C' ) ) || empty( $_email ) ) {
1195
- return 0;
1196
- }
1197
-
1198
- // specific post ID supplied
1199
- if ( ! empty( $_post_id ) ) {
1200
-
1201
- // generate the WHERE for post ID for the DB query
1202
- $posts_where = '';
1203
- if ( ! is_array( $_post_id ) ) {
1204
- $posts_where = "post_id = " . intval( $_post_id );
1205
- } else {
1206
- foreach ( $_post_id as $a_post_id ) {
1207
- $posts_where .= "post_id = '" . intval( $a_post_id ) . "' OR ";
1208
- }
1209
- $posts_where = substr( $posts_where, 0, - 4 );
1210
- }
1211
-
1212
- // all posts
1213
- } else {
1214
- $posts_where = '1=1';
1215
- }
1216
-
1217
- // generate WHERE for email for the DB query
1218
- $emails_where = '';
1219
- if ( ! is_array( $_email ) ) {
1220
- $emails_where = "meta_key = '_stcr@_" . $this->utils->clean_email( $_email ) . "'";
1221
- } else {
1222
- foreach ( $_email as $a_email ) {
1223
- $emails_where .= "meta_key = '_stcr@_" . $this->utils->clean_email( $a_email ) . "' OR ";
1224
- }
1225
- $emails_where = substr( $emails_where, 0, - 4 );
1226
- }
1227
-
1228
- $meta_length = ( strpos( $_new_status, 'C' ) !== false ) ? 21 : 20;
1229
- $new_status = ( $_new_status == '-C' ) ? '' : $_new_status;
1230
-
1231
- // update DB
1232
- return $wpdb->query(
1233
- "UPDATE $wpdb->postmeta
1234
- SET meta_value = CONCAT(SUBSTRING(meta_value, 1, $meta_length), '$new_status')
1235
- WHERE ($posts_where) AND ($emails_where)"
1236
- );
1237
-
1238
- }
1239
-
1240
- /**
1241
- * Updates the email address of an existing subscription
1242
- *
1243
- * @since 190705 cleanup
1244
- */
1245
- public function update_subscription_email( $_post_id = 0, $_email = '', $_new_email = '' ) {
1246
-
1247
- global $wpdb;
1248
-
1249
- // return if no email supplied
1250
- if ( empty( $_email ) || empty( $_new_email ) || strpos( $_new_email, '@' ) == 0 ) {
1251
- return;
1252
- }
1253
-
1254
- // sanitize old and new email
1255
- $clean_values[] = "_stcr@_" . $this->utils->clean_email( $_new_email );
1256
- $clean_values[] = "_stcr@_" . $this->utils->clean_email( $_email );
1257
-
1258
- // generate WHERE for DB query
1259
- $post_where = '';
1260
- if ( ! empty( $_post_id ) ) {
1261
- $post_where = ' AND post_id = %d';
1262
- $clean_values[] = $_post_id;
1263
- }
1264
-
1265
- // update the email in postmeta table
1266
- $rowsAffected = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_key = %s WHERE meta_key = %s $post_where", $clean_values ) );
1267
-
1268
- // update the email in subscribe_reloaded_subscribers table
1269
- if ( $rowsAffected > 0 || $rowsAffected !== false) {
1270
- $salt = time();
1271
- $rowsAffected = $wpdb->query(
1272
- $wpdb->prepare("UPDATE ". $wpdb->prefix .
1273
- "subscribe_reloaded_subscribers SET subscriber_email = %s,
1274
- salt = %d,
1275
- subscriber_unique_id = %s
1276
- WHERE subscriber_email = %s",
1277
- $_new_email, $salt, $this->utils->generate_temp_key( $salt . $_new_email ),$_email )
1278
- );
1279
- }
1280
-
1281
- return false;
1282
-
1283
- }
1284
-
1285
- /**
1286
- * Retrieves a list of emails subscribed to a specific post
1287
- *
1288
- * @since 190705 cleanup
1289
- */
1290
- public function get_subscriptions( $_search_field = array( 'email' ), $_operator = array( 'equals' ), $_search_value = array( '' ), $_order_by = 'dt', $_order = 'ASC', $_offset = 0, $_limit_results = 0 ) {
1291
-
1292
- global $wpdb;
1293
-
1294
- // Type adjustments
1295
- $search_fields = ( ! is_array( $_search_field ) ) ? array( $_search_field ) : $_search_field;
1296
- $operators = ( ! is_array( $_operator ) ) ? array( $_operator ) : $_operator;
1297
- $search_values = ( ! is_array( $_search_value ) ) ? array( $_search_value ) : $_search_value;
1298
-
1299
- // Find if exists a 'replies only' subscription for the parent comment
1300
- if ( $search_fields[0] == 'parent' ) {
1301
-
1302
- $parent_comment_id = $search_values[0];
1303
- $comment_post_id = $search_values[1];
1304
-
1305
- // Get the parent comment author email so we can search for any Replies Only subscriptions
1306
- $parent_comment_author_email = "\_stcr@\_" . get_comment_author_email( $parent_comment_id );
1307
-
1308
- // Check if $parent_comment_author_email has any Replies Only (R) subscriptions for $comment_post_id
1309
-
1310
- /*
1311
- Heads up: this will return Replies Only subscriptions for a given post, *not* for a given comment.
1312
- This plugin does not track subscriptions for specific comments but rather for entire posts, so there
1313
- is no way to figure out if a specific parent comment has a subscription (of any type). To make the
1314
- Replies Only feature half-work, we check if a parent comment author has *any* Replies Only subscriptions
1315
- for a given post. If they do, we assume that they must want to get notified of replies to *any* of their
1316
- comments on *that* post.
1317
- */
1318
-
1319
- return $wpdb->get_results(
1320
- $wpdb->prepare(
1321
- "SELECT pm.meta_id, REPLACE(pm.meta_key, '_stcr@_', '') AS email, pm.post_id, SUBSTRING(pm.meta_value, 1, 19) AS dt, SUBSTRING(pm.meta_value, 21) AS status, srs.subscriber_unique_id AS email_key
1322
- FROM $wpdb->postmeta pm
1323
- INNER JOIN {$wpdb->prefix}subscribe_reloaded_subscribers srs ON ( REPLACE(pm.meta_key, '_stcr@_', '') = srs.subscriber_email )
1324
- WHERE pm.meta_key LIKE %s
1325
- AND pm.meta_value LIKE '%%R'
1326
- AND pm.post_id = %d", $parent_comment_author_email, $comment_post_id
1327
- ), OBJECT
1328
- );
1329
-
1330
- } else {
1331
-
1332
- // generate WHERE for the DB query
1333
- $where_clause = '';
1334
- foreach ( $search_fields as $a_idx => $a_field ) {
1335
- $where_clause .= ' AND';
1336
- $offset_status = ( $a_field == 'status' && $search_values[$a_idx] == 'C' ) ? 22 : 21;
1337
- switch ( $a_field ) {
1338
- case 'status':
1339
- $where_clause .= " SUBSTRING(meta_value, $offset_status)";
1340
- break;
1341
- case 'post_id':
1342
- $where_clause .= ' post_id';
1343
- break;
1344
- default:
1345
- $where_clause .= ' SUBSTRING(meta_key, 8)';
1346
- }
1347
- switch ( $operators[$a_idx] ) {
1348
- case 'equals':
1349
- $where_clause .= " = %s";
1350
- $where_values[] = $search_values[$a_idx];
1351
- break;
1352
- case 'does not contain':
1353
- $where_clause .= " NOT LIKE %s";
1354
- $where_values[] = "%{$search_values[$a_idx]}%";
1355
- break;
1356
- case 'starts with':
1357
- $where_clause .= " LIKE %s";
1358
- $where_values[] = "{$search_values[$a_idx]}%";
1359
- break;
1360
- case 'ends with':
1361
- $where_clause .= " LIKE %s";
1362
- $where_values[] = "%{$search_values[$a_idx]}";
1363
- break;
1364
- default: // contains
1365
- $where_clause .= " LIKE %s";
1366
- $where_values[] = "%{$search_values[$a_idx]}%";
1367
- }
1368
- }
1369
-
1370
- // generated ORDER BY for the DB query
1371
- switch ( $_order_by ) {
1372
- case 'status':
1373
- $order_by = "status";
1374
- break;
1375
- case 'email':
1376
- $order_by = 'meta_key';
1377
- break;
1378
- case 'dt':
1379
- $order_by = 'dt';
1380
- break;
1381
- default:
1382
- $order_by = 'post_id';
1383
- }
1384
- $order = ( $_order != 'ASC' && $_order != 'DESC' ) ? 'DESC' : $_order;
1385
-
1386
- // this is the 'official' way to have an offset without a limit
1387
- $row_count = ( $_limit_results <= 0 ) ? '18446744073709551610' : $_limit_results;
1388
-
1389
- // run the DB query
1390
- return $wpdb->get_results(
1391
- $wpdb->prepare(
1392
- "SELECT meta_id, REPLACE(meta_key, '_stcr@_', '') AS email, post_id, SUBSTRING(meta_value, 1, 19) AS dt, SUBSTRING(meta_value, 21) AS status, srs.subscriber_unique_id AS email_key
1393
- FROM $wpdb->postmeta
1394
- INNER JOIN {$wpdb->prefix}subscribe_reloaded_subscribers srs ON ( REPLACE(meta_key, '_stcr@_', '') = srs.subscriber_email )
1395
- WHERE meta_key LIKE '\_stcr@\_%%' $where_clause
1396
- ORDER BY $order_by $order
1397
- LIMIT $_offset,$row_count", $where_values
1398
- ), OBJECT
1399
- );
1400
-
1401
- }
1402
-
1403
- }
1404
-
1405
- /**
1406
- * Sends the notification message to a given user
1407
- *
1408
- * @since 190705 cleanup
1409
- */
1410
- public function notify_user( $_post_ID = 0, $_email = '', $_comment_ID = 0 ) {
1411
-
1412
- // vars
1413
- $post = get_post( $_post_ID );
1414
- $comment = get_comment( $_comment_ID );
1415
- $post_permalink = get_permalink( $_post_ID );
1416
- $comment_permalink = get_comment_link( $_comment_ID );
1417
- $comment_reply_permalink = get_permalink( $_post_ID ) . '?replytocom=' . $_comment_ID . '#respond';
1418
- $info = $this->_get_comment_object( $_comment_ID );
1419
-
1420
- // WPML compatibility
1421
- if ( defined('ICL_SITEPRESS_VERSION') && defined('ICL_LANGUAGE_CODE') ) {
1422
- global $sitepress;
1423
- $language = $sitepress->get_language_for_element( $_post_ID, 'post_' . $post->post_type );
1424
- $sitepress->switch_lang($language);
1425
- }
1426
-
1427
- // vars
1428
- $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_subject', 'There is a new comment on the post [post_title]' ) ), ENT_QUOTES, 'UTF-8' );
1429
- $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_content', '' ) ), ENT_QUOTES, 'UTF-8' );
1430
- $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
1431
- $one_click_unsubscribe_link = $manager_link;
1432
-
1433
- // qTranslate compatibility
1434
- if ( function_exists( 'qtrans_convertURL' ) ) {
1435
- $manager_link = qtrans_convertURL( $manager_link );
1436
- }
1437
-
1438
- // vars
1439
- $clean_email = $this->utils->clean_email( $_email );
1440
- $subscriber_salt = $this->utils->generate_temp_key( $clean_email );
1441
- $manager_link .= ( ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?' )
1442
- . "srek=" . $this->utils->get_subscriber_key( $clean_email )
1443
- . "&srk=$subscriber_salt";
1444
- $one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' )
1445
- . "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=$subscriber_salt"
1446
- . "&sra=u&srsrc=e" . "&srp=" . $_post_ID;
1447
- $comment_content = $comment->comment_content;
1448
-
1449
- // replace tags with their actual values
1450
- $subject = str_replace( '[post_title]', $post->post_title, $subject );
1451
- $subject = str_replace( '[comment_author]', $comment->comment_author, $subject );
1452
- $subject = str_replace( '[blog_name]' , get_bloginfo('name'), $subject );
1453
- $message = str_replace( '[post_permalink]', $post_permalink, $message );
1454
- $message = str_replace( '[comment_permalink]', $comment_permalink, $message );
1455
- $message = str_replace( '[comment_reply_permalink]', $comment_reply_permalink, $message );
1456
- $message = str_replace( '[comment_author]', $comment->comment_author, $message );
1457
- $message = str_replace( '[comment_content]', $comment_content, $message );
1458
- $message = str_replace( '[manager_link]', $manager_link, $message );
1459
- $message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $message );
1460
- $message = str_replace( '[comment_gravatar]', get_avatar($info->comment_author_email, 40), $message );
1461
- $message = str_replace( '[comment_date]', date( get_option( 'date_format'), strtotime( $comment->comment_date ) ), $message );
1462
- $message = str_replace( '[comment_time]', date( get_option( 'time_format'), strtotime( $comment->comment_date ) ), $message );
1463
-
1464
- // qTranslate support
1465
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
1466
- $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
1467
- $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $post->post_title ), $message );
1468
- $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
1469
- } else {
1470
- $message = str_replace( '[post_title]', $post->post_title, $message );
1471
- }
1472
-
1473
- $message = apply_filters( 'stcr_notify_user_message', $message, $_post_ID, $clean_email, $_comment_ID );
1474
-
1475
- // email settings
1476
- $email_settings = array(
1477
- 'subject' => $subject,
1478
- 'message' => $message,
1479
- 'toEmail' => $clean_email,
1480
- 'XPostId' => $_post_ID,
1481
- 'XCommentId' => $_comment_ID
1482
- );
1483
-
1484
- // send email
1485
- $this->utils->send_email( $email_settings );
1486
-
1487
- }
1488
-
1489
- /**
1490
- * Displays the checkbox to allow visitors to subscribe
1491
- *
1492
- * @since 190705 cleanup
1493
- */
1494
- function subscribe_reloaded_show( $submit_field = '' ) {
1495
-
1496
- // echo on action, return on filter
1497
- $echo = false;
1498
- if ( doing_action( 'comment_form' ) || doing_action( 'comment_form_must_log_in_after' ) ) {
1499
- $echo = true;
1500
- }
1501
-
1502
- // vars
1503
- global $post, $wp_subscribe_reloaded;
1504
- $checkbox_subscription_type = null;
1505
- $_comment_ID = null;
1506
- $post_permalink = get_permalink( $post->ID );
1507
- $post_permalink = "post_permalink=" . $post_permalink;
1508
- $post_type = get_post_type( $post->ID );
1509
- $only_for_posts = get_option( 'subscribe_reloaded_only_for_posts', 'no' );
1510
- $only_for_logged_in = get_option( 'subscribe_reloaded_only_for_logged_in', 'no' );
1511
-
1512
- // if not enabled for this post type, return default
1513
- if ( $only_for_posts == 'yes' && $post_type !== 'post' ) {
1514
- if ( $echo ) {
1515
- echo $submit_field;
1516
- } else {
1517
- return $submit_field;
1518
- }
1519
- return;
1520
- }
1521
-
1522
- // only for logged in users
1523
- if ( $only_for_logged_in == 'yes' && ! is_user_logged_in() ) {
1524
- if ( $echo ) {
1525
- echo $submit_field;
1526
- } else {
1527
- return $submit_field;
1528
- }
1529
- return;
1530
- }
1531
-
1532
- // enqueue scripts and styles
1533
- $wp_subscribe_reloaded->stcr->utils->add_plugin_js_scripts();
1534
- wp_enqueue_style( 'stcr-plugin-style' );
1535
-
1536
- // return if subscriptions disabled for this post
1537
- $is_disabled = get_post_meta( $post->ID, 'stcr_disable_subscriptions', true );
1538
- if ( ! empty( $is_disabled ) ) {
1539
- if ( $echo ) {
1540
- echo $submit_field;
1541
- } else {
1542
- return $submit_field;
1543
- }
1544
- return;
1545
- }
1546
-
1547
- // vars
1548
- $show_subscription_box = true;
1549
- $html_to_show = '';
1550
- $user_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '' );
1551
-
1552
- // qTranslate compatibility
1553
- if ( function_exists( 'qtrans_convertURL' ) ) {
1554
- $user_link = qtrans_convertURL( $user_link );
1555
- }
1556
-
1557
- // link for management page
1558
- $manager_link = ( strpos( $user_link, '?' ) !== false ) ?
1559
- "$user_link&amp;srp=$post->ID&amp;srk=" . get_option( 'subscribe_reloaded_unique_key' ) :
1560
- "$user_link?srp=$post->ID&amp;srk=" . get_option( 'subscribe_reloaded_unique_key' );
1561
-
1562
- // link for user
1563
- $user_link = ( strpos( $user_link, '?' ) !== false ) ?
1564
- "$user_link&" . $post_permalink :
1565
- "$user_link?" . $post_permalink;
1566
-
1567
- // if subscription pending confirmation
1568
- if ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '', 'C' ) ) {
1569
- $html_to_show = str_replace(
1570
- '[manager_link]', $user_link,
1571
- html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribed_waiting_label', __( "Your subscription to this post needs to be confirmed. <a href='[manager_link]'>Manage your subscriptions</a>.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1572
- );
1573
- $show_subscription_box = false;
1574
-
1575
- // if subscription active
1576
- } elseif ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '' ) ) {
1577
- $html_to_show = str_replace(
1578
- '[manager_link]', $user_link ,
1579
- html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribed_label', __( "You are subscribed to this post. <a href='[manager_link]'>Manage</a> your subscriptions.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1580
- );
1581
- $show_subscription_box = false;
1582
- }
1583
-
1584
- // if current user is author of the post
1585
- if ( $wp_subscribe_reloaded->stcr->is_author( $post->post_author ) ) {
1586
- if ( get_option( 'subscribe_reloaded_admin_subscribe', 'no' ) == 'no' ) {
1587
- $show_subscription_box = false;
1588
- }
1589
- $html_to_show .= ' ';
1590
- $html_to_show .= str_replace(
1591
- '[manager_link]', $manager_link,
1592
- html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_author_label', __( "You can <a href='[manager_link]'>manage the subscriptions</a> of this post.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1593
- );
1594
- }
1595
-
1596
- // show the subscription form
1597
- if ( $show_subscription_box ) {
1598
-
1599
- // label
1600
- $checkbox_label = str_replace(
1601
- '[subscribe_link]', "$manager_link&amp;sra=s&amp;srsrc=f",
1602
- html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_label', __( "Notify me of followup comments via e-mail. You can also <a href='[subscribe_link]'>subscribe</a> without commenting.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1603
- );
1604
-
1605
- // CSS style
1606
- $checkbox_inline_style = get_option( 'subscribe_reloaded_checkbox_inline_style', 'width:30px' );
1607
- if ( ! empty( $checkbox_inline_style ) ) {
1608
- $checkbox_inline_style = " style='$checkbox_inline_style'";
1609
- }
1610
-
1611
- $checkbox_html_wrap = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_html', '' ) ), ENT_QUOTES, 'UTF-8' );
1612
-
1613
- // regular subscriptions form
1614
- if ( get_option( 'subscribe_reloaded_enable_advanced_subscriptions', 'no' ) == 'no' ) {
1615
- switch ( get_option( 'subscribe_reloaded_checked_by_default_value' ) ) {
1616
- case '0':
1617
- $checkbox_subscription_type = 'yes';
1618
- break;
1619
- case '1':
1620
- $checkbox_subscription_type = 'replies';
1621
- break;
1622
- }
1623
- $checkbox_field = "<input$checkbox_inline_style type='checkbox' name='subscribe-reloaded' id='subscribe-reloaded' value='$checkbox_subscription_type'" . ( ( get_option( 'subscribe_reloaded_checked_by_default', 'no' ) == 'yes' ) ? " checked='checked'" : '' ) . " />";
1624
-
1625
- // advanced subscriptions form
1626
- } else {
1627
- $checkbox_field = "<select name='subscribe-reloaded' id='subscribe-reloaded'>
1628
- <option value='none' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '0' ) ? "selected='selected'" : '' ) . ">" . __( "Don't subscribe", 'subscribe-to-comments-reloaded' ) . "</option>
1629
- <option value='yes' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '1' ) ? "selected='selected'" : '' ) . ">" . __( "All", 'subscribe-to-comments-reloaded' ) . "</option>
1630
- <option value='replies' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '2' ) ? "selected='selected'" : '' ) . ">" . __( "Replies to my comments", 'subscribe-to-comments-reloaded' ) . "</option>
1631
- </select>";
1632
- }
1633
-
1634
- if ( empty( $checkbox_html_wrap ) ) {
1635
- $html_to_show = "$checkbox_field <label for='subscribe-reloaded'>$checkbox_label</label>" . $html_to_show;
1636
- } else {
1637
- $checkbox_html_wrap = str_replace( '[checkbox_field]', $checkbox_field, $checkbox_html_wrap );
1638
- $html_to_show = str_replace( '[checkbox_label]', $checkbox_label, $checkbox_html_wrap ) . $html_to_show;
1639
- }
1640
-
1641
- }
1642
-
1643
- // qTranslate compatiblity
1644
- if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
1645
- $html_to_show = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $html_to_show );
1646
- }
1647
-
1648
- $output = '';
1649
- // Check for the Comment Form location
1650
- if( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
1651
- $output .= "<style type='text/css'>.stcr-hidden{display: none !important;}</style>";
1652
- $output .= "<div class='stcr-form stcr-hidden'>";
1653
- $output .= $html_to_show;
1654
- $output .= "</div>";
1655
- } else {
1656
- $output .= $html_to_show;
1657
- }
1658
-
1659
- // echo or return
1660
- if ( $echo ) {
1661
- echo $output . $submit_field;
1662
- } else {
1663
- return $output . $submit_field;
1664
- }
1665
-
1666
- }
1667
-
1668
- /**
1669
- * Set a cookie if the user just subscribed without commenting
1670
- *
1671
- * @since 190705
1672
- */
1673
- public function set_user_cookie() {
1674
-
1675
- $subscribe_to_comments_action = ! empty( $_POST['sra'] ) ? $_POST['sra'] : ( ! empty( $_GET['sra'] ) ? $_GET['sra'] : 0 );
1676
- $subscribe_to_comments_post_ID = ! empty( $_POST['srp'] ) ? intval( $_POST['srp'] ) : ( ! empty( $_GET['srp'] ) ? intval( $_GET['srp'] ) : 0 );
1677
-
1678
- if ( ! empty( $subscribe_to_comments_action ) && ! empty( $_POST['subscribe_reloaded_email'] ) &&
1679
- ( $subscribe_to_comments_action == 's' ) && ( $subscribe_to_comments_post_ID > 0 )
1680
- ) {
1681
- $subscribe_to_comments_clean_email = $this->utils->clean_email( $_POST['subscribe_reloaded_email'] );
1682
- if ( get_option( 'subscribe_reloaded_use_cookies', 'yes' ) == 'yes' ) {
1683
- setcookie( 'comment_author_email_' . COOKIEHASH, $subscribe_to_comments_clean_email, time() + 1209600, '/' );
1684
- }
1685
- }
1686
- }
1687
-
1688
- /**
1689
- * Management page shortcode
1690
- *
1691
- * @since 190325
1692
- */
1693
- public function management_page_sc() {
1694
-
1695
- $data = $this->subscribe_reloaded_manage();
1696
- return $data[0]->post_content;
1697
-
1698
- }
1699
-
1700
- /**
1701
- * Add custom output before comment content
1702
- *
1703
- * @since 190801
1704
- */
1705
- public function comment_content_prepend( $comment_text, $comment = null ) {
1706
-
1707
- // do not proceed if comment info is not passed
1708
- if ( empty( $comment ) || ! isset( $comment->comment_approved ) ) {
1709
- return $comment_text;
1710
- }
1711
-
1712
- global $wp_subscribe_reloaded;
1713
- global $post;
1714
-
1715
- $prepend = '';
1716
-
1717
- // comment held for moderation and email is subscribed to the post
1718
- if ( $comment->comment_approved == '0' && $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, $comment->comment_author_email, 'C' ) ) {
1719
- $prepend = '<p><em>' . __( 'Check your email to confirm your subscription.', 'subscribe-to-comments-reloaded' ) . '</em></p>';
1720
- }
1721
-
1722
- // pass it back
1723
- return $prepend . $comment_text;
1724
-
1725
- }
1726
-
1727
- /**
1728
- * Move form with JS
1729
- *
1730
- * @since 200626
1731
- */
1732
- public function move_form_with_js() {
1733
-
1734
- $output = '';
1735
-
1736
- if ( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
1737
- $output .= '<script type="text/javascript">document.addEventListener("DOMContentLoaded",function(){if(document.querySelectorAll("div.stcr-form").length){let e=document.querySelectorAll("div.stcr-form")[0],t=document.querySelectorAll("#commentform input[type=submit]")[0];t.parentNode.insertBefore(e,t),e.classList.remove("stcr-hidden")}});</script>';
1738
- }
1739
-
1740
- echo $output;
1741
-
1742
- }
1743
-
1744
- }
1745
-
1746
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace stcr;
3
+
4
+ // Avoid direct access to this piece of code
5
+ if ( ! function_exists( 'add_action' ) ) {
6
+ header( 'Location: /' );
7
+ exit;
8
+ }
9
+
10
+ // globals
11
+ define( __NAMESPACE__.'\\VERSION','220502' );
12
+ define( __NAMESPACE__.'\\DEVELOPMENT', false );
13
+ define( __NAMESPACE__.'\\SLUG', "subscribe-to-comments-reloaded" );
14
+
15
+ // load files
16
+ require_once dirname(__FILE__).'/utils/stcr_manage.php';
17
+ require_once dirname(__FILE__).'/classes/stcr_i18n.php';
18
+ require_once dirname(__FILE__).'/utils/functions.php';
19
+
20
+ // Main plugin class
21
+ if( ! class_exists('\\'.__NAMESPACE__.'\\wp_subscribe_reloaded') ) {
22
+
23
+ /**
24
+ * Main plugin class
25
+ *
26
+ * __construct ( Constructor )
27
+ * add_test_subscriptions ( Adds subscriptions for testing purposes )
28
+ * define_wp_hooks ( Define the WordPress Hooks that will be used by the plugin. )
29
+ * display_admin_header ( Display admin header menu )
30
+ * subscribe_reloaded_load_plugin_textdomain ( Load localization files )
31
+ * plugin_settings_link ( Add Settings link to plugin on plugins page )
32
+ * _get_comment_object ( Retrieves the comment information from the database )
33
+ * new_comment_posted ( Takes the appropriate action, when a new comment is posted )
34
+ * is_double_check_enabled ( Is double check ( subscriptions need to be confirmed ) enabled )
35
+ * comment_status_changed ( Actions when comments status changes ( approve/unapprove/spam/trash ) )
36
+ * comment_deleted ( Actions when comment is deleted )
37
+ * subscribe_post_author ( Subscribe the post author )
38
+ * subscribe_reloaded_manage ( Displays the appropriate management page )
39
+ * is_author ( Checks if current logged in user is the author )
40
+ * is_user_subscribed ( Checks if a given email address is subscribed to a post )
41
+ * add_subscription ( Adds a new subscription )
42
+ * delete_subscriptions ( Deletes one or more subscriptions from the database )
43
+ * retrieve_user_subscriptions ( Retries user subscriptions by post ID )
44
+ * update_subscription_status ( Updates the status of an existing subscription )
45
+ * update_subscription_email ( Updates the email address of an existing subscription )
46
+ * get_subscriptions ( Retrieves a list of emails subscribed to a specific post )
47
+ * notify_user ( Sends the notification message to a given user )
48
+ * subscribe_reloaded_show ( Displays the checkbox to allow visitors to subscribe )
49
+ * set_user_cookie ( Set a cookie if the user just subscribed without commenting )
50
+ * management_page_sc ( Management page shortcode )
51
+ * comment_content_prepend ( Add custom content before comment content )
52
+ */
53
+ class wp_subscribe_reloaded extends stcr_manage {
54
+
55
+ public $stcr_i18n;
56
+
57
+ /**
58
+ * Constructor
59
+ */
60
+ public function __construct() {
61
+
62
+ // run parent constructor.
63
+ parent::__construct();
64
+
65
+ $this->salt = defined( 'NONCE_KEY' ) ? NONCE_KEY : 'please create a unique key in your wp-config.php';
66
+
67
+ // show the checkbox - You can manually override this by adding the corresponding function in your template
68
+ if ( get_option( 'subscribe_reloaded_show_subscription_box' ) === 'yes' ) {
69
+
70
+ if ( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
71
+ add_action( 'comment_form', array($this, 'subscribe_reloaded_show'), 5, 0 );
72
+ } else {
73
+ add_filter( 'comment_form_submit_field', array($this, 'subscribe_reloaded_show'), 5, 1 );
74
+ }
75
+
76
+ // when users must be logged in to comment and current visitor is not logged in
77
+ add_action( 'comment_form_must_log_in_after', array($this, 'subscribe_reloaded_show'), 5, 0 );
78
+
79
+ }
80
+
81
+ $this->maybe_update();
82
+
83
+ // define WordPress hooks the plugin uses
84
+ $this->define_wp_hooks();
85
+
86
+ // localization
87
+ $this->stcr_i18n = new stcr_i18n();
88
+
89
+ // add subscriptions for tests
90
+ if ( DEVELOPMENT ) {
91
+ $this->add_test_subscriptions( 1000, 18,'Y', 'dev', 30);
92
+ }
93
+
94
+ // management page shortcode
95
+ add_shortcode( 'stcr_management_page', array( $this, 'management_page_sc' ) );
96
+
97
+ }
98
+
99
+ /**
100
+ * Adds subscriptions for testing purposes
101
+ *
102
+ * @since 190705
103
+ */
104
+ public function add_test_subscriptions( $iterations, $post_id, $status = 'Y', $email_prefix = 'dev', $last_id_subs = 0 ) {
105
+ for ( $i = $last_id_subs+1; $i <= $iterations; $i++) {
106
+ $this->add_subscription( $post_id, "{$email_prefix}_{$i}" . time() . "@dev.com", $status );
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Define the WordPress Hooks that will be used by the plugin.
112
+ *
113
+ * @since 180302
114
+ */
115
+ public function define_wp_hooks() {
116
+
117
+ // new comment posted
118
+ add_action( 'comment_post', array( $this, 'new_comment_posted' ), 12, 2 );
119
+
120
+ // add hook for the subscribe_reloaded_purge, define on the constructure so that the hook is read on time.
121
+ add_action('_cron_subscribe_reloaded_purge', array($this, 'subscribe_reloaded_purge'), 10 );
122
+ add_action('_cron_log_file_purge', array($this, 'log_file_purge'), 10 );
123
+
124
+ // load text domain
125
+ add_action( 'plugins_loaded', array( $this, 'subscribe_reloaded_load_plugin_textdomain' ) );
126
+
127
+ // front end
128
+ if ( ! is_admin() ) {
129
+
130
+ // management page permalink
131
+ $manager_page_permalink = get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
132
+ if ( function_exists( 'qtrans_convertURL' ) ) {
133
+ $manager_page_permalink = qtrans_convertURL( $manager_page_permalink );
134
+ }
135
+
136
+ // management page permalink fallback
137
+ if ( empty( $manager_page_permalink ) ) {
138
+ $manager_page_permalink = '/comment-subscriptions/';
139
+ }
140
+
141
+ // remove the ending slash so both variations (with and without slash) work in the strpos check below
142
+ $manager_page_permalink = rtrim( $manager_page_permalink, '/' );
143
+
144
+ // if we are on the management page, filter the_posts
145
+ if ( ( strpos( $_SERVER["REQUEST_URI"], $manager_page_permalink ) !== false ) ) {
146
+
147
+ $request_uri = $_SERVER['REQUEST_URI'];
148
+ $request_uri_arr = explode( $manager_page_permalink, $request_uri );
149
+
150
+ // don't show management page if a "child page"
151
+ if ( empty( $request_uri_arr[1] ) || $request_uri_arr[1] == '/' || strpos( $request_uri_arr[1], '/?' ) === 0 ) {
152
+ add_filter( 'the_posts', array( $this, 'subscribe_reloaded_manage' ), 10, 2 );
153
+ }
154
+
155
+ }
156
+
157
+ // filter to add custom output before comment content
158
+ add_filter( 'comment_text', array( $this, 'comment_content_prepend' ), 10, 2 );
159
+
160
+ // script to move the subscription form
161
+ add_action( 'wp_footer', array( $this, 'move_form_with_js' ), 20 );
162
+
163
+ // enqueue scripts
164
+ $this->utils->hook_plugin_scripts();
165
+
166
+ // wp admin
167
+ } else {
168
+
169
+ // hook for WPMU - new blog created
170
+ add_action( 'wpmu_new_blog', array( $this, 'new_blog' ), 10, 1 );
171
+
172
+ // remove subscriptions for post that is being deleted
173
+ add_action( 'delete_post', array( $this, 'delete_subscriptions' ), 10, 2 );
174
+
175
+ // remove subscriptions when a comment is deleted or status changed
176
+ add_action( 'deleted_comment', array( $this, 'comment_deleted' ) );
177
+ add_action( 'wp_set_comment_status', array( $this, 'comment_status_changed' ) );
178
+
179
+ // new columns in post/comment tables ( WP admin > Posts and WP admin > Comments )
180
+ add_filter( 'manage_edit-comments_columns', array( $this, 'add_column_header' ) );
181
+ add_filter( 'manage_posts_columns', array( $this, 'add_column_header' ) );
182
+ add_action( 'manage_comments_custom_column', array( $this, 'add_comment_column' ) );
183
+ add_action( 'manage_posts_custom_column', array( $this, 'add_post_column' ) );
184
+
185
+ // Add appropriate entries in the admin menu
186
+ add_action( 'admin_menu', array( $this, 'add_config_menu' ) );
187
+ add_action( 'admin_print_styles-edit-comments.php', array( $this, 'add_post_comments_stylesheet' ) );
188
+ add_action( 'admin_print_styles-edit.php', array( $this, 'add_post_comments_stylesheet' ) );
189
+
190
+ // admin header
191
+ add_action( 'in_admin_header', array( $this, 'display_admin_header' ), 100 );
192
+
193
+ // admin init
194
+ add_action( 'admin_init', array( $this, 'stcr_admin_init' ) );
195
+
196
+ // admin notices
197
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
198
+
199
+ // shortcodes to use the management URL sitewide
200
+ add_shortcode( 'subscribe-url', array( $this, 'subscribe_url_shortcode' ) );
201
+
202
+ // action links for listing on WP admin > Plugins
203
+ add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
204
+
205
+ // subscribe post authors, if auto subscribe for authors enabled
206
+ if ( get_option( 'subscribe_reloaded_notify_authors' ) === 'yes' ) {
207
+ add_action( 'publish_post', array( $this, 'subscribe_post_author' ) );
208
+ }
209
+
210
+ // enqueue scripts
211
+ $this->utils->hook_admin_scripts();
212
+
213
+ // ajax for admin notices ( mark as read )
214
+ $this->utils->stcr_create_ajax_notices();
215
+
216
+ // download system information file
217
+ add_action( 'admin_init', array( $this, 'sysinfo_download' ) );
218
+
219
+ // exclude subscriptions on post duplication
220
+ add_filter( 'duplicate_post_blacklist_filter', array( $this, 'duplicate_post_exclude_subs' ) );
221
+
222
+ }
223
+
224
+ }
225
+
226
+ /**
227
+ * Display the admin header menu
228
+ *
229
+ * @since 190705 Cleanup
230
+ */
231
+ public function display_admin_header () {
232
+
233
+ global $wp_locale;
234
+
235
+ $slug = 'stcr_manage_subscriptions';
236
+ $current_page = isset( $_GET['page'] ) ? $_GET['page'] : '';
237
+
238
+ // define the menu items
239
+ $array_pages = array(
240
+ 'stcr_manage_subscriptions' => __( 'Manage subscriptions', 'subscribe-to-comments-reloaded' ),
241
+ 'stcr_comment_form' => __( 'Comment Form', 'subscribe-to-comments-reloaded' ),
242
+ 'stcr_management_page' => __( 'Management Page', 'subscribe-to-comments-reloaded' ),
243
+ 'stcr_notifications' => __( 'Notifications', 'subscribe-to-comments-reloaded' ),
244
+ 'stcr_options' => __( 'Options', 'subscribe-to-comments-reloaded' ),
245
+ 'stcr_support' => __( 'Support', 'subscribe-to-comments-reloaded' ),
246
+ 'stcr_system' => __( 'Options', 'subscribe-to-comments-reloaded' )
247
+ );
248
+
249
+ // do not proceed if not on a STCR admin page
250
+ if ( ! array_key_exists( $current_page, $array_pages) ) {
251
+ return;
252
+ }
253
+
254
+ ?>
255
+
256
+ <nav class="navbar navbar-expand-lg navbar-light bg-light <?php echo $wp_locale->text_direction ?>">
257
+
258
+ <a class="navbar-brand"><img src="<?php echo plugins_url( '/images/stcr-logo-150.png', STCR_PLUGIN_FILE ); ?>" alt="" width="25" height="19"></a>
259
+
260
+ <div class="collapse navbar-collapse">
261
+
262
+ <ul class="navbar-nav">
263
+
264
+ <?php
265
+
266
+ // go through each stcr admin page
267
+ foreach ( $array_pages as $page => $page_desc ) :
268
+
269
+ // skip strc_system because it's added as part of stcr_options
270
+ if ( $page == 'stcr_system' ) continue;
271
+
272
+ ?><li class="<?php echo $page == 'stcr_options' ? 'dropdown' : ''; ?>"><?php
273
+
274
+ // dropdrown for options menu item
275
+ if ( $page == 'stcr_options' ) :
276
+
277
+ ?>
278
+ <a
279
+ class="nav-link dropdown-toggle <?php echo ( $current_page == $page || $current_page == 'stcr_system' ? ' stcr-active-tab' : '' ); ?>"
280
+ style="padding: 5px 12px 0 0;"
281
+ href="#"
282
+ id="navbarDropdown"
283
+ role="button"
284
+ data-toggle="dropdown"
285
+ aria-haspopup="true"
286
+ aria-expanded="false">
287
+ <?php echo $page_desc; ?>
288
+ </a>
289
+ <div class="dropdown-menu" aria-labelledby="navbarDropdown">
290
+ <a class="dropdown-item" href="admin.php?page=<?php echo $page; ?>"><?php echo __('StCR Options', 'subscribe-to-comments-reloaded'); ?></a>
291
+ <div class="dropdown-divider"></div>
292
+ <a class="dropdown-item" href="admin.php?page=stcr_system"><?php echo __('StCR System', 'subscribe-to-comments-reloaded'); ?></a>
293
+ </div>
294
+ <?php
295
+
296
+ // regular menu items
297
+ else :
298
+
299
+ ?>
300
+ <a
301
+ class="navbar-brand <?php echo ( $current_page == $page ) ? ' stcr-active-tab' : ''; ?>"
302
+ href="admin.php?page=<?php echo $page; ?>">
303
+ <?php echo $page_desc; ?>
304
+ </a>
305
+ <?php
306
+
307
+ endif;
308
+
309
+ ?></li><?php
310
+
311
+ endforeach;
312
+
313
+ ?>
314
+
315
+ </ul><!-- .navbar-nav -->
316
+
317
+ </div><!-- .navbar-collapse -->
318
+
319
+ </nav><!-- .navbar -->
320
+ <?php
321
+
322
+ }
323
+
324
+ /**
325
+ * Load localization files
326
+ *
327
+ * @since 190705 cleanup
328
+ */
329
+ function subscribe_reloaded_load_plugin_textdomain() {
330
+
331
+ load_plugin_textdomain( 'subscribe-to-comments-reloaded', FALSE, SLUG . '/langs/' );
332
+
333
+ }
334
+
335
+ /**
336
+ * Add Settings link to plugin on plugins page
337
+ *
338
+ * @since 190705 cleanup
339
+ */
340
+ public function plugin_settings_link( $links, $file ) {
341
+
342
+ if ( plugin_basename( STCR_PLUGIN_FILE ) == $file ) {
343
+ $links['settings'] = sprintf( '<a href="%s"> %s </a>', admin_url( 'admin.php?page=stcr_options' ), __( 'Settings', 'subscribe-to-comments-reloaded' ) );
344
+ }
345
+
346
+ return $links;
347
+
348
+ }
349
+
350
+ /**
351
+ * Retrieves the comment information from the database
352
+ *
353
+ * @since 190705 cleanup
354
+ */
355
+ public function _get_comment_object( $_comment_ID ) {
356
+
357
+ global $wpdb;
358
+
359
+ return $wpdb->get_row(
360
+ $wpdb->prepare(
361
+ "SELECT comment_post_ID, comment_author_email, comment_approved, comment_type, comment_parent
362
+ FROM $wpdb->comments
363
+ WHERE comment_ID = %d
364
+ LIMIT 1", $_comment_ID
365
+ ), OBJECT
366
+ );
367
+
368
+ }
369
+
370
+ /**
371
+ * Takes the appropriate action, when a new comment is posted
372
+ *
373
+ * @since 190705 cleanup
374
+ */
375
+ public function new_comment_posted( $_comment_ID = 0, $_comment_status = 0 ) {
376
+
377
+ // get information about the comment
378
+ $info = $this->_get_comment_object( $_comment_ID );
379
+
380
+ // return if no info found or comment marked as spam
381
+ if ( empty( $info ) || $info->comment_approved == 'spam' ) {
382
+ return $_comment_ID;
383
+ }
384
+
385
+ // return if subscriptions disabled for this post
386
+ $is_disabled = get_post_meta( $info->comment_post_ID, 'stcr_disable_subscriptions', true );
387
+ if ( ! empty( $is_disabled ) ) {
388
+ return $_comment_ID;
389
+ }
390
+
391
+ // return if trackback/pingback ( if set not to notify on those )
392
+ if ( ( get_option( 'subscribe_reloaded_process_trackbacks', 'no' ) == 'no' ) && ( $info->comment_type == 'trackback' || $info->comment_type == 'pingback' ) ) {
393
+ return $_comment_ID;
394
+ }
395
+
396
+ // process the subscription
397
+ if ( ! empty( $_POST['subscribe-reloaded'] ) && ! empty( $info->comment_author_email ) ) {
398
+
399
+ // check if subscription type is valid
400
+ if ( in_array( $_POST['subscribe-reloaded'], array( 'replies', 'digest', 'yes' ) ) ) {
401
+
402
+ // get subscription type
403
+ switch ($_POST['subscribe-reloaded']) {
404
+ case 'replies':
405
+ $status = 'R';
406
+ break;
407
+ case 'digest':
408
+ $status = 'D';
409
+ break;
410
+ default:
411
+ $status = 'Y';
412
+ break;
413
+ }
414
+
415
+ // if not already subscribed
416
+ if ( ! $this->is_user_subscribed($info->comment_post_ID, $info->comment_author_email)) {
417
+
418
+ // if double check enabled, send confirmation email and append C to status
419
+ if ( $this->is_double_check_enabled($info) ) {
420
+ $this->sendConfirmationEMail($info);
421
+ $status = "{$status}C";
422
+ }
423
+
424
+ // add the subscription
425
+ $this->add_subscription($info->comment_post_ID, $info->comment_author_email, $status);
426
+
427
+ // return ( do not proceed with sending notifications ) if comment held for moderation
428
+ if ( $info->comment_approved == 0 ) {
429
+ return $_comment_ID;
430
+ }
431
+
432
+ }
433
+
434
+ }
435
+
436
+ }
437
+
438
+ // if comment approved, notify subscribed users about the comment
439
+ if ( $info->comment_approved == 1 ) {
440
+
441
+ // get all subscriptions
442
+ $subscriptions = $this->get_subscriptions(
443
+ array(
444
+ 'post_id',
445
+ 'status'
446
+ ),
447
+ array(
448
+ 'equals',
449
+ 'equals'
450
+ ),
451
+ array(
452
+ $info->comment_post_ID,
453
+ 'Y'
454
+ )
455
+ );
456
+
457
+ // is this a reply to an existing comment?
458
+ if ( ! empty( $info->comment_parent ) ) {
459
+
460
+ // merge subscriptions
461
+ $subscriptions = array_merge(
462
+ $subscriptions,
463
+ $this->get_subscriptions(
464
+ 'parent',
465
+ 'equals',
466
+ array(
467
+ $info->comment_parent,
468
+ $info->comment_post_ID
469
+ )
470
+ )
471
+ );
472
+
473
+ }
474
+
475
+ // post author info
476
+ $post_author_id = get_post_field( 'post_author', $info->comment_post_ID );
477
+ $post_author_data = get_userdata( $post_author_id );
478
+ $post_author_email = $post_author_data->user_email;
479
+ $post_author_notified = false;
480
+
481
+ // notify subscribers
482
+ foreach ( $subscriptions as $a_subscription ) {
483
+
484
+ // skip comment author
485
+ if ( $a_subscription->email != $info->comment_author_email ) {
486
+ $has_blacklist_email = $this->utils->blacklisted_emails( $a_subscription->email );
487
+ // Do not proceed on sending the new comment email, if the email
488
+ // address is already in blacklist email list.
489
+ if ( false === $has_blacklist_email ) {
490
+ continue;
491
+ }
492
+
493
+ // notify the user
494
+ $this->notify_user( $info->comment_post_ID, $a_subscription->email, $_comment_ID );
495
+
496
+ // post author notified?
497
+ if ( $a_subscription->email == $post_author_email ) {
498
+ $post_author_notified = true;
499
+ }
500
+
501
+ }
502
+
503
+ }
504
+
505
+ // notify author
506
+ if ( ! $post_author_notified && get_option( 'subscribe_reloaded_notify_authors', 'no' ) == 'yes' ) {
507
+
508
+ // send email to author unless the author made the comment
509
+ if ( $info->comment_author_email != $post_author_email ) {
510
+ $has_blacklist_email = $this->utils->blacklisted_emails( $info->comment_author_email );
511
+ // Do not proceed on sending the new comment email, if the email
512
+ // address is already in blacklist email list.
513
+ if ( false === $has_blacklist_email ) {
514
+ return;
515
+ }
516
+
517
+ $this->notify_user( $info->comment_post_ID, $post_author_email, $_comment_ID );
518
+ }
519
+
520
+ }
521
+
522
+ }
523
+
524
+ // that's all, return
525
+ return $_comment_ID;
526
+
527
+ }
528
+
529
+ /**
530
+ * Is double check ( subscriptions need to be confirmed ) enabled
531
+ *
532
+ * @since 190705
533
+ */
534
+ public function is_double_check_enabled( $info ) {
535
+
536
+ $is_subscribe_to_post = false;
537
+ $is_user_logged_in = is_user_logged_in();
538
+ $is_option_enabled = false;
539
+ if ( get_option( 'subscribe_reloaded_enable_double_check', 'no' ) == 'yes' ) {
540
+ $is_option_enabled = true;
541
+ }
542
+
543
+ $approved_subscriptions = $this->get_subscriptions(
544
+ array(
545
+ 'status',
546
+ 'email'
547
+ ),
548
+ array(
549
+ 'equals',
550
+ 'equals'
551
+ ), array(
552
+ 'Y',
553
+ $info->comment_author_email
554
+ )
555
+ );
556
+
557
+ // check if the user is already subscribed to the requested Post ID
558
+ foreach ( $approved_subscriptions as $subscription ) {
559
+ if ( $info->comment_post_ID == $subscription->post_id ) {
560
+ $is_subscribe_to_post = true;
561
+ }
562
+ }
563
+
564
+ // option enabled AND user not logged in AND not already subscribed
565
+ if ( $is_option_enabled && ! $is_user_logged_in && ( ! $is_subscribe_to_post || empty( $approved_subscriptions ) ) ) {
566
+ return true;
567
+ } else {
568
+ return false;
569
+ }
570
+
571
+ }
572
+
573
+ /**
574
+ * Actions when comments status changes ( approve/unapprove/spam/trash )
575
+ *
576
+ * @since 190705 cleanup
577
+ */
578
+ public function comment_status_changed( $_comment_ID = 0, $_comment_status = 0 ) {
579
+
580
+ // get information about the comment
581
+ $info = $this->_get_comment_object( $_comment_ID );
582
+
583
+ // return, no information found
584
+ if ( empty( $info ) ) {
585
+ return $_comment_ID;
586
+ }
587
+
588
+ // go through the types of statuses
589
+ switch ( $info->comment_approved ) {
590
+
591
+ // unapproved
592
+ case '0':
593
+
594
+ $this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, 'C' );
595
+ break;
596
+
597
+ // approved
598
+ case '1':
599
+
600
+ $this->update_subscription_status( $info->comment_post_ID, $info->comment_author_email, '-C' );
601
+
602
+ // get subscriptions
603
+ $subscriptions = $this->get_subscriptions(
604
+ array(
605
+ 'post_id',
606
+ 'status'
607
+ ), array(
608
+ 'equals',
609
+ 'equals'
610
+ ), array(
611
+ $info->comment_post_ID,
612
+ 'Y'
613
+ )
614
+ );
615
+
616
+ if ( ! empty( $info->comment_parent ) ) {
617
+
618
+ $subscriptions = array_merge(
619
+ $subscriptions, $this->get_subscriptions(
620
+ 'parent',
621
+ 'equals',
622
+ array(
623
+ $info->comment_parent,
624
+ $info->comment_post_ID
625
+ )
626
+ )
627
+ );
628
+
629
+ }
630
+
631
+ // go through subscriptions and notify subscribers
632
+ foreach ( $subscriptions as $a_subscription ) {
633
+
634
+ // skip the comment author
635
+ if ( $a_subscription->email != $info->comment_author_email ) {
636
+ $has_blacklist_email = $this->utils->blacklisted_emails( $a_subscription->email );
637
+ // Do not proceed on sending the new comment email, if the email
638
+ // address is already in blacklist email list.
639
+ if ( false === $has_blacklist_email ) {
640
+ continue;
641
+ }
642
+
643
+ $this->notify_user( $info->comment_post_ID, $a_subscription->email, $_comment_ID );
644
+ }
645
+
646
+ }
647
+
648
+ break;
649
+
650
+ case 'trash':
651
+
652
+ case 'spam':
653
+
654
+ // perform the same actions as if it were deleted
655
+ $this->comment_deleted( $_comment_ID );
656
+ break;
657
+
658
+ default:
659
+ break;
660
+
661
+ }
662
+
663
+ // return
664
+ return $_comment_ID;
665
+
666
+ }
667
+
668
+ /**
669
+ * Actions when comment is deleted
670
+ *
671
+ * @since 190705 cleanup
672
+ */
673
+ public function comment_deleted( $_comment_ID ) {
674
+
675
+ global $wpdb;
676
+
677
+ // get information about the comments
678
+ $info = $this->_get_comment_object( $_comment_ID );
679
+
680
+ // return, no information found
681
+ if ( empty( $info ) ) {
682
+ return $_comment_ID;
683
+ }
684
+
685
+ // how many comments does the author have on this post
686
+ $count_approved_comments = $wpdb->get_var( $wpdb->prepare(
687
+ "SELECT COUNT(*)
688
+ FROM $wpdb->comments
689
+ WHERE comment_post_ID = %d
690
+ AND comment_author_email = %s
691
+ AND comment_approved = 1",
692
+ $info->comment_post_ID,
693
+ $info->comment_author_email
694
+ ));
695
+
696
+ // if author has no comments left on this post, remove his subscription
697
+ if ( intval( $count_approved_comments ) == 0 ) {
698
+ $this->delete_subscriptions( $info->comment_post_ID, $info->comment_author_email );
699
+ }
700
+
701
+ // return
702
+ return $_comment_ID;
703
+ }
704
+
705
+ /**
706
+ * Subscribe the post author
707
+ *
708
+ * @since 190705 cleanup
709
+ */
710
+ public function subscribe_post_author( $_post_ID ) {
711
+
712
+ $new_post = get_post( $_post_ID );
713
+ $author_email = get_the_author_meta( 'user_email', $new_post->post_author );
714
+
715
+ if ( ! empty( $author_email ) ) {
716
+ $this->add_subscription( $_post_ID, $author_email, 'Y' );
717
+ }
718
+
719
+ }
720
+
721
+ /**
722
+ * Displays the appropriate management page
723
+ *
724
+ * @since 190705 cleanup
725
+ */
726
+ public function subscribe_reloaded_manage( $_posts = '', $_query = '' ) {
727
+
728
+ // vars
729
+ global $current_user;
730
+ $stcr_unique_key = get_option( 'subscribe_reloaded_unique_key' );
731
+ $date = date_i18n( 'Y-m-d H:i:s' );
732
+ $error_exits = false;
733
+ $email = '';
734
+ $virtual_page_enabled = get_option( 'subscribe_reloaded_manager_page_enabled', 'yes' );
735
+
736
+ // if something exists at this URL and virtual page disabled, abort mission
737
+ if ( ! empty( $_posts ) && $virtual_page_enabled == 'no' ) {
738
+ return $_posts;
739
+ }
740
+
741
+ // make sure we don't call the code below twice on non-virtual page
742
+ if ( $virtual_page_enabled == 'no' && ! in_the_loop() ) {
743
+ return;
744
+ }
745
+
746
+ try {
747
+
748
+ // get post ID
749
+ $post_ID = !empty($_POST['srp']) ? intval($_POST['srp']) : (!empty($_GET['srp']) ? intval($_GET['srp']) : 0);
750
+
751
+ // does a post with that ID exist
752
+ $target_post = get_post($post_ID);
753
+ if ( ( $post_ID > 0 ) && ! is_object($target_post) ) {
754
+ return $_posts;
755
+ }
756
+
757
+ // vars
758
+ $action = !empty($_POST['sra']) ? $_POST['sra'] : (!empty($_GET['sra']) ? $_GET['sra'] : 0);
759
+ $key = !empty($_POST['srk']) ? $_POST['srk'] : (!empty($_GET['srk']) ? $_GET['srk'] : 0);
760
+
761
+ $sre = !empty($_POST['sre']) ? $_POST['sre'] : (!empty($_GET['sre']) ? $_GET['sre'] : '');
762
+ if ( is_user_logged_in() ) {
763
+ $sre = $current_user->data->user_email;
764
+ }
765
+
766
+ $srek = !empty($_POST['srek']) ? $_POST['srek'] : (!empty($_GET['srek']) ? $_GET['srek'] : '');
767
+ $link_source = !empty($_POST['srsrc']) ? $_POST['srsrc'] : (!empty($_GET['srsrc']) ? $_GET['srsrc'] : '');
768
+ $key_expired = !empty($_POST['key_expired']) ? $_POST['key_expired'] : (!empty($_GET['key_expired']) ? $_GET['key_expired'] : '0');
769
+
770
+ // check if the current subscriber has valid email using the $srek key.
771
+ $email_by_key = $this->utils->get_subscriber_email_by_key($srek);
772
+
773
+ // stop if invalid SRE key
774
+ if ( ! $email_by_key && ! empty( $srek ) ) {
775
+
776
+ $this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find an email with the SRE key: ( $srek )\n");
777
+ $email = '';
778
+
779
+ // valid key, proceed
780
+ } else {
781
+
782
+ if ( ! $email_by_key && empty( $sre ) ) {
783
+ $email = '';
784
+ } else if ( $email_by_key && ! empty( $email_by_key ) ) {
785
+ $email = $email_by_key;
786
+ } else if ( ! empty( $sre ) ) {
787
+ $email = $this->utils->check_valid_email( $sre );
788
+ } else {
789
+ $email = '';
790
+ }
791
+
792
+ }
793
+
794
+ // comes from the comment form.
795
+ if ($link_source == 'f') {
796
+
797
+ // Check for a valid SRK key, until this point we know the email is correct but the $key has expired/change
798
+ // or is wrong, in that case display the request management page template
799
+ if ($email !== "" && $key !== 0 && $stcr_unique_key !== $key || $key_expired == "1") {
800
+ if ($key_expired == "1") {
801
+ $error_exits = true;
802
+ } else {
803
+ $this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
804
+ $error_exits = true;
805
+ }
806
+ }
807
+
808
+ // comes from email link
809
+ } else if ($link_source == 'e') {
810
+
811
+ if ($email !== "" && $key !== 0 && !$this->utils->_is_valid_key($key, $email) || $key_expired == "1") {
812
+ if ($key_expired == "1") {
813
+ $error_exits = true;
814
+ } else {
815
+ $this->utils->stcr_logger("\n [ERROR][$date] - Couldn\'t find a valid SRK key with the email ( $email_by_key ) and the SRK key: ( $key )\n This is the current unique key: ( $stcr_unique_key )\n");
816
+ $error_exits = true;
817
+ }
818
+ }
819
+
820
+ }
821
+
822
+ // error found, show message
823
+ if ($error_exits) {
824
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/key_expired.php';
825
+
826
+ // all fine, proceed
827
+ } else {
828
+
829
+ // subscribe without commenting
830
+ if (
831
+ !empty($action) &&
832
+ ($action == 's') &&
833
+ ($post_ID > 0) &&
834
+ $key_expired != "1"
835
+ ) {
836
+
837
+ if ( get_option( 'subscribe_reloaded_allow_subscribe_without_comment', 'yes' ) == 'yes' ) {
838
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/subscribe.php';
839
+ } else {
840
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/not-allowed.php';
841
+ }
842
+
843
+ // post author
844
+ } elseif (
845
+ ($post_ID > 0) &&
846
+ $this->is_author($target_post->post_author)
847
+ ) {
848
+
849
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/author.php';
850
+
851
+ // confirm subscription
852
+ } elseif (
853
+ ($post_ID > 0) &&
854
+ !empty($email) &&
855
+ !empty($key) &&
856
+ !empty($action) &&
857
+ $this->utils->_is_valid_key($key, $email) &&
858
+ $this->is_user_subscribed($post_ID, $email, 'C') &&
859
+ ($action == 'c') &&
860
+ $key_expired != "1"
861
+ ) {
862
+
863
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/confirm.php';
864
+
865
+ // unsubscribe
866
+ } elseif (
867
+ ($post_ID > 0) &&
868
+ !empty($email) &&
869
+ !empty($key) &&
870
+ !empty($action) &&
871
+ $this->utils->_is_valid_key($key, $email) &&
872
+ ($action == 'u') &&
873
+ $key_expired != "1"
874
+ ) {
875
+
876
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/one-click-unsubscribe.php';
877
+
878
+ // user management page
879
+ } elseif (
880
+ !empty($email) &&
881
+ ($key !== 0 && $this->utils->_is_valid_key($key, $email) || (!empty($current_user->data->user_email) && ($current_user->data->user_email === $email && current_user_can('read'))))
882
+ ) {
883
+
884
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/user.php';
885
+
886
+ // wrong request
887
+ } elseif (
888
+ !empty($email) &&
889
+ ($key === 0 && (!empty($current_user->data->user_email) && ($current_user->data->user_email !== $email)))
890
+ ) {
891
+
892
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/wrong-request.php';
893
+
894
+ }
895
+
896
+ // request management link
897
+ if (empty($include_post_content)) {
898
+
899
+ if ( get_option( 'subscribe_reloaded_allow_request_management_link', 'yes' ) == 'yes' ) {
900
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/request-management-link.php';
901
+ } else {
902
+ $include_post_content = include trailingslashit( dirname( STCR_PLUGIN_FILE ) ) . 'templates/not-allowed.php';
903
+ }
904
+
905
+ }
906
+
907
+ }
908
+
909
+ global $wp_query;
910
+
911
+ // management page title
912
+ $manager_page_title = html_entity_decode(get_option('subscribe_reloaded_manager_page_title', 'Manage subscriptions'), ENT_QUOTES, 'UTF-8');
913
+ if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
914
+ $manager_page_title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($manager_page_title);
915
+ } else {
916
+ $manager_page_title = $manager_page_title;
917
+ }
918
+
919
+ // fake posts
920
+ $posts[] =
921
+ (object)array(
922
+ 'ID' => '-999',
923
+ 'post_author' => '1',
924
+ 'post_date' => current_time( 'mysql' ),
925
+ 'post_date_gmt' => current_time( 'mysql', 1 ),
926
+ 'post_content' => $include_post_content,
927
+ 'post_title' => $manager_page_title,
928
+ 'post_excerpt' => '',
929
+ 'post_status' => 'publish',
930
+ 'comment_status' => 'closed',
931
+ 'ping_status' => 'closed',
932
+ 'post_password' => '',
933
+ 'to_ping' => '',
934
+ 'pinged' => '',
935
+ 'post_modified' => current_time( 'mysql' ),
936
+ 'post_modified_gmt' => current_time( 'mysql', 1 ),
937
+ 'post_content_filtered' => '',
938
+ 'post_parent' => '0',
939
+ 'menu_order' => '0',
940
+ 'post_type' => 'page',
941
+ 'post_mime_type' => '',
942
+ 'post_category' => '0',
943
+ 'comment_count' => '0',
944
+ 'filter' => 'raw',
945
+ 'guid' => get_bloginfo('url') . '/?page_id=-999',
946
+ 'post_name' => get_bloginfo('url') . '/?page_id=-999',
947
+ 'ancestors' => array()
948
+ );
949
+
950
+ // Make WP believe this is a real page, with no comments attached
951
+ $wp_query->is_page = true;
952
+ $wp_query->is_single = false;
953
+ $wp_query->is_home = false;
954
+ $wp_query->comments = false;
955
+
956
+ // Discard 404 errors thrown by other checks
957
+ unset($wp_query->query["error"]);
958
+ $wp_query->query_vars["error"] = "";
959
+ $wp_query->is_404 = false;
960
+
961
+ // Seems like WP adds its own HTML formatting code to the content, we don't need that here
962
+ remove_filter('the_content', 'wpautop');
963
+
964
+ // Look like the plugin is call twice and therefor subscribe to the "the_posts" filter again so we need to
965
+ // tell to WordPress to not register again.
966
+ // remove_filter("the_posts", array($this, "subscribe_reloaded_manage"));
967
+ add_action('wp_head', array($this, 'add_custom_header_meta'));
968
+
969
+ // log the error
970
+ } catch(\Exception $ex) {
971
+
972
+ $this->utils->stcr_logger( "\n [ERROR][$date] - $ex->getMessage()\n" );
973
+ $this->utils->stcr_logger( "\n [ERROR][$date] - $ex->getTraceAsString()\n" );
974
+
975
+ }
976
+
977
+ // return filtered posts
978
+ return $posts;
979
+
980
+ }
981
+
982
+ /**
983
+ * Checks if current logged in user is the author
984
+ *
985
+ * @since 190705 cleanup
986
+ */
987
+ public function is_author( $_post_author ) {
988
+
989
+ global $current_user;
990
+ return ! empty( $current_user ) && ( ( $_post_author == $current_user->ID ) || current_user_can( 'manage_options' ) );
991
+
992
+ }
993
+
994
+ /**
995
+ * Checks if a given email address is subscribed to a post
996
+ *
997
+ * @since 190705 cleanup
998
+ */
999
+ public function is_user_subscribed( $_post_ID = 0, $_email = '', $_status = '' ) {
1000
+
1001
+ global $current_user;
1002
+
1003
+ // return, no info about email available
1004
+ if ( ( empty( $current_user->user_email ) && empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) && empty( $_email ) ) || empty( $_post_ID ) ) {
1005
+ return false;
1006
+ }
1007
+
1008
+ $operator = ( $_status != '' ) ? 'equals' : 'contains';
1009
+
1010
+ // get subscriptions
1011
+ $subscriptions = $this->get_subscriptions(
1012
+ array(
1013
+ 'post_id',
1014
+ 'status'
1015
+ ),
1016
+ array(
1017
+ 'equals',
1018
+ $operator
1019
+ ), array(
1020
+ $_post_ID,
1021
+ $_status
1022
+ )
1023
+ );
1024
+
1025
+ // if email not supplied, tried to get it
1026
+ if ( empty( $_email ) ) {
1027
+ $user_email = ! empty( $current_user->user_email ) ? $current_user->user_email : ( ! empty( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ? stripslashes( esc_attr( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) : '#undefined#' );
1028
+
1029
+ // if supplied, use it
1030
+ } else {
1031
+ $user_email = $_email;
1032
+ }
1033
+
1034
+ // go through all subscriptions and return true if the email is found
1035
+ foreach ( $subscriptions as $a_subscription ) {
1036
+ if ( $user_email == $a_subscription->email ) {
1037
+ return true;
1038
+ }
1039
+ }
1040
+
1041
+ // return false, the email is not subscribed
1042
+ return false;
1043
+
1044
+ }
1045
+
1046
+ /**
1047
+ * Adds a new subscription
1048
+ *
1049
+ * @since 190705 cleanup
1050
+ */
1051
+ public function add_subscription( $_post_id = 0, $_email = '', $_status = 'Y' ) {
1052
+
1053
+ $has_blacklist_email = $this->utils->blacklisted_emails( $_email );
1054
+ // Do not proceed on adding the email address in subscription table,
1055
+ // if the email address is already in blacklist email list.
1056
+ if ( false === $has_blacklist_email ) {
1057
+ return;
1058
+ }
1059
+
1060
+ global $wpdb;
1061
+
1062
+ // does the post exist?
1063
+ $target_post = get_post( $_post_id );
1064
+ if ( ( $_post_id > 0 ) && ! is_object( $target_post ) ) {
1065
+ return;
1066
+ }
1067
+
1068
+ // return if status incorrect
1069
+ if ( ! in_array( $_status, array( 'Y', 'YC', 'R', 'RC', 'C', '-C' ) ) || empty( $_status ) ) {
1070
+ return;
1071
+ }
1072
+
1073
+ // using Wordpress local time
1074
+ $dt = date_i18n( 'Y-m-d H:i:s' );
1075
+
1076
+ // sanitize email
1077
+ $clean_email = $this->utils->clean_email( $_email );
1078
+
1079
+ // insert subscriber into postmeta
1080
+ $wpdb->query( $wpdb->prepare(
1081
+ "INSERT IGNORE INTO $wpdb->postmeta (post_id, meta_key, meta_value)
1082
+ SELECT %d, %s, %s
1083
+ FROM DUAL
1084
+ WHERE NOT EXISTS (
1085
+ SELECT post_id
1086
+ FROM $wpdb->postmeta
1087
+ WHERE post_id = %d
1088
+ AND meta_key = %s
1089
+ LIMIT 0,1
1090
+ )", $_post_id, "_stcr@_$clean_email", "$dt|$_status", $_post_id, "_stcr@_$clean_email"
1091
+ ));
1092
+
1093
+ // Insert user into subscribe_reloaded_subscribers table
1094
+ // TODO: Only on this section the user should be added to the subscribers table. On the send confirmation email is repeating this method.
1095
+ $OK = $this->utils->add_user_subscriber_table( $clean_email );
1096
+
1097
+ }
1098
+
1099
+ /**
1100
+ * Deletes one or more subscriptions from the database
1101
+ *
1102
+ * @since 190705 cleanup
1103
+ */
1104
+ public function delete_subscriptions( $_post_id = 0, $_email = '' ) {
1105
+
1106
+ // related to wp 5.5 delete_post coming with 2nd parameter of WP Post object
1107
+ if ( is_object( $_email ) ) {
1108
+ $_email = '';
1109
+ }
1110
+
1111
+ global $wpdb;
1112
+
1113
+ $has_subscriptions = false;
1114
+
1115
+ // no post ID supplied, return 0
1116
+ if ( empty( $_post_id ) ) {
1117
+ return 0;
1118
+ }
1119
+
1120
+ // generate search for the DB query
1121
+ $posts_where = '';
1122
+ if ( ! is_array( $_post_id ) ) {
1123
+ $posts_where = $wpdb->prepare( "post_id = %d", intval( $_post_id ) );
1124
+ } else {
1125
+ foreach ( $_post_id as $a_post_id ) {
1126
+ $posts_where .= $wpdb->prepare( "post_id = %d OR ", intval( $a_post_id ) );
1127
+ }
1128
+ $posts_where = substr( $posts_where, 0, - 4 );
1129
+ }
1130
+
1131
+ // if email supplied, add it to the search for the DB query
1132
+ if ( ! empty( $_email ) ) {
1133
+ $emails_where = '';
1134
+ if ( ! is_array( $_email ) ) {
1135
+ $emails_where = $wpdb->prepare( "meta_key = %s", '_stcr@_' . $this->utils->clean_email( $_email ) );
1136
+ $has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $_email );
1137
+ if ( $has_subscriptions === false) {
1138
+ $this->utils->remove_user_subscriber_table( $_email );
1139
+ }
1140
+ } else {
1141
+ foreach ( $_email as $a_email ) {
1142
+ $emails_where .= $wpdb->prepare( "meta_key = %s OR ", '_stcr@_' . $this->utils->clean_email( $a_email ) );
1143
+ // Deletion on every email on the subscribers table.
1144
+ $has_subscriptions = $this->retrieve_user_subscriptions( $_post_id, $a_email );
1145
+ if ( $has_subscriptions === false ) {
1146
+ $this->utils->remove_user_subscriber_table( $a_email );
1147
+ }
1148
+ }
1149
+
1150
+ $emails_where = substr( $emails_where, 0, - 4 );
1151
+ }
1152
+
1153
+ // remove subscription from DB
1154
+ return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE ($posts_where) AND ($emails_where)" );
1155
+
1156
+ } else {
1157
+
1158
+ // remove all subscriptions for specific post from DB
1159
+ return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '\_stcr@\_%' AND ($posts_where)" );
1160
+
1161
+ }
1162
+
1163
+ }
1164
+
1165
+ /**
1166
+ * The function must search for subscription by a given post id.
1167
+ *
1168
+ * @param $_post_id The post ID to search
1169
+ * @param $_email The user email, use to search the subscriptions.
1170
+ * @param bool $in If set to true the search will return the subscription information, if false then it
1171
+ * should retrieve all the subscriptions but not the given.
1172
+ *
1173
+ * @return bool|object If $in is true then it could return the subscription or false, false means not found,
1174
+ * if $in is false the it could return the subscriptions or false, false means not found
1175
+ */
1176
+ public function retrieve_user_subscriptions( $_post_id, $_email, $in = false ) {
1177
+
1178
+ global $wpdb;
1179
+
1180
+ $meta_key = '_stcr@_';
1181
+ $in_values = '';
1182
+
1183
+ // single post
1184
+ if( ! is_array( $_post_id ) ){
1185
+
1186
+ if ( ! $in ) {
1187
+ $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id <> %d AND meta_key = %s";
1188
+ } else if ( $in ) {
1189
+ $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s";
1190
+ }
1191
+
1192
+ $result = $wpdb->get_results( $wpdb->prepare( $retrieve_subscriptions, $_post_id, $meta_key.$_email ), OBJECT );
1193
+
1194
+ // array of posts
1195
+ } else {
1196
+
1197
+ $in_values = implode( ',', $_post_id );
1198
+
1199
+ if ( ! $in ) {
1200
+ $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id NOT IN ($in_values) AND meta_key = %s";
1201
+ } else if ( $in ) {
1202
+ $retrieve_subscriptions = "SELECT * FROM $wpdb->postmeta WHERE post_id IN ($in_values) AND meta_key = %s";
1203
+ }
1204
+
1205
+ $result = $wpdb->get_results($wpdb->prepare( $retrieve_subscriptions, $meta_key.$_email ), OBJECT);
1206
+
1207
+ }
1208
+
1209
+ return $result === false || $result == 0 || empty( $result ) ? false : $result;
1210
+
1211
+ }
1212
+
1213
+ /**
1214
+ * Updates the status of an existing subscription
1215
+ *
1216
+ * @since 190705 cleanup
1217
+ */
1218
+ public function update_subscription_status( $_post_id = 0, $_email = '', $_new_status = 'C' ) {
1219
+
1220
+ global $wpdb;
1221
+
1222
+ // if not a valid status, return
1223
+ if ( empty( $_new_status ) || ! in_array( $_new_status, array( 'Y', 'R', 'C', '-C' ) ) || empty( $_email ) ) {
1224
+ return 0;
1225
+ }
1226
+
1227
+ // specific post ID supplied
1228
+ if ( ! empty( $_post_id ) ) {
1229
+
1230
+ // generate the WHERE for post ID for the DB query
1231
+ $posts_where = '';
1232
+ if ( ! is_array( $_post_id ) ) {
1233
+ $posts_where = $wpdb->prepare( "post_id = %d", intval( $_post_id ) );
1234
+ } else {
1235
+ foreach ( $_post_id as $a_post_id ) {
1236
+ $posts_where .= $wpdb->prepare( "post_id = %d OR ", intval( $a_post_id ) );
1237
+ }
1238
+ $posts_where = substr( $posts_where, 0, - 4 );
1239
+ }
1240
+
1241
+ // all posts
1242
+ } else {
1243
+ $posts_where = '1=1';
1244
+ }
1245
+
1246
+ // generate WHERE for email for the DB query
1247
+ $emails_where = '';
1248
+ if ( ! is_array( $_email ) ) {
1249
+ $emails_where = $wpdb->prepare( "meta_key = %s", '_stcr@_' . $this->utils->clean_email( $_email ) );
1250
+ } else {
1251
+ foreach ( $_email as $a_email ) {
1252
+ $emails_where .= $wpdb->prepare( "meta_key = %s OR ", '_stcr@_' . $this->utils->clean_email( $a_email ) );
1253
+ }
1254
+ $emails_where = substr( $emails_where, 0, - 4 );
1255
+ }
1256
+
1257
+ $meta_length = ( strpos( $_new_status, 'C' ) !== false ) ? 21 : 20;
1258
+ $new_status = ( $_new_status == '-C' ) ? '' : $_new_status;
1259
+
1260
+ // update DB
1261
+ return $wpdb->query(
1262
+ "UPDATE $wpdb->postmeta
1263
+ SET meta_value = CONCAT(SUBSTRING(meta_value, 1, $meta_length), '$new_status')
1264
+ WHERE ($posts_where) AND ($emails_where)"
1265
+ );
1266
+
1267
+ }
1268
+
1269
+ /**
1270
+ * Updates the email address of an existing subscription
1271
+ *
1272
+ * @since 190705 cleanup
1273
+ */
1274
+ public function update_subscription_email( $_post_id = 0, $_email = '', $_new_email = '' ) {
1275
+
1276
+ global $wpdb;
1277
+
1278
+ // return if no email supplied
1279
+ if ( empty( $_email ) || empty( $_new_email ) || strpos( $_new_email, '@' ) == 0 ) {
1280
+ return;
1281
+ }
1282
+
1283
+ // sanitize old and new email
1284
+ $clean_values[] = "_stcr@_" . $this->utils->clean_email( $_new_email );
1285
+ $clean_values[] = "_stcr@_" . $this->utils->clean_email( $_email );
1286
+
1287
+ // generate WHERE for DB query
1288
+ $post_where = '';
1289
+ if ( ! empty( $_post_id ) ) {
1290
+ $post_where = ' AND post_id = %d';
1291
+ $clean_values[] = $_post_id;
1292
+ }
1293
+
1294
+ // update the email in postmeta table
1295
+ $rowsAffected = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_key = %s WHERE meta_key = %s $post_where", $clean_values ) );
1296
+
1297
+ // update the email in subscribe_reloaded_subscribers table
1298
+ if ( $rowsAffected > 0 || $rowsAffected !== false) {
1299
+ $salt = time();
1300
+ $rowsAffected = $wpdb->query(
1301
+ $wpdb->prepare("UPDATE ". $wpdb->prefix .
1302
+ "subscribe_reloaded_subscribers SET subscriber_email = %s,
1303
+ salt = %d,
1304
+ subscriber_unique_id = %s
1305
+ WHERE subscriber_email = %s",
1306
+ $_new_email, $salt, $this->utils->generate_temp_key( $salt . $_new_email ),$_email )
1307
+ );
1308
+ }
1309
+
1310
+ return false;
1311
+
1312
+ }
1313
+
1314
+ /**
1315
+ * Retrieves a list of emails subscribed to a specific post
1316
+ *
1317
+ * @since 190705 cleanup
1318
+ */
1319
+ public function get_subscriptions( $_search_field = array( 'email' ), $_operator = array( 'equals' ), $_search_value = array( '' ), $_order_by = 'dt', $_order = 'ASC', $_offset = 0, $_limit_results = 0 ) {
1320
+
1321
+ global $wpdb;
1322
+
1323
+ // Type adjustments
1324
+ $search_fields = ( ! is_array( $_search_field ) ) ? array( $_search_field ) : $_search_field;
1325
+ $operators = ( ! is_array( $_operator ) ) ? array( $_operator ) : $_operator;
1326
+ $search_values = ( ! is_array( $_search_value ) ) ? array( $_search_value ) : $_search_value;
1327
+
1328
+ // Find if exists a 'replies only' subscription for the parent comment
1329
+ if ( $search_fields[0] == 'parent' ) {
1330
+
1331
+ $parent_comment_id = $search_values[0];
1332
+ $comment_post_id = $search_values[1];
1333
+
1334
+ // Get the parent comment author email so we can search for any Replies Only subscriptions
1335
+ $parent_comment_author_email = "\_stcr@\_" . get_comment_author_email( $parent_comment_id );
1336
+
1337
+ // Check if $parent_comment_author_email has any Replies Only (R) subscriptions for $comment_post_id
1338
+
1339
+ /*
1340
+ Heads up: this will return Replies Only subscriptions for a given post, *not* for a given comment.
1341
+ This plugin does not track subscriptions for specific comments but rather for entire posts, so there
1342
+ is no way to figure out if a specific parent comment has a subscription (of any type). To make the
1343
+ Replies Only feature half-work, we check if a parent comment author has *any* Replies Only subscriptions
1344
+ for a given post. If they do, we assume that they must want to get notified of replies to *any* of their
1345
+ comments on *that* post.
1346
+ */
1347
+
1348
+ return $wpdb->get_results(
1349
+ $wpdb->prepare(
1350
+ "SELECT pm.meta_id, REPLACE(pm.meta_key, '_stcr@_', '') AS email, pm.post_id, SUBSTRING(pm.meta_value, 1, 19) AS dt, SUBSTRING(pm.meta_value, 21) AS status, srs.subscriber_unique_id AS email_key
1351
+ FROM $wpdb->postmeta pm
1352
+ INNER JOIN {$wpdb->prefix}subscribe_reloaded_subscribers srs ON ( REPLACE(pm.meta_key, '_stcr@_', '') = srs.subscriber_email )
1353
+ WHERE pm.meta_key LIKE %s
1354
+ AND pm.meta_value LIKE '%%R'
1355
+ AND pm.post_id = %d", $parent_comment_author_email, $comment_post_id
1356
+ ), OBJECT
1357
+ );
1358
+
1359
+ } else {
1360
+
1361
+ // generate WHERE for the DB query
1362
+ $where_clause = '';
1363
+ foreach ( $search_fields as $a_idx => $a_field ) {
1364
+ $where_clause .= ' AND';
1365
+ $offset_status = ( $a_field == 'status' && $search_values[$a_idx] == 'C' ) ? 22 : 21;
1366
+ switch ( $a_field ) {
1367
+ case 'status':
1368
+ $where_clause .= " SUBSTRING(meta_value, $offset_status)";
1369
+ break;
1370
+ case 'post_id':
1371
+ $where_clause .= ' post_id';
1372
+ break;
1373
+ default:
1374
+ $where_clause .= ' SUBSTRING(meta_key, 8)';
1375
+ }
1376
+ switch ( $operators[$a_idx] ) {
1377
+ case 'equals':
1378
+ $where_clause .= " = %s";
1379
+ $where_values[] = $search_values[$a_idx];
1380
+ break;
1381
+ case 'does not contain':
1382
+ $where_clause .= " NOT LIKE %s";
1383
+ $where_values[] = "%{$search_values[$a_idx]}%";
1384
+ break;
1385
+ case 'starts with':
1386
+ $where_clause .= " LIKE %s";
1387
+ $where_values[] = "{$search_values[$a_idx]}%";
1388
+ break;
1389
+ case 'ends with':
1390
+ $where_clause .= " LIKE %s";
1391
+ $where_values[] = "%{$search_values[$a_idx]}";
1392
+ break;
1393
+ default: // contains
1394
+ $where_clause .= " LIKE %s";
1395
+ $where_values[] = "%{$search_values[$a_idx]}%";
1396
+ }
1397
+ }
1398
+
1399
+ // generated ORDER BY for the DB query
1400
+ switch ( $_order_by ) {
1401
+ case 'status':
1402
+ $order_by = "status";
1403
+ break;
1404
+ case 'email':
1405
+ $order_by = 'meta_key';
1406
+ break;
1407
+ case 'dt':
1408
+ $order_by = 'dt';
1409
+ break;
1410
+ default:
1411
+ $order_by = 'post_id';
1412
+ }
1413
+ $order = ( $_order != 'ASC' && $_order != 'DESC' ) ? 'DESC' : $_order;
1414
+
1415
+ // this is the 'official' way to have an offset without a limit
1416
+ $row_count = ( $_limit_results <= 0 ) ? '18446744073709551610' : $_limit_results;
1417
+
1418
+ // run the DB query
1419
+ return $wpdb->get_results(
1420
+ $wpdb->prepare(
1421
+ "SELECT meta_id, REPLACE(meta_key, '_stcr@_', '') AS email, post_id, SUBSTRING(meta_value, 1, 19) AS dt, SUBSTRING(meta_value, 21) AS status, srs.subscriber_unique_id AS email_key
1422
+ FROM $wpdb->postmeta
1423
+ INNER JOIN {$wpdb->prefix}subscribe_reloaded_subscribers srs ON ( REPLACE(meta_key, '_stcr@_', '') = srs.subscriber_email )
1424
+ WHERE meta_key LIKE '\_stcr@\_%%' $where_clause
1425
+ ORDER BY $order_by $order
1426
+ LIMIT $_offset,$row_count", $where_values
1427
+ ), OBJECT
1428
+ );
1429
+
1430
+ }
1431
+
1432
+ }
1433
+
1434
+ /**
1435
+ * Sends the notification message to a given user
1436
+ *
1437
+ * @since 190705 cleanup
1438
+ */
1439
+ public function notify_user( $_post_ID = 0, $_email = '', $_comment_ID = 0 ) {
1440
+
1441
+ // vars
1442
+ $post = get_post( $_post_ID );
1443
+ $comment = get_comment( $_comment_ID );
1444
+ $post_permalink = get_permalink( $_post_ID );
1445
+ $comment_permalink = get_comment_link( $_comment_ID );
1446
+ $comment_reply_permalink = get_permalink( $_post_ID ) . '?replytocom=' . $_comment_ID . '#respond';
1447
+ $info = $this->_get_comment_object( $_comment_ID );
1448
+
1449
+ // WPML compatibility
1450
+ if ( defined('ICL_SITEPRESS_VERSION') && defined('ICL_LANGUAGE_CODE') ) {
1451
+ global $sitepress;
1452
+ $language = $sitepress->get_language_for_element( $_post_ID, 'post_' . $post->post_type );
1453
+ $sitepress->switch_lang($language);
1454
+ }
1455
+
1456
+ // vars
1457
+ $subject = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_subject', 'There is a new comment on the post [post_title]' ) ), ENT_QUOTES, 'UTF-8' );
1458
+ $message = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_notification_content', '' ) ), ENT_QUOTES, 'UTF-8' );
1459
+ $manager_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '/comment-subscriptions/' );
1460
+ $one_click_unsubscribe_link = $manager_link;
1461
+
1462
+ // qTranslate compatibility
1463
+ if ( function_exists( 'qtrans_convertURL' ) ) {
1464
+ $manager_link = qtrans_convertURL( $manager_link );
1465
+ }
1466
+
1467
+ // vars
1468
+ $clean_email = $this->utils->clean_email( $_email );
1469
+ $subscriber_salt = $this->utils->generate_temp_key( $clean_email );
1470
+ $manager_link .= ( ( strpos( $manager_link, '?' ) !== false ) ? '&' : '?' )
1471
+ . "srek=" . $this->utils->get_subscriber_key( $clean_email )
1472
+ . "&srk=$subscriber_salt";
1473
+ $one_click_unsubscribe_link .= ( ( strpos( $one_click_unsubscribe_link, '?' ) !== false ) ? '&' : '?' )
1474
+ . "srek=" . $this->utils->get_subscriber_key( $clean_email ) . "&srk=$subscriber_salt"
1475
+ . "&sra=u&srsrc=e" . "&srp=" . $_post_ID;
1476
+ $comment_content = $comment->comment_content;
1477
+
1478
+ // replace tags with their actual values
1479
+ $subject = str_replace( '[post_title]', $post->post_title, $subject );
1480
+ $subject = str_replace( '[comment_author]', $comment->comment_author, $subject );
1481
+ $subject = str_replace( '[blog_name]' , get_bloginfo('name'), $subject );
1482
+ $message = str_replace( '[post_permalink]', $post_permalink, $message );
1483
+ $message = str_replace( '[comment_permalink]', $comment_permalink, $message );
1484
+ $message = str_replace( '[comment_reply_permalink]', $comment_reply_permalink, $message );
1485
+ $message = str_replace( '[comment_author]', $comment->comment_author, $message );
1486
+ $message = str_replace( '[comment_content]', $comment_content, $message );
1487
+ $message = str_replace( '[manager_link]', $manager_link, $message );
1488
+ $message = str_replace( '[oneclick_link]', $one_click_unsubscribe_link, $message );
1489
+ $message = str_replace( '[comment_gravatar]', get_avatar($info->comment_author_email, 40), $message );
1490
+ $message = str_replace( '[comment_date]', date( get_option( 'date_format'), strtotime( $comment->comment_date ) ), $message );
1491
+ $message = str_replace( '[comment_time]', date( get_option( 'time_format'), strtotime( $comment->comment_date ) ), $message );
1492
+
1493
+ // qTranslate support
1494
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
1495
+ $subject = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $subject );
1496
+ $message = str_replace( '[post_title]', qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $post->post_title ), $message );
1497
+ $message = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $message );
1498
+ } else {
1499
+ $message = str_replace( '[post_title]', $post->post_title, $message );
1500
+ }
1501
+
1502
+ $message = apply_filters( 'stcr_notify_user_message', $message, $_post_ID, $clean_email, $_comment_ID );
1503
+
1504
+ // email settings
1505
+ $email_settings = array(
1506
+ 'subject' => $subject,
1507
+ 'message' => $message,
1508
+ 'toEmail' => $clean_email,
1509
+ 'XPostId' => $_post_ID,
1510
+ 'XCommentId' => $_comment_ID
1511
+ );
1512
+
1513
+ // send email
1514
+ $this->utils->send_email( $email_settings );
1515
+
1516
+ }
1517
+
1518
+ /**
1519
+ * Displays the checkbox to allow visitors to subscribe
1520
+ *
1521
+ * @since 190705 cleanup
1522
+ */
1523
+ function subscribe_reloaded_show( $submit_field = '' ) {
1524
+
1525
+ // echo on action, return on filter
1526
+ $echo = false;
1527
+ if ( doing_action( 'comment_form' ) || doing_action( 'comment_form_must_log_in_after' ) ) {
1528
+ $echo = true;
1529
+ }
1530
+
1531
+ // vars
1532
+ global $post, $wp_subscribe_reloaded;
1533
+ $checkbox_subscription_type = null;
1534
+ $_comment_ID = null;
1535
+ $post_permalink = get_permalink( $post->ID );
1536
+ $post_permalink = "post_permalink=" . $post_permalink;
1537
+ $post_type = get_post_type( $post->ID );
1538
+ $only_for_logged_in = get_option( 'subscribe_reloaded_only_for_logged_in', 'no' );
1539
+ $supported_post_types = get_option( 'subscribe_reloaded_post_type_supports' );
1540
+ if ( in_array( 'stcr_none', $supported_post_types, true ) ) {
1541
+ $supported_post_types = array_flip( $supported_post_types );
1542
+ unset( $supported_post_types['stcr_none'] );
1543
+ }
1544
+ $supported_post_types = array_flip( $supported_post_types );
1545
+
1546
+ // if not enabled for this post type, return default
1547
+ if ( ! in_array( $post_type, $supported_post_types, true ) ) {
1548
+ if ( $echo ) {
1549
+ echo $submit_field;
1550
+ } else {
1551
+ return $submit_field;
1552
+ }
1553
+ return;
1554
+ }
1555
+
1556
+ // only for logged in users
1557
+ if ( $only_for_logged_in == 'yes' && ! is_user_logged_in() ) {
1558
+ if ( $echo ) {
1559
+ echo $submit_field;
1560
+ } else {
1561
+ return $submit_field;
1562
+ }
1563
+ return;
1564
+ }
1565
+
1566
+ // enqueue scripts and styles
1567
+ $wp_subscribe_reloaded->stcr->utils->add_plugin_js_scripts();
1568
+ wp_enqueue_style( 'stcr-plugin-style' );
1569
+
1570
+ // return if subscriptions disabled for this post
1571
+ $is_disabled = get_post_meta( $post->ID, 'stcr_disable_subscriptions', true );
1572
+ if ( ! empty( $is_disabled ) ) {
1573
+ if ( $echo ) {
1574
+ echo $submit_field;
1575
+ } else {
1576
+ return $submit_field;
1577
+ }
1578
+ return;
1579
+ }
1580
+
1581
+ // vars
1582
+ $show_subscription_box = true;
1583
+ $html_to_show = '';
1584
+ $user_link = get_bloginfo( 'url' ) . get_option( 'subscribe_reloaded_manager_page', '' );
1585
+
1586
+ // qTranslate compatibility
1587
+ if ( function_exists( 'qtrans_convertURL' ) ) {
1588
+ $user_link = qtrans_convertURL( $user_link );
1589
+ }
1590
+
1591
+ // link for management page
1592
+ $manager_link = ( strpos( $user_link, '?' ) !== false ) ?
1593
+ "$user_link&amp;srp=$post->ID&amp;srk=" . get_option( 'subscribe_reloaded_unique_key' ) :
1594
+ "$user_link?srp=$post->ID&amp;srk=" . get_option( 'subscribe_reloaded_unique_key' );
1595
+
1596
+ // link for user
1597
+ $user_link = ( strpos( $user_link, '?' ) !== false ) ?
1598
+ "$user_link&" . $post_permalink :
1599
+ "$user_link?" . $post_permalink;
1600
+
1601
+ // if subscription pending confirmation
1602
+ if ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '', 'C' ) ) {
1603
+ $html_to_show = str_replace(
1604
+ '[manager_link]', $user_link,
1605
+ html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribed_waiting_label', __( "Your subscription to this post needs to be confirmed. <a href='[manager_link]'>Manage your subscriptions</a>.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1606
+ );
1607
+ $show_subscription_box = false;
1608
+
1609
+ // if subscription active
1610
+ } elseif ( $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, '' ) ) {
1611
+ $html_to_show = str_replace(
1612
+ '[manager_link]', $user_link ,
1613
+ html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_subscribed_label', __( "You are subscribed to this post. <a href='[manager_link]'>Manage</a> your subscriptions.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1614
+ );
1615
+ $show_subscription_box = false;
1616
+ }
1617
+
1618
+ // if current user is author of the post
1619
+ if ( $wp_subscribe_reloaded->stcr->is_author( $post->post_author ) ) {
1620
+ if ( get_option( 'subscribe_reloaded_admin_subscribe', 'no' ) == 'no' ) {
1621
+ $show_subscription_box = false;
1622
+ }
1623
+ $html_to_show .= ' ';
1624
+ $html_to_show .= str_replace(
1625
+ '[manager_link]', $manager_link,
1626
+ html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_author_label', __( "You can <a href='[manager_link]'>manage the subscriptions</a> of this post.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1627
+ );
1628
+ }
1629
+
1630
+ // show the subscription form
1631
+ if ( $show_subscription_box ) {
1632
+
1633
+ // label
1634
+ $checkbox_label = str_replace(
1635
+ '[subscribe_link]', "$manager_link&amp;sra=s&amp;srsrc=f",
1636
+ html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_label', __( "Notify me of followup comments via e-mail. You can also <a href='[subscribe_link]'>subscribe</a> without commenting.", 'subscribe-to-comments-reloaded' ) ) ), ENT_QUOTES, 'UTF-8' )
1637
+ );
1638
+
1639
+ // CSS style
1640
+ $checkbox_inline_style = get_option( 'subscribe_reloaded_checkbox_inline_style', 'width:30px' );
1641
+ if ( ! empty( $checkbox_inline_style ) ) {
1642
+ $checkbox_inline_style = " style='$checkbox_inline_style'";
1643
+ }
1644
+
1645
+ $checkbox_html_wrap = html_entity_decode( stripslashes( get_option( 'subscribe_reloaded_checkbox_html', '' ) ), ENT_QUOTES, 'UTF-8' );
1646
+
1647
+ // regular subscriptions form
1648
+ if ( get_option( 'subscribe_reloaded_enable_advanced_subscriptions', 'no' ) == 'no' ) {
1649
+ switch ( get_option( 'subscribe_reloaded_checked_by_default_value' ) ) {
1650
+ case '0':
1651
+ $checkbox_subscription_type = 'yes';
1652
+ break;
1653
+ case '1':
1654
+ $checkbox_subscription_type = 'replies';
1655
+ break;
1656
+ }
1657
+ $checkbox_field = "<input$checkbox_inline_style type='checkbox' name='subscribe-reloaded' id='subscribe-reloaded' value='$checkbox_subscription_type'" . ( ( get_option( 'subscribe_reloaded_checked_by_default', 'no' ) == 'yes' ) ? " checked='checked'" : '' ) . " />";
1658
+
1659
+ // advanced subscriptions form
1660
+ } else {
1661
+ $checkbox_field = "<select name='subscribe-reloaded' id='subscribe-reloaded'>
1662
+ <option value='none' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '0' ) ? "selected='selected'" : '' ) . ">" . __( "Don't subscribe", 'subscribe-to-comments-reloaded' ) . "</option>
1663
+ <option value='yes' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '1' ) ? "selected='selected'" : '' ) . ">" . __( "All", 'subscribe-to-comments-reloaded' ) . "</option>
1664
+ <option value='replies' " . ( ( get_option( 'subscribe_reloaded_default_subscription_type' ) === '2' ) ? "selected='selected'" : '' ) . ">" . __( "Replies to my comments", 'subscribe-to-comments-reloaded' ) . "</option>
1665
+ </select>";
1666
+ }
1667
+
1668
+ if ( empty( $checkbox_html_wrap ) ) {
1669
+ $html_to_show = "$checkbox_field <label for='subscribe-reloaded'>$checkbox_label</label>" . $html_to_show;
1670
+ } else {
1671
+ $checkbox_html_wrap = str_replace( '[checkbox_field]', $checkbox_field, $checkbox_html_wrap );
1672
+ $html_to_show = str_replace( '[checkbox_label]', $checkbox_label, $checkbox_html_wrap ) . $html_to_show;
1673
+ }
1674
+
1675
+ }
1676
+
1677
+ // qTranslate compatiblity
1678
+ if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) {
1679
+ $html_to_show = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $html_to_show );
1680
+ }
1681
+
1682
+ $output = '';
1683
+ // Check for the Comment Form location
1684
+ if( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
1685
+ $output .= "<style type='text/css'>.stcr-hidden{display: none !important;}</style>";
1686
+ $output .= "<div class='stcr-form stcr-hidden'>";
1687
+ $output .= $html_to_show;
1688
+ $output .= "</div>";
1689
+ } else {
1690
+ $output .= $html_to_show;
1691
+ }
1692
+
1693
+ // echo or return
1694
+ if ( $echo ) {
1695
+ echo $output . $submit_field;
1696
+ } else {
1697
+ return $output . $submit_field;
1698
+ }
1699
+
1700
+ }
1701
+
1702
+ /**
1703
+ * Set a cookie if the user just subscribed without commenting
1704
+ *
1705
+ * @since 190705
1706
+ */
1707
+ public function set_user_cookie() {
1708
+
1709
+ $subscribe_to_comments_action = ! empty( $_POST['sra'] ) ? $_POST['sra'] : ( ! empty( $_GET['sra'] ) ? $_GET['sra'] : 0 );
1710
+ $subscribe_to_comments_post_ID = ! empty( $_POST['srp'] ) ? intval( $_POST['srp'] ) : ( ! empty( $_GET['srp'] ) ? intval( $_GET['srp'] ) : 0 );
1711
+
1712
+ if ( ! empty( $subscribe_to_comments_action ) && ! empty( $_POST['subscribe_reloaded_email'] ) &&
1713
+ ( $subscribe_to_comments_action == 's' ) && ( $subscribe_to_comments_post_ID > 0 )
1714
+ ) {
1715
+ $subscribe_to_comments_clean_email = $this->utils->clean_email( $_POST['subscribe_reloaded_email'] );
1716
+ if ( get_option( 'subscribe_reloaded_use_cookies', 'yes' ) == 'yes' ) {
1717
+ setcookie( 'comment_author_email_' . COOKIEHASH, $subscribe_to_comments_clean_email, time() + 1209600, '/' );
1718
+ }
1719
+ }
1720
+ }
1721
+
1722
+ /**
1723
+ * Management page shortcode
1724
+ *
1725
+ * @since 190325
1726
+ */
1727
+ public function management_page_sc() {
1728
+
1729
+ $data = $this->subscribe_reloaded_manage();
1730
+ return $data[0]->post_content;
1731
+
1732
+ }
1733
+
1734
+ /**
1735
+ * Add custom output before comment content
1736
+ *
1737
+ * @since 190801
1738
+ */
1739
+ public function comment_content_prepend( $comment_text, $comment = null ) {
1740
+
1741
+ // do not proceed if comment info is not passed
1742
+ if ( empty( $comment ) || ! isset( $comment->comment_approved ) ) {
1743
+ return $comment_text;
1744
+ }
1745
+
1746
+ global $wp_subscribe_reloaded;
1747
+ global $post;
1748
+
1749
+ $prepend = '';
1750
+
1751
+ // comment held for moderation and email is subscribed to the post
1752
+ if ( $comment->comment_approved == '0' && $wp_subscribe_reloaded->stcr->is_user_subscribed( $post->ID, $comment->comment_author_email, 'C' ) ) {
1753
+ $prepend = '<p><em>' . __( 'Check your email to confirm your subscription.', 'subscribe-to-comments-reloaded' ) . '</em></p>';
1754
+ }
1755
+
1756
+ // pass it back
1757
+ return $prepend . $comment_text;
1758
+
1759
+ }
1760
+
1761
+ /**
1762
+ * Move form with JS
1763
+ *
1764
+ * @since 200626
1765
+ */
1766
+ public function move_form_with_js() {
1767
+
1768
+ $output = '';
1769
+
1770
+ if ( get_option('subscribe_reloaded_stcr_position') == 'yes' ) {
1771
+ $output .= '<script type="text/javascript">document.addEventListener("DOMContentLoaded",function(){if(document.querySelectorAll("div.stcr-form").length){let e=document.querySelectorAll("div.stcr-form")[0],t=document.querySelectorAll("#commentform input[type=submit]")[0];t.parentNode.insertBefore(e,t),e.classList.remove("stcr-hidden")}});</script>';
1772
+ }
1773
+
1774
+ echo $output;
1775
+
1776
+ }
1777
+
1778
+ }
1779
+
1780
+ }