PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.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 5.2.2 5.3 All 153 releases
← All changes | class/class-mainwp-notification.php +32 -110 5.0.3.24.1 View file →
@@ -33,10 +33,8 @@
33 33 *
34 34 * @param int $userId User ID.
35 35 * @param string $subject Email Subject.
36 36 * @param string $content Email Content.
37 - *
38 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_notification_email()
39 37 */
40 38 public static function send_notify_user( $userId, $subject, $content ) {
41 39 $content_type = 'content-type: text/html';
42 40 self::send_wp_mail(
@@ -55,15 +53,13 @@
55 53 *
56 54 * @param mixed $email_settings Email settings.
57 55 * @param array $sites_status Websites http status.
58 56 * @param bool $plain_text Text format.
57 + * @param bool $general Either general or individual notification.
59 58 *
60 59 * @return bool False if failed.
61 - *
62 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
63 - * @uses \MainWP\Dashboard\MainWP_Notification_Template::get_template_html()
64 60 */
65 - public static function send_http_check_notification( $email_settings, $sites_status, $plain_text ) {
61 + public static function send_http_check_notification( $email_settings, $sites_status, $plain_text, $general = true ) {
66 62
67 63 if ( $plain_text ) {
68 64 $content_type = "Content-Type: text/plain; charset=\"utf-8\"\r\n";
69 65 } else {
@@ -82,69 +78,19 @@
82 78 );
83 79
84 80 $email = '';
85 81
86 - if ( ! empty( $email_settings['recipients'] ) ) {
87 - $email .= ',' . $email_settings['recipients']; // send to recipients.
82 + // do not send individual data to admin.
83 + if ( $general ) {
84 + $email = get_option( 'mainwp_updatescheck_mail_email' );
88 85 }
89 86
90 - $email = trim( $email, ',' );
91 -
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 - }
102 -
103 - return false;
104 - }
105 -
106 -
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 ) {
119 -
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 -
126 - $heading = $email_settings['heading'];
127 - $subject = $email_settings['subject'];
128 -
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 - );
136 -
137 - $email = '';
138 -
139 87 if ( ! empty( $email_settings['recipients'] ) ) {
140 88 $email .= ',' . $email_settings['recipients']; // send to recipients.
141 89 }
142 90
143 - $email = trim( $email, ',' );
144 -
145 91 if ( ! empty( $email ) ) {
146 - MainWP_Logger::instance()->debug( 'license deactivated alert:: send mail ::' );
92 + MainWP_Logger::instance()->debug( 'CRON :: http check :: send mail to :: ' . $email );
147 93 self::send_wp_mail(
148 94 $email,
149 95 $subject,
150 96 $formated_content,
@@ -155,30 +101,25 @@
155 101
156 102 return false;
157 103 }
158 104
159 -
160 105 /**
161 106 * Method send_daily_digest_notification().
162 107 *
163 108 * Sent available updates notification email.
164 109 *
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()
110 + * @param array $email_settings Email settings.
111 + * @param bool $available_updates Update avaiable.
112 + * @param mixed $wp_updates WP updates.
113 + * @param mixed $plugin_updates Plugins updates.
114 + * @param mixed $theme_updates Themes updates.
115 + * @param mixed $sites_disconnected Sites disconnected.
116 + * @param bool $plain_text Text format.
117 + * @param array $sites_ids Websites ids - default false (option).
118 + * @param bool $to_admin Send to admin or not - default false (option).
119 + * @param object $email_site current report site.
179 120 */
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 ) {
121 + public static function send_daily_digest_notification( $email_settings, $available_updates, $wp_updates, $plugin_updates, $theme_updates, $sites_disconnected, $plain_text, $sites_ids = false, $to_admin = false, $email_site = false ) {
181 122
182 123 if ( $email_settings['disable'] ) {
183 124 return false; // disabled send daily digest notification.
184 125 }
@@ -184,14 +125,16 @@
184 125 }
185 126
186 127 $email = '';
187 128
129 + if ( empty( $sites_ids ) || $to_admin ) {
130 + $email = get_option( 'mainwp_updatescheck_mail_email' ); // general notification, do not send individual notification to admin.
131 + }
132 +
188 133 if ( ! empty( $email_settings['recipients'] ) ) {
189 - $email .= ',' . $email_settings['recipients']; // send to recipients, individual email settings or general email settings.
134 + $email .= ',' . $email_settings['recipients']; // send to recipients.
190 135 }
191 136
192 - $email = trim( $email, ',' );
193 -
194 137 if ( empty( $email ) ) {
195 138 return false;
196 139 }
197 140
@@ -228,20 +171,16 @@
228 171 'current_email_site' => $email_site, // support tokens process.
229 172 )
230 173 );
231 174
175 + MainWP_Logger::instance()->debug( 'CRON :: updates check - daily digest :: send mail to [' . $email . ']' );
232 176 $subject = $email_settings['subject'];
233 - $sent = self::send_wp_mail(
177 + self::send_wp_mail(
234 178 $email,
235 179 $subject,
236 180 $formated_content,
237 181 $content_type
238 182 );
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 183 return true;
245 184 }
246 185
247 186
@@ -253,10 +192,8 @@
253 192 * @param string $emails notification emails.
254 193 * @param string $subject email subject.
255 194 * @param string $mail_content email content.
256 195 * @param bool $plain_text Text format.
257 - *
258 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
259 196 */
260 197 public static function send_websites_uptime_monitoring( $emails, $subject, $mail_content, $plain_text ) {
261 198
262 199 if ( $plain_text ) {
@@ -264,10 +201,10 @@
264 201 } else {
265 202 $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
266 203 }
267 204
268 - if ( ! empty( $emails ) && ! empty( $mail_content ) ) {
269 - MainWP_Logger::instance()->debug( 'sites status :: send mail ::' );
205 + if ( ! empty( $emails ) && '' != $mail_content ) {
206 + MainWP_Logger::instance()->debug( 'CRON :: sites status :: send mail to [' . $emails . ']' );
270 207 self::send_wp_mail(
271 208 $emails,
272 209 $subject,
273 210 $mail_content,
@@ -284,10 +221,8 @@
284 221 * @param string $email notification email.
285 222 * @param string $subject subject.
286 223 * @param string $mail_content email content.
287 224 * @param bool $plain_text Text format.
288 - *
289 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
290 225 */
291 226 public static function send_websites_health_status_notification( $email, $subject, $mail_content, $plain_text ) {
292 227
293 228 if ( $plain_text ) {
@@ -295,10 +230,10 @@
295 230 } else {
296 231 $content_type = "Content-Type: text/html; charset=\"utf-8\"\r\n";
297 232 }
298 233
299 - if ( ! empty( $email ) && ! empty( $mail_content ) ) {
300 - MainWP_Logger::instance()->debug( 'sites health :: send mail ::' );
234 + if ( ! empty( $email ) && '' != $mail_content ) {
235 + MainWP_Logger::instance()->debug( 'CRON :: sites health :: send mail to [' . $email . ']' );
301 236 self::send_wp_mail(
302 237 $email,
303 238 $subject,
304 239 $mail_content,
@@ -317,30 +252,17 @@
317 252 * @param string $subject email content.
318 253 * @param bool $mail_content Text format.
319 254 * @param string $content_type email content.
320 255 */
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 - }
325 -
326 - $from_header = array(
327 - 'from_name' => get_option( 'admin_email' ),
328 - 'from_email' => get_option( 'admin_email' ),
329 - );
330 -
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 - }
335 -
336 - return wp_mail(
256 + public static function send_wp_mail( $email, $subject, $mail_content, $content_type ) {
257 + wp_mail(
337 258 $email,
338 259 $subject,
339 260 $mail_content,
340 261 array(
341 - 'From: "' . $from_header['from_name'] . '" <' . $from_header['from_email'] . '>',
262 + 'From: "' . get_option( 'admin_email' ) . '" <' . get_option( 'admin_email' ) . '>',
342 263 $content_type,
343 264 )
344 265 );
345 266 }
267 +
346 268 }