PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.1.2
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.1.2
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 / givewp / email-suppressor.php

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

83 lines 1.6 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. Mirrors Charitable's pattern
8 * (add_filter( 'charitable_send_email', '__return_false' )).
9 *
10 * @package SureDonation
11 */
12
13 namespace SureDonation\Inc\Import\Givewp;
14
15 use SureDonation\Inc\Traits\Get_Instance;
16
17 // Exit if accessed directly.
18 defined( 'ABSPATH' ) || exit;
19
20 /**
21 * Email_Suppressor class.
22 *
23 * @since 1.0.0
24 */
25 class Email_Suppressor {
26 use Get_Instance;
27
28 /**
29 * Whether suppression is currently engaged.
30 *
31 * @var bool
32 */
33 private $active = false;
34
35 /**
36 * Engage email suppression filters.
37 *
38 * Safe to call repeatedly; only adds the filters once.
39 *
40 * @return void
41 * @since 1.0.0
42 */
43 public function activate() {
44 if ( $this->active ) {
45 return;
46 }
47
48 add_filter( 'suredonation_send_email', '__return_false', 999 );
49 add_filter( 'suredonation_pro_send_email', '__return_false', 999 );
50
51 $this->active = true;
52 }
53
54 /**
55 * Disengage email suppression filters.
56 *
57 * Safe to call repeatedly.
58 *
59 * @return void
60 * @since 1.0.0
61 */
62 public function deactivate() {
63 if ( ! $this->active ) {
64 return;
65 }
66
67 remove_filter( 'suredonation_send_email', '__return_false', 999 );
68 remove_filter( 'suredonation_pro_send_email', '__return_false', 999 );
69
70 $this->active = false;
71 }
72
73 /**
74 * Whether suppression is engaged.
75 *
76 * @return bool
77 * @since 1.0.0
78 */
79 public function is_active() {
80 return $this->active;
81 }
82 }
83