PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.6.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.6.0
1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
suredonation / inc / import / charitable / email-suppressor.php

email-suppressor.php in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 1.6.0, at inc/import/charitable/email-suppressor.php

82 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Email suppression for migration sessions.
4 *
5 * Activated for the duration of write-phase batches so the import does
6 * not blast donation receipts or admin notifications to donors when
7 * their historical records are inserted.
8 *
9 * @package SureDonation
10 */
11
12 namespace SureDonation\Inc\Import\Charitable;
13
14 use SureDonation\Inc\Traits\Get_Instance;
15
16 // Exit if accessed directly.
17 defined( 'ABSPATH' ) || exit;
18
19 /**
20 * Email_Suppressor class.
21 *
22 * @since 1.0.0
23 */
24 class Email_Suppressor {
25 use Get_Instance;
26
27 /**
28 * Whether suppression is currently engaged.
29 *
30 * @var bool
31 */
32 private $active = false;
33
34 /**
35 * Engage email suppression filters.
36 *
37 * Safe to call repeatedly; only adds the filters once.
38 *
39 * @return void
40 * @since 1.0.0
41 */
42 public function activate() {
43 if ( $this->active ) {
44 return;
45 }
46
47 add_filter( 'suredonation_send_email', '__return_false', 999 );
48 add_filter( 'suredonation_pro_send_email', '__return_false', 999 );
49
50 $this->active = true;
51 }
52
53 /**
54 * Disengage email suppression filters.
55 *
56 * Safe to call repeatedly.
57 *
58 * @return void
59 * @since 1.0.0
60 */
61 public function deactivate() {
62 if ( ! $this->active ) {
63 return;
64 }
65
66 remove_filter( 'suredonation_send_email', '__return_false', 999 );
67 remove_filter( 'suredonation_pro_send_email', '__return_false', 999 );
68
69 $this->active = false;
70 }
71
72 /**
73 * Whether suppression is engaged.
74 *
75 * @return bool
76 * @since 1.0.0
77 */
78 public function is_active() {
79 return $this->active;
80 }
81 }
82