Version Description
- 12th August 2020 =
- Fixed: In certain situations, the password reset key would get modified when using the User Lost Password - For User notification.
- Fixed: An issue in the Custom Fields add-on where the Send to Author checkbox did not send a User Custom Field Updated notification to the user.
- Improved: Compatibility with the latest version of the Digest add-on.
- Improved: Compatibility with the latest version of the Multisite add-on.
Download this release
Release Info
Developer | voltronik |
Plugin | Better Notifications for WordPress |
Version | 1.8.4 |
Comparing to | |
See all releases |
Code changes from version 1.8.3 to 1.8.4
- README.txt +706 -693
- assets/js/bnfw.js +13 -11
- bnfw.php +30 -25
- includes/admin/class-bnfw-notification.php +8 -2
- includes/engine/class-bnfw-engine.php +1532 -1452
- includes/overrides.php +8 -3
README.txt
CHANGED
@@ -1,693 +1,706 @@
|
|
1 |
-
=== Better Notifications for WP ===
|
2 |
-
Contributors: voltronik
|
3 |
-
Donate link: https://betternotificationsforwp.com/donate/
|
4 |
-
Tags: notification, email,
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to: 5.
|
7 |
-
Requires PHP: 5.6
|
8 |
-
Stable tag: 1.8.
|
9 |
-
License: GPLv2 or later
|
10 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
-
|
12 |
-
Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available.
|
13 |
-
|
14 |
-
== Description ==
|
15 |
-
|
16 |
-
Better Notifications for WP is a simple but powerful plugin for beginners to advanced users that allows you to customise the email notifications that WordPress sends using the WYSIWYG editor and shortcodes. All of the default WordPress email notifications are available to customise as well as lots of new ones. You can choose to send notifications to individual users, multiple users, all users in a user role, multiple roles - you name it! You can also power-up your notifications with [Premium Add-ons](https://betternotificationsforwp.com/downloads/). Emails are sent out via your WordPress website (using `wp_mail`) but can be sent via SMTP using an appropriate 3rd party plugin should you wish.
|
17 |
-
|
18 |
-
Here's a quick walkthrough of the plugin in action:
|
19 |
-
[youtube https://www.youtube.com/watch?v=MxPUyRZPJ1Q]
|
20 |
-
|
21 |
-
= An Example: =
|
22 |
-
You want all the users in the Editor role to be notified via email when a new post is published and you'd like to customise it to include your logo along with the author's name and date / time it was published - with this plugin, that's easy.
|
23 |
-
|
24 |
-
> A handy list of shortcodes you can use is available [here](https://betternotificationsforwp.com/shortcodes/ "Shortcodes for use in Better Notifications for WP").
|
25 |
-
|
26 |
-
= Premium Add-ons =
|
27 |
-
Power-up your notifications using add-ons:
|
28 |
-
|
29 |
-
[Notification Add-on Bundles](https://betternotificationsforwp.com/add-on-bundles/) - Everything you need for your WordPress notifications. Save big when you buy an add-on bundle. Instant access.
|
30 |
-
|
31 |
-
[Subscriptions (GDPR)](https://betternotificationsforwp.com/downloads/subscriptions-gdpr/) - Allow users to manage their subscriptions for BNFW notifications.
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
* User
|
58 |
-
* Password
|
59 |
-
*
|
60 |
-
* User
|
61 |
-
* User
|
62 |
-
*
|
63 |
-
*
|
64 |
-
* Privacy – Confirm Action:
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
* New User
|
70 |
-
* User
|
71 |
-
* Password
|
72 |
-
*
|
73 |
-
* User Email Changed - For User
|
74 |
-
* User
|
75 |
-
* User
|
76 |
-
*
|
77 |
-
*
|
78 |
-
* Privacy – Confirm Action:
|
79 |
-
* Privacy – Data
|
80 |
-
* Privacy – Data
|
81 |
-
*
|
82 |
-
* Profile Builder –
|
83 |
-
* Profile Builder –
|
84 |
-
* Profile Builder – Account
|
85 |
-
*
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
* Post
|
91 |
-
* Post
|
92 |
-
*
|
93 |
-
* Post
|
94 |
-
*
|
95 |
-
*
|
96 |
-
* New Comment
|
97 |
-
*
|
98 |
-
* Post -
|
99 |
-
* Post -
|
100 |
-
*
|
101 |
-
* New
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
* Page
|
107 |
-
* Page
|
108 |
-
*
|
109 |
-
* Page
|
110 |
-
* Page
|
111 |
-
* Page - New Comment
|
112 |
-
* Page - Comment
|
113 |
-
* Page - Comment
|
114 |
-
* Page -
|
115 |
-
* Page -
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
* Media
|
121 |
-
* Media
|
122 |
-
* Media - New Comment
|
123 |
-
* Media - Comment
|
124 |
-
* Media - Comment
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
* New
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
* New
|
139 |
-
*
|
140 |
-
* Network Admin Email
|
141 |
-
*
|
142 |
-
* Site
|
143 |
-
* Site
|
144 |
-
* Site Admin Email
|
145 |
-
*
|
146 |
-
* New
|
147 |
-
* New User
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
>
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
*
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
* Fixed:
|
246 |
-
|
247 |
-
|
248 |
-
*
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
*
|
253 |
-
|
254 |
-
|
255 |
-
*
|
256 |
-
|
257 |
-
|
258 |
-
*
|
259 |
-
|
260 |
-
|
261 |
-
*
|
262 |
-
*
|
263 |
-
|
264 |
-
= 1.
|
265 |
-
*
|
266 |
-
* New:
|
267 |
-
*
|
268 |
-
*
|
269 |
-
|
270 |
-
|
271 |
-
*
|
272 |
-
*
|
273 |
-
*
|
274 |
-
*
|
275 |
-
*
|
276 |
-
|
277 |
-
= 1.7.
|
278 |
-
*
|
279 |
-
*
|
280 |
-
* Added:
|
281 |
-
*
|
282 |
-
*
|
283 |
-
*
|
284 |
-
|
285 |
-
|
286 |
-
*
|
287 |
-
*
|
288 |
-
*
|
289 |
-
|
290 |
-
|
291 |
-
*
|
292 |
-
|
293 |
-
|
294 |
-
*
|
295 |
-
*
|
296 |
-
*
|
297 |
-
|
298 |
-
|
299 |
-
*
|
300 |
-
*
|
301 |
-
*
|
302 |
-
* Fixed: The
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
*
|
310 |
-
* Fixed:
|
311 |
-
* Fixed: An issue
|
312 |
-
* Fixed:
|
313 |
-
|
314 |
-
|
315 |
-
*
|
316 |
-
|
317 |
-
|
318 |
-
*
|
319 |
-
*
|
320 |
-
|
321 |
-
|
322 |
-
* New:
|
323 |
-
*
|
324 |
-
*
|
325 |
-
*
|
326 |
-
|
327 |
-
|
328 |
-
*
|
329 |
-
*
|
330 |
-
*
|
331 |
-
*
|
332 |
-
*
|
333 |
-
*
|
334 |
-
|
335 |
-
|
336 |
-
* New:
|
337 |
-
* New:
|
338 |
-
* New:
|
339 |
-
*
|
340 |
-
*
|
341 |
-
*
|
342 |
-
*
|
343 |
-
* Fixed:
|
344 |
-
|
345 |
-
|
346 |
-
*
|
347 |
-
|
348 |
-
|
349 |
-
*
|
350 |
-
*
|
351 |
-
*
|
352 |
-
|
353 |
-
|
354 |
-
*
|
355 |
-
*
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
*
|
362 |
-
*
|
363 |
-
*
|
364 |
-
*
|
365 |
-
|
366 |
-
|
367 |
-
*
|
368 |
-
*
|
369 |
-
|
370 |
-
|
371 |
-
*
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
*
|
376 |
-
*
|
377 |
-
*
|
378 |
-
|
379 |
-
|
380 |
-
*
|
381 |
-
*
|
382 |
-
*
|
383 |
-
*
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
*
|
389 |
-
*
|
390 |
-
* Fixed:
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
*
|
395 |
-
* Fixed:
|
396 |
-
*
|
397 |
-
|
398 |
-
|
399 |
-
*
|
400 |
-
|
401 |
-
|
402 |
-
*
|
403 |
-
*
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
*
|
408 |
-
*
|
409 |
-
*
|
410 |
-
*
|
411 |
-
*
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
*
|
416 |
-
*
|
417 |
-
|
418 |
-
|
419 |
-
*
|
420 |
-
*
|
421 |
-
|
422 |
-
|
423 |
-
* Fixed: The '
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
*
|
428 |
-
*
|
429 |
-
*
|
430 |
-
*
|
431 |
-
Fixed:
|
432 |
-
* Fixed:
|
433 |
-
* Fixed:
|
434 |
-
|
435 |
-
|
436 |
-
* Fixed: The '
|
437 |
-
|
438 |
-
|
439 |
-
*
|
440 |
-
|
441 |
-
|
442 |
-
*
|
443 |
-
*
|
444 |
-
|
445 |
-
*
|
446 |
-
*
|
447 |
-
*
|
448 |
-
*
|
449 |
-
*
|
450 |
-
*
|
451 |
-
*
|
452 |
-
*
|
453 |
-
|
454 |
-
|
455 |
-
*
|
456 |
-
*
|
457 |
-
*
|
458 |
-
*
|
459 |
-
|
460 |
-
|
461 |
-
*
|
462 |
-
*
|
463 |
-
|
464 |
-
|
465 |
-
*
|
466 |
-
*
|
467 |
-
*
|
468 |
-
*
|
469 |
-
|
470 |
-
|
471 |
-
* Fixed: '
|
472 |
-
|
473 |
-
= 1.5 -
|
474 |
-
*
|
475 |
-
*
|
476 |
-
|
477 |
-
|
478 |
-
*
|
479 |
-
*
|
480 |
-
*
|
481 |
-
*
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
*
|
488 |
-
*
|
489 |
-
*
|
490 |
-
*
|
491 |
-
|
492 |
-
|
493 |
-
*
|
494 |
-
*
|
495 |
-
*
|
496 |
-
|
497 |
-
|
498 |
-
*
|
499 |
-
*
|
500 |
-
*
|
501 |
-
*
|
502 |
-
*
|
503 |
-
*
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
*
|
508 |
-
|
509 |
-
|
510 |
-
*
|
511 |
-
|
512 |
-
|
513 |
-
*
|
514 |
-
*
|
515 |
-
|
516 |
-
|
517 |
-
*
|
518 |
-
|
519 |
-
|
520 |
-
* Fixed:
|
521 |
-
|
522 |
-
|
523 |
-
*
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
*
|
533 |
-
*
|
534 |
-
* Fixed:
|
535 |
-
* Fixed:
|
536 |
-
|
537 |
-
|
538 |
-
*
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
*
|
547 |
-
*
|
548 |
-
*
|
549 |
-
|
550 |
-
|
551 |
-
* Fixed:
|
552 |
-
*
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
* Fixed: An issue where
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
*
|
562 |
-
*
|
563 |
-
*
|
564 |
-
*
|
565 |
-
*
|
566 |
-
|
567 |
-
|
568 |
-
* Fixed:
|
569 |
-
* Fixed:
|
570 |
-
* Fixed:
|
571 |
-
*
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
* New: You can now
|
576 |
-
* New:
|
577 |
-
* New:
|
578 |
-
* New:
|
579 |
-
*
|
580 |
-
*
|
581 |
-
*
|
582 |
-
* Fixed:
|
583 |
-
* Fixed:
|
584 |
-
*
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
*
|
591 |
-
*
|
592 |
-
|
593 |
-
|
594 |
-
*
|
595 |
-
*
|
596 |
-
*
|
597 |
-
*
|
598 |
-
|
599 |
-
|
600 |
-
* Fixed:
|
601 |
-
|
602 |
-
|
603 |
-
* Fixed:
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
* New:
|
608 |
-
* New:
|
609 |
-
*
|
610 |
-
*
|
611 |
-
*
|
612 |
-
*
|
613 |
-
* Fixed:
|
614 |
-
* Fixed:
|
615 |
-
*
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
*
|
622 |
-
*
|
623 |
-
*
|
624 |
-
*
|
625 |
-
*
|
626 |
-
|
627 |
-
|
628 |
-
*
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
*
|
635 |
-
*
|
636 |
-
*
|
637 |
-
*
|
638 |
-
*
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
*
|
643 |
-
|
644 |
-
|
645 |
-
* New
|
646 |
-
* New
|
647 |
-
* New
|
648 |
-
*
|
649 |
-
*
|
650 |
-
*
|
651 |
-
*
|
652 |
-
*
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
*
|
657 |
-
*
|
658 |
-
*
|
659 |
-
|
660 |
-
|
661 |
-
*
|
662 |
-
*
|
663 |
-
*
|
664 |
-
|
665 |
-
|
666 |
-
*
|
667 |
-
|
668 |
-
|
669 |
-
*
|
670 |
-
*
|
671 |
-
*
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
*
|
677 |
-
|
678 |
-
= 0
|
679 |
-
*
|
680 |
-
|
681 |
-
|
682 |
-
*
|
683 |
-
*
|
684 |
-
*
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Customize WordPress Emails and Alerts - Better Notifications for WP ===
|
2 |
+
Contributors: voltronik
|
3 |
+
Donate link: https://betternotificationsforwp.com/donate/
|
4 |
+
Tags: notification, email, alert, message, notify, send, HTML, customize, bulk, trigger, CC, BCC
|
5 |
+
Requires at least: 4.8
|
6 |
+
Tested up to: 5.5.1
|
7 |
+
Requires PHP: 5.6
|
8 |
+
Stable tag: 1.8.4
|
9 |
+
License: GPLv2 or later
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
|
12 |
+
Supercharge your WordPress email notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Increase power with Add-ons.
|
13 |
+
|
14 |
+
== Description ==
|
15 |
+
|
16 |
+
Better Notifications for WP is a simple but powerful plugin for beginners to advanced users that allows you to customise the email notifications that WordPress sends using the WYSIWYG editor and shortcodes. All of the default WordPress email notifications are available to customise as well as lots of new ones. You can choose to send notifications to individual users, multiple users, all users in a user role, multiple roles - you name it! You can also power-up your notifications with [Premium Add-ons](https://betternotificationsforwp.com/downloads/). Emails are sent out via your WordPress website (using `wp_mail`) but can be sent via SMTP using an appropriate 3rd party plugin should you wish.
|
17 |
+
|
18 |
+
Here's a quick walkthrough of the plugin in action:
|
19 |
+
[youtube https://www.youtube.com/watch?v=MxPUyRZPJ1Q]
|
20 |
+
|
21 |
+
= An Example: =
|
22 |
+
You want all the users in the Editor role to be notified via email when a new post is published and you'd like to customise it to include your logo along with the author's name and date / time it was published - with this plugin, that's easy.
|
23 |
+
|
24 |
+
> A handy list of shortcodes you can use is available [here](https://betternotificationsforwp.com/shortcodes/ "Shortcodes for use in Better Notifications for WP").
|
25 |
+
|
26 |
+
= Premium Add-ons =
|
27 |
+
Power-up your notifications using add-ons:
|
28 |
+
|
29 |
+
[Notification Add-on Bundles](https://betternotificationsforwp.com/add-on-bundles/) - Everything you need for your WordPress notifications. Save big when you buy an add-on bundle. Instant access.
|
30 |
+
|
31 |
+
[Subscriptions (GDPR)](https://betternotificationsforwp.com/downloads/subscriptions-gdpr/) - Allow users to manage their subscriptions for BNFW notifications.
|
32 |
+
If you want to let users create their own email notifications, check out my other plugin: [Content Notify](https://contentnotify.com).
|
33 |
+
|
34 |
+
[Conditional Notifications](https://betternotificationsforwp.com/downloads/conditional-notifications/) - Limit certain notifications depending on which categories, tags, post formats, or terms you choose.
|
35 |
+
|
36 |
+
[Custom Fields](https://betternotificationsforwp.com/downloads/custom-fields/) - Provides a number of new shortcodes allowing you to include data from custom fields and custom user fields created using [ACF](https://wordpress.org/plugins/advanced-custom-fields/).
|
37 |
+
|
38 |
+
[Send to Any Email](https://betternotificationsforwp.com/downloads/send-to-any-email/) - Send notifications to non-WordPress Users.
|
39 |
+
|
40 |
+
[Digest](https://betternotificationsforwp.com/downloads/digest/) - Group multiple notifications into a single digest notification.
|
41 |
+
|
42 |
+
[Global Override](https://betternotificationsforwp.com/downloads/per-post-override/) - Override some of the settings of notifications directly when editing a post, page, or custom post type.
|
43 |
+
|
44 |
+
[Reminders](https://betternotificationsforwp.com/downloads/update-reminder/) - Send a reminder to your users and/or user roles when a post, page, or custom post type hasn't been updated after a set amount of time. Also send a notification when a user hasn't logged in for a set amount of time.
|
45 |
+
|
46 |
+
[Multisite](https://betternotificationsforwp.com/downloads/multisite/) - Adds new notifications and shortcodes for WordPress Multisite to Better Notifications for WP.
|
47 |
+
|
48 |
+
[Profile Builder](https://betternotificationsforwp.com/downloads/profile-builder/) - Adds compatibility and new notifications and shortcodes for Profile Builder Free, Hobbyist, and Pro plugins to Better Notifications for WP.
|
49 |
+
|
50 |
+
...and more coming soon!
|
51 |
+
|
52 |
+
= Notifications =
|
53 |
+
The notifications that are currently available to use are:
|
54 |
+
|
55 |
+
**Admin**
|
56 |
+
|
57 |
+
* New User Registration - For Admin
|
58 |
+
* User Lost Password - For Admin
|
59 |
+
* Password Changed - For Admin
|
60 |
+
* User Email Changed - For Admin
|
61 |
+
* User Role Changed - For Admin
|
62 |
+
* User Logged In - For Admin
|
63 |
+
* WordPress Core Automatic Background Updates
|
64 |
+
* Privacy – Confirm Action: Export Data Request – For Admin
|
65 |
+
* Privacy – Confirm Action: Erase Data Request – For Admin
|
66 |
+
|
67 |
+
**Transactional**
|
68 |
+
|
69 |
+
* New User Registration - For User
|
70 |
+
* New User - Post-registration Email
|
71 |
+
* User Lost Password - For User
|
72 |
+
* Password Changed - For User
|
73 |
+
* User Email Changed Confirmation - For User
|
74 |
+
* User Email Changed - For User
|
75 |
+
* User Role Changed - For User
|
76 |
+
* User Logged In - For User
|
77 |
+
* Comment Reply
|
78 |
+
* Privacy – Confirm Action: Export Data Request – For User
|
79 |
+
* Privacy – Confirm Action: Erase Data Request – For User
|
80 |
+
* Privacy – Data Export – For User
|
81 |
+
* Privacy – Data Erased – For User
|
82 |
+
* Profile Builder – Approval Request for Admin ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
|
83 |
+
* Profile Builder – Email Confirmation ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
|
84 |
+
* Profile Builder – Account Approved ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
|
85 |
+
* Profile Builder – Account Unapproved ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
|
86 |
+
* User Login Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
87 |
+
|
88 |
+
**Posts / Custom Post Types**
|
89 |
+
|
90 |
+
* New Post Published
|
91 |
+
* Post Updated
|
92 |
+
* Post Pending Review
|
93 |
+
* New Private Post
|
94 |
+
* Post Scheduled
|
95 |
+
* Published Post Moved to Trash
|
96 |
+
* New Comment
|
97 |
+
* New Comment Awaiting Moderation
|
98 |
+
* Post - Comment Approved
|
99 |
+
* Post - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
100 |
+
* Post - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
|
101 |
+
* New Trackback
|
102 |
+
* New Pingback
|
103 |
+
|
104 |
+
**Pages**
|
105 |
+
|
106 |
+
* New Page Published
|
107 |
+
* Page Updated
|
108 |
+
* Page Pending Review
|
109 |
+
* New Private Page
|
110 |
+
* Page Scheduled
|
111 |
+
* Page - New Comment
|
112 |
+
* Page - New Comment Awaiting Moderation
|
113 |
+
* Page - Comment Approved
|
114 |
+
* Page - Comment Reply
|
115 |
+
* Page - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
116 |
+
* Page - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
|
117 |
+
|
118 |
+
**Media**
|
119 |
+
|
120 |
+
* New Media Published
|
121 |
+
* Media Updated
|
122 |
+
* Media - New Comment
|
123 |
+
* Media - New Comment Awaiting Moderation
|
124 |
+
* Media - Comment Approved
|
125 |
+
* Media - Comment Reply
|
126 |
+
|
127 |
+
**Posts**
|
128 |
+
|
129 |
+
* New Category
|
130 |
+
* New Tag
|
131 |
+
|
132 |
+
**Custom Post Types**
|
133 |
+
|
134 |
+
* New Term
|
135 |
+
|
136 |
+
**Multisite ([Multisite Add-on](https://betternotificationsforwp.com/downloads/multisite/))**
|
137 |
+
|
138 |
+
* New Site Activated or Created - For Network Admin
|
139 |
+
* New User Created - For Network Admin
|
140 |
+
* Network Admin Email Change Attempted - For New Network Admin
|
141 |
+
* Network Admin Email Changed - For Old Network Admin
|
142 |
+
* New Site Activated or Created - For Site Admin
|
143 |
+
* Site Deleted - For Site Admin
|
144 |
+
* Site Admin Email Change Attempted - For New Site Admin
|
145 |
+
* Site Admin Email Changed - For Old Site Admin
|
146 |
+
* New Site Activated - For User
|
147 |
+
* New User Created - For User
|
148 |
+
* New User Invited to Site - For User
|
149 |
+
|
150 |
+
If you'd like to see a notification in the list above, please drop me a line in the forum and I'll see what I can do to add it.
|
151 |
+
|
152 |
+
If you want to let users create their own email notifications, check out my other plugin: [Content Notify](https://contentnotify.com).
|
153 |
+
|
154 |
+
> Like this plugin? Please leave it [a great review](https://wordpress.org/support/plugin/bnfw/reviews/?rate=5#new-post)! Don't think the plugin is worthy of 5 stars? Having problems? Let me know in the [forum](https://wordpress.org/support/plugin/bnfw/) and I'll do my best to help.
|
155 |
+
|
156 |
+
> DISCLAIMER
|
157 |
+
> This is an incredibly useful and highly rated plugin however, it's possible that overuse or abuse of this plugin could upset your users by sending them too many notifications. By downloading / installing / using this plugin, you take full responsibility of the management / quantity / types of notifications that are sent out from it including abiding by any SPAM laws in your country / operating areas, dealing with / responding to subscription / unsubscription requests, complaints, and so on. I accept no liability or responsibility for SPAM or abuse of this plugin from the user(s) of or anyone that may receive notifications as a result of the use of this plugin. I'm trusting you, please don't abuse your users.
|
158 |
+
|
159 |
+
|
160 |
+
|
161 |
+
== Installation ==
|
162 |
+
|
163 |
+
1. Upload the 'bnfw' plugin folder to the '/wp-content/plugins/' directory or install it via your WordPress Admin.
|
164 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
165 |
+
3. Use the settings in the new 'Notifications' Menu item in the sidebar to configure the plugin.
|
166 |
+
4. (Optional) Install a plugin to use SMTP instead of `wp_mail()`. I recommend [Post SMTP Mailer/Email Log](https://wordpress.org/plugins/post-smtp/).
|
167 |
+
5. Test by creating a notification with some [shortcodes](https://betternotificationsforwp.com/shortcodes/ "Shortcodes for use in Better Notifications for WP").
|
168 |
+
|
169 |
+
|
170 |
+
|
171 |
+
== Frequently Asked Questions ==
|
172 |
+
|
173 |
+
> Full Documentation for BNFW can be found [here](https://betternotificationsforwp.com/documentation/ "Documentation for Better Notifications for WP").
|
174 |
+
|
175 |
+
= Is this plugin compatible with the new Block Editor (Gutenberg) in WordPress 5? =
|
176 |
+
|
177 |
+
Yes and no. Most notifications work but full support can't be guaranteed for all notifications at the moment. Full support is on the roadmap but for the time being, I'd recommend using the [Classic Editor plugin](https://wordpress.org/plugins/classic-editor/) with BNFW.
|
178 |
+
|
179 |
+
= What are shortcodes? Where can I use them in this plugin? =
|
180 |
+
|
181 |
+
Shortcodes are text in square brackets that output content of some kind. For example, if you want to add the content of a post to a notification for 'New Post Published', you can use the `[post_content]` shortcode to display this in the email that is sent out.
|
182 |
+
|
183 |
+
Shortcodes can be used in the 'Subject' and 'Message Body' of your notifications, except for a select few (due to a restriction in WordPress).
|
184 |
+
|
185 |
+
> A handy list of shortcodes you can use is available [here](https://betternotificationsforwp.com/shortcodes/ "Shortcodes for use in Better Notifications for WP").
|
186 |
+
|
187 |
+
= What are some scenarios this plugin could be used for? =
|
188 |
+
|
189 |
+
* Outreach: A blog/news site with hundreds of subscribers and want to use it to alert them of new blog posts.
|
190 |
+
* Communication: A small, internal WordPress site and use it to alert staff of new posts or comments.
|
191 |
+
* Monitor: A website for an awesome new product or service and use it for notifications of pingbacks and trackbacks.
|
192 |
+
* Security: To receive alerts of password reset requests and their corresponding user.
|
193 |
+
|
194 |
+
The possibilities are endless!
|
195 |
+
|
196 |
+
= Does this plugin work with anti-spam plugins, such as Akismet? =
|
197 |
+
|
198 |
+
Yes! There is an option for suppressing comments marked as SPAM in the plugin settings.
|
199 |
+
|
200 |
+
= Does this plugin and the add-ons work with Multisite? =
|
201 |
+
|
202 |
+
Yes! Full support for WordPress Multisite was added in 1.6.13, alongside the release of the [Multisite Add-on](https://betternotificationsforwp.com/downloads/multisite/).
|
203 |
+
|
204 |
+
= Can users create their own email notifications? =
|
205 |
+
|
206 |
+
Not using BNFW. If you want to let users create their own email notifications, check out my other plugin: [Content Notify](https://contentnotify.com).
|
207 |
+
|
208 |
+
= Notifications aren't coming through! =
|
209 |
+
|
210 |
+
First of all, follow [this article](https://betternotificationsforwp.com/how-can-i-receive-the-best-support/) about how to find out what might be causing the problem. Additionally, please take a look at [this help document](https://betternotificationsforwp.com/documentation/getting-started/how-to-improve-email-delivery/) to see how you might improve email delivery when using Better Notifications for WP.
|
211 |
+
|
212 |
+
Many hosts place a limit on the number of emails that can be sent out within an hour so this may also cause some delay in emails arriving. [This article](https://support.mailpoet.com/knowledgebase/lists-of-hosts-and-their-sending-limits/) has a fairly extensive list of hosts and their corresponding email rate limits that's worth checking out. Alternatively, please check with your host directly to find out what your limit is.
|
213 |
+
|
214 |
+
If you're still having problems, please drop me a line in the [Free Support Forums](https://wordpress.org/support/plugin/bnfw) and I'll do my best to help.
|
215 |
+
|
216 |
+
= Some of my shortcodes aren't working! =
|
217 |
+
|
218 |
+
It's possible you're inserting a shortcode into a notification that cannot use it. For example: the 'New Category' email notification cannot use any of the author or time shortcodes as WordPress only stores the category name, category slug and category description in the database by default. It's also worth checking the spelling and underscores in any shortcodes as well as if they are wrapped in square brackets `[]`.
|
219 |
+
|
220 |
+
= Other emails from WordPress / other plugins are being messed up! =
|
221 |
+
|
222 |
+
WordPress, by default, sends all emails in Plain Text. If you'd like to include code or use the WYSIWYG editor as part of Better Notifications for WP in your emails, you can change this to HTML using the global setting in Better Notification for WordPress. This can be found under the 'Notifications > Settings' screen. Changing this global email format setting will affect how all emails are sent out from WordPress however, so you may experience formatting issues with emails sent out from other plugins if you change the email format setting in this way. If you do, change this setting to Plain Text. You can also set the email format on a per-notification basis when setting-up a new Notification. The caveat is that WordPress will only either allow setting the email format globally (for all emails) or individually for anything that's non-transactional.
|
223 |
+
|
224 |
+
= Custom Post Type 'X' isn't showing in the list of available custom post types =
|
225 |
+
|
226 |
+
This is most likely because it's `public` setting is set to `false`. Try changing this and see if it shows up in the list. If the custom post type has been created by a plugin and is set to private (such as [TablePress](https://wordpress.org/plugins/tablepress/ "TablePress")), you'll need to get in touch with the plugin author to see if they'll consider changing it to public instead so that BNFW can send out notifications for it.
|
227 |
+
|
228 |
+
= Can I translate this plugin? =
|
229 |
+
|
230 |
+
Yes, of course! The plugin is completely translation-friendly and if you send me your .po file, I'll make sure to include it in the plugin and credit you in the changelog.
|
231 |
+
|
232 |
+
|
233 |
+
|
234 |
+
== Screenshots ==
|
235 |
+
|
236 |
+
1. All Notifications
|
237 |
+
|
238 |
+
2. Add New / Edit Notification
|
239 |
+
|
240 |
+
|
241 |
+
|
242 |
+
== Changelog ==
|
243 |
+
|
244 |
+
= 1.8.4 - 12th August 2020 =
|
245 |
+
* Fixed: In certain situations, the password reset key would get modified when using the User Lost Password - For User notification.
|
246 |
+
* Fixed: An issue in the Custom Fields add-on where the Send to Author checkbox did not send a User Custom Field Updated notification to the user.
|
247 |
+
* Improved: Compatibility with the latest version of the [Digest add-on](https://betternotificationsforwp.com/downloads/digest/).
|
248 |
+
* Improved: Compatibility with the latest version of the [Multisite add-on](https://betternotificationsforwp.com/downloads/multisite/).
|
249 |
+
|
250 |
+
= 1.8.3 - 1st June 2020 =
|
251 |
+
* Fixed: If you activate BNFW and have not created any notifications, the default WordPress personal data export and erase request emails did not get sent.
|
252 |
+
* Added: Compatibility with the 1.2 release of the [Custom Fields add-on](https://betternotificationsforwp.com/downloads/custom-fields/).
|
253 |
+
|
254 |
+
= 1.8.2 - 14th May 2020 =
|
255 |
+
* Fixed: Email addresses stored in custom fields weren't being used in Comment notifications when the Custom Fields add-on was installed.
|
256 |
+
* Fixed: Two PHP notices showing above the subscriptions form when the Subscriptions add-on was installed.
|
257 |
+
* Fixed: 'The User Lost Password - For User' notification wasn't outputting shortcodes in the message subject.
|
258 |
+
* Fixed: 'The User Lost Password - For User' notification had an incorrect shortcode when inserting the default email content.
|
259 |
+
|
260 |
+
= 1.8.1 - 21st April 2020 =
|
261 |
+
* Added: Core changes to allow the [Global Override add-on](https://betternotificationsforwp.com/downloads/per-post-override/) to only send out notifications once.
|
262 |
+
* Fixed: A range of issues relating to the [Global Override add-on](https://betternotificationsforwp.com/downloads/per-post-override/).
|
263 |
+
|
264 |
+
= 1.8 - 8th April 2020 =
|
265 |
+
* POTENTIAL BREAKING CHANGES - Please edit and re-save each comment notification you have set-up to ensure that the correct notification is selected and saved.
|
266 |
+
* New: A huge overhaul of the comment notifications which now gives a great comment management workflow.
|
267 |
+
* New: New Comment, New Comment Awaiting Moderation, Comment Approved, and Comment Reply notifications are now availble to all posts, pages, custom post types, and media attachments.
|
268 |
+
* Improved: The 'Send this notification to the Author' checkbox has been overhauled to work better for the above notifications. See the relevant section in [this support document](https://betternotificationsforwp.com/documentation/notifications/adding-a-new-notification/) for more information.
|
269 |
+
|
270 |
+
= 1.7.7 - 27th March 2020 =
|
271 |
+
* New: Three new notifications! "New Media Published", "Media Updated", "Media Comment" - complete with new shortcodes for caption, alt text, dimensions, etc.
|
272 |
+
* New: "User Logged In - For Admin" notification - sends a notification to the admin when users log in.
|
273 |
+
* New: "User Logged In - For User" notification - sends a notification to the user when they log in.
|
274 |
+
* New: "Published to Trash" notification - sends a notification when a published post is moved to the trash.
|
275 |
+
* Improved: Support for plugins that allow users to be assigned to multiple user roles.
|
276 |
+
|
277 |
+
= 1.7.6 - 30th January 2020 =
|
278 |
+
* New Notification: New Comment Approved. This is sent after the comment has been approved.
|
279 |
+
* New: You can now output the description for the first available category in any new Post/Page/Custom Post Type notification, as well as to New Comment, Comment Awaiting Moderation, and Comment Reply notifications using the shortcode `[post_category_description]`. You can also use the `[post_category_slug]` notification to output the first available category slug.
|
280 |
+
* Added: Merged two pull requests that came in via the GitHub clone of this plugin relating to filters - ([#1](https://github.com/jackmcconnell/bnfw/pull/4/commits/501d7cdcb9855ad5aa08e4510f752f9ff319567f) and [#2](https://github.com/jackmcconnell/bnfw/pull/5)).
|
281 |
+
* Added: `$update` as 3rd parameter to `bnfw_trigger_insert_post` filter.
|
282 |
+
* Added: Additional translatable strings.
|
283 |
+
* Improved: 'Post Pending Review' notifications are now only sent for the first update to a post that is pending review. Subsequent updates will not trigger another notification.
|
284 |
+
* Fixed: Advanced Custom Fields (ACF) was triggering incorrect notifications when post/page/custom post types were submitted via a front-end form.
|
285 |
+
* Fixed: The `[post_excerpt]` shortcode now conforms to the `excerpt_length` filter.
|
286 |
+
* Fixed: Post Pending Review notifications were being sent in duplicate in certain situations.
|
287 |
+
* Fixed: Added an additional check to ensure a Multisite doesn't crash when BNFW is enabled on a site with no Administrator users.
|
288 |
+
* Fixed: Multisite notifications were showing the HTMl/Text options for notifications that could only support text.
|
289 |
+
|
290 |
+
= 1.7.5 - 23rd September 2019 =
|
291 |
+
* Added: Support for the new [Digest add-on](https://betternotificationsforwp.com/downloads/digest/)!
|
292 |
+
* Added: Support for some big changes coming to the [Custom Fields add-on](https://betternotificationsforwp.com/downloads/custom-fields/).
|
293 |
+
* Added: New Spanish translation.
|
294 |
+
* Fixed: An issue relating to shortcodes in the [Multisite add-on](https://betternotificationsforwp.com/downloads/multisite/).
|
295 |
+
* Fixed: Any 'Privacy' notifications are now hiding options that can't be overridden.
|
296 |
+
* Fixed: Disabling automatic paragraphs on the 'User Lost Password - For User' notification wasn't working.
|
297 |
+
|
298 |
+
= 1.7.4 - 19th August 2019 =
|
299 |
+
* New: You can now filter the mail headers in BNFW using `bnfw_mail_headers`. More details [here](https://betternotificationsforwp.com/documentation/actions-and-filters/).
|
300 |
+
* Added: Better support for the new Block Editor (Gutenberg) and all post/page/custom post type notifications. More and better support coming soon.
|
301 |
+
* Added: Support for the upcoming [Digest add-on](https://betternotificationsforwp.com/downloads/digest/).
|
302 |
+
* Fixed: The 'New User Registration - For Admin' notification was sending out the default WordPress notification as well as the BNFW notification in some cases.
|
303 |
+
* Fixed: The 'New Comment - Awaiting Moderation' notification was missing from the [Global Override add-on](https://betternotificationsforwp.com/downloads/per-post-override/).
|
304 |
+
* Fixed: A fatal error which occasionally occurred when a user changes their password on the front-end.
|
305 |
+
|
306 |
+
= 1.7.3 - 10th April 2019 =
|
307 |
+
* New: Notification - 'User Email Changed - For Admin'. This is sent to an admin after a user has successfully changed and confirmed a new email address.
|
308 |
+
* New: Notification - 'User Email Changed Confirmation - For User'. This is sent to a user in order for them to confirm a change to their email address.
|
309 |
+
* Added: You can now Enable or Disable a notification by hovering over it on the 'All Notifications' screen as well as enabling or disabling notifications in bulk from the Bulk Actions dropdown menu.
|
310 |
+
* Fixed: The 'User Email Changed - For User' and 'User Password Changed' notifications were no longer being disabled when attempting to override it since WordPress 5.0.
|
311 |
+
* Fixed: An issue where the new Block Editor (Gutenberg) caused double notifications upon publishing a post. Better support for Gutenberg will be coming this year. For now, it is recommended to use the [Classic Editor](https://wordpress.org/plugins/classic-editor/) plugin.
|
312 |
+
* Fixed: The 'New User Registration - For Admin' and 'New User Registration - For User' notifications should work better now after the changes that were made in 1.7.
|
313 |
+
* Fixed: The 'Send this Notification to the Author' checkbox was missing from the 'New Comment' notification.
|
314 |
+
* Fixed: The `[comment_moderation_link]` shortcode was outputting blank when used on the 'Post – New Comment Awaiting Moderation' notification and sent to non-Administrator user roles.
|
315 |
+
* Fixed: The `[edit_post]` shortcode was escaping ampersands in the URL.
|
316 |
+
|
317 |
+
= 1.7.2 - 21st November 2018 =
|
318 |
+
* Fixed: WYSIWYG editor and meta box compatibility for Gutenberg. After the public release of WordPress 5.0 BNFW will continue to use the Classic Editor, as opposed to the new block editor.
|
319 |
+
* Fixed: New Comment Awaiting Moderation notifications weren't being sent to the Post Author, where selected.
|
320 |
+
|
321 |
+
= 1.7.1 - 5th November 2018 =
|
322 |
+
* New: Full support for the new [Subscriptions (GDPR)](https://betternotificationsforwp.com/downloads/subscriptions-gdpr/) add-on.
|
323 |
+
* Fixed: Comments marked as SPAM were triggering the 'New Comment Awaiting Moderation' notification.
|
324 |
+
* Fixed: An issue relating to the 'New Comment Awaiting Moderation' notification not saving when used in conjunction with the Send To Any Email and Custom Fields add-ons.
|
325 |
+
* Fixed: A couple of minor javascript errors relating to BNFW add-ons.
|
326 |
+
|
327 |
+
= 1.7 - 5th September 2018 =
|
328 |
+
* A huge update packed full of new features and bug fixes, especially for those that like privacy and comment notifications!
|
329 |
+
* New: Six GDPR / Privacy Notifications. These allow you to override all the new notifications that WordPress 4.9.6 introduced relating to exporting and erasing user data. These are: Privacy – Confirm Action: Export Data Request – For User, Privacy – Confirm Action: Erase Data Request – For User, Privacy – Data Export – For User, Privacy – Data Erased – For User, Privacy – Confirm Action: Export Data Request – For Admin, Privacy – Confirm Action: Erase Data Request – For Admin.
|
330 |
+
* New: The 'New Comment / Awaiting Moderation' notification has now been split into two so you can have a notification for just New Comments, or just Comments Awaiting Moderation, or both! Can be used on Posts, Pages, and Custom Post Types.
|
331 |
+
* New: Shortcode - `[user_role]`. This outputs the user's role (or roles if assigned to more than one).
|
332 |
+
* New: Shortcode - `[first_image]`. Outputs the URL of the first image in a post/page/custom post.
|
333 |
+
* New: Shortcode - `[post_type_archive]`. Outputs the link for the post type / custom post type archive page.
|
334 |
+
* New: Shortcode - `[post_category_slug]`. Outputs the category slug of a post or the first category slug if the post is assigned to multiple categories.
|
335 |
+
* New: Shortcode - `[comment_moderation_link]`. This outputs the link to the WP Admin where you can moderate a new comment.
|
336 |
+
* New: Shortcode - `[comment_parent_content]`. This outputs the content of the parent comment when used in a Comment Reply notification.
|
337 |
+
* New: Three Comment Moderation Shortcodes - `[comment_moderation_approve]`, `[comment_moderation_spam]`, `[comment_moderation_delete]`. All for new comments. All should be self-explanatory.
|
338 |
+
* New: A new column is available in the 'All Notifications' screen that shows which users are excluded from a notification.
|
339 |
+
* Added: Dutch translation (props Piet).
|
340 |
+
* Changed: The 'New User Registration - For Admin' notification can now override/be overridden by notifications that use the `wp_new_user_notification_email_admin` filter, introduced in WordPress 4.9.
|
341 |
+
* Updated: Some of the default content that can be quickly added to a default notification was out-of-date.
|
342 |
+
* Changed: Freemius has now been removed in favour for the previous iteration of user tracking. This is now an opt-in checkbox on the Notifications > Settings page. Please consider checking this box to help make BNFW even better.
|
343 |
+
* Fixed: The 'Send this notification to the Author' checkbox still required a user or role to be entered into the 'Send To' box as well.
|
344 |
+
* Fixed: The `[edit_post]` shortcode wasn't outputting anything when a non-Editor role could post on the front-end.
|
345 |
+
* Fixed: Email addresses beginning with numbers weren't being saved when used in conjunction with the Send to Any Email add-on.
|
346 |
+
* Fixed: The SVG icon on WordPress.org wasn't exported correctly.
|
347 |
+
|
348 |
+
= 1.6.14 - 25th May 2018 =
|
349 |
+
* New: As part of my plans for implementing GDPR within BNFW, you can now exclude users and/or roles from your notifications in the new 'Except For' box.
|
350 |
+
* New: You can now include the post/page author in addition to the list of users and user roles in your notifications (not either/or).
|
351 |
+
* New: You can now enable the output of shortcodes again when using the `[post_content]` shortcode in your notifications via a new checkbox in the Settings screen.
|
352 |
+
* New: A list of available actions and filters in BNFW is now available in the [website documentation](https://betternotificationsforwp.com/documentation/actions-and-filters/).
|
353 |
+
* Updated: The user tracking SDK I use (Freemius) has been updated to allow Multisite network admins to opt-in an entire multisite or delegate opt-in to site-level admins.
|
354 |
+
* Fixed: Media inserted via the WYSIWYG editor wasn't showing. This should now be fixed.
|
355 |
+
* Fixed: An issue where the `[post_term taxonomy="X"]` shortcode could only be used once in a notification.
|
356 |
+
* Fixed: All date shortcodes are now translatable.
|
357 |
+
|
358 |
+
= 1.6.13 - 5th April 2018 =
|
359 |
+
* Added: Full support for the new [Multisite](https://betternotificationsforwp.com/downloads/multisite/) add-on.
|
360 |
+
* Fixed: Multisite-only - the user_id was being used instead of the username in the login URL in the Lost Password - For User notification.
|
361 |
+
* Fixed: Multisite-only - the New User Registration - For User notification wasn't working at all.
|
362 |
+
* Fixed: Multisite-only - Permalink shortcodes weren't using the correct structure and instead were using the default `?p=123` structure when used on sub-sites.
|
363 |
+
* Fixed: Some user shortcodes were only being outputted for the first user in a user role.
|
364 |
+
* Fixed: An occasional issue where some notifications weren't appearing for custom post types.
|
365 |
+
|
366 |
+
= 1.6.12 - 1st March 2018 =
|
367 |
+
* New: Lots of new global user shortcodes! It's always been a bit difficult to explain how the user shortcodes changes between notifications - sometimes they're for the author of a post, sometimes they're the recipient user. Now, all user shortcodes are used solely for the author and a new set of global user shortcodes are available for the recipient. Full details are on the [Shortcodes](https://betternotificationsforwp.com/documentation/notifications/shortcodes/) documentation page.
|
368 |
+
* Added: Preliminary changes for the upcoming [Multisite](https://betternotificationsforwp.com/downloads/multisite/) add-on.
|
369 |
+
|
370 |
+
= 1.6.11 - 13th February 2018 =
|
371 |
+
* Fixed: Update Reminder and Custom Field Updated notifications weren't showing for custom post types.
|
372 |
+
|
373 |
+
= 1.6.10 - 31st January 2018 =
|
374 |
+
* New: Faster customisation! You can now add the subject and message body from a default WordPress email to notifications. Just choose a default WordPress email and click the 'Insert Default Content' button next to the WYSIWYG editor when adding or editing a notification.
|
375 |
+
* New: If you want to allow other user roles to create or edit notifications, you can now grant them the 'bnfw' capability using a role editor.
|
376 |
+
* Added: A new notice will display at the top of all Notification screens explaining how you can improve email deliverability. You can dismiss this permanently at any time.
|
377 |
+
* Added: Inline help tips are now available when creating or editing a notification. Handy if you want to remember how something works but don't want to sift through the documentation.
|
378 |
+
* Added: Merged two pull request that came in via the GitHub clone of this plugin - ([#1](https://github.com/jackmcconnell/bnfw/pull/1) and [#2](https://github.com/jackmcconnell/bnfw/pull/2)).
|
379 |
+
* Added: For faster support, there is now a Priority Support menu item in the BNFW Notifications menu. Priority Support is available to customers with an active subscription to an add-on.
|
380 |
+
* Improved: All date related shortcodes now output in the date and time format set in Settings > General in the WordPress Admin.
|
381 |
+
* Improved: The list of available notifications has been re-ordered to make more sense.
|
382 |
+
* Improved: A warning will now show if the total user count in the Send To box is more than 200 users.
|
383 |
+
* Improved: Usage tracking will now only load on single sites and not on sites that are part of a Multisite network.
|
384 |
+
* Updated: Usage tracking SDK updated to the latest version.
|
385 |
+
* Fixed: Warnings were showing when posting a new comment on the front-end.
|
386 |
+
|
387 |
+
= 1.6.9 - 7th December 2017 =
|
388 |
+
* Merry Christmas & Happy New Year!
|
389 |
+
* New: Support for new [Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/).
|
390 |
+
* Fixed: An issue where the YouTube video wasn't showing properly on the BNFW WP.org plugin page.
|
391 |
+
|
392 |
+
= 1.6.8 - 23rd November 2017 =
|
393 |
+
* New: All shortcodes that are correctly registered within WordPress will now be stripped from the `[post_excerpt]` and `[post_content]` shortcodes so as to not cause layout or styling issues within your notifications.
|
394 |
+
* Added: A minimum PHP version of 5.6 is now required to run BNFW.
|
395 |
+
* Fixed: Compatibility with the [Reminders](https://betternotificationsforwp.com/downloads/update-reminder/) and [Conditional Notifications](https://betternotificationsforwp.com/downloads/conditional-notifications/) add-ons.
|
396 |
+
* Reminder: You may be asked to opt into plugin tracking when updating. Please consider doing so as it really helps with the development of the plugin. Full details on what is tracked is available on [this page](https://betternotificationsforwp.com/documentation/settings/what-information-will-be-tracked-by-opting-into-usage-tracking/).
|
397 |
+
|
398 |
+
= 1.6.7 - 10th August 2017 =
|
399 |
+
* New: Shortcode - `[current_time]` Will output the current time as per the settings in WordPress > Settings.
|
400 |
+
* New: Shortcode - `[current_date]` Will output the current date as per the settings in WordPress > Settings.
|
401 |
+
* New: Shortcode - `[admin_email]` Adds the email address of the main site admin as per the settings in WordPress > Settings.
|
402 |
+
* Fixed: BNFW now respects the post status of posts submitted via ACF's front-end forms (acf_form).
|
403 |
+
* Fixed: Privately Published posts that are updated now trigger the 'Post Updated' notification.
|
404 |
+
* Changed: The opt-in for plugin tracking in BNFW has changed. You may be asked to opt-in / opt-out when updating the plugin.
|
405 |
+
|
406 |
+
= 1.6.6 - 28th June 2017 =
|
407 |
+
* Fixed: New Comments on Custom Post Types weren't always sending notifications.
|
408 |
+
* Fixed: An issue where using the `bnfw_trigger_insert_post()` filter wasn't always working correctly.
|
409 |
+
* Fixed: An issue where checking a notification was disabled wasn't always working correctly.
|
410 |
+
* Added: Support for limiting 'New User Registration - For User' notifications to specific user roles in the recently updated [Conditional Notifications add-on](https://betternotificationsforwp.com/downloads/conditional-notifications/).
|
411 |
+
* Added: Support for huge logic enhancements to the soon to be updated [Global Override add-on](https://betternotificationsforwp.com/downloads/per-post-override/).
|
412 |
+
* Added: Support for the new 'User Login Reminder' notification in the soon to be updated [Reminders add-on](https://betternotificationsforwp.com/downloads/update-reminder/).
|
413 |
+
|
414 |
+
= 1.6.5 - 18th May 2017 =
|
415 |
+
* New: ACF Form compatibility has now been re-added! Props to @elliotcondon for the help.
|
416 |
+
* Remember to subscribe to the [mailing list](http://voltronik.us2.list-manage2.com/subscribe?u=57c012217219b2d81dda0085f&id=28eebdab28) if you want to be notified of new add-ons for BNFW and receive 10% off your first add-on purchase.
|
417 |
+
|
418 |
+
= 1.6.4 - 18th April 2017 =
|
419 |
+
* New: You can now use `[global_user_username]` in any notification to output the recipient's username.
|
420 |
+
* New: When a user is assigned to multiple roles which have been added to a notification, they will only receive the notification once and not once for each role that the notification is configured to send to.
|
421 |
+
* Improved: Clearer labelling on new custom post type notifications.
|
422 |
+
* Removed / Fixed: The addition of ACF Form compatibility in the last version was causing a range of issues, some minor, some serious. Until a more robust solution is found, this has been removed from the plugin whilst I try and get in touch with the author of ACF and work on a solution or collaboration.
|
423 |
+
* Fixed: The 'Send To' select box was being overlayed by the dropdown that shows when clicking in the box.
|
424 |
+
* Fixed: Searching for a user when a site has more than 200 users in the 'Send To' box now works as expected.
|
425 |
+
|
426 |
+
= 1.6.3 - 13th March 2017 =
|
427 |
+
* Added: Support for the new [Send to Any Email add-on](https://betternotificationsforwp.com/downloads/send-to-any-email/).
|
428 |
+
* Added: Support for Advanced Custom Field (ACF) front-end forms. Finally!
|
429 |
+
* Updated: French translation (props @matcho).
|
430 |
+
* Improved: The 'Lost Password' notifications now begin with 'User Lost Password' to make them easier to understand.
|
431 |
+
* Fixed: The 'Reply To' fields weren't saving correctly.
|
432 |
+
* Fixed: Ensure post shortcodes are rendered before sending (props @cliffpaulick).
|
433 |
+
* Fixed: A minor issue with the custom field selection box when using the [Custom Fields add-on](https://betternotificationsforwp.com/downloads/custom-fields/).
|
434 |
+
|
435 |
+
= 1.6.2 - 17th February 2017 =
|
436 |
+
* Fixed: The 'Shortcode Help' button wasn't working correctly for some of the new notifications.
|
437 |
+
|
438 |
+
= 1.6.1 - 17th February 2017 =
|
439 |
+
* New & Improved: The 'Password Changed - For User', 'Password Changed - For Admin', and 'User Email Changed - For User' notifications have now been fully implemented.
|
440 |
+
* New: You can now use `[post_term taxonomy="TAXONOMY_NAME"]` to output the term(s) from the chosen taxonomy.
|
441 |
+
* Improved: Any anti-SPAM plugin should now work with BNFW, not just Akismet.
|
442 |
+
* Improved: Emails sent via the "Send me a Test Email" button now prepend the Subject line with "Test Email: " so that you can tell which is a test notification and which is a real notification when using an email log plugin.
|
443 |
+
* Fixed: The Global User Shortcodes weren't outputting anything when used in the 'User Email Changed - For User' notification.
|
444 |
+
Fixed: When a 'Lost Password – For User' notification had been set-up but disabled, it wasn't disabling the default WordPress notification.
|
445 |
+
* Fixed: The 'WordPress Core Automatic Background Updates' notification wasn't working at all.
|
446 |
+
* Fixed: The Global User Shortcodes were being output incorrectly in test emails.
|
447 |
+
* Fixed: The `[featured_image]` shortcode was outputting the shortcode name as opposed to a blank when no featured image is set.
|
448 |
+
* Fixed: A number of warnings and notices relating to the 'Lost Password' notifications when on WordPress's Lost Password screen.
|
449 |
+
* Fixed: The 'Add-on Licenses' screen was displaying HTML characters where there shouldn't be any.
|
450 |
+
* Fixed: An error was occurring when triggering notifications when used in conjunction with the latest version of the Custom Fields add-on.
|
451 |
+
* Fixed: Some language translation strings were incorrect.
|
452 |
+
* Updated: EDD_SL_Plugin_Updater is now at the latest version for add-ons.
|
453 |
+
|
454 |
+
= 1.6 - 12th December 2016 =
|
455 |
+
* Merry Christmas & Happy New Year!
|
456 |
+
* New: Anonymous tracking of the features you use in BNFW is now an opt-in checkbox on the Notifications > Settings page. Please consider checking this box to help make BNFW even better. You'll also receive a 10% off coupon code when you sign-up to the [mailing list](http://voltronik.us2.list-manage2.com/subscribe?u=57c012217219b2d81dda0085f&id=28eebdab28) too.
|
457 |
+
* New: Notifications for privately published posts / pages / custom post types.
|
458 |
+
* New: Notification and accompanying shortcode for customising WordPress Core Automatic Background Updates (Success / Fail / Critical).
|
459 |
+
* New: Notification for User Password Changed.
|
460 |
+
* New: Notification for User Email Changed - For User.
|
461 |
+
* New: Shortcodes for showing the old and new user role when used in conjunction with the User Role Changed notifications.
|
462 |
+
* New: You can now add a 'Reply To' name and email address in the Additional Email Fields for all notifications that support it.
|
463 |
+
* New: You can now prevent yourself from receiving notifications of comments or replies to comments on one of your posts by combining the two checkboxes 'Send this notification to the Author only' and 'Do not send this Notification to the User that triggered it'.
|
464 |
+
* New: All transactional notifications can now be set to either HTML or Plain Text.
|
465 |
+
* Improved: Better compatibility with [Theme My Login](https://en-gb.wordpress.org/plugins/theme-my-login/).
|
466 |
+
* Improved: Re-worded a checkbox to be more understandable. It did say, "Disable this Notification for the User that triggered it", but now says, "Do not send this Notification to the User that triggered it".
|
467 |
+
* Improved: Compatibility with Mashshare.
|
468 |
+
* Fixed: Global User Shortcodes weren't being outputted correctly in the 'Lost Password - For User' notification.
|
469 |
+
* Fixed: Child themes weren't being registered correctly in the filter when using the front-end forms filter.
|
470 |
+
* Fixed: The number of options within notifications was being limited to the number of blog posts WordPress was set to show.
|
471 |
+
* Fixed: The 'Shortcode Help' button wasn't linking to the BNFW website correctly for some BNFW add-ons.
|
472 |
+
|
473 |
+
= 1.5.3 - 13th September 2016 =
|
474 |
+
* Fixed: User Roles in the 'User Roles / Users' admin column were being displayed only in lowercase.
|
475 |
+
* Fixed: The `[wp_capabilities]` shortcode wasn't outputting properly. It now displays the higher-level capabilities that the user has.
|
476 |
+
|
477 |
+
= 1.5.2 - 6th September 2016 =
|
478 |
+
* Fixed: Custom User Roles were showing 0 users in the 'To' field.
|
479 |
+
* Added: Generic CSS classes to BNFW admin.
|
480 |
+
* Updated: German Translation to show English in certain places where translation text breaks the WP Admin UI (props @helmi).
|
481 |
+
* Full code review and submission to WordPress VIP!
|
482 |
+
|
483 |
+
= 1.5.1 - 5th August 2016 =
|
484 |
+
* Fixed: 'Text' mode in the WYSIWYG editor didn't show any buttons when the BNFW Per-post Override Add-on was activated.
|
485 |
+
|
486 |
+
= 1.5 - 25th July 2016 =
|
487 |
+
* New: Global Site Shortcodes! Include these in any notification to output the site title (`[global_site_title]`), site tagline (`[global_site_tagline]`), or site URL (`[global_site_url]`).
|
488 |
+
* New: Global User Shortcodes! Include these in any notification to output the user's first name (`[global_user_firstname]`), user's last name (`[global_user_lastname]`), or user's email address (`[global_user_email]`).
|
489 |
+
* New: The 'User Role Changed' notification has been split into two transactional notifications - one that can be sent to users and one that can be sent to admins.
|
490 |
+
* New: Shortcode `[featured_image]`. Outputs the URL for the featured image (if one is available).
|
491 |
+
* New: Shortcode `[user_avatar]`. Outputs the User's avatar when used in a capable notification.
|
492 |
+
* New: Shortcode `[commenter_avatar]`. Outputs the comment author's avatar for comment-based notifications.
|
493 |
+
* Improved: 'Comment Reply' notifications are now available to use for Pages and Custom Post Types.
|
494 |
+
* Improved: When sending notifications to user roles in the 'To' field, it will now show how many users are in that role.
|
495 |
+
* Improved: The 'Lost Password - For User', 'User Role Changed - For Admin', and 'User Role Changed - For User' notifications now have the option to 'Stop additional paragraph and line break HTML from being inserted into my notifications' via the checkbox below the WYSIWYG editor on the Add New / Edit Notification screen.
|
496 |
+
|
497 |
+
= 1.4.1 - 3rd June 2016 =
|
498 |
+
* Fixed: Multiple emails were being sent for a single notification for a small number of users. After lots of hunting and lots of testing, I'm hoping this should now be fixed.
|
499 |
+
* Fixed: The 'User Role Changed' notification was broken after the update to WordPress 4.5.
|
500 |
+
* Fixed: The 'Password Reset - For User' and 'New User - Post-registration Email' notifications were being sent in HTML but with all carriage returns / line breaks stripped out.
|
501 |
+
* Fixed: User shortcodes for new comments on custom post types weren't being outputted properly.
|
502 |
+
* Fixed: The 'Notifications' BNFW menu item in the Sidebar in the WordPress Admin was showing for non-admins.
|
503 |
+
* Added: German Translation (props Michael Schröttle).
|
504 |
+
|
505 |
+
= 1.4 - 8th April 2016 =
|
506 |
+
* New: Shortcode `[post_slug]`. Output the post slug.
|
507 |
+
* New: Shortcode `[edit_post]`. Outputs the link to edit the post / page / custom post.
|
508 |
+
* New: Shortcode `[post_parent_permalink]`. Outputs a permalink to the post / page / custom post's parent item.
|
509 |
+
* New: Shortcode `[author_link]`. Outputs a link to the post / page / custom post's author archive.
|
510 |
+
* New: You can now add the collection of User Shortcodes to the 'Lost Password - For User' email.
|
511 |
+
* New: Support for the 'O2' plugin, when used in conjunction with the 'P2' Theme via a filter. Please see the [documentation](https://betternotificationsforwp.com/documentation/) for details.
|
512 |
+
* Improved: Users were getting confused with the 'Welcome Email', thinking it operated like that in the 'SB Welcome Email Editor' plugin. The name of this notification has been changed from 'New User - Welcome Email' to 'New User - Post-registration Email' to help differentiate its functionality in BNFW.
|
513 |
+
* Improved: The screen where you add your license(s) after purchasing any BNFW add-on(s) is now called 'Add-on Licenses', instead of going to 'Settings' and adding them there.
|
514 |
+
* Improved: Setting a notification to send to 'the author only' now shows a label in the 'User Roles / Users' column in the 'All Notifications' screen.
|
515 |
+
* Improved: 'New Comment / Awaiting Moderation', 'New Trackback', and 'New Pingback' notifications now show the 'Send this notification to the Author only' checkbox.
|
516 |
+
* Improved: If a notification is present but disabled, the default WordPress notification (if there is one), will not be sent.
|
517 |
+
* Fixed: New Post Published notifications weren't being sent if you had the Per-post Override add-on installed.
|
518 |
+
|
519 |
+
= 1.3.9.5 - 26th February 2016 =
|
520 |
+
* Fixed: New Post Published notifications were triggering multiple times due to `auto_draft_to_publish`.
|
521 |
+
|
522 |
+
= 1.3.9.4 - 15th February 2016 =
|
523 |
+
* Filter improvements for the new [Per-post Override add-on](https://betternotificationsforwp.com/downloads/per-post-override/).
|
524 |
+
|
525 |
+
= 1.3.9.3 - 12th February 2016 =
|
526 |
+
* General bug fixes and updates relating to future add-ons and the new [Per-post Override add-on](https://betternotificationsforwp.com/downloads/per-post-override/) which allows you to override your notifications for each post / page / custom post.
|
527 |
+
* Added: New Post Published notifications now trigger on `auto_draft_to_publish`. This may or may not effect you if you publish through a front-end form or from an app.
|
528 |
+
|
529 |
+
= 1.3.9.2 - 29th January 2016 =
|
530 |
+
* The [Add-on Store](https://betternotificationsforwp.com/downloads/) is now live! Looking for some extra, premium functionality in your notifications? You might find an add-on for it!
|
531 |
+
* New: A filter is now available for adding compatibility to themes for creating posts using `wp_insert_post`. Please see the bottom of the [FAQ](https://wordpress.org/plugins/bnfw/faq/) for details.
|
532 |
+
* Fixed: 'User Role Changed' notifications were being triggered for new users.
|
533 |
+
* Fixed: The label for custom taxonomies was showing in the Notification select box even if you didn't have any.
|
534 |
+
* Fixed: A warning was showing when no 'CC' or 'BCC' details were added but the 'Name' and 'From' details were specified.
|
535 |
+
* Fixed: A warning was showing after a taxonomy was deleted but a notification existed for it.
|
536 |
+
* Fixed: Replaced select2 v4 script for full version for better compatibility with other plugins.
|
537 |
+
* Fixed: The javascript in the plugin is now translatable.
|
538 |
+
* Added: French translation - props Mygale06.
|
539 |
+
|
540 |
+
= 1.3.9.1 - 9th January 2016 =
|
541 |
+
* Fixed: Missing shortcode link for new 'User Role Changed' notification.
|
542 |
+
* Fixed: Duplicate 'User Role Changed' listing in the Notification select box.
|
543 |
+
|
544 |
+
= 1.3.9 - 9th January 2016 =
|
545 |
+
* Happy New Year!
|
546 |
+
* New: Transactional notification for when a User Role Changed. This is sent to the user when their User Role is changed.
|
547 |
+
* Fixed: Ensure that at least one User or User Role is selected before saving a notification.
|
548 |
+
* Fixed: select2 v4 update and compatibility with Ultimate Member and ACF Pro.
|
549 |
+
|
550 |
+
= 1.3.8 - 16th December 2015 =
|
551 |
+
* Fixed: Notifications weren't being sent out at all. After lots of testing, I think this should now be resolved.
|
552 |
+
* Fixed: An issue where quotes in the Subject field were causing part of/all the field content to be removed.
|
553 |
+
* Improved: If you have more than 100 users on your site, the User Roles / Users select box will show the first 100 users only. You can search through the rest by typing the first character of a username in the select box and it will show you any matching users.
|
554 |
+
|
555 |
+
= 1.3.7 - 11th December 2015 =
|
556 |
+
* Fixed: An issue where EDD_SL_Plugin_Updater class was already declared by another plugin.
|
557 |
+
|
558 |
+
= 1.3.6 - 11th December 2015 =
|
559 |
+
* Merry Christmas to you all!
|
560 |
+
* New: Password Reset notifications can now be in HTML or Plain Text.
|
561 |
+
* Improved: The Users / User Role select box now utilises live search instead of showing all users in a long list if you have more than 100 users. This should be a huge performance improvement if your site has a lot of users.
|
562 |
+
* Updated: select2.js library updated to v4.
|
563 |
+
* Fixed: Compatibility with password reset notifications in WordPress 4.1.0 and below.
|
564 |
+
* Fixed: An issue where the 'Tag' label was showing incorrectly in the 'All Notifications' screen.
|
565 |
+
* I've added a short disclaimer to the [Description Tab](https://wordpress.org/plugins/bnfw/) regarding SPAM and overuse/abuse of this plugin which I recommend a quick read through.
|
566 |
+
|
567 |
+
= 1.3.5 - 9th October 2015 =
|
568 |
+
* Fixed: A large bug that was causing issues with Password URL shortcodes in the 'New User Registration - For User' and 'Password Reset - For User' notifications.
|
569 |
+
* Fixed: An issue where the 'disabled wpautop' checkbox was appearing on transactional emails.
|
570 |
+
* Fixed: Some labels in the 'All Notifications' screen weren't formatted correctly.
|
571 |
+
* Fixed: Translations weren't referenced correctly. Auto-translation will be [done by WordPress.org automatically](https://make.wordpress.org/plugins/2015/09/01/plugin-translations-on-wordpress-org/) at some point in the future.
|
572 |
+
|
573 |
+
= 1.3.4 - 2nd October 2015 =
|
574 |
+
* New: Choose automatic or manual paragraph / line breaks in the WYSIWYG editor. This fixes an issue where they were inserted automatically when they weren't desired. The checkbox for this is below the WYSIWYG editor.
|
575 |
+
* New: You can now add images to your notifications using the 'Add Media' button above the WYSIWYG editor.
|
576 |
+
* New: Portuguese Brazil translation for v1.3.3 (props Glayton Caixeta).
|
577 |
+
* New: BNFW now has it's own [website](https://betternotificationsforwp.com/)!
|
578 |
+
* New: Buttons have been added linking to the Documentation and Shortcode Help sections of the website next to the WYSIWYG editor.
|
579 |
+
* New: Support for premium add-ons, coming very soon! More info and sign-up for updates [here](https://wordpress.org/support/topic/add-ons-are-coming-sign-up-for-updates).
|
580 |
+
* New: Added a video overview of BNFW showing it's features and functionality to the main plugin page and website.
|
581 |
+
* Fixed: The 'New User Registration - For User' now works again after WordPress 4.3 broke it.
|
582 |
+
* Fixed: HTML using quotes was being escaped in emails.
|
583 |
+
* Fixed: The 'Settings' sidebar menu item wasn't highlighting properly.
|
584 |
+
* I also added all previous release dates to this changelog.
|
585 |
+
* If you liked this plugin, please feel free to leave an honest [review](https://wordpress.org/support/view/plugin-reviews/bnfw?filter=5#postform). If you didn't or have a problem, please send me a message in the [Support Forum](https://wordpress.org/support/plugin/bnfw).
|
586 |
+
|
587 |
+
= 1.3.3 - 22nd August 2015 =
|
588 |
+
* New: You can now send a notification to the Post Author only, where a notification supports it.
|
589 |
+
* New: There is now an option in the Settings screen to globally set WordPress to send emails in either HTML or Plain Text. Please read the [FAQ](https://wordpress.org/plugins/bnfw/faq/) for more information about this as there is a small caveat.
|
590 |
+
* New: Support for WordPress 4.3.
|
591 |
+
* New: Pending posts that are changed to Published now trigger the 'New Post / Page Notification'.
|
592 |
+
* Improved: Scheduled notifications now trigger two notifications, one for when they're saved as Scheduled ('Post Scheduled' / 'Page Scheduled') and one for when they're actually published ('New Post Published / New Page Published').
|
593 |
+
* Improved: Swapped the green tick for a dashicons tick for a slightly more speedier, native-feeling plugin.
|
594 |
+
* Improved: Reduced the flash of hidden elements when loading the New / Edit Notification screen.
|
595 |
+
* Fixed: WordPress 4.3 doesn't allow passwords to be automatically created for new users and will instead, send them to a password generator page. The `[password]` shortcode has been replaced with `[password_url]`. `[password]` should still work though so it won't break your existing notifications.
|
596 |
+
* Fixed: Some output was being showed when WP_DEBUG was enabled.
|
597 |
+
* Fixed: Removed the 'slug' field when enabled from Screen Options.
|
598 |
+
|
599 |
+
= 1.3.2 - 20th July 2015 =
|
600 |
+
* Fixed: Replaced a deprecated function which might cause a warning to show when `WP_DEBUG` was enabled.
|
601 |
+
|
602 |
+
= 1.3.1 - 18th July 2015 =
|
603 |
+
* Fixed: The P2 theme wasn't triggering new post or comment notifications.
|
604 |
+
* Fixed: Sometimes the shortcode help link at the bottom of the notification editor wouldn't link to the help page properly.
|
605 |
+
|
606 |
+
= 1.3 - 2nd July 2015 =
|
607 |
+
* New: Option to disable notifications going to the user that triggered them.
|
608 |
+
* New: Comment Reply Notification. This is a transactional notification that will only trigger when replying to the original comment (i.e. Up to 2-levels deep).
|
609 |
+
* New: New Shortcode: Update Author. Use `[post_update_author]` in any Post or Page notifications to see which user updated the post.
|
610 |
+
* New: Choose between sending the notification as plain text or HTML.
|
611 |
+
* New: A basic implementation of shortcode help has been added into the plugin. Click the link below the message body editor to see which shortcodes can be used for the currently selected notification.
|
612 |
+
* Improved: The 'New User Registration' (For Admin & User) and 'Welcome Email' notifications now allow you to use all of the 'User' shortcodes.
|
613 |
+
* Fixed: Formatting in emails sent from other plugins were being effected by BNFW.
|
614 |
+
* Fixed: Notifications for Categories, Terms and Tags weren't getting triggered.
|
615 |
+
* Fixed: Notifications weren't getting triggered when using the P2 theme (please see the [FAQ](https://wordpress.org/plugins/bnfw/faq/) for more information about this).
|
616 |
+
* Fixed: Additional Email fields were being shown for transactional notifications that couldn't use them.
|
617 |
+
|
618 |
+
= 1.2 - 19th May 2015 =
|
619 |
+
* New: WYSIWYG Editor for notifications!
|
620 |
+
* New: From Name, From Email, CC and BCC options are now available to use for each notification!
|
621 |
+
* New: 'Send Me a Test Email' button. Save your notification first and then send yourself a test email! This will only go to you and not to any of the other users selected in the notification. Shortcodes will not be expanded but will be shown in place.
|
622 |
+
* Improved: The User Role / Users drop down box has been unified for simplicity.
|
623 |
+
* Fixed: Lost Password (For User) notifications were being sent in plain text.
|
624 |
+
* Fixed: Not all custom post types were showing when setting up a new notification.
|
625 |
+
* Fixed: Notifications for New Terms not generating notification emails.
|
626 |
+
* Fixed: Custom Taxonomies missing from columns in the All Notifications screen.
|
627 |
+
* Fixed: Added a space after lists of tags, categories, and terms.
|
628 |
+
* Thank you again for all of your support, feedback, and awesome reviews. You people make WordPress great!
|
629 |
+
|
630 |
+
= 1.1.5.3 - 21st April 2015 =
|
631 |
+
* Compatibility with WordPress 4.2.
|
632 |
+
|
633 |
+
= 1.1.5.2 - 15th April 2015 =
|
634 |
+
* Fixed: Custom Post Type Pending Posts not being sent.
|
635 |
+
* Fixed: Post excerpt not outputting anything.
|
636 |
+
* Removed: `[closedpostboxes_page], [rich_editing], and [admin_color]` as was a bit defunct and causing issues.
|
637 |
+
* Changed: `[post_author]` now outputs the display name instead of the author ID.
|
638 |
+
* Improved: Clarity of custom post type and taxonomy labels.
|
639 |
+
|
640 |
+
= 1.1.5.1 - 13th April 2015 =
|
641 |
+
* Fix for Custom Post Type notifications not populating shortcodes.
|
642 |
+
* Fix for Custom Taxonomy terms not sending out notification emails.
|
643 |
+
|
644 |
+
= 1.1.5 - 10th April 2015 =
|
645 |
+
* New Shortcode: [permalink].
|
646 |
+
* New Notifications: 'Scheduled Posts' and 'Scheduled Pages'.
|
647 |
+
* New Shortcodes for the above Notifications: [post_scheduled_date] and [post_scheduled_date_gmt].
|
648 |
+
* New Notification: 'New Page Published'.
|
649 |
+
* New Notification: 'Page 'Updated'.
|
650 |
+
* New Notification: 'Page Pending Review'.
|
651 |
+
* New Notification: 'New Page - Comment'.
|
652 |
+
* Fixed: A few bugs reported via the forums and some others that i've found - thanks everyone!
|
653 |
+
|
654 |
+
= 1.1 - 16th March 2015 =
|
655 |
+
* Lots of cool new stuff and more to come soon!
|
656 |
+
* Transactional notifications (notifications intended only for the end user) have been added as a new group in the notifications select box.
|
657 |
+
* New Notification: Post Pending Review (for all post types).
|
658 |
+
* New Notification: New User Registration (Transactional).
|
659 |
+
* New Notification: Password Reset (Transactional).
|
660 |
+
* New Notification: New User Welcome Email (Transactional).
|
661 |
+
* Added an option to enable or disable each notification.
|
662 |
+
* Better support for custom taxonomies and terms.
|
663 |
+
* Fixed: A few PHP warnings were showing when using `WP_DEBUG`.
|
664 |
+
* Fixed: HTML tags being stripped from `[post_content]` and `[comment_content]`.
|
665 |
+
* Removed: Some WordPress Multisite shortcodes that didn't work properly. Proper support for Multisite will come later.
|
666 |
+
* If you liked this plugin, please leave a review. If you didn't or have a problem, please send me a message in the Support Forum.
|
667 |
+
|
668 |
+
= 1.0.2 - 17th January 2015 =
|
669 |
+
* Bug fix for `[ID]` shortcode not outputting anything.
|
670 |
+
* Bug fix for `[post_category]` showing as empty.
|
671 |
+
* Added tags shortcode for use in certain notifications using `[post_tag]`.
|
672 |
+
|
673 |
+
= 1.0.1 - 21th December 2014 =
|
674 |
+
* Bug fix for notifications not being sent to custom user roles or individual users of custom roles.
|
675 |
+
* Added a 'Notification Type' column to the notifications screen.
|
676 |
+
* Renamed 'User Roles' column in notifications screen to 'User Roles/Users'.
|
677 |
+
|
678 |
+
= 1.0 - 17th December 2014 =
|
679 |
+
* First major release - we're no longer in beta!
|
680 |
+
* Total overhaul. The plugin has been completely re-written.
|
681 |
+
* Auto-importer: Your old notifications will be imported when updating the plugin.
|
682 |
+
* New 'Generator' for easily creating and editing your notifications.
|
683 |
+
* More options and notification types as per feedback via the forums - thanks everyone!
|
684 |
+
* Granular control over choosing either user roles or individual users you'd like to send a notification to.
|
685 |
+
* Fully translatable.
|
686 |
+
* Loads of bugfixes and improvements.
|
687 |
+
|
688 |
+
= 0.2.1 beta - 4th June 2013 =
|
689 |
+
* Minor Bugfixes
|
690 |
+
|
691 |
+
= 0.2 beta - 8th April 2013 =
|
692 |
+
* Added an option to suppress SPAM comment notifications.
|
693 |
+
|
694 |
+
= 0.1 beta - 25th March 2013 =
|
695 |
+
* Initial version of the plugin.
|
696 |
+
* Settings page for configuring notification types for roles.
|
697 |
+
* Email Templates page for customising emails using HTML and shortcodes.
|
698 |
+
|
699 |
+
|
700 |
+
|
701 |
+
== Upgrade Notice ==
|
702 |
+
|
703 |
+
= Migrating from 0.2.1 to 1.0 =
|
704 |
+
|
705 |
+
Version 1 features an auto-importer which should migrate all of your notifications from any previous versions of the plugin to 1.0.
|
706 |
+
Please ensure that you check, double check and test your notifications before and after upgrading.
|
assets/js/bnfw.js
CHANGED
@@ -40,7 +40,7 @@ jQuery(document).ready(function($) {
|
|
40 |
}
|
41 |
|
42 |
var notification = $( '#notification' ).val();
|
43 |
-
|
44 |
if ( 'new-comment' === notification || 'approve' === check_comment[0] || 'moderate-comment' === notification ) {
|
45 |
$( '#current-user' ).show();
|
46 |
}
|
@@ -50,10 +50,12 @@ jQuery(document).ready(function($) {
|
|
50 |
var notification = $('#notification').val();
|
51 |
|
52 |
$("#notification, .bnfw-select2").select2();
|
|
|
53 |
$(".user-select2").select2({
|
54 |
tags: BNFW.enableTags,
|
55 |
-
|
56 |
} );
|
|
|
57 |
$(".user-ajax-select2").select2( {
|
58 |
ajax: {
|
59 |
url: ajaxurl,
|
@@ -81,7 +83,7 @@ jQuery(document).ready(function($) {
|
|
81 |
|
82 |
toggle_fields();
|
83 |
|
84 |
-
|
85 |
|
86 |
if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
|
87 |
'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
|
@@ -131,8 +133,8 @@ jQuery(document).ready(function($) {
|
|
131 |
toggle_users();
|
132 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
133 |
} else if ('user-login' === notification){
|
134 |
-
|
135 |
-
|
136 |
} else {
|
137 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
138 |
toggle_fields();
|
@@ -161,7 +163,7 @@ jQuery(document).ready(function($) {
|
|
161 |
var $this = $(this),
|
162 |
notification = $this.val();
|
163 |
|
164 |
-
|
165 |
|
166 |
if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
|
167 |
'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
|
@@ -212,8 +214,8 @@ jQuery(document).ready(function($) {
|
|
212 |
toggle_users();
|
213 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
214 |
} else if ('user-login' === notification){
|
215 |
-
|
216 |
-
|
217 |
} else {
|
218 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
219 |
$('#user-password-msg').hide();
|
@@ -267,8 +269,8 @@ jQuery(document).ready(function($) {
|
|
267 |
case 'email-changed':
|
268 |
case 'email-changing':
|
269 |
case 'new-user':
|
270 |
-
|
271 |
-
|
272 |
case 'welcome-email':
|
273 |
case 'user-role':
|
274 |
case 'admin-role':
|
@@ -307,7 +309,7 @@ jQuery(document).ready(function($) {
|
|
307 |
case 'comment':
|
308 |
notification_slug = 'new-comment';
|
309 |
break;
|
310 |
-
|
311 |
notification_slug = 'approve-comment';
|
312 |
break;
|
313 |
case 'moderate':
|
40 |
}
|
41 |
|
42 |
var notification = $( '#notification' ).val();
|
43 |
+
var check_comment = notification.split('-');
|
44 |
if ( 'new-comment' === notification || 'approve' === check_comment[0] || 'moderate-comment' === notification ) {
|
45 |
$( '#current-user' ).show();
|
46 |
}
|
50 |
var notification = $('#notification').val();
|
51 |
|
52 |
$("#notification, .bnfw-select2").select2();
|
53 |
+
|
54 |
$(".user-select2").select2({
|
55 |
tags: BNFW.enableTags,
|
56 |
+
tokenSeparators: BNFW.enabletokenSeparators
|
57 |
} );
|
58 |
+
|
59 |
$(".user-ajax-select2").select2( {
|
60 |
ajax: {
|
61 |
url: ajaxurl,
|
83 |
|
84 |
toggle_fields();
|
85 |
|
86 |
+
var check_comment = notification.split('-');
|
87 |
|
88 |
if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
|
89 |
'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
|
133 |
toggle_users();
|
134 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
135 |
} else if ('user-login' === notification){
|
136 |
+
$('#cc, #bcc, #users, #exclude-users, #current-user, #post-author').hide();
|
137 |
+
$('#toggle-fields').show();
|
138 |
} else {
|
139 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
140 |
toggle_fields();
|
163 |
var $this = $(this),
|
164 |
notification = $this.val();
|
165 |
|
166 |
+
var check_comment = notification.split('-');
|
167 |
|
168 |
if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
|
169 |
'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
|
214 |
toggle_users();
|
215 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
216 |
} else if ('user-login' === notification){
|
217 |
+
$('#cc, #bcc, #users, #exclude-users, #current-user, #post-author').hide();
|
218 |
+
$('#toggle-fields').show();
|
219 |
} else {
|
220 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
221 |
$('#user-password-msg').hide();
|
269 |
case 'email-changed':
|
270 |
case 'email-changing':
|
271 |
case 'new-user':
|
272 |
+
case 'user-login':
|
273 |
+
case 'admin-user-login':
|
274 |
case 'welcome-email':
|
275 |
case 'user-role':
|
276 |
case 'admin-role':
|
309 |
case 'comment':
|
310 |
notification_slug = 'new-comment';
|
311 |
break;
|
312 |
+
case 'approve':
|
313 |
notification_slug = 'approve-comment';
|
314 |
break;
|
315 |
case 'moderate':
|
bnfw.php
CHANGED
@@ -1,12 +1,14 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Plugin Name: Better Notifications for WP
|
4 |
* Plugin URI: https://wordpress.org/plugins/bnfw/
|
5 |
* Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
|
6 |
-
* Version: 1.8.
|
|
|
|
|
7 |
* Author: Made with Fuel
|
8 |
-
* Author URI: https://
|
9 |
-
* Author Email: hello@betternotificationsforwp.com
|
10 |
* License: GPLv2 or later
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
* Text Domain: bnfw
|
@@ -165,13 +167,13 @@ class BNFW {
|
|
165 |
add_action( 'user_register' , array( $this, 'user_register' ) );
|
166 |
|
167 |
add_action( 'user_register' , array( $this, 'welcome_email' ) );
|
168 |
-
|
169 |
if ( is_plugin_active('members/members.php') ) {
|
170 |
add_action( 'profile_update' , array( $this, 'user_role_added' ), 10, 2 );
|
171 |
}else{
|
172 |
add_action( 'set_user_role' , array( $this, 'user_role_changed' ), 10, 3 );
|
173 |
}
|
174 |
-
|
175 |
add_action( 'wp_login' , array( $this, 'user_login' ),10,2);
|
176 |
|
177 |
if ( version_compare( $wp_version, '4.4', '>=' ) ) {
|
@@ -420,7 +422,7 @@ class BNFW {
|
|
420 |
}
|
421 |
}
|
422 |
|
423 |
-
|
424 |
/**
|
425 |
* Fires when a post is moved publish to trash.
|
426 |
*
|
@@ -431,7 +433,7 @@ class BNFW {
|
|
431 |
}
|
432 |
$post_id = $post->ID;
|
433 |
$post_type = $post->post_type;
|
434 |
-
|
435 |
if (BNFW_Notification::POST_TYPE != $post_type) {
|
436 |
$this->send_notification_async('trash-' . $post_type, $post_id);
|
437 |
}
|
@@ -456,7 +458,7 @@ class BNFW {
|
|
456 |
}
|
457 |
}
|
458 |
|
459 |
-
|
460 |
/**
|
461 |
* On Media Published.
|
462 |
*
|
@@ -465,12 +467,12 @@ class BNFW {
|
|
465 |
|
466 |
public function new_publish_media_notification( $post_id ) {
|
467 |
$post_type = get_post_type($post_id);
|
468 |
-
|
469 |
if (BNFW_Notification::POST_TYPE != $post_type && $post_type == 'attachment') {
|
470 |
-
$this->send_notification_async( 'new-media', $post_id );
|
471 |
}
|
472 |
}
|
473 |
-
|
474 |
/**
|
475 |
* On Media Attachment Data Update.
|
476 |
*
|
@@ -480,7 +482,7 @@ class BNFW {
|
|
480 |
public function media_attachment_data_update_notification($post_id ) {
|
481 |
$post_type = get_post_type($post_id);
|
482 |
if (BNFW_Notification::POST_TYPE != $post_type && $post_type == 'attachment') {
|
483 |
-
$this->send_notification_async( 'update-media', $post_id );
|
484 |
}
|
485 |
}
|
486 |
|
@@ -517,11 +519,11 @@ class BNFW {
|
|
517 |
}
|
518 |
|
519 |
$post = get_post( $comment->comment_post_ID );
|
520 |
-
|
521 |
$notification_type = 'approve-'.$post->post_type.'-comment';
|
522 |
|
523 |
$this->send_notification( $notification_type, $comment->comment_ID );
|
524 |
-
|
525 |
// Send new comment notification after comment approve
|
526 |
$notification_type = 'new-comment'; // old notification name
|
527 |
|
@@ -530,7 +532,7 @@ class BNFW {
|
|
530 |
}
|
531 |
|
532 |
$this->send_notification( $notification_type, $comment->comment_ID );
|
533 |
-
|
534 |
// Send comment reply notification after comment approve.
|
535 |
$this->commentsReply($comment->comment_ID);
|
536 |
}
|
@@ -556,9 +558,9 @@ class BNFW {
|
|
556 |
if ( 'post' != $post->post_type ) {
|
557 |
$notification_type = 'comment-' . $post->post_type;
|
558 |
}
|
559 |
-
|
560 |
$this->send_notification( $notification_type, $comment_id );
|
561 |
-
|
562 |
// comment reply notification.
|
563 |
$this->commentsReply($comment_id);
|
564 |
}
|
@@ -573,7 +575,7 @@ class BNFW {
|
|
573 |
public function commentsReply($comment_id) {
|
574 |
$the_comment = get_comment( $comment_id );
|
575 |
$post = get_post( $the_comment->comment_post_ID );
|
576 |
-
|
577 |
// comment reply notification.
|
578 |
if ( $this->can_send_comment_notification( $the_comment ) ) {
|
579 |
if ( $the_comment->comment_parent > 0 ) {
|
@@ -689,6 +691,9 @@ class BNFW {
|
|
689 |
}
|
690 |
} else {
|
691 |
add_filter( 'wp_mail_content_type', array( $this, 'set_text_content_type' ) );
|
|
|
|
|
|
|
692 |
}
|
693 |
} else {
|
694 |
if ( $this->notifier->notification_exists( 'user-password', false ) ) {
|
@@ -894,11 +899,11 @@ class BNFW {
|
|
894 |
public function user_login( $user_name, $user_data ) {
|
895 |
$user_id = $user_data->ID;
|
896 |
$notifications = $this->notifier->get_notifications( 'user-login' );
|
897 |
-
|
898 |
foreach ( $notifications as $notification ) {
|
899 |
$this->engine->send_user_login_email( $this->notifier->read_settings( $notification->ID ), get_userdata( $user_id ) );
|
900 |
}
|
901 |
-
|
902 |
$this->user_login_admin_notification($user_id);
|
903 |
}
|
904 |
|
@@ -910,7 +915,7 @@ class BNFW {
|
|
910 |
*/
|
911 |
public function user_login_admin_notification( $user_id ) {
|
912 |
$notifications = $this->notifier->get_notifications( 'admin-user-login' );
|
913 |
-
|
914 |
foreach ( $notifications as $notification ) {
|
915 |
$this->engine->send_user_login_email_for_admin( $this->notifier->read_settings( $notification->ID ), get_userdata( $user_id ) );
|
916 |
}
|
@@ -1002,14 +1007,14 @@ class BNFW {
|
|
1002 |
* @param array $old_roles Old User role
|
1003 |
*/
|
1004 |
public function user_role_added( $user_id, $old_user_data ) {
|
1005 |
-
|
1006 |
if(isset($_POST['members_user_roles']) && !empty($_POST['members_user_roles'])){
|
1007 |
// Get the current user roles.
|
1008 |
$old_roles = (array) $old_user_data->roles;
|
1009 |
|
1010 |
// Sanitize the posted roles.
|
1011 |
$new_roles = array_map( 'members_sanitize_role', $_POST['members_user_roles'] );
|
1012 |
-
|
1013 |
sort($old_roles);
|
1014 |
sort($new_roles);
|
1015 |
$old_roles_str = implode('', $old_roles);
|
@@ -1052,7 +1057,7 @@ class BNFW {
|
|
1052 |
}
|
1053 |
}
|
1054 |
}
|
1055 |
-
|
1056 |
/**
|
1057 |
* Sanitizes a role name. This is a wrapper for the `sanitize_key()` WordPress function. Only
|
1058 |
* alphanumeric characters and underscores are allowed. Hyphens are also replaced with underscores.
|
@@ -1148,7 +1153,7 @@ class BNFW {
|
|
1148 |
$new_content = $this->handle_user_request_notification( $notification_name, $field, $email_data );
|
1149 |
break;
|
1150 |
}
|
1151 |
-
|
1152 |
if(!empty($new_content)){
|
1153 |
return $new_content;
|
1154 |
}else{
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Plugin Name: Better Notifications for WP
|
5 |
* Plugin URI: https://wordpress.org/plugins/bnfw/
|
6 |
* Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
|
7 |
+
* Version: 1.8.4
|
8 |
+
* Requires at least: 4.8
|
9 |
+
* Requires PHP: 5.6
|
10 |
* Author: Made with Fuel
|
11 |
+
* Author URI: https://madewithfuel.com/
|
|
|
12 |
* License: GPLv2 or later
|
13 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
14 |
* Text Domain: bnfw
|
167 |
add_action( 'user_register' , array( $this, 'user_register' ) );
|
168 |
|
169 |
add_action( 'user_register' , array( $this, 'welcome_email' ) );
|
170 |
+
|
171 |
if ( is_plugin_active('members/members.php') ) {
|
172 |
add_action( 'profile_update' , array( $this, 'user_role_added' ), 10, 2 );
|
173 |
}else{
|
174 |
add_action( 'set_user_role' , array( $this, 'user_role_changed' ), 10, 3 );
|
175 |
}
|
176 |
+
|
177 |
add_action( 'wp_login' , array( $this, 'user_login' ),10,2);
|
178 |
|
179 |
if ( version_compare( $wp_version, '4.4', '>=' ) ) {
|
422 |
}
|
423 |
}
|
424 |
|
425 |
+
|
426 |
/**
|
427 |
* Fires when a post is moved publish to trash.
|
428 |
*
|
433 |
}
|
434 |
$post_id = $post->ID;
|
435 |
$post_type = $post->post_type;
|
436 |
+
|
437 |
if (BNFW_Notification::POST_TYPE != $post_type) {
|
438 |
$this->send_notification_async('trash-' . $post_type, $post_id);
|
439 |
}
|
458 |
}
|
459 |
}
|
460 |
|
461 |
+
|
462 |
/**
|
463 |
* On Media Published.
|
464 |
*
|
467 |
|
468 |
public function new_publish_media_notification( $post_id ) {
|
469 |
$post_type = get_post_type($post_id);
|
470 |
+
|
471 |
if (BNFW_Notification::POST_TYPE != $post_type && $post_type == 'attachment') {
|
472 |
+
$this->send_notification_async( 'new-media', $post_id );
|
473 |
}
|
474 |
}
|
475 |
+
|
476 |
/**
|
477 |
* On Media Attachment Data Update.
|
478 |
*
|
482 |
public function media_attachment_data_update_notification($post_id ) {
|
483 |
$post_type = get_post_type($post_id);
|
484 |
if (BNFW_Notification::POST_TYPE != $post_type && $post_type == 'attachment') {
|
485 |
+
$this->send_notification_async( 'update-media', $post_id );
|
486 |
}
|
487 |
}
|
488 |
|
519 |
}
|
520 |
|
521 |
$post = get_post( $comment->comment_post_ID );
|
522 |
+
|
523 |
$notification_type = 'approve-'.$post->post_type.'-comment';
|
524 |
|
525 |
$this->send_notification( $notification_type, $comment->comment_ID );
|
526 |
+
|
527 |
// Send new comment notification after comment approve
|
528 |
$notification_type = 'new-comment'; // old notification name
|
529 |
|
532 |
}
|
533 |
|
534 |
$this->send_notification( $notification_type, $comment->comment_ID );
|
535 |
+
|
536 |
// Send comment reply notification after comment approve.
|
537 |
$this->commentsReply($comment->comment_ID);
|
538 |
}
|
558 |
if ( 'post' != $post->post_type ) {
|
559 |
$notification_type = 'comment-' . $post->post_type;
|
560 |
}
|
561 |
+
|
562 |
$this->send_notification( $notification_type, $comment_id );
|
563 |
+
|
564 |
// comment reply notification.
|
565 |
$this->commentsReply($comment_id);
|
566 |
}
|
575 |
public function commentsReply($comment_id) {
|
576 |
$the_comment = get_comment( $comment_id );
|
577 |
$post = get_post( $the_comment->comment_post_ID );
|
578 |
+
|
579 |
// comment reply notification.
|
580 |
if ( $this->can_send_comment_notification( $the_comment ) ) {
|
581 |
if ( $the_comment->comment_parent > 0 ) {
|
691 |
}
|
692 |
} else {
|
693 |
add_filter( 'wp_mail_content_type', array( $this, 'set_text_content_type' ) );
|
694 |
+
if('text' == $setting['email-formatting'] ){
|
695 |
+
$message = strip_tags($message);
|
696 |
+
}
|
697 |
}
|
698 |
} else {
|
699 |
if ( $this->notifier->notification_exists( 'user-password', false ) ) {
|
899 |
public function user_login( $user_name, $user_data ) {
|
900 |
$user_id = $user_data->ID;
|
901 |
$notifications = $this->notifier->get_notifications( 'user-login' );
|
902 |
+
|
903 |
foreach ( $notifications as $notification ) {
|
904 |
$this->engine->send_user_login_email( $this->notifier->read_settings( $notification->ID ), get_userdata( $user_id ) );
|
905 |
}
|
906 |
+
|
907 |
$this->user_login_admin_notification($user_id);
|
908 |
}
|
909 |
|
915 |
*/
|
916 |
public function user_login_admin_notification( $user_id ) {
|
917 |
$notifications = $this->notifier->get_notifications( 'admin-user-login' );
|
918 |
+
|
919 |
foreach ( $notifications as $notification ) {
|
920 |
$this->engine->send_user_login_email_for_admin( $this->notifier->read_settings( $notification->ID ), get_userdata( $user_id ) );
|
921 |
}
|
1007 |
* @param array $old_roles Old User role
|
1008 |
*/
|
1009 |
public function user_role_added( $user_id, $old_user_data ) {
|
1010 |
+
|
1011 |
if(isset($_POST['members_user_roles']) && !empty($_POST['members_user_roles'])){
|
1012 |
// Get the current user roles.
|
1013 |
$old_roles = (array) $old_user_data->roles;
|
1014 |
|
1015 |
// Sanitize the posted roles.
|
1016 |
$new_roles = array_map( 'members_sanitize_role', $_POST['members_user_roles'] );
|
1017 |
+
|
1018 |
sort($old_roles);
|
1019 |
sort($new_roles);
|
1020 |
$old_roles_str = implode('', $old_roles);
|
1057 |
}
|
1058 |
}
|
1059 |
}
|
1060 |
+
|
1061 |
/**
|
1062 |
* Sanitizes a role name. This is a wrapper for the `sanitize_key()` WordPress function. Only
|
1063 |
* alphanumeric characters and underscores are allowed. Hyphens are also replaced with underscores.
|
1153 |
$new_content = $this->handle_user_request_notification( $notification_name, $field, $email_data );
|
1154 |
break;
|
1155 |
}
|
1156 |
+
|
1157 |
if(!empty($new_content)){
|
1158 |
return $new_content;
|
1159 |
}else{
|
includes/admin/class-bnfw-notification.php
CHANGED
@@ -70,7 +70,7 @@ class BNFW_Notification {
|
|
70 |
'show_ui' => true,
|
71 |
'show_in_menu' => true,
|
72 |
'menu_icon' => 'dashicons-email-alt',
|
73 |
-
'menu_position' =>
|
74 |
'rewrite' => false,
|
75 |
'map_meta_cap' => false,
|
76 |
'capabilities' => array(
|
@@ -750,10 +750,16 @@ foreach ( $taxs as $tax ) {
|
|
750 |
if ( ! current_user_can( 'bnfw' ) ) {
|
751 |
return;
|
752 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
753 |
|
754 |
$setting = array(
|
755 |
'notification' => sanitize_text_field( $_POST['notification'] ),
|
756 |
-
'subject' =>
|
757 |
'message' => $_POST['notification_message'],
|
758 |
'disabled' => isset( $_POST['disabled'] ) ? sanitize_text_field( $_POST['disabled'] ) : 'false',
|
759 |
'email-formatting' => isset( $_POST['email-formatting'] ) ? sanitize_text_field( $_POST['email-formatting'] ) : 'html',
|
70 |
'show_ui' => true,
|
71 |
'show_in_menu' => true,
|
72 |
'menu_icon' => 'dashicons-email-alt',
|
73 |
+
'menu_position' => 101,
|
74 |
'rewrite' => false,
|
75 |
'map_meta_cap' => false,
|
76 |
'capabilities' => array(
|
750 |
if ( ! current_user_can( 'bnfw' ) ) {
|
751 |
return;
|
752 |
}
|
753 |
+
|
754 |
+
if ( isset( $_POST['digest-interval'] ) && 'no' != $_POST['digest-interval']) {
|
755 |
+
$subject = $_POST['subject'];
|
756 |
+
}else{
|
757 |
+
$subject = sanitize_text_field( $_POST['subject'] );
|
758 |
+
}
|
759 |
|
760 |
$setting = array(
|
761 |
'notification' => sanitize_text_field( $_POST['notification'] ),
|
762 |
+
'subject' => $subject,
|
763 |
'message' => $_POST['notification_message'],
|
764 |
'disabled' => isset( $_POST['disabled'] ) ? sanitize_text_field( $_POST['disabled'] ) : 'false',
|
765 |
'email-formatting' => isset( $_POST['email-formatting'] ) ? sanitize_text_field( $_POST['email-formatting'] ) : 'html',
|
includes/engine/class-bnfw-engine.php
CHANGED
@@ -1,1470 +1,1550 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* BNFW Engine
|
4 |
*
|
5 |
* @since 1.0
|
6 |
*/
|
7 |
-
|
8 |
class BNFW_Engine {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
}
|
345 |
}
|
346 |
-
|
347 |
-
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
}
|
350 |
}
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
break;
|
518 |
-
case 'new-user':
|
519 |
-
case 'user-role':
|
520 |
-
case 'admin-role':
|
521 |
-
case 'password-changed':
|
522 |
-
// handle users (lost password and new user registration)
|
523 |
-
$message = $this->user_shortcodes( $message, $extra_data );
|
524 |
-
break;
|
525 |
-
|
526 |
-
case 'email-changed':
|
527 |
-
case 'user-password':
|
528 |
-
// handle users (lost password and new user registration)
|
529 |
-
$message = $this->user_shortcodes( $message, $extra_data, 'email_' );
|
530 |
-
break;
|
531 |
-
|
532 |
-
case 'new-category':
|
533 |
-
// handle new category
|
534 |
-
$message = $this->taxonomy_shortcodes( $message, 'category', $extra_data );
|
535 |
-
break;
|
536 |
-
|
537 |
-
case 'new-post_tag':
|
538 |
-
// handle new tag
|
539 |
-
$message = $this->taxonomy_shortcodes( $message, 'post_tag', $extra_data );
|
540 |
-
break;
|
541 |
-
|
542 |
-
case 'core-updated':
|
543 |
-
// handle core updated type
|
544 |
-
$message = $this->core_updated_shortcodes( $message, $extra_data );
|
545 |
-
break;
|
546 |
-
|
547 |
-
case 'data-export':
|
548 |
-
// handle data export email
|
549 |
-
$message = $this->data_export_shortcodes( $message, $extra_data );
|
550 |
-
break;
|
551 |
-
|
552 |
-
case 'data-erased':
|
553 |
-
// handle data export email
|
554 |
-
$message = $this->data_erased_shortcodes( $message, $extra_data );
|
555 |
-
break;
|
556 |
-
|
557 |
-
case 'new-media':
|
558 |
-
case 'update-media':
|
559 |
-
$message = $this->post_shortcodes( $message, $extra_data );
|
560 |
-
$post = get_post( $extra_data );
|
561 |
-
if ( $post instanceof WP_Post ) {
|
562 |
-
$message = $this->user_shortcodes( $message, $post->post_author );
|
563 |
-
}
|
564 |
-
break;
|
565 |
-
|
566 |
-
default:
|
567 |
-
$type = explode( '-', $notification, 2 );
|
568 |
-
if ( 'newterm' == $type[0] ) {
|
569 |
-
// handle new terms
|
570 |
-
$message = $this->taxonomy_shortcodes( $message, $type[1], $extra_data );
|
571 |
-
|
572 |
-
} elseif ( 'new' == $type[0] || 'update' == $type[0] || 'pending' == $type[0] || 'future' == $type[0] || 'private' == $type[0] || 'trash' == $type[0]) {
|
573 |
-
// handle new, update and pending posts
|
574 |
-
$post_types = get_post_types( array( 'public' => true ), 'names' );
|
575 |
-
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
576 |
-
|
577 |
-
if ( in_array( $type[1], $post_types ) ) {
|
578 |
-
$message = $this->post_shortcodes( $message, $extra_data );
|
579 |
-
$post = get_post( $extra_data );
|
580 |
-
if ( $post instanceof WP_Post ) {
|
581 |
-
$message = $this->user_shortcodes( $message, $post->post_author );
|
582 |
-
}
|
583 |
-
}
|
584 |
-
} elseif ( 'comment' == $type[0] || 'moderate' == $type[0] || 'commentreply' == $type[0] ) {
|
585 |
-
$message = $this->comment_shortcodes( $message, $extra_data );
|
586 |
-
$comment = get_comment( $extra_data );
|
587 |
-
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
588 |
-
if ( 0 != $comment->user_id ) {
|
589 |
-
$message = $this->user_shortcodes( $message, $comment->user_id );
|
590 |
-
}
|
591 |
-
}elseif ( 'approve' === $type[0] ) {
|
592 |
-
// handle Approve comments notification
|
593 |
-
$message = $this->comment_shortcodes( $message, $extra_data );
|
594 |
-
$comment = get_comment( $extra_data );
|
595 |
-
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
596 |
-
if ( 0 != $comment->user_id ) {
|
597 |
-
$message = $this->user_shortcodes( $message, $comment->user_id );
|
598 |
-
}
|
599 |
-
break;
|
600 |
-
} elseif ( 'ca' === $type[0] ) {
|
601 |
-
$message = $this->confirm_action_shortcodes( $message, $extra_data );
|
602 |
-
$message = $this->handle_global_user_shortcodes( $message, $extra_data['email'] );
|
603 |
-
} elseif ( 'uc' === $type[0] ) {
|
604 |
-
$message = $this->confirmed_action_shortcodes( $message, $extra_data );
|
605 |
-
$message = $this->handle_global_user_shortcodes( $message, $extra_data['admin_email'] );
|
606 |
-
}
|
607 |
-
break;
|
608 |
-
}
|
609 |
-
|
610 |
-
$message = $this->global_shortcodes( $message );
|
611 |
-
|
612 |
-
$message = apply_filters( 'bnfw_shortcodes', $message, $notification, $extra_data, $this );
|
613 |
-
return $message;
|
614 |
-
}
|
615 |
-
|
616 |
-
/**
|
617 |
-
* Handle Global shortcodes.
|
618 |
-
*
|
619 |
-
* @since 1.5
|
620 |
-
*
|
621 |
-
* @param string $message String with shortcodes.
|
622 |
-
*
|
623 |
-
* @return string String after processing global shortcodes.
|
624 |
-
*/
|
625 |
-
private function global_shortcodes( $message ) {
|
626 |
-
$message = str_replace( '[global_site_title]', get_bloginfo( 'name' ), $message );
|
627 |
-
$message = str_replace( '[global_site_tagline]', get_bloginfo( 'description' ), $message );
|
628 |
-
$message = str_replace( '[global_site_url]', get_bloginfo( 'url' ), $message );
|
629 |
-
|
630 |
-
$message = str_replace( '[current_time]', current_time( get_option( 'time_format' ) ), $message );
|
631 |
-
$message = str_replace( '[current_date]', date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message );
|
632 |
-
$message = str_replace( '[admin_email]', get_option( 'admin_email' ), $message );
|
633 |
-
|
634 |
-
return $message;
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Handle Global shortcodes.
|
639 |
-
*
|
640 |
-
* @param string $message Message.
|
641 |
-
* @param string $email Email.
|
642 |
-
*
|
643 |
-
* @return string
|
644 |
-
*/
|
645 |
-
public function handle_global_shortcodes( $message, $email ) {
|
646 |
-
$message = $this->global_shortcodes( $message );
|
647 |
-
|
648 |
-
return $this->handle_global_user_shortcodes( $message, $email );
|
649 |
-
}
|
650 |
-
|
651 |
-
/**
|
652 |
-
* Handle Global User Shortcodes.
|
653 |
-
*
|
654 |
-
* @param string $message String to be processed.
|
655 |
-
* @param string $email Email of the user.
|
656 |
-
*
|
657 |
-
* @return string Processed string.
|
658 |
-
*/
|
659 |
-
public function handle_global_user_shortcodes( $message, $email ) {
|
660 |
-
$user = get_user_by( 'email', $email );
|
661 |
-
|
662 |
-
if ( false === $user ) {
|
663 |
-
$message = str_replace( '[global_user_firstname]', $email, $message );
|
664 |
-
$message = str_replace( '[global_user_lastname]', $email, $message );
|
665 |
-
$message = str_replace( '[global_user_username]', $email, $message );
|
666 |
-
} else {
|
667 |
-
$message = str_replace( '[global_user_firstname]', $user->first_name, $message );
|
668 |
-
$message = str_replace( '[global_user_lastname]', $user->last_name, $message );
|
669 |
-
$message = str_replace( '[global_user_username]', $user->user_login, $message );
|
670 |
-
|
671 |
-
$message = $this->user_shortcodes( $message, $user->ID, 'email_' );
|
672 |
-
}
|
673 |
-
|
674 |
-
$message = str_replace( '[global_user_email]', $email, $message );
|
675 |
-
|
676 |
-
return $message;
|
677 |
-
}
|
678 |
-
|
679 |
-
/**
|
680 |
-
* Handle media post shortcodes.
|
681 |
-
*
|
682 |
-
* @since 1.0
|
683 |
-
* @param string $message
|
684 |
-
* @param int $post_id
|
685 |
-
* @return string
|
686 |
-
*/
|
687 |
-
public function media_post_shortcodes( $message, $post ) {
|
688 |
-
$post_content = $this->may_be_strip_shortcode( $post->post_content );
|
689 |
-
$post_content = apply_filters( 'the_content', $post_content );
|
690 |
-
$post_content = str_replace( ']]>', ']]>', $post_content );
|
691 |
-
$message = str_replace( '[ID]', $post->ID, $message );
|
692 |
-
$message = str_replace( '[media_date]', bnfw_format_date( $post->post_date ), $message );
|
693 |
-
$message = str_replace( '[media_date_gmt]', bnfw_format_date( $post->post_date_gmt ), $message );
|
694 |
-
$message = str_replace( '[media_description]', $post_content, $message );
|
695 |
-
$message = str_replace( '[media_title]', $post->post_title, $message );
|
696 |
-
$message = str_replace( '[media_alt_text]',get_post_meta($post->ID,'_wp_attachment_image_alt',true),$message);
|
697 |
-
$message = str_replace( '[media_caption]', $this->may_be_strip_shortcode( get_the_excerpt( $post ) ), $message );
|
698 |
-
$message = str_replace( '[media_status]', $post->post_status, $message );
|
699 |
-
$message = str_replace( '[media_modified]', bnfw_format_date( $post->post_modified ), $message );
|
700 |
-
$message = str_replace( '[media_modified_gmt]', bnfw_format_date( $post->post_modified_gmt ), $message );
|
701 |
-
$message = str_replace( '[media_content_filtered]', $post->post_content_filtered, $message );
|
702 |
-
$message = str_replace( '[media_type]', $post->post_type, $message );
|
703 |
-
$message = str_replace( '[media_mime_type]', $post->post_mime_type, $message );
|
704 |
-
$message = str_replace( '[media_slug]', $post->post_name, $message );
|
705 |
-
$dimensions = get_post_meta($post->ID,'_wp_attachment_metadata',true);
|
706 |
-
$media_dimensions = $dimensions['width'].' x '.$dimensions['height'];
|
707 |
-
$message = str_replace( '[media_dimensions]', $media_dimensions, $message );
|
708 |
-
$user_info = get_userdata( $post->post_author );
|
709 |
-
$message = str_replace( '[media_author]', $user_info->display_name, $message );
|
710 |
-
|
711 |
return $message;
|
712 |
}
|
713 |
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
* @since 1.0
|
718 |
-
* @param string $message
|
719 |
-
* @param int $post_id
|
720 |
-
* @return string
|
721 |
-
*/
|
722 |
-
public function post_shortcodes( $message, $post_id ) {
|
723 |
-
$post = get_post( $post_id );
|
724 |
-
|
725 |
-
if ( ! $post instanceof WP_Post ) {
|
726 |
-
return $message;
|
727 |
-
}
|
728 |
-
|
729 |
-
if($post->post_type == 'attachment'){
|
730 |
-
$message = $this->media_post_shortcodes($message, $post);
|
731 |
-
}
|
732 |
-
|
733 |
-
$post_content = $this->may_be_strip_shortcode( $post->post_content );
|
734 |
-
$post_content = apply_filters( 'the_content', $post_content );
|
735 |
-
$post_content = str_replace( ']]>', ']]>', $post_content );
|
736 |
-
|
737 |
-
$message = str_replace( '[ID]', $post->ID, $message );
|
738 |
-
$message = str_replace( '[post_date]', bnfw_format_date( $post->post_date ), $message );
|
739 |
-
$message = str_replace( '[post_date_gmt]', bnfw_format_date( $post->post_date_gmt ), $message );
|
740 |
-
$message = str_replace( '[post_content]', $post_content, $message );
|
741 |
-
$message = str_replace( '[post_title]', $post->post_title, $message );
|
742 |
-
$message = str_replace( '[post_excerpt]', $this->may_be_strip_shortcode( get_the_excerpt( $post ) ), $message );
|
743 |
-
$message = str_replace( '[post_status]', $post->post_status, $message );
|
744 |
-
$message = str_replace( '[comment_status]', $post->comment_status, $message );
|
745 |
-
$message = str_replace( '[ping_status]', $post->ping_status, $message );
|
746 |
-
$message = str_replace( '[post_password]', $post->post_password, $message );
|
747 |
-
$message = str_replace( '[post_name]', $post->post_name, $message );
|
748 |
-
$message = str_replace( '[post_slug]', $post->post_name, $message );
|
749 |
-
$message = str_replace( '[to_ping]', $post->to_ping, $message );
|
750 |
-
$message = str_replace( '[pinged]', $post->pinged, $message );
|
751 |
-
$message = str_replace( '[post_modified]', bnfw_format_date( $post->post_modified ), $message );
|
752 |
-
$message = str_replace( '[post_modified_gmt]', bnfw_format_date( $post->post_modified_gmt ), $message );
|
753 |
-
$message = str_replace( '[post_content_filtered]', $post->post_content_filtered, $message );
|
754 |
-
$message = str_replace( '[post_parent]', $post->post_parent, $message );
|
755 |
-
$message = str_replace( '[post_parent_permalink]', get_permalink( $post->post_parent ), $message );
|
756 |
-
$message = str_replace( '[guid]', $post->guid, $message );
|
757 |
-
$message = str_replace( '[menu_order]', $post->menu_order, $message );
|
758 |
-
$message = str_replace( '[post_type]', $post->post_type, $message );
|
759 |
-
$message = str_replace( '[post_mime_type]', $post->post_mime_type, $message );
|
760 |
-
$message = str_replace( '[comment_count]', $post->comment_count, $message );
|
761 |
-
$message = str_replace( '[permalink]', get_permalink( $post->ID ), $message );
|
762 |
-
$message = str_replace( '[post_type_archive]', get_post_type_archive_link($post->post_type), $message );
|
763 |
-
|
764 |
-
$message = str_replace( '[edit_post]', $this->get_edit_post_link( $post->ID, 'return' ), $message );
|
765 |
-
|
766 |
-
$featured_image = '';
|
767 |
-
if ( has_post_thumbnail( $post->ID ) ) {
|
768 |
-
$image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
|
769 |
-
if ( is_array( $image_url ) ) {
|
770 |
-
$featured_image = $image_url[0];
|
771 |
-
}
|
772 |
-
}
|
773 |
-
$message = str_replace( '[featured_image]', $featured_image, $message );
|
774 |
-
|
775 |
-
$message = str_replace( '[first_image]', $this->get_first_image($post->post_content), $message );
|
776 |
-
|
777 |
-
if ( 'future' == $post->post_status ) {
|
778 |
-
$message = str_replace( '[post_scheduled_date]', bnfw_format_date( $post->post_date ), $message );
|
779 |
-
$message = str_replace( '[post_scheduled_date_gmt]', bnfw_format_date( $post->post_date_gmt ), $message );
|
780 |
-
} else {
|
781 |
-
$message = str_replace( '[post_scheduled_date]', 'Published', $message );
|
782 |
-
$message = str_replace( '[post_scheduled_date_gmt]', 'Published', $message );
|
783 |
-
}
|
784 |
-
|
785 |
-
$categories = wp_get_post_categories( $post_id, array( 'fields' => 'all' ) );
|
786 |
-
|
787 |
-
$message = str_replace( '[post_category]', implode( ', ', wp_list_pluck( $categories, 'name' ) ), $message );
|
788 |
-
|
789 |
-
if ( count( $categories ) > 0 ) {
|
790 |
-
$message = str_replace(
|
791 |
-
array(
|
792 |
-
'[post_category_slug]',
|
793 |
-
'[post_category_description]',
|
794 |
-
),
|
795 |
-
array(
|
796 |
-
$categories[0]->slug,
|
797 |
-
$categories[0]->description,
|
798 |
-
),
|
799 |
-
$message
|
800 |
-
);
|
801 |
-
}
|
802 |
-
|
803 |
-
$tag_list = implode( ', ', wp_get_post_tags( $post_id, array( 'fields' => 'names' ) ) );
|
804 |
-
$message = str_replace( '[post_tag]', $tag_list, $message );
|
805 |
-
|
806 |
-
$user_info = get_userdata( $post->post_author );
|
807 |
-
$message = str_replace( '[post_author]', $user_info->display_name, $message );
|
808 |
-
|
809 |
-
$message = str_replace( '[author_link]', get_author_posts_url( $post->post_author ), $message );
|
810 |
-
|
811 |
-
if ( $last_id = get_post_meta( $post->ID, '_edit_last', true ) ) {
|
812 |
-
if ( $post->post_author != $last_id ) {
|
813 |
-
$last_user_info = get_userdata( $last_id );
|
814 |
-
} else {
|
815 |
-
$last_user_info = $user_info;
|
816 |
-
}
|
817 |
-
|
818 |
-
$message = str_replace( '[post_update_author]', $last_user_info->display_name, $message );
|
819 |
-
}
|
820 |
-
|
821 |
-
$message = str_replace( '[post_term', '[post_term id="' . $post_id . '"', $message );
|
822 |
-
add_shortcode( 'post_term', array( $this, 'post_term_shortcode_handler' ) );
|
823 |
-
$message = do_shortcode( $message );
|
824 |
-
remove_shortcode( 'post_term', array( $this, 'post_term_shortcode_handler' ) );
|
825 |
-
|
826 |
-
return apply_filters( 'bnfw_shortcodes_post', $message, $post_id );
|
827 |
-
}
|
828 |
-
|
829 |
-
/**
|
830 |
-
* Retrieves the edit post link for post.
|
831 |
-
*
|
832 |
-
* This is a copy of the built-in function without the user check.
|
833 |
-
*
|
834 |
-
* Can be used within the WordPress loop or outside of it. Can be used with
|
835 |
-
* pages, posts, attachments, and revisions.
|
836 |
-
*
|
837 |
-
* @param int|WP_Post $id Optional. Post ID or post object. Default is the global `$post`.
|
838 |
-
* @param string $context Optional. How to output the '&' character. Default '&'.
|
839 |
-
* @return string|null The edit post link for the given post. null if the post type is invalid or does
|
840 |
-
* not allow an editing UI.
|
841 |
-
*/
|
842 |
-
public function get_edit_post_link( $id = 0, $context = 'display' ) {
|
843 |
-
if ( ! $post = get_post( $id ) )
|
844 |
-
return;
|
845 |
-
|
846 |
-
if ( 'revision' === $post->post_type )
|
847 |
-
$action = '';
|
848 |
-
elseif ( 'display' == $context )
|
849 |
-
$action = '&action=edit';
|
850 |
-
else
|
851 |
-
$action = '&action=edit';
|
852 |
-
|
853 |
-
$post_type_object = get_post_type_object( $post->post_type );
|
854 |
-
if ( !$post_type_object )
|
855 |
-
return;
|
856 |
-
|
857 |
-
if ( $post_type_object->_edit_link ) {
|
858 |
-
$link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) );
|
859 |
-
} else {
|
860 |
-
$link = '';
|
861 |
-
}
|
862 |
-
|
863 |
-
/**
|
864 |
-
* Filters the post edit link.
|
865 |
-
*
|
866 |
-
* @since 2.3.0
|
867 |
-
*
|
868 |
-
* @param string $link The edit link.
|
869 |
-
* @param int $post_id Post ID.
|
870 |
-
* @param string $context The link context. If set to 'display' then ampersands
|
871 |
-
* are encoded.
|
872 |
-
*/
|
873 |
-
return apply_filters( 'get_edit_post_link', $link, $post->ID, $context );
|
874 |
-
}
|
875 |
-
|
876 |
-
/**
|
877 |
-
* Handle post term shortcode.
|
878 |
-
*
|
879 |
-
* @param array $atts Shortocde attributes.
|
880 |
-
*
|
881 |
-
* @return string Processed string.
|
882 |
-
*/
|
883 |
-
public function post_term_shortcode_handler( $atts ) {
|
884 |
-
$atts = shortcode_atts( array(
|
885 |
-
'taxonomy' => '',
|
886 |
-
'id' => 0,
|
887 |
-
), $atts );
|
888 |
-
|
889 |
-
$terms = wp_get_post_terms( $atts['id'], $atts['taxonomy'], array( 'fields' => 'names' ) );
|
890 |
-
|
891 |
-
if ( ! is_wp_error( $terms ) ) {
|
892 |
-
return implode( ', ', $terms );
|
893 |
-
}
|
894 |
-
|
895 |
-
return '';
|
896 |
-
}
|
897 |
-
|
898 |
-
/**
|
899 |
-
* Strip shortcodes, unless disabled.
|
900 |
-
*
|
901 |
-
* @param string $content Content who's shortcodes should be stripped.
|
902 |
-
*
|
903 |
-
* @return string Processed content.
|
904 |
-
*/
|
905 |
-
private function may_be_strip_shortcode( $content ) {
|
906 |
-
$enable_shortcode = get_option( 'bnfw_enable_shortcodes' );
|
907 |
-
|
908 |
-
if ( '1' == $enable_shortcode ) {
|
909 |
-
return $content;
|
910 |
-
}
|
911 |
-
|
912 |
-
return strip_shortcodes( $content );
|
913 |
-
}
|
914 |
-
|
915 |
-
/**
|
916 |
-
* Handle comment shortcodes.
|
917 |
-
*
|
918 |
-
* @since 1.0
|
919 |
-
*
|
920 |
-
* @param string $message String to be processed.
|
921 |
-
* @param int $comment_id Comment id.
|
922 |
-
*
|
923 |
-
* @return string Processed string.
|
924 |
-
*/
|
925 |
-
private function comment_shortcodes( $message, $comment_id ) {
|
926 |
-
$comment = get_comment( $comment_id );
|
927 |
-
|
928 |
-
$message = str_replace( '[comment_ID]', $comment->comment_ID, $message );
|
929 |
-
$message = str_replace( '[comment_post_ID]', $comment->comment_post_ID, $message );
|
930 |
-
$message = str_replace( '[comment_author]', $comment->comment_author, $message );
|
931 |
-
$message = str_replace( '[comment_author_email]', $comment->comment_author_email, $message );
|
932 |
-
$message = str_replace( '[comment_author_url]', $comment->comment_author_url, $message );
|
933 |
-
$message = str_replace( '[comment_author_IP]', $comment->comment_author_IP, $message );
|
934 |
-
$message = str_replace( '[comment_date]', bnfw_format_date( $comment->comment_date ), $message );
|
935 |
-
$message = str_replace( '[comment_date_gmt]', bnfw_format_date( $comment->comment_date_gmt ), $message );
|
936 |
-
$message = str_replace( '[comment_content]', get_comment_text( $comment->comment_ID ), $message );
|
937 |
-
$message = str_replace( '[comment_karma]', $comment->comment_karma, $message );
|
938 |
-
$message = str_replace( '[comment_approved]', str_replace( array( '0', '1', 'spam' ), array( 'Awaiting Moderation', 'Approved', 'Spam' ), $comment->comment_approved ), $message );
|
939 |
-
$message = str_replace( '[comment_agent]', $comment->comment_agent, $message );
|
940 |
-
$message = str_replace( '[comment_type]', $comment->comment_type, $message );
|
941 |
-
$message = str_replace( '[comment_parent]', $comment->comment_parent, $message );
|
942 |
-
$message = str_replace( '[user_id]', $comment->user_id, $message );
|
943 |
-
$message = str_replace( '[permalink]', get_comment_link( $comment->comment_ID ), $message );
|
944 |
-
$message = str_replace( '[comment_moderation_link]', admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID, $message );
|
945 |
-
$message = str_replace( '[comment_moderation_approve]', '<a href="' . wp_nonce_url(admin_url("comment.php?action=approve&c={$comment->comment_ID}#wpbody-content")) . '">Approve</a>', $message );
|
946 |
-
$message = str_replace( '[comment_moderation_spam]', '<a href="' . wp_nonce_url(admin_url("comment.php?action=spam&c={$comment->comment_ID}#wpbody-content")) . '">Spam</a>', $message );
|
947 |
-
$message = str_replace( '[comment_moderation_delete]', '<a href="' . wp_nonce_url(admin_url("comment.php?action=trash&c={$comment->comment_ID}#wpbody-content")) . '">Delete</a>', $message );
|
948 |
-
|
949 |
-
$parent_comment = get_comment( $comment->comment_parent );
|
950 |
-
if ( $parent_comment instanceof WP_Comment) {
|
951 |
-
$message = str_replace( '[comment_parent_content]', $parent_comment->comment_content, $message );
|
952 |
-
}
|
953 |
-
|
954 |
-
return $message;
|
955 |
-
}
|
956 |
-
|
957 |
-
/**
|
958 |
-
* Handle user shortcodes.
|
959 |
-
*
|
960 |
-
* @since 1.0
|
961 |
-
*
|
962 |
-
* @param string $message String to be processed.
|
963 |
-
* @param int $user_id User id.
|
964 |
-
*
|
965 |
-
* @return string Processed string.
|
966 |
-
*/
|
967 |
-
public function user_shortcodes( $message, $user_id, $prefix = '' ) {
|
968 |
-
global $wp_roles;
|
969 |
-
|
970 |
-
$user_info = get_userdata( $user_id );
|
971 |
-
|
972 |
-
if ( ! $user_info instanceof WP_User ) {
|
973 |
-
return $message;
|
974 |
-
}
|
975 |
-
|
976 |
-
// deprecated
|
977 |
-
$message = str_replace( '[ID]', $user_info->ID, $message );
|
978 |
-
$message = str_replace( '[display_name]', $user_info->display_name, $message );
|
979 |
-
$message = str_replace( '[nickname]', $user_info->nickname, $message );
|
980 |
-
$message = str_replace( '[commenter_avatar]', get_avatar_url( $user_id ), $message );
|
981 |
-
|
982 |
-
$message = str_replace( '[' . $prefix . 'user_id]', $user_info->ID, $message );
|
983 |
-
$message = str_replace( '[' . $prefix . 'user_login]', $user_info->user_login, $message );
|
984 |
-
$message = str_replace( '[' . $prefix . 'user_nicename]', $user_info->user_nicename, $message );
|
985 |
-
$message = str_replace( '[' . $prefix . 'user_email]', $user_info->user_email, $message );
|
986 |
-
$message = str_replace( '[' . $prefix . 'user_url]', $user_info->user_url, $message );
|
987 |
-
$message = str_replace( '[' . $prefix . 'user_registered]', $user_info->user_registered, $message );
|
988 |
-
$message = str_replace( '[' . $prefix . 'user_display_name]', $user_info->display_name, $message );
|
989 |
-
$message = str_replace( '[' . $prefix . 'user_firstname]', $user_info->user_firstname, $message );
|
990 |
-
$message = str_replace( '[' . $prefix . 'user_lastname]', $user_info->user_lastname, $message );
|
991 |
-
$message = str_replace( '[' . $prefix . 'user_nickname]', $user_info->nickname, $message );
|
992 |
-
$message = str_replace( '[' . $prefix . 'user_description]', $user_info->user_description, $message );
|
993 |
-
$message = str_replace( '[' . $prefix . 'user_avatar]', get_avatar_url( $user_id ), $message );
|
994 |
-
|
995 |
-
$roles = array_map( array( $this, 'get_role_label_by_name' ), $user_info->roles );
|
996 |
-
$message = str_replace( '[' . $prefix . 'user_role]', implode( ', ', $roles ), $message );
|
997 |
-
|
998 |
-
$user_capabilities = bnfw_format_user_capabilities( $user_info->wp_capabilities );
|
999 |
-
if ( ! empty( $user_capabilities ) ) {
|
1000 |
-
$message = str_replace( '[wp_capabilities]', $user_capabilities, $message );
|
1001 |
-
$message = str_replace( '[' . $prefix . 'user_wp_capabilities]', $user_capabilities, $message );
|
1002 |
-
}
|
1003 |
-
|
1004 |
-
$message = apply_filters( 'bnfw_shortcodes_user', $message, $user_id, $prefix );
|
1005 |
-
return $message;
|
1006 |
-
}
|
1007 |
-
|
1008 |
-
/**
|
1009 |
-
* Handle taxonomy shortcodes.
|
1010 |
-
*
|
1011 |
-
* @access private
|
1012 |
-
* @since 1.1
|
1013 |
-
*
|
1014 |
-
* @param string $message
|
1015 |
-
* @param string $taxonomy
|
1016 |
-
* @param int $term_id
|
1017 |
-
* @return string
|
1018 |
-
*/
|
1019 |
-
private function taxonomy_shortcodes( $message, $taxonomy, $term_id ) {
|
1020 |
-
$term_info = get_term( $term_id, $taxonomy );
|
1021 |
-
|
1022 |
-
$message = str_replace( '[slug]', $term_info->slug, $message );
|
1023 |
-
$message = str_replace( '[name]', $term_info->name, $message );
|
1024 |
-
$message = str_replace( '[description]', $term_info->description, $message );
|
1025 |
-
|
1026 |
-
return $message;
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
/**
|
1030 |
-
* Handle Core Updated Shortcodes.
|
1031 |
-
*
|
1032 |
-
* @since 1.6
|
1033 |
-
*
|
1034 |
-
* @param string $message Original message with shortcodes.
|
1035 |
-
* @param string $type The type of email being sent. Can be one of
|
1036 |
-
* 'success', 'fail', 'manual', 'critical'.
|
1037 |
-
*
|
1038 |
-
* @return string Modified content.
|
1039 |
-
*/
|
1040 |
-
private function core_updated_shortcodes( $message, $type ) {
|
1041 |
-
$message = str_replace( '[core_update_status]', $type, $message );
|
1042 |
-
|
1043 |
-
return $message;
|
1044 |
-
}
|
1045 |
-
|
1046 |
-
/**
|
1047 |
-
* Get the list of emails from the notification settings.
|
1048 |
-
*
|
1049 |
-
* @since 1.0
|
1050 |
-
*
|
1051 |
-
* @param array $setting Notification settings
|
1052 |
-
* @param int $id
|
1053 |
-
* @param bool $process_post_authors
|
1054 |
-
* @param bool $process_exclude_current_user
|
1055 |
-
*
|
1056 |
-
* @return array Emails
|
1057 |
-
*/
|
1058 |
-
public function get_emails( $setting, $id, $process_post_authors = true, $process_exclude_current_user = true ) {
|
1059 |
-
global $current_user;
|
1060 |
-
|
1061 |
-
$emails = array();
|
1062 |
-
|
1063 |
-
$exclude = null;
|
1064 |
-
if ( $process_exclude_current_user && 'true' == $setting['disable-current-user'] ) {
|
1065 |
-
if ( isset( $current_user->ID ) ) {
|
1066 |
-
$exclude = $current_user->ID;
|
1067 |
-
}
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
$emails['to'] = array();
|
1071 |
-
|
1072 |
-
if ( ! empty( $setting['users'] ) ) {
|
1073 |
-
$emails['to'] = $this->get_emails_from_users( $setting['users'], $exclude, $id, $setting );
|
1074 |
-
}
|
1075 |
-
|
1076 |
-
/**
|
1077 |
-
* BNFW get to emails.
|
1078 |
-
*/
|
1079 |
-
|
1080 |
-
if ( $process_post_authors && 'true' === $setting['only-post-author'] ) {
|
1081 |
-
$post_id = $id;
|
1082 |
-
|
1083 |
-
if ( bnfw_is_comment_notification( $setting['notification'] ) ) {
|
1084 |
-
$comment = get_comment( $id );
|
1085 |
-
$post_id = $comment->comment_post_ID;
|
1086 |
-
}
|
1087 |
-
|
1088 |
-
$type = explode( '-', $setting['notification'], 2 );
|
1089 |
-
if ('approve' == $type[0] ) {
|
1090 |
-
if ( ! in_array( $comment->comment_author_email, $emails['to'] ) ) {
|
1091 |
-
$emails['to'][] = $comment->comment_author_email;
|
1092 |
-
}
|
1093 |
-
}else{
|
1094 |
-
$post_author = get_post_field( 'post_author', $post_id );
|
1095 |
-
$author = get_user_by( 'id', $post_author );
|
1096 |
-
if ( false !== $author && $post_author != $exclude ) {
|
1097 |
-
if ( ! in_array( $author->user_email, $emails['to'] ) ) {
|
1098 |
-
$emails['to'][] = $author->user_email;
|
1099 |
-
}
|
1100 |
-
}
|
1101 |
-
}
|
1102 |
-
}
|
1103 |
-
|
1104 |
-
if ( 'true' == $setting['show-fields'] ) {
|
1105 |
-
$default_from_field = get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) . '>';
|
1106 |
-
|
1107 |
-
if ( ! empty( $setting['from-name'] ) && ! empty( $setting['from-email'] ) && is_email( $setting['from-email'] ) ) {
|
1108 |
-
$default_from_field = $setting['from-name'] . ' <' . $setting['from-email'] . '>';
|
1109 |
-
}
|
1110 |
-
|
1111 |
-
/**
|
1112 |
-
* Filter Email From Field.
|
1113 |
-
*/
|
1114 |
-
$emails['from'] = apply_filters( 'bnfw_from_field', $default_from_field, $setting, $id, $emails['to'] );
|
1115 |
-
|
1116 |
-
/**
|
1117 |
-
* Filter Reply Name Field.
|
1118 |
-
*/
|
1119 |
-
$emails['reply-name'] = apply_filters( 'bnfw_reply_name_field', $setting['reply-name'], $setting, $id, $emails['to'] );
|
1120 |
-
|
1121 |
-
/**
|
1122 |
-
* Filter Reply Email Field.
|
1123 |
-
*/
|
1124 |
-
$emails['reply-email'] = apply_filters( 'bnfw_reply_email_field', $setting['reply-email'], $setting, $id, $emails['to'] );
|
1125 |
-
|
1126 |
-
if ( ! empty( $setting['cc'] ) ) {
|
1127 |
-
$emails['cc'] = $this->get_emails_from_users( $setting['cc'], $exclude, $id, $setting );
|
1128 |
-
}
|
1129 |
-
|
1130 |
-
if ( ! empty( $setting['bcc'] ) ) {
|
1131 |
-
$emails['bcc'] = $this->get_emails_from_users( $setting['bcc'], $exclude, $id, $setting );
|
1132 |
-
}
|
1133 |
-
}
|
1134 |
-
|
1135 |
-
$excluded_emails = array();
|
1136 |
-
|
1137 |
-
if ( ! empty( $setting['exclude-users'] ) ) {
|
1138 |
-
$excluded_emails = $this->get_emails_from_users( $setting['exclude-users'] );
|
1139 |
-
}
|
1140 |
-
|
1141 |
-
if ( ! empty( $excluded_emails ) ) {
|
1142 |
-
$emails['to'] = array_diff( $emails['to'], $excluded_emails );
|
1143 |
-
|
1144 |
-
if ( ! empty( $emails['cc'] ) ) {
|
1145 |
-
$emails['cc'] = array_diff( $emails['cc'], $excluded_emails );
|
1146 |
-
}
|
1147 |
-
|
1148 |
-
if ( ! empty( $emails['bcc'] ) ) {
|
1149 |
-
$emails['bcc'] = array_diff( $emails['bcc'], $excluded_emails );
|
1150 |
-
}
|
1151 |
-
}
|
1152 |
-
$emails['to'] = apply_filters( 'bnfw_to_emails', $emails['to'], $setting, $id );
|
1153 |
-
|
1154 |
-
return $emails;
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
/**
|
1158 |
-
* Get emails from users.
|
1159 |
-
*
|
1160 |
-
* @since 1.2
|
1161 |
-
*
|
1162 |
-
* @param array $users Users Array
|
1163 |
-
* @param int $exclude User id to exclude
|
1164 |
-
* @param int $post_id Post id.
|
1165 |
-
* @param array $setting Notification setting.
|
1166 |
-
*
|
1167 |
-
* @return array
|
1168 |
-
*/
|
1169 |
-
public function get_emails_from_users( $users, $exclude = null, $post_id = 0, $setting = array() ) {
|
1170 |
-
$user_ids = array();
|
1171 |
-
$user_roles = array();
|
1172 |
-
$non_wp_users = array();
|
1173 |
-
|
1174 |
-
if ( empty( $users ) ) {
|
1175 |
-
return array();
|
1176 |
-
}
|
1177 |
-
|
1178 |
-
foreach ( $users as $user ) {
|
1179 |
-
if ( $this->starts_with( $user, 'role-' ) ) {
|
1180 |
-
$user_roles[] = str_replace( 'role-', '', $user );
|
1181 |
-
} elseif ( strpos( $user, '@' ) !== false ) {
|
1182 |
-
$non_wp_users[] = $user;
|
1183 |
-
continue;
|
1184 |
-
} elseif ( absint( $user ) > 0 ) {
|
1185 |
-
$user_ids[] = absint( $user );
|
1186 |
-
} else {
|
1187 |
-
$non_wp_users[] = $user;
|
1188 |
-
}
|
1189 |
-
}
|
1190 |
-
|
1191 |
-
if ( null != $exclude ) {
|
1192 |
-
$user_ids = array_diff( $user_ids, array( $exclude ) );
|
1193 |
-
}
|
1194 |
-
|
1195 |
-
$emails_from_user_ids = $this->get_emails_from_id( $user_ids );
|
1196 |
-
$emails_from_user_roles = $this->get_emails_from_role( $user_roles, $exclude );
|
1197 |
-
|
1198 |
-
if ( ! empty( $setting ) ) {
|
1199 |
-
// for new comment notifications, we need to use post id instead of comment id.
|
1200 |
-
if ( bnfw_is_comment_notification( $setting['notification'] ) && $post_id ) {
|
1201 |
-
$comment = get_comment( $post_id );
|
1202 |
-
$post_id = $comment->comment_post_ID;
|
1203 |
-
}
|
1204 |
-
}
|
1205 |
-
|
1206 |
-
$non_wp_emails = apply_filters( 'bnfw_non_wp_emails', array(), $non_wp_users, $post_id );
|
1207 |
-
|
1208 |
-
return array_merge( $emails_from_user_roles, $emails_from_user_ids, $non_wp_emails );
|
1209 |
-
}
|
1210 |
-
|
1211 |
-
/**
|
1212 |
-
* Get user emails by user ids.
|
1213 |
-
*
|
1214 |
-
* @since 1.0
|
1215 |
-
*
|
1216 |
-
* @param array $user_ids.
|
1217 |
-
*
|
1218 |
-
* @return array Emails.
|
1219 |
-
*/
|
1220 |
-
private function get_emails_from_id( $user_ids ) {
|
1221 |
-
$email_list = array();
|
1222 |
-
if ( is_array( $user_ids ) && count( $user_ids ) > 0 ) {
|
1223 |
-
$user_query = new WP_User_Query( array( 'include' => $user_ids ) );
|
1224 |
-
foreach ( $user_query->results as $user ) {
|
1225 |
-
$email_list[] = $user->user_email;
|
1226 |
-
}
|
1227 |
-
}
|
1228 |
-
return $email_list;
|
1229 |
-
}
|
1230 |
-
|
1231 |
-
/**
|
1232 |
-
* Get emails of users based on role.
|
1233 |
-
*
|
1234 |
-
* @since 1.0
|
1235 |
-
* @param array $roles User Roles
|
1236 |
-
* @param int $exclude User id to exclude
|
1237 |
-
* @return array Email ids
|
1238 |
-
*/
|
1239 |
-
private function get_emails_from_role( $roles, $exclude = null ) {
|
1240 |
-
if ( ! is_array( $roles ) ) {
|
1241 |
-
$roles = array( $roles );
|
1242 |
-
}
|
1243 |
-
|
1244 |
-
$email_list = array();
|
1245 |
-
foreach ( $roles as $role ) {
|
1246 |
-
$role_name = $this->get_role_name_by_label( $role );
|
1247 |
-
$users = get_users(
|
1248 |
-
array(
|
1249 |
-
'role' => $role_name,
|
1250 |
-
'fields' => array( 'user_email', 'ID' ),
|
1251 |
-
)
|
1252 |
-
);
|
1253 |
-
|
1254 |
-
foreach ( $users as $user ) {
|
1255 |
-
if ( null != $exclude ) {
|
1256 |
-
if ( $user->ID == $exclude ) {
|
1257 |
-
continue;
|
1258 |
-
}
|
1259 |
-
}
|
1260 |
-
|
1261 |
-
if ( ! in_array( $user->user_email, $email_list ) ) {
|
1262 |
-
$email_list[] = $user->user_email;
|
1263 |
-
}
|
1264 |
-
}
|
1265 |
-
}
|
1266 |
-
|
1267 |
-
return $email_list;
|
1268 |
-
}
|
1269 |
-
|
1270 |
-
/**
|
1271 |
-
* Find if a string starts with another string.
|
1272 |
-
*
|
1273 |
-
* @since 1.2
|
1274 |
-
*
|
1275 |
-
* @param $haystack
|
1276 |
-
* @param $needle
|
1277 |
-
*
|
1278 |
-
* @return bool
|
1279 |
-
*/
|
1280 |
-
private function starts_with( $haystack, $needle ) {
|
1281 |
-
// search backwards starting from haystack length characters from the end
|
1282 |
-
return '' === $needle || strrpos( $haystack, $needle, -strlen( $haystack ) ) !== false;
|
1283 |
-
}
|
1284 |
-
|
1285 |
-
/**
|
1286 |
-
* Get User role name by label.
|
1287 |
-
*
|
1288 |
-
* @param mixed $role_label
|
1289 |
-
*
|
1290 |
-
* @return int|string
|
1291 |
-
*/
|
1292 |
-
protected function get_role_name_by_label( $role_label ) {
|
1293 |
-
global $wp_roles;
|
1294 |
-
foreach ( $wp_roles->roles as $role_name => $role_info ) {
|
1295 |
-
if ( $role_label == $role_info['name'] || $role_name == $role_label ) {
|
1296 |
-
return $role_name;
|
1297 |
-
}
|
1298 |
-
}
|
1299 |
-
|
1300 |
-
// There is something wrong
|
1301 |
-
return '';
|
1302 |
-
}
|
1303 |
-
|
1304 |
-
/**
|
1305 |
-
* Get the lable for a user role from name.
|
1306 |
-
*
|
1307 |
-
* @param string $role_name Role name
|
1308 |
-
*
|
1309 |
-
* @return string Role Label.
|
1310 |
-
*/
|
1311 |
-
public function get_role_label_by_name( $role_name ) {
|
1312 |
-
global $wp_roles;
|
1313 |
-
|
1314 |
-
if ( ! isset( $wp_roles->roles[ $role_name ] ) ) {
|
1315 |
-
return '';
|
1316 |
-
}
|
1317 |
-
|
1318 |
-
return translate_user_role( $wp_roles->roles[ $role_name ]['name'] );
|
1319 |
-
}
|
1320 |
-
|
1321 |
-
/**
|
1322 |
-
* Get first image in post.
|
1323 |
-
*
|
1324 |
-
* @param mixed $post_content
|
1325 |
-
*
|
1326 |
-
* @return string
|
1327 |
-
*/
|
1328 |
-
protected function get_first_image($post_content) {
|
1329 |
-
if (preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post_content, $matches)) {
|
1330 |
-
return $matches[1][0];
|
1331 |
-
}
|
1332 |
-
}
|
1333 |
-
|
1334 |
-
/**
|
1335 |
-
* Generate email headers based on the emails.
|
1336 |
-
*
|
1337 |
-
* @since 1.0
|
1338 |
-
* @param array $emails
|
1339 |
-
* @return array
|
1340 |
-
*/
|
1341 |
-
public function get_headers( $emails ) {
|
1342 |
-
$headers = array();
|
1343 |
-
|
1344 |
-
if ( ! empty( $emails['from'] ) ) {
|
1345 |
-
$headers[] = 'From:' . $emails['from'];
|
1346 |
-
}
|
1347 |
-
|
1348 |
-
if ( ! empty( $emails['reply-email'] ) && is_email( $emails['reply-email'] ) ) {
|
1349 |
-
$headers[] = 'Reply-To:' . $emails['reply-name'] . '<' . $emails['reply-email'] . '>';
|
1350 |
-
}
|
1351 |
-
|
1352 |
-
if ( ! empty( $emails['cc'] ) ) {
|
1353 |
-
$headers[] = 'Cc:' . implode( ',', $emails['cc'] );
|
1354 |
-
}
|
1355 |
-
if ( ! empty( $emails['bcc'] ) ) {
|
1356 |
-
$headers[] = 'Bcc:' . implode( ',', $emails['bcc'] );
|
1357 |
-
}
|
1358 |
-
|
1359 |
-
/**
|
1360 |
-
* Filter out mail headers.
|
1361 |
-
*
|
1362 |
-
* @param array $headers Headers.
|
1363 |
-
* @param array $emails Emails.
|
1364 |
-
*/
|
1365 |
-
return apply_filters( 'bnfw_mail_headers', $headers, $emails );
|
1366 |
-
}
|
1367 |
-
|
1368 |
-
public function handle_user_request_email_shortcodes( $message, $setting, $email_data ) {
|
1369 |
-
$message = $this->handle_shortcodes( $message, $setting['notification'], $email_data );
|
1370 |
-
|
1371 |
-
return $message;
|
1372 |
-
}
|
1373 |
-
|
1374 |
-
public function handle_user_confirmed_action_email_shortcodes( $message, $setting, $email_data ) {
|
1375 |
-
$message = $this->handle_shortcodes( $message, $setting['notification'], $email_data );
|
1376 |
-
|
1377 |
-
return $message;
|
1378 |
-
}
|
1379 |
-
|
1380 |
-
public function handle_data_export_email_shortcodes( $message, $setting, $request_id ) {
|
1381 |
-
$message = $this->handle_shortcodes( $message, $setting['notification'], $request_id );
|
1382 |
-
|
1383 |
-
return $message;
|
1384 |
-
}
|
1385 |
-
|
1386 |
-
protected function confirm_action_shortcodes( $message, $extra_data ) {
|
1387 |
-
$message = $this->data_request_shortcodes( $message, $extra_data );
|
1388 |
-
$message = str_replace( '[request_confirmation_link]', $extra_data['confirm_url'], $message );
|
1389 |
-
if ( isset( $extra_data['email'] ) ) {
|
1390 |
-
$message = str_replace( '[request_email]', $extra_data['email'], $message );
|
1391 |
-
}
|
1392 |
-
|
1393 |
-
if ( isset( $extra_data['user_email'] ) ) {
|
1394 |
-
$message = str_replace( '[request_email]', $extra_data['user_email'], $message );
|
1395 |
-
}
|
1396 |
-
|
1397 |
-
return $message;
|
1398 |
-
}
|
1399 |
-
|
1400 |
-
protected function confirmed_action_shortcodes( $message, $extra_data ) {
|
1401 |
-
$message = $this->data_request_shortcodes( $message, $extra_data );
|
1402 |
-
$message = str_replace( '[data_privacy_requests_url]', $extra_data['manage_url'], $message );
|
1403 |
-
$message = str_replace( '[request_email]', $extra_data['user_email'], $message );
|
1404 |
-
|
1405 |
-
return $message;
|
1406 |
-
}
|
1407 |
-
|
1408 |
-
protected function data_request_shortcodes( $message, $extra_data ) {
|
1409 |
-
$message = str_replace( '[data_request_type]', $extra_data['description'], $message );
|
1410 |
-
|
1411 |
-
return $message;
|
1412 |
-
}
|
1413 |
-
|
1414 |
-
protected function data_export_shortcodes( $message, $request_id ) {
|
1415 |
-
$export_file_url = get_post_meta( $request_id, '_export_file_url', true );
|
1416 |
-
$message = str_replace( '[data_privacy_download_url]', $export_file_url, $message );
|
1417 |
-
|
1418 |
-
$expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
|
1419 |
-
$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
|
1420 |
-
$message = str_replace( '[data_privacy_download_expiry]', $expiration_date, $message );
|
1421 |
-
|
1422 |
-
return $message;
|
1423 |
-
}
|
1424 |
-
|
1425 |
-
protected function data_erased_shortcodes( $message, $extra_data ) {
|
1426 |
-
$message = str_replace( '[privacy_policy_url]', $extra_data['privacy_policy_url'], $message );
|
1427 |
-
$message = str_replace( '[sitename]', $extra_data['sitename'], $message );
|
1428 |
-
|
1429 |
-
return $message;
|
1430 |
-
}
|
1431 |
-
|
1432 |
-
/**
|
1433 |
-
* Process shortcodes in email.
|
1434 |
-
*
|
1435 |
-
* @param $email
|
1436 |
-
* @param $post_id
|
1437 |
-
* @param $setting
|
1438 |
-
*
|
1439 |
-
* @return string
|
1440 |
-
*/
|
1441 |
-
public function process_shortcodes_in_email( $email, $post_id, $setting, $to_emails ) {
|
1442 |
-
if ( ! empty( $setting ) ) {
|
1443 |
-
if ( $this->starts_with( $setting['notification'], 'comment-' ) || $this->starts_with( $setting['notification'], 'moderate-' ) ) {
|
1444 |
-
// for new comment notifications, we need to use post id instead of comment id.
|
1445 |
-
$post_id = bnfw_get_post_id_from_comment( $post_id );
|
1446 |
-
}
|
1447 |
-
}
|
1448 |
-
|
1449 |
-
$email = $this->handle_shortcodes( $email, $setting['notification'], $post_id );
|
1450 |
-
|
1451 |
-
if ( is_array( $to_emails ) && ! empty( $to_emails ) ) {
|
1452 |
-
$to_email = $to_emails[0];
|
1453 |
-
|
1454 |
-
$email = $this->handle_global_user_shortcodes( $email, $to_email );
|
1455 |
-
}
|
1456 |
-
|
1457 |
-
$processed_emails = array();
|
1458 |
-
if ( is_email( $email ) ) {
|
1459 |
-
$processed_emails[] = $email;
|
1460 |
-
}
|
1461 |
-
|
1462 |
-
$emails = apply_filters( 'bnfw_non_wp_emails', $processed_emails, array( $email ), $post_id );
|
1463 |
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1467 |
|
1468 |
-
return $emails[0];
|
1469 |
-
}
|
1470 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* BNFW Engine
|
5 |
*
|
6 |
* @since 1.0
|
7 |
*/
|
|
|
8 |
class BNFW_Engine {
|
9 |
|
10 |
+
/**
|
11 |
+
* Send test email.
|
12 |
+
*
|
13 |
+
* @since 1.2
|
14 |
+
*
|
15 |
+
* @param array $setting
|
16 |
+
*/
|
17 |
+
public function send_test_email( $setting ) {
|
18 |
+
$subject = __( 'Test Email:', 'bnfw' ) . ' ' . $setting[ 'subject' ];
|
19 |
+
$message = '<p><strong>' . __( 'This is a test email. All shortcodes below will show in place but not be replaced with content.', 'bnfw' ) . '</strong></p>' . stripslashes( $setting[ 'message' ] );
|
20 |
+
|
21 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
22 |
+
$message = wpautop( $message );
|
23 |
+
}
|
24 |
+
|
25 |
+
$current_user = wp_get_current_user();
|
26 |
+
$email = $current_user->user_email;
|
27 |
+
|
28 |
+
$headers = array();
|
29 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
30 |
+
$headers[] = 'Content-type: text/html';
|
31 |
+
$message = apply_filters( 'bnfw_test_email_message', $message, $setting );
|
32 |
+
} elseif ( 'text' == $setting[ 'email-formatting' ] ) {
|
33 |
+
$message = strip_tags( $message );
|
34 |
+
}
|
35 |
+
|
36 |
+
wp_mail( $email, stripslashes( $subject ), $message, $headers );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Send the notification email.
|
41 |
+
*
|
42 |
+
* @since 1.0
|
43 |
+
* @param array $setting
|
44 |
+
* @param int $id
|
45 |
+
*/
|
46 |
+
public function send_notification( $setting, $id ) {
|
47 |
+
/**
|
48 |
+
* BNFW - Whether notification is disabled?
|
49 |
+
*
|
50 |
+
* @since 1.3.6
|
51 |
+
*/
|
52 |
+
$notification_disabled = apply_filters( 'bnfw_notification_disabled', ( 'true' === $setting[ 'disabled' ] ), $id, $setting );
|
53 |
+
|
54 |
+
if ( ! $notification_disabled ) {
|
55 |
+
$subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $id );
|
56 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $id );
|
57 |
+
$emails = $this->get_emails( $setting, $id );
|
58 |
+
$headers = $this->get_headers( $emails );
|
59 |
+
|
60 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
61 |
+
$message = wpautop( $message );
|
62 |
+
}
|
63 |
+
|
64 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
65 |
+
$headers[] = 'Content-type: text/html';
|
66 |
+
$message = apply_filters( 'bnfw_notification_message', $message, $setting );
|
67 |
+
} else {
|
68 |
+
$headers[] = 'Content-type: text/plain';
|
69 |
+
if ( 'text' == $setting[ 'email-formatting' ] ) {
|
70 |
+
$message = strip_tags( $message );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
$emails = apply_filters( 'bnfw_emails', $emails, $setting, $id );
|
75 |
+
|
76 |
+
$send = apply_filters( 'bnfw_can_send_email', true, $setting, $emails, $subject, $message, $headers );
|
77 |
+
|
78 |
+
if ( ! $send ) {
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( isset( $emails[ 'to' ] ) && is_array( $emails[ 'to' ] ) ) {
|
83 |
+
foreach ( $emails[ 'to' ] as $email ) {
|
84 |
+
wp_mail( $email, stripslashes( $this->handle_global_user_shortcodes( $subject, $email ) ), $this->handle_global_user_shortcodes( $message, $email ), $headers );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Send new user registration notification email.
|
92 |
+
*
|
93 |
+
* @since 1.1
|
94 |
+
* @param array $setting Notification setting
|
95 |
+
* @param object $user User object
|
96 |
+
* @param string $password_url Plain text password in WP < 4.3 and password url in WP > 4.3
|
97 |
+
*/
|
98 |
+
public function send_registration_email( $setting, $user, $password_url = '' ) {
|
99 |
+
/**
|
100 |
+
* Whether to trigger welcome email notification or not.
|
101 |
+
*
|
102 |
+
* @since 1.7
|
103 |
+
*/
|
104 |
+
$trigger_notification = apply_filters( 'bnfw_trigger_welcome-email_notification', true, $setting, $user );
|
105 |
+
|
106 |
+
if ( ! $trigger_notification ) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
$user_id = $user->ID;
|
111 |
+
|
112 |
+
$subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $user_id );
|
113 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $user_id );
|
114 |
+
|
115 |
+
$subject = str_replace( '[password]', $password_url, $subject );
|
116 |
+
$message = str_replace( '[password]', $password_url, $message );
|
117 |
+
|
118 |
+
$subject = str_replace( '[password_url]', $password_url, $subject );
|
119 |
+
$message = str_replace( '[password_url]', $password_url, $message );
|
120 |
+
|
121 |
+
$subject = str_replace( '[login_url]', wp_login_url(), $subject );
|
122 |
+
$message = str_replace( '[login_url]', wp_login_url(), $message );
|
123 |
+
|
124 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
125 |
+
$message = wpautop( $message );
|
126 |
+
}
|
127 |
+
|
128 |
+
$headers = array();
|
129 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
130 |
+
$headers[] = 'Content-type: text/html';
|
131 |
+
$message = apply_filters( 'bnfw_registration_email_message', $message, $setting );
|
132 |
+
} elseif ( 'text' == $setting[ 'email-formatting' ] ) {
|
133 |
+
$message = strip_tags( $message );
|
134 |
+
}
|
135 |
+
|
136 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
137 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
138 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Send user login notification email.
|
143 |
+
*
|
144 |
+
* @since 1.1
|
145 |
+
* @param array $setting Notification setting
|
146 |
+
* @param object $user User object
|
147 |
+
*/
|
148 |
+
public function send_user_login_email( $setting, $user ) {
|
149 |
+
|
150 |
+
$trigger_notification = apply_filters( 'bnfw_trigger_user-login_notification', true, $setting, $user );
|
151 |
+
|
152 |
+
if ( ! $trigger_notification ) {
|
153 |
+
return;
|
154 |
+
}
|
155 |
+
|
156 |
+
$user_id = $user->ID;
|
157 |
+
|
158 |
+
$subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $user_id );
|
159 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $user_id );
|
160 |
+
$emails = $this->get_emails( $setting, $user_id );
|
161 |
+
$headers = $this->get_headers( $emails );
|
162 |
+
|
163 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
164 |
+
$message = wpautop( $message );
|
165 |
+
}
|
166 |
+
|
167 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
168 |
+
$headers[] = 'Content-type: text/html';
|
169 |
+
$message = apply_filters( 'bnfw_notification_message', $message, $setting );
|
170 |
+
} elseif ( 'text' == $setting[ 'email-formatting' ] ) {
|
171 |
+
$message = strip_tags( $message );
|
172 |
+
}
|
173 |
+
|
174 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
175 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
176 |
+
|
177 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Send user login notification email for admin.
|
182 |
+
*
|
183 |
+
* @since 1.1
|
184 |
+
* @param array $setting Notification setting
|
185 |
+
* @param object $user User object
|
186 |
+
*/
|
187 |
+
public function send_user_login_email_for_admin( $setting, $user ) {
|
188 |
+
|
189 |
+
$trigger_notification = apply_filters( 'bnfw_trigger_user-login_notification', true, $setting, $user );
|
190 |
+
|
191 |
+
if ( ! $trigger_notification ) {
|
192 |
+
return;
|
193 |
+
}
|
194 |
+
$user_id = $user->ID;
|
195 |
+
|
196 |
+
$this->send_notification( $setting, $user_id );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Send comment reply notification email.
|
201 |
+
*
|
202 |
+
* @since 1.3
|
203 |
+
* @param array $setting Notification setting
|
204 |
+
* @param object $comment Comment object
|
205 |
+
* @param object $parent_comment Parent comment object
|
206 |
+
*/
|
207 |
+
public function send_comment_reply_email( $setting, $comment,
|
208 |
+
$parent_comment ) {
|
209 |
+
$comment_id = $comment->comment_ID;
|
210 |
+
|
211 |
+
/**
|
212 |
+
* BNFW - Whether notification is disabled?
|
213 |
+
*
|
214 |
+
* @since 1.3.6
|
215 |
+
*/
|
216 |
+
$notification_disabled = apply_filters( 'bnfw_notification_disabled', false, $comment_id, $setting );
|
217 |
+
|
218 |
+
if ( ! $notification_disabled ) {
|
219 |
+
$subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $comment_id );
|
220 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $comment_id );
|
221 |
+
|
222 |
+
$headers = array();
|
223 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
224 |
+
$headers[] = 'Content-type: text/html';
|
225 |
+
} elseif ( 'text' == $setting[ 'email-formatting' ] ) {
|
226 |
+
$message = strip_tags( $message );
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
230 |
+
$message = wpautop( $message );
|
231 |
+
$message = apply_filters( 'bnfw_comment_reply_email_message', $message, $setting );
|
232 |
+
}
|
233 |
+
|
234 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $parent_comment->comment_author_email );
|
235 |
+
$message = $this->handle_global_user_shortcodes( $message, $parent_comment->comment_author_email );
|
236 |
+
wp_mail( $parent_comment->comment_author_email, stripslashes( $subject ), $message, $headers );
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Send user role changed email.
|
242 |
+
*
|
243 |
+
* @since 1.3.9
|
244 |
+
*
|
245 |
+
* @param array $setting Notification setting
|
246 |
+
* @param int $user_id User ID
|
247 |
+
* @param array $old_role Old User Role.
|
248 |
+
* @param array $new_role New User Role.
|
249 |
+
*/
|
250 |
+
public function send_user_role_changed_email( $setting, $user_id, $old_role,
|
251 |
+
$new_role ) {
|
252 |
+
$subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $user_id );
|
253 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $user_id );
|
254 |
+
|
255 |
+
$subject = $this->handle_user_role_shortcodes( $subject, $old_role, $new_role );
|
256 |
+
$message = $this->handle_user_role_shortcodes( $message, $old_role, $new_role );
|
257 |
+
|
258 |
+
$headers = array();
|
259 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
260 |
+
$message = wpautop( $message );
|
261 |
+
}
|
262 |
+
|
263 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
264 |
+
$headers[] = 'Content-type: text/html';
|
265 |
+
$message = apply_filters( 'bnfw_user_role_changed_email_message', $message, $setting );
|
266 |
+
} elseif ( 'text' == $setting[ 'email-formatting' ] ) {
|
267 |
+
$message = strip_tags( $message );
|
268 |
+
}
|
269 |
+
|
270 |
+
$user = get_user_by( 'id', $user_id );
|
271 |
+
|
272 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
273 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
274 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Send user role added support User Role Editor by Members Plugin.
|
279 |
+
*
|
280 |
+
* @since 1.3.9
|
281 |
+
*
|
282 |
+
* @param array $setting Notification setting
|
283 |
+
* @param int $user_id User ID
|
284 |
+
* @param array $old_role Old User Role.
|
285 |
+
* @param array $new_role New User Role.
|
286 |
+
*/
|
287 |
+
public function send_user_role_added_email( $setting, $user_id, $old_role,
|
288 |
+
$new_role ) {
|
289 |
+
$subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $user_id );
|
290 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $user_id );
|
291 |
+
|
292 |
+
$subject = $this->handle_user_added_role_shortcodes( $subject, $old_role, $new_role );
|
293 |
+
$message = $this->handle_user_added_role_shortcodes( $message, $old_role, $new_role );
|
294 |
+
|
295 |
+
$headers = array();
|
296 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
297 |
+
$message = wpautop( $message );
|
298 |
+
}
|
299 |
+
|
300 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
301 |
+
$headers[] = 'Content-type: text/html';
|
302 |
+
$message = apply_filters( 'bnfw_user_role_changed_email_message', $message, $setting );
|
303 |
+
} elseif ( 'text' == $setting[ 'email-formatting' ] ) {
|
304 |
+
$message = strip_tags( $message );
|
305 |
+
}
|
306 |
+
|
307 |
+
$user = get_user_by( 'id', $user_id );
|
308 |
+
|
309 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
310 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
311 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Handle User Role shortcodes.
|
316 |
+
*
|
317 |
+
* @param string $message String that needs shortcode processing.
|
318 |
+
* @param array $old_role Old User Role.
|
319 |
+
* @param array $new_role New User Role.
|
320 |
+
*
|
321 |
+
* @return string Processed string.
|
322 |
+
*/
|
323 |
+
public function handle_user_role_shortcodes( $message, $old_role, $new_role ) {
|
324 |
+
$roles = wp_roles();
|
325 |
+
|
326 |
+
$old_role_name = '';
|
327 |
+
$new_role_name = '';
|
328 |
+
|
329 |
+
if ( isset( $roles->role_names[ $old_role ] ) ) {
|
330 |
+
$old_role_name = $roles->role_names[ $old_role ];
|
331 |
+
}
|
332 |
+
|
333 |
+
if ( isset( $roles->role_names[ $new_role ] ) ) {
|
334 |
+
$new_role_name = $roles->role_names[ $new_role ];
|
335 |
+
}
|
336 |
+
|
337 |
+
$message = str_replace( '[user_role_old]', $old_role_name, $message );
|
338 |
+
$message = str_replace( '[user_role_new]', $new_role_name, $message );
|
339 |
+
|
340 |
+
return $message;
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Handle User Added Role shortcodes.
|
345 |
+
*
|
346 |
+
* @param string $message String that needs shortcode processing.
|
347 |
+
* @param array $old_role Old User Role.
|
348 |
+
* @param array $new_role New User Role.
|
349 |
+
*
|
350 |
+
* @return string Processed string.
|
351 |
+
*/
|
352 |
+
public function handle_user_added_role_shortcodes( $message, $old_roles,
|
353 |
+
$new_roles ) {
|
354 |
+
$roles = wp_roles();
|
355 |
+
|
356 |
+
$old_role_name = array();
|
357 |
+
$new_role_name = array();
|
358 |
+
|
359 |
+
foreach ( $old_roles as $key => $old_role ) {
|
360 |
+
if ( isset( $roles->role_names[ $old_role ] ) ) {
|
361 |
+
$old_role_name[] = $roles->role_names[ $old_role ];
|
362 |
+
}
|
363 |
+
}
|
364 |
+
foreach ( $new_roles as $key => $new_role ) {
|
365 |
+
if ( isset( $roles->role_names[ $new_role ] ) ) {
|
366 |
+
$new_role_name[] = $roles->role_names[ $new_role ];
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
$message = str_replace( '[user_role_old]', implode( ',', $old_role_name ), $message );
|
371 |
+
$message = str_replace( '[user_role_new]', implode( ',', $new_role_name ), $message );
|
372 |
+
|
373 |
+
return $message;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Handle shortcodes for filtered data notifications like `password_changed` and `email_changed`.
|
378 |
+
*
|
379 |
+
* @since 1.6
|
380 |
+
*
|
381 |
+
* @param array $email_data Email data.
|
382 |
+
* @param array $setting Notification settings.
|
383 |
+
* @param string|int $extra_data Extra data.
|
384 |
+
*
|
385 |
+
* @return array Modified email data.
|
386 |
+
*/
|
387 |
+
public function handle_filtered_data_notification( $email_data, $setting,
|
388 |
+
$extra_data ) {
|
389 |
+
$email_data[ 'message' ] = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $extra_data );
|
390 |
+
$email_data[ 'subject' ] = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $extra_data );
|
391 |
+
|
392 |
+
$email_data[ 'message' ] = $this->handle_global_user_shortcodes( $email_data[ 'message' ], $email_data[ 'to' ] );
|
393 |
+
$email_data[ 'subject' ] = $this->handle_global_user_shortcodes( $email_data[ 'subject' ], $email_data[ 'to' ] );
|
394 |
+
|
395 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
396 |
+
$email_data[ 'message' ] = wpautop( $email_data[ 'message' ] );
|
397 |
+
}
|
398 |
+
|
399 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
400 |
+
$headers[] = 'Content-type: text/html';
|
401 |
+
} else {
|
402 |
+
$headers[] = 'Content-type: text/plain';
|
403 |
+
if ( 'text' == $setting[ 'email-formatting' ] ) {
|
404 |
+
$message = strip_tags( $message );
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
$email_data[ 'headers' ] = $headers;
|
409 |
+
|
410 |
+
return $email_data;
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Handle shortcodes for core updated notification.
|
415 |
+
*
|
416 |
+
* @since 1.6
|
417 |
+
*
|
418 |
+
* @param array $email_data Email data.
|
419 |
+
* @param array $setting Notification settings.
|
420 |
+
* @param string $type Result of update.
|
421 |
+
*
|
422 |
+
* @return array Modified email data.
|
423 |
+
*/
|
424 |
+
public function handle_core_updated_notification( $email_data, $setting,
|
425 |
+
$type ) {
|
426 |
+
$email_data[ 'body' ] = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $type );
|
427 |
+
$email_data[ 'subject' ] = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $type );
|
428 |
+
|
429 |
+
$emails = $this->get_emails( $setting, $type );
|
430 |
+
$headers = $this->get_headers( $emails );
|
431 |
+
|
432 |
+
$email_data[ 'body' ] = $this->handle_global_user_shortcodes( $email_data[ 'body' ], $emails[ 'to' ][ 0 ] );
|
433 |
+
$email_data[ 'subject' ] = $this->handle_global_user_shortcodes( $email_data[ 'subject' ], $emails[ 'to' ][ 0 ] );
|
434 |
+
|
435 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
436 |
+
$email_data[ 'body' ] = wpautop( $email_data[ 'body' ] );
|
437 |
+
}
|
438 |
+
|
439 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
440 |
+
$headers[] = 'Content-type: text/html';
|
441 |
+
} else {
|
442 |
+
$headers[] = 'Content-type: text/plain';
|
443 |
+
if ( 'text' == $setting[ 'email-formatting' ] ) {
|
444 |
+
$message = strip_tags( $message );
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
$email_data[ 'headers' ] = $headers;
|
449 |
+
|
450 |
+
return $email_data;
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Handle shortcode for password reset email message.
|
455 |
+
*
|
456 |
+
* @since 1.1
|
457 |
+
*
|
458 |
+
* @param $setting
|
459 |
+
* @param $key
|
460 |
+
* @param $user_login
|
461 |
+
* @param $user_data
|
462 |
+
*
|
463 |
+
* @return mixed|string
|
464 |
+
*/
|
465 |
+
public function handle_password_reset_shortcodes( $setting, $key,
|
466 |
+
$user_login, $user_data ) {
|
467 |
+
$message = '';
|
468 |
+
|
469 |
+
if ( '' != $user_login ) {
|
470 |
+
// For WordPress version 4.1.0 or less, we could have empty user_login
|
471 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], 'user-password', $user_data->ID );
|
472 |
+
$message = $this->handle_global_user_shortcodes( $message, $user_data->user_email );
|
473 |
+
|
474 |
+
$reset_link = network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' );
|
475 |
+
$message = str_replace( '[password_reset_link]', $reset_link, $message );
|
476 |
+
}
|
477 |
+
|
478 |
+
return $message;
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* Send Password Changed email.
|
483 |
+
*
|
484 |
+
* @param array $setting Notification Setting.
|
485 |
+
* @param WP_User $user User for whom the password has changed.
|
486 |
+
*/
|
487 |
+
public function send_password_changed_email( $setting, $user ) {
|
488 |
+
$user_id = $user->ID;
|
489 |
+
|
490 |
+
$subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $user_id );
|
491 |
+
$message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $user_id );
|
492 |
+
|
493 |
+
if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
|
494 |
+
$message = wpautop( $message );
|
495 |
+
}
|
496 |
+
|
497 |
+
$headers = array();
|
498 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
499 |
+
$headers[] = 'Content-type: text/html';
|
500 |
+
} elseif ( 'text' == $setting[ 'email-formatting' ] ) {
|
501 |
+
$message = strip_tags( $message );
|
502 |
+
}
|
503 |
+
|
504 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
505 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
506 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Generate message for notification.
|
511 |
+
*
|
512 |
+
* @since 1.0
|
513 |
+
* public since @since 1.6
|
514 |
+
*
|
515 |
+
* @param string $message String may have shortcode.
|
516 |
+
* @param string $notification Notification name.
|
517 |
+
* @param string|int $extra_data Additional data for shortcode.
|
518 |
+
*
|
519 |
+
* @return string Processed string.
|
520 |
+
*/
|
521 |
+
public function handle_shortcodes( $message, $notification, $extra_data ) {
|
522 |
+
switch ( $notification ) {
|
523 |
+
case 'new-comment':
|
524 |
+
case 'new-trackback':
|
525 |
+
case 'new-pingback':
|
526 |
+
case 'reply-comment':
|
527 |
+
// handle new comments, trackbacks and pingbacks
|
528 |
+
$message = $this->comment_shortcodes( $message, $extra_data );
|
529 |
+
$comment = get_comment( $extra_data );
|
530 |
+
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
531 |
+
if ( 0 != $comment->user_id ) {
|
532 |
+
$message = $this->user_shortcodes( $message, $comment->user_id );
|
533 |
+
}
|
534 |
+
break;
|
535 |
+
|
536 |
+
case 'admin-password':
|
537 |
+
case 'admin-password-changed':
|
538 |
+
case 'admin-email-changed':
|
539 |
+
case 'admin-user':
|
540 |
+
case 'welcome-email':
|
541 |
+
case 'user-login':
|
542 |
+
$message = $this->user_shortcodes( $message, $extra_data );
|
543 |
+
break;
|
544 |
+
case 'admin-user-login':
|
545 |
+
$message = $this->user_shortcodes( $message, $extra_data );
|
546 |
+
break;
|
547 |
+
case 'new-user':
|
548 |
+
case 'user-role':
|
549 |
+
case 'admin-role':
|
550 |
+
case 'password-changed':
|
551 |
+
// handle users (lost password and new user registration)
|
552 |
+
$message = $this->user_shortcodes( $message, $extra_data );
|
553 |
+
break;
|
554 |
+
|
555 |
+
case 'email-changed':
|
556 |
+
case 'user-password':
|
557 |
+
// handle users (lost password and new user registration)
|
558 |
+
$message = $this->user_shortcodes( $message, $extra_data, 'email_' );
|
559 |
+
break;
|
560 |
+
|
561 |
+
case 'new-category':
|
562 |
+
// handle new category
|
563 |
+
$message = $this->taxonomy_shortcodes( $message, 'category', $extra_data );
|
564 |
+
break;
|
565 |
+
|
566 |
+
case 'new-post_tag':
|
567 |
+
// handle new tag
|
568 |
+
$message = $this->taxonomy_shortcodes( $message, 'post_tag', $extra_data );
|
569 |
+
break;
|
570 |
+
|
571 |
+
case 'core-updated':
|
572 |
+
// handle core updated type
|
573 |
+
$message = $this->core_updated_shortcodes( $message, $extra_data );
|
574 |
+
break;
|
575 |
+
|
576 |
+
case 'data-export':
|
577 |
+
// handle data export email
|
578 |
+
$message = $this->data_export_shortcodes( $message, $extra_data );
|
579 |
+
break;
|
580 |
+
|
581 |
+
case 'data-erased':
|
582 |
+
// handle data export email
|
583 |
+
$message = $this->data_erased_shortcodes( $message, $extra_data );
|
584 |
+
break;
|
585 |
+
|
586 |
+
case 'new-media':
|
587 |
+
case 'update-media':
|
588 |
+
$message = $this->post_shortcodes( $message, $extra_data );
|
589 |
+
$post = get_post( $extra_data );
|
590 |
+
if ( $post instanceof WP_Post ) {
|
591 |
+
$message = $this->user_shortcodes( $message, $post->post_author );
|
592 |
+
}
|
593 |
+
break;
|
594 |
+
|
595 |
+
default:
|
596 |
+
$type = explode( '-', $notification, 2 );
|
597 |
+
if ( 'newterm' == $type[ 0 ] ) {
|
598 |
+
// handle new terms
|
599 |
+
$message = $this->taxonomy_shortcodes( $message, $type[ 1 ], $extra_data );
|
600 |
+
} elseif ( 'new' == $type[ 0 ] || 'update' == $type[ 0 ] || 'pending' == $type[ 0 ] || 'future' == $type[ 0 ] || 'private' == $type[ 0 ] || 'trash' == $type[ 0 ] ) {
|
601 |
+
// handle new, update and pending posts
|
602 |
+
$post_types = get_post_types( array( 'public' => true ), 'names' );
|
603 |
+
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
604 |
+
|
605 |
+
if ( in_array( $type[ 1 ], $post_types ) ) {
|
606 |
+
$message = $this->post_shortcodes( $message, $extra_data );
|
607 |
+
$post = get_post( $extra_data );
|
608 |
+
if ( $post instanceof WP_Post ) {
|
609 |
+
$message = $this->user_shortcodes( $message, $post->post_author );
|
610 |
+
}
|
611 |
+
}
|
612 |
+
} elseif ( 'comment' == $type[ 0 ] || 'moderate' == $type[ 0 ] || 'commentreply' == $type[ 0 ] ) {
|
613 |
+
$message = $this->comment_shortcodes( $message, $extra_data );
|
614 |
+
$comment = get_comment( $extra_data );
|
615 |
+
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
616 |
+
if ( 0 != $comment->user_id ) {
|
617 |
+
$message = $this->user_shortcodes( $message, $comment->user_id );
|
618 |
+
}
|
619 |
+
} elseif ( 'approve' === $type[ 0 ] ) {
|
620 |
+
// handle Approve comments notification
|
621 |
+
$message = $this->comment_shortcodes( $message, $extra_data );
|
622 |
+
$comment = get_comment( $extra_data );
|
623 |
+
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
624 |
+
if ( 0 != $comment->user_id ) {
|
625 |
+
$message = $this->user_shortcodes( $message, $comment->user_id );
|
626 |
+
}
|
627 |
+
break;
|
628 |
+
} elseif ( 'ca' === $type[ 0 ] ) {
|
629 |
+
$message = $this->confirm_action_shortcodes( $message, $extra_data );
|
630 |
+
$message = $this->handle_global_user_shortcodes( $message, $extra_data[ 'email' ] );
|
631 |
+
} elseif ( 'uc' === $type[ 0 ] ) {
|
632 |
+
$message = $this->confirmed_action_shortcodes( $message, $extra_data );
|
633 |
+
$message = $this->handle_global_user_shortcodes( $message, $extra_data[ 'admin_email' ] );
|
634 |
+
}
|
635 |
+
break;
|
636 |
+
}
|
637 |
+
|
638 |
+
$message = $this->global_shortcodes( $message );
|
639 |
+
|
640 |
+
$message = apply_filters( 'bnfw_shortcodes', $message, $notification, $extra_data, $this );
|
641 |
+
return $message;
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* Handle Global shortcodes.
|
646 |
+
*
|
647 |
+
* @since 1.5
|
648 |
+
*
|
649 |
+
* @param string $message String with shortcodes.
|
650 |
+
*
|
651 |
+
* @return string String after processing global shortcodes.
|
652 |
+
*/
|
653 |
+
private function global_shortcodes( $message ) {
|
654 |
+
$message = str_replace( '[global_site_title]', get_bloginfo( 'name' ), $message );
|
655 |
+
$message = str_replace( '[global_site_tagline]', get_bloginfo( 'description' ), $message );
|
656 |
+
$message = str_replace( '[global_site_url]', get_bloginfo( 'url' ), $message );
|
657 |
+
|
658 |
+
$message = str_replace( '[current_time]', current_time( get_option( 'time_format' ) ), $message );
|
659 |
+
$message = str_replace( '[current_date]', date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message );
|
660 |
+
$message = str_replace( '[admin_email]', get_option( 'admin_email' ), $message );
|
661 |
+
|
662 |
+
return $message;
|
663 |
+
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
* Handle Global shortcodes.
|
667 |
+
*
|
668 |
+
* @param string $message Message.
|
669 |
+
* @param string $email Email.
|
670 |
+
*
|
671 |
+
* @return string
|
672 |
+
*/
|
673 |
+
public function handle_global_shortcodes( $message, $email ) {
|
674 |
+
$message = $this->global_shortcodes( $message );
|
675 |
+
|
676 |
+
return $this->handle_global_user_shortcodes( $message, $email );
|
677 |
+
}
|
678 |
+
|
679 |
+
/**
|
680 |
+
* Handle Global User Shortcodes.
|
681 |
+
*
|
682 |
+
* @param string $message String to be processed.
|
683 |
+
* @param string $email Email of the user.
|
684 |
+
*
|
685 |
+
* @return string Processed string.
|
686 |
+
*/
|
687 |
+
public function handle_global_user_shortcodes( $message, $email ) {
|
688 |
+
$user = get_user_by( 'email', $email );
|
689 |
+
|
690 |
+
if ( false === $user ) {
|
691 |
+
$message = str_replace( '[global_user_firstname]', $email, $message );
|
692 |
+
$message = str_replace( '[global_user_lastname]', $email, $message );
|
693 |
+
$message = str_replace( '[global_user_username]', $email, $message );
|
694 |
+
} else {
|
695 |
+
$message = str_replace( '[global_user_firstname]', $user->first_name, $message );
|
696 |
+
$message = str_replace( '[global_user_lastname]', $user->last_name, $message );
|
697 |
+
$message = str_replace( '[global_user_username]', $user->user_login, $message );
|
698 |
+
|
699 |
+
$message = $this->user_shortcodes( $message, $user->ID, 'email_' );
|
700 |
+
}
|
701 |
+
|
702 |
+
$message = str_replace( '[global_user_email]', $email, $message );
|
703 |
+
|
704 |
+
return $message;
|
705 |
+
}
|
706 |
+
|
707 |
+
/**
|
708 |
+
* Handle media post shortcodes.
|
709 |
+
*
|
710 |
+
* @since 1.0
|
711 |
+
* @param string $message
|
712 |
+
* @param int $post_id
|
713 |
+
* @return string
|
714 |
+
*/
|
715 |
+
public function media_post_shortcodes( $message, $post ) {
|
716 |
+
$post_content = $this->may_be_strip_shortcode( $post->post_content );
|
717 |
+
$post_content = apply_filters( 'the_content', $post_content );
|
718 |
+
$post_content = str_replace( ']]>', ']]>', $post_content );
|
719 |
+
$message = str_replace( '[ID]', $post->ID, $message );
|
720 |
+
$message = str_replace( '[media_date]', bnfw_format_date( $post->post_date ), $message );
|
721 |
+
$message = str_replace( '[media_date_gmt]', bnfw_format_date( $post->post_date_gmt ), $message );
|
722 |
+
$message = str_replace( '[media_description]', $post_content, $message );
|
723 |
+
$message = str_replace( '[media_title]', $post->post_title, $message );
|
724 |
+
$message = str_replace( '[media_alt_text]', get_post_meta( $post->ID, '_wp_attachment_image_alt', true ), $message );
|
725 |
+
$message = str_replace( '[media_caption]', $this->may_be_strip_shortcode( get_the_excerpt( $post ) ), $message );
|
726 |
+
$message = str_replace( '[media_status]', $post->post_status, $message );
|
727 |
+
$message = str_replace( '[media_modified]', bnfw_format_date( $post->post_modified ), $message );
|
728 |
+
$message = str_replace( '[media_modified_gmt]', bnfw_format_date( $post->post_modified_gmt ), $message );
|
729 |
+
$message = str_replace( '[media_content_filtered]', $post->post_content_filtered, $message );
|
730 |
+
$message = str_replace( '[media_type]', $post->post_type, $message );
|
731 |
+
$message = str_replace( '[media_mime_type]', $post->post_mime_type, $message );
|
732 |
+
$message = str_replace( '[media_slug]', $post->post_name, $message );
|
733 |
+
$dimensions = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
|
734 |
+
$media_dimensions = $dimensions[ 'width' ] . ' x ' . $dimensions[ 'height' ];
|
735 |
+
$message = str_replace( '[media_dimensions]', $media_dimensions, $message );
|
736 |
+
$user_info = get_userdata( $post->post_author );
|
737 |
+
$message = str_replace( '[media_author]', $user_info->display_name, $message );
|
738 |
+
|
739 |
+
return $message;
|
740 |
+
}
|
741 |
+
|
742 |
+
/**
|
743 |
+
* Handle post shortcodes.
|
744 |
+
*
|
745 |
+
* @since 1.0
|
746 |
+
* @param string $message
|
747 |
+
* @param int $post_id
|
748 |
+
* @return string
|
749 |
+
*/
|
750 |
+
public function post_shortcodes( $message, $post_id ) {
|
751 |
+
$post = get_post( $post_id );
|
752 |
+
|
753 |
+
if ( ! $post instanceof WP_Post ) {
|
754 |
+
return $message;
|
755 |
+
}
|
756 |
+
|
757 |
+
if ( $post->post_type == 'attachment' ) {
|
758 |
+
$message = $this->media_post_shortcodes( $message, $post );
|
759 |
+
}
|
760 |
+
|
761 |
+
$post_content = $this->may_be_strip_shortcode( $post->post_content );
|
762 |
+
$post_content = apply_filters( 'the_content', $post_content );
|
763 |
+
$post_content = str_replace( ']]>', ']]>', $post_content );
|
764 |
+
|
765 |
+
$message = str_replace( '[ID]', $post->ID, $message );
|
766 |
+
$message = str_replace( '[post_date]', bnfw_format_date( $post->post_date ), $message );
|
767 |
+
$message = str_replace( '[post_date_gmt]', bnfw_format_date( $post->post_date_gmt ), $message );
|
768 |
+
$message = str_replace( '[post_content]', $post_content, $message );
|
769 |
+
$message = str_replace( '[post_title]', $post->post_title, $message );
|
770 |
+
$message = str_replace( '[post_excerpt]', $this->may_be_strip_shortcode( get_the_excerpt( $post ) ), $message );
|
771 |
+
$message = str_replace( '[post_status]', $post->post_status, $message );
|
772 |
+
$message = str_replace( '[comment_status]', $post->comment_status, $message );
|
773 |
+
$message = str_replace( '[ping_status]', $post->ping_status, $message );
|
774 |
+
$message = str_replace( '[post_password]', $post->post_password, $message );
|
775 |
+
$message = str_replace( '[post_name]', $post->post_name, $message );
|
776 |
+
$message = str_replace( '[post_slug]', $post->post_name, $message );
|
777 |
+
$message = str_replace( '[to_ping]', $post->to_ping, $message );
|
778 |
+
$message = str_replace( '[pinged]', $post->pinged, $message );
|
779 |
+
$message = str_replace( '[post_modified]', bnfw_format_date( $post->post_modified ), $message );
|
780 |
+
$message = str_replace( '[post_modified_gmt]', bnfw_format_date( $post->post_modified_gmt ), $message );
|
781 |
+
$message = str_replace( '[post_content_filtered]', $post->post_content_filtered, $message );
|
782 |
+
$message = str_replace( '[post_parent]', $post->post_parent, $message );
|
783 |
+
$message = str_replace( '[post_parent_permalink]', get_permalink( $post->post_parent ), $message );
|
784 |
+
$message = str_replace( '[guid]', $post->guid, $message );
|
785 |
+
$message = str_replace( '[menu_order]', $post->menu_order, $message );
|
786 |
+
$message = str_replace( '[post_type]', $post->post_type, $message );
|
787 |
+
$message = str_replace( '[post_mime_type]', $post->post_mime_type, $message );
|
788 |
+
$message = str_replace( '[comment_count]', $post->comment_count, $message );
|
789 |
+
$message = str_replace( '[permalink]', get_permalink( $post->ID ), $message );
|
790 |
+
$message = str_replace( '[post_type_archive]', get_post_type_archive_link( $post->post_type ), $message );
|
791 |
+
|
792 |
+
$message = str_replace( '[edit_post]', $this->get_edit_post_link( $post->ID, 'return' ), $message );
|
793 |
+
|
794 |
+
$featured_image = '';
|
795 |
+
if ( has_post_thumbnail( $post->ID ) ) {
|
796 |
+
$image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
|
797 |
+
if ( is_array( $image_url ) ) {
|
798 |
+
$featured_image = $image_url[ 0 ];
|
799 |
+
}
|
800 |
+
}
|
801 |
+
$message = str_replace( '[featured_image]', $featured_image, $message );
|
802 |
+
|
803 |
+
$message = str_replace( '[first_image]', $this->get_first_image( $post->post_content ), $message );
|
804 |
+
|
805 |
+
if ( 'future' == $post->post_status ) {
|
806 |
+
$message = str_replace( '[post_scheduled_date]', bnfw_format_date( $post->post_date ), $message );
|
807 |
+
$message = str_replace( '[post_scheduled_date_gmt]', bnfw_format_date( $post->post_date_gmt ), $message );
|
808 |
+
} else {
|
809 |
+
$message = str_replace( '[post_scheduled_date]', 'Published', $message );
|
810 |
+
$message = str_replace( '[post_scheduled_date_gmt]', 'Published', $message );
|
811 |
+
}
|
812 |
+
|
813 |
+
$categories = wp_get_post_categories( $post_id, array( 'fields' => 'all' ) );
|
814 |
+
|
815 |
+
$message = str_replace( '[post_category]', implode( ', ', wp_list_pluck( $categories, 'name' ) ), $message );
|
816 |
+
|
817 |
+
if ( count( $categories ) > 0 ) {
|
818 |
+
$message = str_replace(
|
819 |
+
array(
|
820 |
+
'[post_category_slug]',
|
821 |
+
'[post_category_description]',
|
822 |
+
),
|
823 |
+
array(
|
824 |
+
$categories[ 0 ]->slug,
|
825 |
+
$categories[ 0 ]->description,
|
826 |
+
),
|
827 |
+
$message
|
828 |
+
);
|
829 |
+
}
|
830 |
+
|
831 |
+
$tag_list = implode( ', ', wp_get_post_tags( $post_id, array( 'fields' => 'names' ) ) );
|
832 |
+
$message = str_replace( '[post_tag]', $tag_list, $message );
|
833 |
+
|
834 |
+
$user_info = get_userdata( $post->post_author );
|
835 |
+
$message = str_replace( '[post_author]', $user_info->display_name, $message );
|
836 |
+
|
837 |
+
$message = str_replace( '[author_link]', get_author_posts_url( $post->post_author ), $message );
|
838 |
+
|
839 |
+
if ( $last_id = get_post_meta( $post->ID, '_edit_last', true ) ) {
|
840 |
+
if ( $post->post_author != $last_id ) {
|
841 |
+
$last_user_info = get_userdata( $last_id );
|
842 |
+
} else {
|
843 |
+
$last_user_info = $user_info;
|
844 |
+
}
|
845 |
+
|
846 |
+
$message = str_replace( '[post_update_author]', $last_user_info->display_name, $message );
|
847 |
+
}
|
848 |
+
|
849 |
+
$message = str_replace( '[post_term', '[post_term id="' . $post_id . '"', $message );
|
850 |
+
add_shortcode( 'post_term', array( $this, 'post_term_shortcode_handler' ) );
|
851 |
+
$message = do_shortcode( $message );
|
852 |
+
remove_shortcode( 'post_term', array( $this, 'post_term_shortcode_handler' ) );
|
853 |
+
|
854 |
+
return apply_filters( 'bnfw_shortcodes_post', $message, $post_id );
|
855 |
+
}
|
856 |
+
|
857 |
+
/**
|
858 |
+
* Retrieves the edit post link for post.
|
859 |
+
*
|
860 |
+
* This is a copy of the built-in function without the user check.
|
861 |
+
*
|
862 |
+
* Can be used within the WordPress loop or outside of it. Can be used with
|
863 |
+
* pages, posts, attachments, and revisions.
|
864 |
+
*
|
865 |
+
* @param int|WP_Post $id Optional. Post ID or post object. Default is the global `$post`.
|
866 |
+
* @param string $context Optional. How to output the '&' character. Default '&'.
|
867 |
+
* @return string|null The edit post link for the given post. null if the post type is invalid or does
|
868 |
+
* not allow an editing UI.
|
869 |
+
*/
|
870 |
+
public function get_edit_post_link( $id = 0, $context = 'display' ) {
|
871 |
+
if ( ! $post = get_post( $id ) )
|
872 |
+
return;
|
873 |
+
|
874 |
+
if ( 'revision' === $post->post_type )
|
875 |
+
$action = '';
|
876 |
+
elseif ( 'display' == $context )
|
877 |
+
$action = '&action=edit';
|
878 |
+
else
|
879 |
+
$action = '&action=edit';
|
880 |
+
|
881 |
+
$post_type_object = get_post_type_object( $post->post_type );
|
882 |
+
if ( ! $post_type_object )
|
883 |
+
return;
|
884 |
+
|
885 |
+
if ( $post_type_object->_edit_link ) {
|
886 |
+
$link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) );
|
887 |
+
} else {
|
888 |
+
$link = '';
|
889 |
+
}
|
890 |
+
|
891 |
+
/**
|
892 |
+
* Filters the post edit link.
|
893 |
+
*
|
894 |
+
* @since 2.3.0
|
895 |
+
*
|
896 |
+
* @param string $link The edit link.
|
897 |
+
* @param int $post_id Post ID.
|
898 |
+
* @param string $context The link context. If set to 'display' then ampersands
|
899 |
+
* are encoded.
|
900 |
+
*/
|
901 |
+
return apply_filters( 'get_edit_post_link', $link, $post->ID, $context );
|
902 |
+
}
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Handle post term shortcode.
|
906 |
+
*
|
907 |
+
* @param array $atts Shortocde attributes.
|
908 |
+
*
|
909 |
+
* @return string Processed string.
|
910 |
+
*/
|
911 |
+
public function post_term_shortcode_handler( $atts ) {
|
912 |
+
$atts = shortcode_atts( array(
|
913 |
+
'taxonomy' => '',
|
914 |
+
'id' => 0,
|
915 |
+
), $atts );
|
916 |
+
|
917 |
+
$terms = wp_get_post_terms( $atts[ 'id' ], $atts[ 'taxonomy' ], array( 'fields' => 'names' ) );
|
918 |
+
|
919 |
+
if ( ! is_wp_error( $terms ) ) {
|
920 |
+
return implode( ', ', $terms );
|
921 |
+
}
|
922 |
+
|
923 |
+
return '';
|
924 |
+
}
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Strip shortcodes, unless disabled.
|
928 |
+
*
|
929 |
+
* @param string $content Content who's shortcodes should be stripped.
|
930 |
+
*
|
931 |
+
* @return string Processed content.
|
932 |
+
*/
|
933 |
+
private function may_be_strip_shortcode( $content ) {
|
934 |
+
$enable_shortcode = get_option( 'bnfw_enable_shortcodes' );
|
935 |
+
|
936 |
+
if ( '1' == $enable_shortcode ) {
|
937 |
+
return $content;
|
938 |
+
}
|
939 |
+
|
940 |
+
return strip_shortcodes( $content );
|
941 |
+
}
|
942 |
+
|
943 |
+
/**
|
944 |
+
* Handle comment shortcodes.
|
945 |
+
*
|
946 |
+
* @since 1.0
|
947 |
+
*
|
948 |
+
* @param string $message String to be processed.
|
949 |
+
* @param int $comment_id Comment id.
|
950 |
+
*
|
951 |
+
* @return string Processed string.
|
952 |
+
*/
|
953 |
+
private function comment_shortcodes( $message, $comment_id ) {
|
954 |
+
$comment = get_comment( $comment_id );
|
955 |
+
|
956 |
+
$message = str_replace( '[comment_ID]', $comment->comment_ID, $message );
|
957 |
+
$message = str_replace( '[comment_post_ID]', $comment->comment_post_ID, $message );
|
958 |
+
$message = str_replace( '[comment_author]', $comment->comment_author, $message );
|
959 |
+
$message = str_replace( '[comment_author_email]', $comment->comment_author_email, $message );
|
960 |
+
$message = str_replace( '[comment_author_url]', $comment->comment_author_url, $message );
|
961 |
+
$message = str_replace( '[comment_author_IP]', $comment->comment_author_IP, $message );
|
962 |
+
$message = str_replace( '[comment_date]', bnfw_format_date( $comment->comment_date ), $message );
|
963 |
+
$message = str_replace( '[comment_date_gmt]', bnfw_format_date( $comment->comment_date_gmt ), $message );
|
964 |
+
$message = str_replace( '[comment_content]', get_comment_text( $comment->comment_ID ), $message );
|
965 |
+
$message = str_replace( '[comment_karma]', $comment->comment_karma, $message );
|
966 |
+
$message = str_replace( '[comment_approved]', str_replace( array( '0', '1', 'spam' ), array( 'Awaiting Moderation', 'Approved', 'Spam' ), $comment->comment_approved ), $message );
|
967 |
+
$message = str_replace( '[comment_agent]', $comment->comment_agent, $message );
|
968 |
+
$message = str_replace( '[comment_type]', $comment->comment_type, $message );
|
969 |
+
$message = str_replace( '[comment_parent]', $comment->comment_parent, $message );
|
970 |
+
$message = str_replace( '[user_id]', $comment->user_id, $message );
|
971 |
+
$message = str_replace( '[permalink]', get_comment_link( $comment->comment_ID ), $message );
|
972 |
+
$message = str_replace( '[comment_moderation_link]', admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID, $message );
|
973 |
+
$message = str_replace( '[comment_moderation_approve]', '<a href="' . wp_nonce_url( admin_url( "comment.php?action=approve&c={$comment->comment_ID}#wpbody-content" ) ) . '">Approve</a>', $message );
|
974 |
+
$message = str_replace( '[comment_moderation_spam]', '<a href="' . wp_nonce_url( admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . '">Spam</a>', $message );
|
975 |
+
$message = str_replace( '[comment_moderation_delete]', '<a href="' . wp_nonce_url( admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . '">Delete</a>', $message );
|
976 |
+
|
977 |
+
$parent_comment = get_comment( $comment->comment_parent );
|
978 |
+
if ( $parent_comment instanceof WP_Comment ) {
|
979 |
+
$message = str_replace( '[comment_parent_content]', $parent_comment->comment_content, $message );
|
980 |
+
}
|
981 |
+
|
982 |
+
return $message;
|
983 |
+
}
|
984 |
+
|
985 |
+
/**
|
986 |
+
* Handle user shortcodes.
|
987 |
+
*
|
988 |
+
* @since 1.0
|
989 |
+
*
|
990 |
+
* @param string $message String to be processed.
|
991 |
+
* @param int $user_id User id.
|
992 |
+
*
|
993 |
+
* @return string Processed string.
|
994 |
+
*/
|
995 |
+
public function user_shortcodes( $message, $user_id, $prefix = '' ) {
|
996 |
+
global $wp_roles;
|
997 |
+
|
998 |
+
$user_info = get_userdata( $user_id );
|
999 |
+
|
1000 |
+
if ( ! $user_info instanceof WP_User ) {
|
1001 |
+
return $message;
|
1002 |
+
}
|
1003 |
+
|
1004 |
+
// deprecated
|
1005 |
+
$message = str_replace( '[ID]', $user_info->ID, $message );
|
1006 |
+
$message = str_replace( '[display_name]', $user_info->display_name, $message );
|
1007 |
+
$message = str_replace( '[nickname]', $user_info->nickname, $message );
|
1008 |
+
$message = str_replace( '[commenter_avatar]', get_avatar_url( $user_id ), $message );
|
1009 |
+
|
1010 |
+
$message = str_replace( '[' . $prefix . 'user_id]', $user_info->ID, $message );
|
1011 |
+
$message = str_replace( '[' . $prefix . 'user_login]', $user_info->user_login, $message );
|
1012 |
+
$message = str_replace( '[' . $prefix . 'user_nicename]', $user_info->user_nicename, $message );
|
1013 |
+
$message = str_replace( '[' . $prefix . 'user_email]', $user_info->user_email, $message );
|
1014 |
+
$message = str_replace( '[' . $prefix . 'user_url]', $user_info->user_url, $message );
|
1015 |
+
$message = str_replace( '[' . $prefix . 'user_registered]', $user_info->user_registered, $message );
|
1016 |
+
$message = str_replace( '[' . $prefix . 'user_display_name]', $user_info->display_name, $message );
|
1017 |
+
$message = str_replace( '[' . $prefix . 'user_firstname]', $user_info->user_firstname, $message );
|
1018 |
+
$message = str_replace( '[' . $prefix . 'user_lastname]', $user_info->user_lastname, $message );
|
1019 |
+
$message = str_replace( '[' . $prefix . 'user_nickname]', $user_info->nickname, $message );
|
1020 |
+
$message = str_replace( '[' . $prefix . 'user_description]', $user_info->user_description, $message );
|
1021 |
+
$message = str_replace( '[' . $prefix . 'user_avatar]', get_avatar_url( $user_id ), $message );
|
1022 |
+
|
1023 |
+
$roles = array_map( array( $this, 'get_role_label_by_name' ), $user_info->roles );
|
1024 |
+
$message = str_replace( '[' . $prefix . 'user_role]', implode( ', ', $roles ), $message );
|
1025 |
+
|
1026 |
+
$user_capabilities = bnfw_format_user_capabilities( $user_info->wp_capabilities );
|
1027 |
+
if ( ! empty( $user_capabilities ) ) {
|
1028 |
+
$message = str_replace( '[wp_capabilities]', $user_capabilities, $message );
|
1029 |
+
$message = str_replace( '[' . $prefix . 'user_wp_capabilities]', $user_capabilities, $message );
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
$message = apply_filters( 'bnfw_shortcodes_user', $message, $user_id, $prefix );
|
1033 |
+
return $message;
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
/**
|
1037 |
+
* Handle taxonomy shortcodes.
|
1038 |
+
*
|
1039 |
+
* @access private
|
1040 |
+
* @since 1.1
|
1041 |
+
*
|
1042 |
+
* @param string $message
|
1043 |
+
* @param string $taxonomy
|
1044 |
+
* @param int $term_id
|
1045 |
+
* @return string
|
1046 |
+
*/
|
1047 |
+
private function taxonomy_shortcodes( $message, $taxonomy, $term_id ) {
|
1048 |
+
$term_info = get_term( $term_id, $taxonomy );
|
1049 |
+
|
1050 |
+
$message = str_replace( '[slug]', $term_info->slug, $message );
|
1051 |
+
$message = str_replace( '[name]', $term_info->name, $message );
|
1052 |
+
$message = str_replace( '[description]', $term_info->description, $message );
|
1053 |
+
|
1054 |
+
return $message;
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
/**
|
1058 |
+
* Handle Core Updated Shortcodes.
|
1059 |
+
*
|
1060 |
+
* @since 1.6
|
1061 |
+
*
|
1062 |
+
* @param string $message Original message with shortcodes.
|
1063 |
+
* @param string $type The type of email being sent. Can be one of
|
1064 |
+
* 'success', 'fail', 'manual', 'critical'.
|
1065 |
+
*
|
1066 |
+
* @return string Modified content.
|
1067 |
+
*/
|
1068 |
+
private function core_updated_shortcodes( $message, $type ) {
|
1069 |
+
$message = str_replace( '[core_update_status]', $type, $message );
|
1070 |
+
|
1071 |
+
return $message;
|
1072 |
+
}
|
1073 |
+
|
1074 |
+
/**
|
1075 |
+
* Get the list of emails from the notification settings.
|
1076 |
+
*
|
1077 |
+
* @since 1.0
|
1078 |
+
*
|
1079 |
+
* @param array $setting Notification settings
|
1080 |
+
* @param int $id
|
1081 |
+
* @param bool $process_post_authors
|
1082 |
+
* @param bool $process_exclude_current_user
|
1083 |
+
*
|
1084 |
+
* @return array Emails
|
1085 |
+
*/
|
1086 |
+
public function get_emails( $setting, $id, $process_post_authors = true,
|
1087 |
+
$process_exclude_current_user = true ) {
|
1088 |
+
global $current_user;
|
1089 |
+
|
1090 |
+
$emails = array();
|
1091 |
+
|
1092 |
+
$exclude = null;
|
1093 |
+
if ( $process_exclude_current_user && 'true' == $setting[ 'disable-current-user' ] ) {
|
1094 |
+
if ( isset( $current_user->ID ) ) {
|
1095 |
+
$exclude = $current_user->ID;
|
1096 |
+
}
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
$emails[ 'to' ] = array();
|
1100 |
+
|
1101 |
+
if ( ! empty( $setting[ 'users' ] ) ) {
|
1102 |
+
$emails[ 'to' ] = $this->get_emails_from_users( $setting[ 'users' ], $exclude, $id, $setting );
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
/**
|
1106 |
+
* BNFW get to emails.
|
1107 |
+
*/
|
1108 |
+
if ( $process_post_authors && 'true' === $setting[ 'only-post-author' ] ) {
|
1109 |
+
$post_id = $id;
|
1110 |
+
|
1111 |
+
if ( bnfw_is_comment_notification( $setting[ 'notification' ] ) ) {
|
1112 |
+
$comment = get_comment( $id );
|
1113 |
+
$post_id = $comment->comment_post_ID;
|
1114 |
+
}
|
1115 |
+
|
1116 |
+
$type = explode( '-', $setting[ 'notification' ], 2 );
|
1117 |
+
if ( 'approve' == $type[ 0 ] ) {
|
1118 |
+
if ( ! in_array( $comment->comment_author_email, $emails[ 'to' ] ) ) {
|
1119 |
+
$emails[ 'to' ][] = $comment->comment_author_email;
|
1120 |
+
}
|
1121 |
+
} else {
|
1122 |
+
if ( $setting[ 'notification' ] == 'user-customfield' || $setting[ 'notification' ] == 'user-customfieldvalue' ) {
|
1123 |
+
$post_author = $post_id;
|
1124 |
+
} else {
|
1125 |
+
$post_author = get_post_field( 'post_author', $post_id );
|
1126 |
+
}
|
1127 |
+
$author = get_user_by( 'id', $post_author );
|
1128 |
+
if ( false !== $author && $post_author != $exclude ) {
|
1129 |
+
if ( ! in_array( $author->user_email, $emails[ 'to' ] ) ) {
|
1130 |
+
$emails[ 'to' ][] = $author->user_email;
|
1131 |
}
|
1132 |
}
|
1133 |
+
}
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
if ( 'true' == $setting[ 'show-fields' ] ) {
|
1137 |
+
$default_from_field = get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) . '>';
|
1138 |
+
|
1139 |
+
if ( ! empty( $setting[ 'from-name' ] ) && ! empty( $setting[ 'from-email' ] ) && is_email( $setting[ 'from-email' ] ) ) {
|
1140 |
+
$default_from_field = $setting[ 'from-name' ] . ' <' . $setting[ 'from-email' ] . '>';
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
/**
|
1144 |
+
* Filter Email From Field.
|
1145 |
+
*/
|
1146 |
+
$emails[ 'from' ] = apply_filters( 'bnfw_from_field', $default_from_field, $setting, $id, $emails[ 'to' ] );
|
1147 |
+
|
1148 |
+
/**
|
1149 |
+
* Filter Reply Name Field.
|
1150 |
+
*/
|
1151 |
+
$emails[ 'reply-name' ] = apply_filters( 'bnfw_reply_name_field', $setting[ 'reply-name' ], $setting, $id, $emails[ 'to' ] );
|
1152 |
+
|
1153 |
+
/**
|
1154 |
+
* Filter Reply Email Field.
|
1155 |
+
*/
|
1156 |
+
$emails[ 'reply-email' ] = apply_filters( 'bnfw_reply_email_field', $setting[ 'reply-email' ], $setting, $id, $emails[ 'to' ] );
|
1157 |
+
|
1158 |
+
if ( ! empty( $setting[ 'cc' ] ) ) {
|
1159 |
+
$emails[ 'cc' ] = $this->get_emails_from_users( $setting[ 'cc' ], $exclude, $id, $setting );
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
if ( ! empty( $setting[ 'bcc' ] ) ) {
|
1163 |
+
$emails[ 'bcc' ] = $this->get_emails_from_users( $setting[ 'bcc' ], $exclude, $id, $setting );
|
1164 |
+
}
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
$excluded_emails = array();
|
1168 |
+
|
1169 |
+
if ( ! empty( $setting[ 'exclude-users' ] ) ) {
|
1170 |
+
$excluded_emails = $this->get_emails_from_users( $setting[ 'exclude-users' ] );
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
if ( ! empty( $excluded_emails ) ) {
|
1174 |
+
$emails[ 'to' ] = array_diff( $emails[ 'to' ], $excluded_emails );
|
1175 |
+
|
1176 |
+
if ( ! empty( $emails[ 'cc' ] ) ) {
|
1177 |
+
$emails[ 'cc' ] = array_diff( $emails[ 'cc' ], $excluded_emails );
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
if ( ! empty( $emails[ 'bcc' ] ) ) {
|
1181 |
+
$emails[ 'bcc' ] = array_diff( $emails[ 'bcc' ], $excluded_emails );
|
1182 |
+
}
|
1183 |
+
}
|
1184 |
+
$emails[ 'to' ] = apply_filters( 'bnfw_to_emails', $emails[ 'to' ], $setting, $id );
|
1185 |
+
|
1186 |
+
return $emails;
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
/**
|
1190 |
+
* Get emails from users.
|
1191 |
+
*
|
1192 |
+
* @since 1.2
|
1193 |
+
*
|
1194 |
+
* @param array $users Users Array
|
1195 |
+
* @param int $exclude User id to exclude
|
1196 |
+
* @param int $post_id Post id.
|
1197 |
+
* @param array $setting Notification setting.
|
1198 |
+
*
|
1199 |
+
* @return array
|
1200 |
+
*/
|
1201 |
+
public function get_emails_from_users( $users, $exclude = null,
|
1202 |
+
$post_id = 0, $setting = array() ) {
|
1203 |
+
$user_ids = array();
|
1204 |
+
$user_roles = array();
|
1205 |
+
$non_wp_users = array();
|
1206 |
+
|
1207 |
+
if ( empty( $users ) ) {
|
1208 |
+
return array();
|
1209 |
+
}
|
1210 |
+
|
1211 |
+
foreach ( $users as $user ) {
|
1212 |
+
if ( $this->starts_with( $user, 'role-' ) ) {
|
1213 |
+
$user_roles[] = str_replace( 'role-', '', $user );
|
1214 |
+
} elseif ( strpos( $user, '@' ) !== false ) {
|
1215 |
+
$non_wp_users[] = $user;
|
1216 |
+
continue;
|
1217 |
+
} elseif ( absint( $user ) > 0 ) {
|
1218 |
+
$user_ids[] = absint( $user );
|
1219 |
+
} else {
|
1220 |
+
$non_wp_users[] = $user;
|
1221 |
+
}
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
if ( null != $exclude ) {
|
1225 |
+
$user_ids = array_diff( $user_ids, array( $exclude ) );
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
$emails_from_user_ids = $this->get_emails_from_id( $user_ids );
|
1229 |
+
$emails_from_user_roles = $this->get_emails_from_role( $user_roles, $exclude );
|
1230 |
+
|
1231 |
+
if ( ! empty( $setting ) ) {
|
1232 |
+
// for new comment notifications, we need to use post id instead of comment id.
|
1233 |
+
if ( bnfw_is_comment_notification( $setting[ 'notification' ] ) && $post_id ) {
|
1234 |
+
$comment = get_comment( $post_id );
|
1235 |
+
$post_id = $comment->comment_post_ID;
|
1236 |
+
}
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
$non_wp_emails = apply_filters( 'bnfw_non_wp_emails', array(), $non_wp_users, $post_id );
|
1240 |
+
|
1241 |
+
return array_merge( $emails_from_user_roles, $emails_from_user_ids, $non_wp_emails );
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
/**
|
1245 |
+
* Get user emails by user ids.
|
1246 |
+
*
|
1247 |
+
* @since 1.0
|
1248 |
+
*
|
1249 |
+
* @param array $user_ids.
|
1250 |
+
*
|
1251 |
+
* @return array Emails.
|
1252 |
+
*/
|
1253 |
+
private function get_emails_from_id( $user_ids ) {
|
1254 |
+
$email_list = array();
|
1255 |
+
if ( is_array( $user_ids ) && count( $user_ids ) > 0 ) {
|
1256 |
+
$user_query = new WP_User_Query( array( 'include' => $user_ids ) );
|
1257 |
+
foreach ( $user_query->results as $user ) {
|
1258 |
+
$email_list[] = $user->user_email;
|
1259 |
+
}
|
1260 |
+
}
|
1261 |
+
return $email_list;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
/**
|
1265 |
+
* Get emails of users based on role.
|
1266 |
+
*
|
1267 |
+
* @since 1.0
|
1268 |
+
* @param array $roles User Roles
|
1269 |
+
* @param int $exclude User id to exclude
|
1270 |
+
* @return array Email ids
|
1271 |
+
*/
|
1272 |
+
private function get_emails_from_role( $roles, $exclude = null ) {
|
1273 |
+
if ( ! is_array( $roles ) ) {
|
1274 |
+
$roles = array( $roles );
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
$email_list = array();
|
1278 |
+
foreach ( $roles as $role ) {
|
1279 |
+
$role_name = $this->get_role_name_by_label( $role );
|
1280 |
+
$users = get_users(
|
1281 |
+
array(
|
1282 |
+
'role' => $role_name,
|
1283 |
+
'fields' => array( 'user_email', 'ID' ),
|
1284 |
+
)
|
1285 |
+
);
|
1286 |
+
|
1287 |
+
foreach ( $users as $user ) {
|
1288 |
+
if ( null != $exclude ) {
|
1289 |
+
if ( $user->ID == $exclude ) {
|
1290 |
+
continue;
|
1291 |
}
|
1292 |
}
|
1293 |
+
|
1294 |
+
if ( ! in_array( $user->user_email, $email_list ) ) {
|
1295 |
+
$email_list[] = $user->user_email;
|
1296 |
+
}
|
1297 |
+
}
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
return $email_list;
|
1301 |
+
}
|
1302 |
+
|
1303 |
+
/**
|
1304 |
+
* Find if a string starts with another string.
|
1305 |
+
*
|
1306 |
+
* @since 1.2
|
1307 |
+
*
|
1308 |
+
* @param $haystack
|
1309 |
+
* @param $needle
|
1310 |
+
*
|
1311 |
+
* @return bool
|
1312 |
+
*/
|
1313 |
+
private function starts_with( $haystack, $needle ) {
|
1314 |
+
// search backwards starting from haystack length characters from the end
|
1315 |
+
return '' === $needle || strrpos( $haystack, $needle, -strlen( $haystack ) ) !== false;
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
/**
|
1319 |
+
* Get User role name by label.
|
1320 |
+
*
|
1321 |
+
* @param mixed $role_label
|
1322 |
+
*
|
1323 |
+
* @return int|string
|
1324 |
+
*/
|
1325 |
+
protected function get_role_name_by_label( $role_label ) {
|
1326 |
+
global $wp_roles;
|
1327 |
+
foreach ( $wp_roles->roles as $role_name => $role_info ) {
|
1328 |
+
if ( $role_label == $role_info[ 'name' ] || $role_name == $role_label ) {
|
1329 |
+
return $role_name;
|
1330 |
+
}
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
// There is something wrong
|
1334 |
+
return '';
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
/**
|
1338 |
+
* Get the lable for a user role from name.
|
1339 |
+
*
|
1340 |
+
* @param string $role_name Role name
|
1341 |
+
*
|
1342 |
+
* @return string Role Label.
|
1343 |
+
*/
|
1344 |
+
public function get_role_label_by_name( $role_name ) {
|
1345 |
+
global $wp_roles;
|
1346 |
+
|
1347 |
+
if ( ! isset( $wp_roles->roles[ $role_name ] ) ) {
|
1348 |
+
return '';
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
return translate_user_role( $wp_roles->roles[ $role_name ][ 'name' ] );
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
/**
|
1355 |
+
* Get first image in post.
|
1356 |
+
*
|
1357 |
+
* @param mixed $post_content
|
1358 |
+
*
|
1359 |
+
* @return string
|
1360 |
+
*/
|
1361 |
+
protected function get_first_image( $post_content ) {
|
1362 |
+
if ( preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post_content, $matches ) ) {
|
1363 |
+
return $matches[ 1 ][ 0 ];
|
1364 |
+
}
|
1365 |
+
}
|
1366 |
+
|
1367 |
+
/**
|
1368 |
+
* Generate email headers based on the emails.
|
1369 |
+
*
|
1370 |
+
* @since 1.0
|
1371 |
+
* @param array $emails
|
1372 |
+
* @return array
|
1373 |
+
*/
|
1374 |
+
public function get_headers( $emails ) {
|
1375 |
+
$headers = array();
|
1376 |
+
|
1377 |
+
if ( ! empty( $emails[ 'from' ] ) ) {
|
1378 |
+
$headers[] = 'From:' . $emails[ 'from' ];
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
if ( ! empty( $emails[ 'reply-email' ] ) && is_email( $emails[ 'reply-email' ] ) ) {
|
1382 |
+
$headers[] = 'Reply-To:' . $emails[ 'reply-name' ] . '<' . $emails[ 'reply-email' ] . '>';
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
if ( ! empty( $emails[ 'cc' ] ) ) {
|
1386 |
+
$headers[] = 'Cc:' . implode( ',', $emails[ 'cc' ] );
|
1387 |
+
}
|
1388 |
+
if ( ! empty( $emails[ 'bcc' ] ) ) {
|
1389 |
+
$headers[] = 'Bcc:' . implode( ',', $emails[ 'bcc' ] );
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
/**
|
1393 |
+
* Filter out mail headers.
|
1394 |
+
*
|
1395 |
+
* @param array $headers Headers.
|
1396 |
+
* @param array $emails Emails.
|
1397 |
+
*/
|
1398 |
+
return apply_filters( 'bnfw_mail_headers', $headers, $emails );
|
1399 |
+
}
|
1400 |
+
|
1401 |
+
public function handle_user_request_email_shortcodes( $message, $setting,
|
1402 |
+
$email_data ) {
|
1403 |
+
$message = $this->handle_shortcodes( $message, $setting[ 'notification' ], $email_data );
|
1404 |
+
|
1405 |
+
return $message;
|
1406 |
+
}
|
1407 |
+
|
1408 |
+
public function handle_user_confirmed_action_email_shortcodes( $message,
|
1409 |
+
$setting,
|
1410 |
+
$email_data ) {
|
1411 |
+
$message = $this->handle_shortcodes( $message, $setting[ 'notification' ], $email_data );
|
1412 |
+
|
1413 |
+
return $message;
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
public function handle_data_export_email_shortcodes( $message, $setting,
|
1417 |
+
$request_id ) {
|
1418 |
+
$message = $this->handle_shortcodes( $message, $setting[ 'notification' ], $request_id );
|
1419 |
+
|
1420 |
+
return $message;
|
1421 |
+
}
|
1422 |
+
|
1423 |
+
protected function confirm_action_shortcodes( $message, $extra_data ) {
|
1424 |
+
$message = $this->data_request_shortcodes( $message, $extra_data );
|
1425 |
+
$message = str_replace( '[request_confirmation_link]', $extra_data[ 'confirm_url' ], $message );
|
1426 |
+
if ( isset( $extra_data[ 'email' ] ) ) {
|
1427 |
+
$message = str_replace( '[request_email]', $extra_data[ 'email' ], $message );
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
if ( isset( $extra_data[ 'user_email' ] ) ) {
|
1431 |
+
$message = str_replace( '[request_email]', $extra_data[ 'user_email' ], $message );
|
1432 |
+
}
|
1433 |
+
|
1434 |
+
return $message;
|
1435 |
+
}
|
1436 |
+
|
1437 |
+
protected function confirmed_action_shortcodes( $message, $extra_data ) {
|
1438 |
+
$message = $this->data_request_shortcodes( $message, $extra_data );
|
1439 |
+
$message = str_replace( '[data_privacy_requests_url]', $extra_data[ 'manage_url' ], $message );
|
1440 |
+
$message = str_replace( '[request_email]', $extra_data[ 'user_email' ], $message );
|
1441 |
+
|
1442 |
+
return $message;
|
1443 |
+
}
|
1444 |
+
|
1445 |
+
protected function data_request_shortcodes( $message, $extra_data ) {
|
1446 |
+
$message = str_replace( '[data_request_type]', $extra_data[ 'description' ], $message );
|
1447 |
+
|
1448 |
+
return $message;
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
protected function data_export_shortcodes( $message, $request_id ) {
|
1452 |
+
$export_file_url = get_post_meta( $request_id, '_export_file_url', true );
|
1453 |
+
$message = str_replace( '[data_privacy_download_url]', $export_file_url, $message );
|
1454 |
+
|
1455 |
+
$expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
|
1456 |
+
$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
|
1457 |
+
$message = str_replace( '[data_privacy_download_expiry]', $expiration_date, $message );
|
1458 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1459 |
return $message;
|
1460 |
}
|
1461 |
|
1462 |
+
protected function data_erased_shortcodes( $message, $extra_data ) {
|
1463 |
+
$message = str_replace( '[privacy_policy_url]', $extra_data[ 'privacy_policy_url' ], $message );
|
1464 |
+
$message = str_replace( '[sitename]', $extra_data[ 'sitename' ], $message );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1465 |
|
1466 |
+
return $message;
|
1467 |
+
}
|
1468 |
+
|
1469 |
+
/**
|
1470 |
+
* Process shortcodes in email.
|
1471 |
+
*
|
1472 |
+
* @param $email
|
1473 |
+
* @param $post_id
|
1474 |
+
* @param $setting
|
1475 |
+
*
|
1476 |
+
* @return string
|
1477 |
+
*/
|
1478 |
+
public function process_shortcodes_in_email( $email, $post_id, $setting,
|
1479 |
+
$to_emails ) {
|
1480 |
+
if ( ! empty( $setting ) ) {
|
1481 |
+
if ( $this->starts_with( $setting[ 'notification' ], 'comment-' ) || $this->starts_with( $setting[ 'notification' ], 'moderate-' ) ) {
|
1482 |
+
// for new comment notifications, we need to use post id instead of comment id.
|
1483 |
+
$post_id = bnfw_get_post_id_from_comment( $post_id );
|
1484 |
+
}
|
1485 |
+
}
|
1486 |
+
|
1487 |
+
$email = $this->handle_shortcodes( $email, $setting[ 'notification' ], $post_id );
|
1488 |
+
|
1489 |
+
if ( is_array( $to_emails ) && ! empty( $to_emails ) ) {
|
1490 |
+
$to_email = $to_emails[ 0 ];
|
1491 |
+
|
1492 |
+
$email = $this->handle_global_user_shortcodes( $email, $to_email );
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
$processed_emails = array();
|
1496 |
+
if ( is_email( $email ) ) {
|
1497 |
+
$processed_emails[] = $email;
|
1498 |
+
}
|
1499 |
+
|
1500 |
+
$emails = apply_filters( 'bnfw_non_wp_emails', $processed_emails, array( $email ), $post_id );
|
1501 |
+
|
1502 |
+
if ( empty( $emails ) ) {
|
1503 |
+
return '';
|
1504 |
+
}
|
1505 |
+
|
1506 |
+
return $emails[ 0 ];
|
1507 |
+
}
|
1508 |
+
|
1509 |
+
/**
|
1510 |
+
* Check email content type.
|
1511 |
+
*
|
1512 |
+
* @param string $setting Setting.
|
1513 |
+
* @param string $content Content.
|
1514 |
+
*
|
1515 |
+
* @return string Content .
|
1516 |
+
*/
|
1517 |
+
public function check_email_content_type( $setting, $content ) {
|
1518 |
+
|
1519 |
+
if ( 'html' == $setting[ 'email-formatting' ] ) {
|
1520 |
+
add_filter( 'wp_mail_content_type', array( $this, 'set_html_content_type' ) );
|
1521 |
+
if ( 'true' !== $setting[ 'disable-autop' ] ) {
|
1522 |
+
$content = wpautop( $content );
|
1523 |
+
}
|
1524 |
+
} else {
|
1525 |
+
add_filter( 'wp_mail_content_type', array( $this, 'set_text_content_type' ) );
|
1526 |
+
$content = strip_tags( $content );
|
1527 |
+
}
|
1528 |
+
|
1529 |
+
return $content;
|
1530 |
+
}
|
1531 |
+
|
1532 |
+
/**
|
1533 |
+
* Set the email formatting to HTML.
|
1534 |
+
*
|
1535 |
+
* @since 1.4
|
1536 |
+
*/
|
1537 |
+
public function set_html_content_type() {
|
1538 |
+
return 'text/html';
|
1539 |
+
}
|
1540 |
+
|
1541 |
+
/**
|
1542 |
+
* Set the email formatting to text.
|
1543 |
+
*
|
1544 |
+
* @since 1.4
|
1545 |
+
*/
|
1546 |
+
public function set_text_content_type() {
|
1547 |
+
return 'text/plain';
|
1548 |
+
}
|
1549 |
|
|
|
|
|
1550 |
}
|
includes/overrides.php
CHANGED
@@ -24,7 +24,6 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) {
|
|
24 |
|
25 |
if ( version_compare( $wp_version, '4.3', '>=' ) ) {
|
26 |
// for WordPress 4.3 and above
|
27 |
-
global $wpdb;
|
28 |
|
29 |
if ( version_compare( $wp_version, '4.3', '=' ) ) {
|
30 |
$notify = $deprecated;
|
@@ -94,8 +93,14 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) {
|
|
94 |
$wp_hasher = new PasswordHash( 8, true );
|
95 |
}
|
96 |
$hashed = time() . ':' . $wp_hasher->HashPassword( $key );
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
if ( $bnfw->notifier->notification_exists( 'new-user', false ) ) {
|
100 |
$notifications = $bnfw->notifier->get_notifications( 'new-user' );
|
101 |
$password_url = network_site_url( 'wp-login.php?action=rp&key=' . $key . '&login=' . rawurlencode( $user->user_login ), 'login' );
|
24 |
|
25 |
if ( version_compare( $wp_version, '4.3', '>=' ) ) {
|
26 |
// for WordPress 4.3 and above
|
|
|
27 |
|
28 |
if ( version_compare( $wp_version, '4.3', '=' ) ) {
|
29 |
$notify = $deprecated;
|
93 |
$wp_hasher = new PasswordHash( 8, true );
|
94 |
}
|
95 |
$hashed = time() . ':' . $wp_hasher->HashPassword( $key );
|
96 |
+
|
97 |
+
wp_update_user(
|
98 |
+
array(
|
99 |
+
'ID' => $user->ID,
|
100 |
+
'user_activation_key' => $hashed,
|
101 |
+
)
|
102 |
+
);
|
103 |
+
|
104 |
if ( $bnfw->notifier->notification_exists( 'new-user', false ) ) {
|
105 |
$notifications = $bnfw->notifier->get_notifications( 'new-user' );
|
106 |
$password_url = network_site_url( 'wp-login.php?action=rp&key=' . $key . '&login=' . rawurlencode( $user->user_login ), 'login' );
|