PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | class/class-mainwp-notification.php +360 -284 5.0.3.1 → 6.2.2 View file →
@@ -6,341 +6,417 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class MainWP_Notification
12 17 *
13 18 * @package MainWP\Dashboard
14 19 */
15 -class MainWP_Notification {
20 +class MainWP_Notification { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16 21
17 - /**
18 - * Method get_class_name()
19 - *
20 - * Get Class Name.
21 - *
22 - * @return object
23 - */
24 - public static function get_class_name() {
25 - return __CLASS__;
26 - }
22 + /**
23 + * Method get_class_name()
24 + *
25 + * Get Class Name.
26 + *
27 + * @return object
28 + */
29 + public static function get_class_name() {
30 + return __CLASS__;
31 + }
27 32
28 33
29 - /**
30 - * Method send_notify_user()
31 - *
32 - * To send user a notification.
33 - *
34 - * @param int $userId User ID.
35 - * @param string $subject Email Subject.
36 - * @param string $content Email Content.
37 - *
38 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_notification_email()
39 - */
40 - public static function send_notify_user( $userId, $subject, $content ) {
41 - $content_type = 'content-type: text/html';
42 - self::send_wp_mail(
43 - MainWP_DB_Common::instance()->get_user_notification_email( $userId ),
44 - $subject,
45 - $content,
46 - $content_type
47 - );
48 - }
34 + /**
35 + * Method send_notify_user()
36 + *
37 + * To send user a notification.
38 + *
39 + * @param int $userId User ID.
40 + * @param string $subject Email Subject.
41 + * @param string $content Email Content.
42 + *
43 + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_notification_email()
44 + */
45 + public static function send_notify_user( $userId, $subject, $content ) {
46 + $content_type = 'content-type: text/html';
47 + static::send_wp_mail(
48 + MainWP_DB_Common::instance()->get_user_notification_email( $userId ),
49 + $subject,
50 + $content,
51 + $content_type
52 + );
53 + }
49 54
50 55
51 - /**
52 - * Method send_http_check_notification().
53 - *
54 - * Send HTTP response email notification.
55 - *
56 - * @param mixed $email_settings Email settings.
57 - * @param array $sites_status Websites http status.
58 - * @param bool $plain_text Text format.
59 - *
60 - * @return bool False if failed.
61 - *
62 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
63 - * @uses \MainWP\Dashboard\MainWP_Notification_Template::get_template_html()
64 - */
65 - public static function send_http_check_notification( $email_settings, $sites_status, $plain_text ) {
56 + /**
57 + * Method send_http_check_notification().
58 + *
59 + * Send HTTP response email notification.
60 + *
61 + * @param mixed $email_settings Email settings.
62 + * @param array $sites_status Websites http status.
63 + * @param bool $plain_text Text format.
64 + *
65 + * @return bool False if failed.
66 + *
67 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
68 + * @uses \MainWP\Dashboard\MainWP_Notification_Template::get_template_html()
69 + */
70 + public static function send_http_check_notification( $email_settings, $sites_status, $plain_text ) {
66 71
67 - if ( $plain_text ) {
68 - $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
69 - } else {
70 - $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
71 - }
72 + if ( $plain_text ) {
73 + $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
74 + } else {
75 + $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
76 + }
72 77
73 - $heading = $email_settings['heading'];
74 - $subject = $email_settings['subject'];
78 + $heading = $email_settings['heading'];
79 + $subject = $email_settings['subject'];
75 80
76 - $formated_content = MainWP_Notification_Template::instance()->get_template_html(
77 - 'emails/mainwp-after-update-http-check-email.php',
78 - array(
79 - 'sites_statuses' => $sites_status,
80 - 'heading' => $heading,
81 - )
82 - );
81 + $formated_content = MainWP_Notification_Template::instance()->get_template_html(
82 + 'emails/mainwp-after-update-http-check-email.php',
83 + array(
84 + 'sites_statuses' => $sites_status,
85 + 'heading' => $heading,
86 + )
87 + );
83 88
84 - $email = '';
89 + $email = '';
85 90
86 - if ( ! empty( $email_settings['recipients'] ) ) {
87 - $email .= ',' . $email_settings['recipients']; // send to recipients.
88 - }
91 + if ( ! empty( $email_settings['recipients'] ) ) {
92 + $email .= ',' . $email_settings['recipients']; // send to recipients.
93 + }
89 94
90 - $email = trim( $email, ',' );
95 + $email = trim( $email, ',' );
91 96
92 - if ( ! empty( $email ) ) {
93 - MainWP_Logger::instance()->debug( 'http check :: send mail ::' );
94 - self::send_wp_mail(
95 - $email,
96 - $subject,
97 - $formated_content,
98 - $content_type
99 - );
100 - return true;
101 - }
97 + if ( ! empty( $email ) ) {
98 + MainWP_Logger::instance()->debug( 'http check :: send mail ::' );
99 + static::send_wp_mail(
100 + $email,
101 + $subject,
102 + $formated_content,
103 + $content_type
104 + );
105 + return true;
106 + }
102 107
103 - return false;
104 - }
108 + return false;
109 + }
105 110
106 111
107 - /**
108 - * Method send_license_deactivated_alert().
109 - *
110 - * Send extensions license deactivated email notification.
111 - *
112 - * @param mixed $email_settings Email settings.
113 - * @param array $deactivated_license Websites http status.
114 - * @param bool $plain_text Text format.
115 - *
116 - * @return bool False if failed.
117 - */
118 - public static function send_license_deactivated_alert( $email_settings, $deactivated_license, $plain_text ) {
112 + /**
113 + * Method send_license_deactivated_alert().
114 + *
115 + * Send extensions license deactivated email notification.
116 + *
117 + * @param mixed $email_settings Email settings.
118 + * @param array $deactivated_license Websites http status.
119 + * @param bool $plain_text Text format.
120 + *
121 + * @return bool False if failed.
122 + */
123 + public static function send_license_deactivated_alert( $email_settings, $deactivated_license, $plain_text ) {
119 124
120 - if ( $plain_text ) {
121 - $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
122 - } else {
123 - $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
124 - }
125 + if ( $plain_text ) {
126 + $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
127 + } else {
128 + $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
129 + }
125 130
126 - $heading = $email_settings['heading'];
127 - $subject = $email_settings['subject'];
131 + $heading = $email_settings['heading'];
132 + $subject = $email_settings['subject'];
128 133
129 - $formated_content = MainWP_Notification_Template::instance()->get_template_html(
130 - 'emails/mainwp-licenses-deactivated-alert-email.php',
131 - array(
132 - 'deactivated_licenses' => $deactivated_license,
133 - 'heading' => $heading,
134 - )
135 - );
134 + $formated_content = MainWP_Notification_Template::instance()->get_template_html(
135 + 'emails/mainwp-licenses-deactivated-alert-email.php',
136 + array(
137 + 'deactivated_licenses' => $deactivated_license,
138 + 'heading' => $heading,
139 + )
140 + );
136 141
137 - $email = '';
142 + $email = '';
138 143
139 - if ( ! empty( $email_settings['recipients'] ) ) {
140 - $email .= ',' . $email_settings['recipients']; // send to recipients.
141 - }
144 + if ( ! empty( $email_settings['recipients'] ) ) {
145 + $email .= ',' . $email_settings['recipients']; // send to recipients.
146 + }
142 147
143 - $email = trim( $email, ',' );
148 + $email = trim( $email, ',' );
144 149
145 - if ( ! empty( $email ) ) {
146 - MainWP_Logger::instance()->debug( 'license deactivated alert:: send mail ::' );
147 - self::send_wp_mail(
148 - $email,
149 - $subject,
150 - $formated_content,
151 - $content_type
152 - );
153 - return true;
154 - }
150 + if ( ! empty( $email ) ) {
151 + MainWP_Logger::instance()->debug( 'license deactivated alert:: send mail ::' );
152 + static::send_wp_mail(
153 + $email,
154 + $subject,
155 + $formated_content,
156 + $content_type
157 + );
158 + return true;
159 + }
155 160
156 - return false;
157 - }
161 + return false;
162 + }
158 163
159 164
160 - /**
161 - * Method send_daily_digest_notification().
162 - *
163 - * Sent available updates notification email.
164 - *
165 - * @param array $email_settings Email settings.
166 - * @param bool $available_updates Update avaiable.
167 - * @param mixed $wp_updates WP updates.
168 - * @param mixed $plugin_updates Plugins updates.
169 - * @param mixed $theme_updates Themes updates.
170 - * @param mixed $sites_disconnected Sites disconnected.
171 - * @param bool $plain_text Text format.
172 - * @param bool $sites_ids Websites ids - default false (option).
173 - * @param bool $email_site current report site.
174 - *
175 - * @return bool
176 - *
177 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
178 - * @uses \MainWP\Dashboard\MainWP_Notification_Template::get_template_html()
179 - */
180 - public static function send_daily_digest_notification( $email_settings, $available_updates, $wp_updates, $plugin_updates, $theme_updates, $sites_disconnected, $plain_text, $sites_ids = false, $email_site = false ) {
165 + /**
166 + * Method send_daily_digest_notification().
167 + *
168 + * Sent available updates notification email.
169 + *
170 + * @param array $email_settings Email settings.
171 + * @param bool $available_updates Update avaiable.
172 + * @param mixed $wp_updates WP updates.
173 + * @param mixed $plugin_updates Plugin updates.
174 + * @param mixed $theme_updates Theme updates.
175 + * @param mixed $sites_disconnected Sites disconnected.
176 + * @param array $params Other params.
177 + *
178 + * @return bool
179 + *
180 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
181 + * @uses \MainWP\Dashboard\MainWP_Notification_Template::get_template_html()
182 + */
183 + public static function send_daily_digest_notification( $email_settings, $available_updates, $wp_updates, $plugin_updates, $theme_updates, $sites_disconnected, $params = array() ) {
181 184
182 - if ( $email_settings['disable'] ) {
183 - return false; // disabled send daily digest notification.
184 - }
185 + if ( ! is_array( $params ) ) {
186 + $params = array();
187 + }
185 188
186 - $email = '';
189 + $plain_text = isset( $params['plain_text'] ) ? $params['plain_text'] : '';
190 + $sites_ids = isset( $params['sites_ids'] ) ? $params['sites_ids'] : false;
191 + $email_site = isset( $params['email_site'] ) ? $params['email_site'] : false;
187 192
188 - if ( ! empty( $email_settings['recipients'] ) ) {
189 - $email .= ',' . $email_settings['recipients']; // send to recipients, individual email settings or general email settings.
190 - }
193 + if ( $email_settings['disable'] ) {
194 + return false; // disabled send daily digest notification.
195 + }
191 196
192 - $email = trim( $email, ',' );
197 + $email = '';
193 198
194 - if ( empty( $email ) ) {
195 - return false;
196 - }
199 + if ( ! empty( $email_settings['recipients'] ) ) {
200 + $email .= ',' . $email_settings['recipients']; // send to recipients, individual email settings or general email settings.
201 + }
197 202
198 - if ( $plain_text ) {
199 - $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
200 - } else {
201 - $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
202 - }
203 + $email = trim( $email, ',' );
203 204
204 - /**
205 - * Filter: mainwp_daily_digest_content
206 - *
207 - * Filters the Daily Digest email content and adds support for enabling text/plain emails.
208 - *
209 - * @param array $sites_ids Array of sites IDs.
210 - * @param bool $plain_text Wether plain text mode is enabled.
211 - *
212 - * @since 4.1
213 - */
214 - $other_digest = apply_filters( 'mainwp_daily_digest_content', false, $sites_ids, $plain_text );
205 + if ( empty( $email ) ) {
206 + return false;
207 + }
215 208
216 - $heading = $email_settings['heading'];
209 + if ( $plain_text ) {
210 + $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
211 + } else {
212 + $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
213 + }
217 214
218 - $formated_content = MainWP_Notification_Template::instance()->get_template_html(
219 - 'emails/mainwp-daily-digest-email.php',
220 - array(
221 - 'available_updates' => $available_updates,
222 - 'wp_updates' => $wp_updates,
223 - 'plugin_updates' => $plugin_updates,
224 - 'theme_updates' => $theme_updates,
225 - 'sites_disconnected' => $sites_disconnected,
226 - 'other_digest' => $other_digest,
227 - 'heading' => $heading,
228 - 'current_email_site' => $email_site, // support tokens process.
229 - )
230 - );
215 + /**
216 + * Filter: mainwp_daily_digest_content
217 + *
218 + * Filters the Daily Digest email content and adds support for enabling text/plain emails.
219 + *
220 + * @param array $sites_ids Array of sites IDs.
221 + * @param bool $plain_text Wether plain text mode is enabled.
222 + *
223 + * @since 4.1
224 + */
225 + $other_digest = apply_filters( 'mainwp_daily_digest_content', false, $sites_ids, $plain_text );
231 226
232 - $subject = $email_settings['subject'];
233 - $sent = self::send_wp_mail(
234 - $email,
235 - $subject,
236 - $formated_content,
237 - $content_type
238 - );
239 - if ( $sent ) {
240 - MainWP_Logger::instance()->log_update_check( 'daily digest :: send mail :: successful :: ' . $email );
241 - } else {
242 - MainWP_Logger::instance()->log_update_check( 'daily digest :: send mail :: failed :: ' . $email );
243 - }
244 - return true;
245 - }
227 + $heading = $email_settings['heading'];
246 228
229 + $formated_content = MainWP_Notification_Template::instance()->get_template_html(
230 + 'emails/mainwp-daily-digest-email.php',
231 + array(
232 + 'available_updates' => $available_updates,
233 + 'wp_updates' => $wp_updates,
234 + 'plugin_updates' => $plugin_updates,
235 + 'theme_updates' => $theme_updates,
236 + 'sites_disconnected' => $sites_disconnected,
237 + 'other_digest' => $other_digest,
238 + 'heading' => $heading,
239 + 'current_email_site' => $email_site, // support tokens process.
240 + )
241 + );
247 242
248 - /**
249 - * Method send_websites_uptime_monitoring().
250 - *
251 - * Send websites status email notification.
252 - *
253 - * @param string $emails notification emails.
254 - * @param string $subject email subject.
255 - * @param string $mail_content email content.
256 - * @param bool $plain_text Text format.
257 - *
258 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
259 - */
260 - public static function send_websites_uptime_monitoring( $emails, $subject, $mail_content, $plain_text ) {
243 + $subject = $email_settings['subject'];
244 + $sent = static::send_wp_mail(
245 + $email,
246 + $subject,
247 + $formated_content,
248 + $content_type
249 + );
250 + if ( $sent ) {
251 + MainWP_Logger::instance()->log_update_check( 'daily digest :: send mail :: successful :: ' . $email );
252 + } else {
253 + MainWP_Logger::instance()->log_update_check( 'daily digest :: send mail :: failed :: ' . $email );
254 + }
255 + return true;
256 + }
261 257
262 - if ( $plain_text ) {
263 - $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
264 - } else {
265 - $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
266 - }
267 258
268 - if ( ! empty( $emails ) && ! empty( $mail_content ) ) {
269 - MainWP_Logger::instance()->debug( 'sites status :: send mail ::' );
270 - self::send_wp_mail(
271 - $emails,
272 - $subject,
273 - $mail_content,
274 - $content_type
275 - );
276 - }
277 - }
259 + /**
260 + * Method send_websites_uptime_monitoring().
261 + *
262 + * Send websites status email notification.
263 + *
264 + * @param string $emails notification emails.
265 + * @param string $subject email subject.
266 + * @param string $mail_content email content.
267 + * @param bool $plain_text Text format.
268 + * @param object $site_mo Monitor website.
269 + *
270 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
271 + */
272 + public static function send_websites_uptime_monitoring( $emails, $subject, $mail_content, $plain_text, $site_mo = false ) {
278 273
279 - /**
280 - * Method send_websites_health_status_notification().
281 - *
282 - * Send websites status email notification.
283 - *
284 - * @param string $email notification email.
285 - * @param string $subject subject.
286 - * @param string $mail_content email content.
287 - * @param bool $plain_text Text format.
288 - *
289 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
290 - */
291 - public static function send_websites_health_status_notification( $email, $subject, $mail_content, $plain_text ) {
274 + if ( $plain_text ) {
275 + $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
276 + } else {
277 + $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
278 + }
292 279
293 - if ( $plain_text ) {
294 - $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
295 - } else {
296 - $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
297 - }
280 + if ( ! empty( $emails ) && ! empty( $mail_content ) ) {
281 + MainWP_Logger::instance()->log_uptime_notice( 'Uptime monitoring status :: send mail :: ' . $subject );
282 + if ( $site_mo ) {
283 + $event_time = ! empty( $site_mo->hb_time_check ) ? gmdate( 'Y-m-d H:i:s', $site_mo->hb_time_check ) : '';
284 + MainWP_Logger::instance()->log_uptime_notice( 'Sending notification :: [subject=' . esc_html( $subject ) . '] :: [event-time=' . $event_time . '] :: [monitorid=' . $site_mo->monitor_id . '] :: [monitor-url=' . ( empty( $site_mo->issub ) ? $site_mo->url : $site_mo->suburl ) . ']' );
285 + }
286 + static::send_wp_mail(
287 + $emails,
288 + $subject,
289 + $mail_content,
290 + $content_type,
291 + $site_mo
292 + );
293 + }
294 + }
298 295
299 - if ( ! empty( $email ) && ! empty( $mail_content ) ) {
300 - MainWP_Logger::instance()->debug( 'sites health :: send mail ::' );
301 - self::send_wp_mail(
302 - $email,
303 - $subject,
304 - $mail_content,
305 - $content_type
306 - );
307 - }
308 - }
296 + /**
297 + * Method send_websites_health_status_notification().
298 + *
299 + * Send websites status email notification.
300 + *
301 + * @param string $email notification email.
302 + * @param string $subject subject.
303 + * @param string $mail_content email content.
304 + * @param bool $plain_text Text format.
305 + *
306 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
307 + */
308 + public static function send_websites_health_status_notification( $email, $subject, $mail_content, $plain_text ) {
309 309
310 + if ( $plain_text ) {
311 + $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
312 + } else {
313 + $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
314 + }
310 315
311 - /**
312 - * Method send_wp_mail().
313 - *
314 - * Send email via wp_mail().
315 - *
316 - * @param string $email send to email.
317 - * @param string $subject email content.
318 - * @param bool $mail_content Text format.
319 - * @param string $content_type email content.
320 - */
321 - public static function send_wp_mail( $email, $subject, $mail_content, $content_type = '' ) {
322 - if ( empty( $content_type ) ) {
323 - $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
324 - }
316 + if ( ! empty( $email ) && ! empty( $mail_content ) ) {
317 + MainWP_Logger::instance()->debug( 'sites health :: send mail ::' );
318 + static::send_wp_mail(
319 + $email,
320 + $subject,
321 + $mail_content,
322 + $content_type
323 + );
324 + }
325 + }
325 326
326 - $from_header = array(
327 - 'from_name' => get_option( 'admin_email' ),
328 - 'from_email' => get_option( 'admin_email' ),
329 - );
330 327
331 - $custom_header = apply_filters( 'mainwp_send_mail_from_header', false, $email, $subject );
332 - if ( is_array( $custom_header ) && isset( $custom_header['from_name'] ) && isset( $custom_header['from_email'] ) && ! empty( $custom_header['from_name'] ) && ! empty( $custom_header['from_email'] ) ) {
333 - $from_header = $custom_header;
334 - }
328 + /**
329 + * Start notification for auto update info.
330 + *
331 + * @param array $admin_email_settings Admin email settings.
332 + * @param array $params Parameters for the notification.
333 + *
334 + * @return void
335 + */
336 + public static function start_notification_auto_updates_info( $admin_email_settings, $params = array() ) {
335 337
336 - return wp_mail(
337 - $email,
338 - $subject,
339 - $mail_content,
340 - array(
341 - 'From: "' . $from_header['from_name'] . '" <' . $from_header['from_email'] . '>',
342 - $content_type,
343 - )
344 - );
345 - }
338 + $email = isset( $admin_email_settings['recipients'] ) ? $admin_email_settings['recipients'] : '';
339 + $subject = isset( $admin_email_settings['subject'] ) ? $admin_email_settings['subject'] : '';
340 + $plain_text = isset( $params['plain_text'] ) ? $params['plain_text'] : false;
341 + $mail_content = isset( $params['mail_content'] ) ? $params['mail_content'] : '';
342 +
343 + if ( $plain_text ) {
344 + $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
345 + } else {
346 + $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
347 + }
348 +
349 + if ( ! empty( $email ) && ! empty( $mail_content ) ) {
350 + MainWP_Logger::instance()->log_events( 'auto-updates', 'Auto updates notification :: send mail' );
351 + static::send_wp_mail(
352 + $email,
353 + $subject,
354 + $mail_content,
355 + $content_type
356 + );
357 + }
358 + }
359 +
360 +
361 + /**
362 + * Method send_wp_mail().
363 + *
364 + * Send email via wp_mail().
365 + *
366 + * @param string $email send to email.
367 + * @param string $subject email content.
368 + * @param string $mail_content Text format.
369 + * @param string $content_type email content.
370 + * @param mixed $object_sending Optional object associated with the email being sent.
371 + */
372 + public static function send_wp_mail( $email, $subject, $mail_content, $content_type = '', $object_sending = null ) {
373 + if ( empty( $content_type ) ) {
374 + $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
375 + }
376 +
377 + $from_header = array(
378 + 'from_name' => get_option( 'admin_email' ),
379 + 'from_email' => get_option( 'admin_email' ),
380 + );
381 +
382 + $custom_header = apply_filters( 'mainwp_send_mail_from_header', false, $email, $subject );
383 + if ( is_array( $custom_header ) && isset( $custom_header['from_name'] ) && isset( $custom_header['from_email'] ) && ! empty( $custom_header['from_name'] ) && ! empty( $custom_header['from_email'] ) ) {
384 + $from_header = $custom_header;
385 + }
386 +
387 + /**
388 + * Fires before an email is sent via wp_mail().
389 + *
390 + * @since 6.1.6
391 + *
392 + * @param string $email Recipient email address.
393 + * @param string $subject Email subject.
394 + * @param string $mail_content Email message content.
395 + * @param string $content_type Email content type.
396 + * @param object|mixed $object_sending Object associated with the email being sent.
397 + */
398 + $email = apply_filters(
399 + 'mainwp_wp_mail_to',
400 + $email,
401 + $subject,
402 + $mail_content,
403 + $content_type,
404 + $object_sending
405 + );
406 +
407 + if ( empty( $email ) ) {
408 + // stop send.
409 + return false;
410 + }
411 +
412 + return wp_mail(
413 + $email,
414 + $subject,
415 + $mail_content,
416 + array(
417 + 'From: "' . $from_header['from_name'] . '" <' . $from_header['from_email'] . '>',
418 + $content_type,
419 + )
420 + );
421 + }
346 422 }