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
mainwp / class / class-mainwp-format.php

class-mainwp-format.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 4.1, at class/class-mainwp-format.php

539 lines 21.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Format Utility
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 /**
11 * Class MainWP_Format
12 *
13 * @package MainWP\Dashboard
14 */
15 class MainWP_Format {
16
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 }
27
28 /**
29 * Method get_update_plugins_items().
30 *
31 * Get plugins update.
32 *
33 * @return string $update_items Plugins update items.
34 */
35 public static function get_update_plugins_items() {
36
37 $pluginsNewUpdate = get_option( 'mainwp_updatescheck_mail_update_plugins_new' );
38 if ( ! is_array( $pluginsNewUpdate ) ) {
39 $pluginsNewUpdate = array();
40 }
41 $pluginsToUpdate = get_option( 'mainwp_updatescheck_mail_update_plugins' );
42 if ( ! is_array( $pluginsToUpdate ) ) {
43 $pluginsToUpdate = array();
44 }
45 $notTrustedPluginsNewUpdate = get_option( 'mainwp_updatescheck_mail_ignore_plugins_new' );
46 if ( ! is_array( $notTrustedPluginsNewUpdate ) ) {
47 $notTrustedPluginsNewUpdate = array();
48 }
49 $notTrustedPluginsToUpdate = get_option( 'mainwp_updatescheck_mail_ignore_plugins' );
50 if ( ! is_array( $notTrustedPluginsToUpdate ) ) {
51 $notTrustedPluginsToUpdate = array();
52 }
53
54 $update_items = array();
55 $update_items = MainWP_Utility::array_merge( $pluginsNewUpdate, $pluginsToUpdate );
56 $update_items = MainWP_Utility::array_merge( $update_items, $notTrustedPluginsNewUpdate );
57 $update_items = MainWP_Utility::array_merge( $update_items, $notTrustedPluginsToUpdate );
58
59 return $update_items;
60 }
61
62 /**
63 * Method get_update_themes_items().
64 *
65 * Get themes update items to email.
66 *
67 * @return string $update_items Update themes.
68 */
69 public static function get_update_themes_items() {
70
71 $themesNewUpdate = get_option( 'mainwp_updatescheck_mail_update_themes_new' );
72 if ( ! is_array( $themesNewUpdate ) ) {
73 $themesNewUpdate = array();
74 }
75 $themesToUpdate = get_option( 'mainwp_updatescheck_mail_update_themes' );
76 if ( ! is_array( $themesToUpdate ) ) {
77 $themesToUpdate = array();
78 }
79 $notTrustedThemesNewUpdate = get_option( 'mainwp_updatescheck_mail_ignore_themes_new' );
80 if ( ! is_array( $notTrustedThemesNewUpdate ) ) {
81 $notTrustedThemesNewUpdate = array();
82 }
83 $notTrustedThemesToUpdate = get_option( 'mainwp_updatescheck_mail_ignore_themes' );
84 if ( ! is_array( $notTrustedThemesToUpdate ) ) {
85 $notTrustedThemesToUpdate = array();
86 }
87
88 $update_items = array();
89
90 $update_items = MainWP_Utility::array_merge( $themesNewUpdate, $themesToUpdate );
91 $update_items = MainWP_Utility::array_merge( $update_items, $notTrustedThemesNewUpdate );
92 $update_items = MainWP_Utility::array_merge( $update_items, $notTrustedThemesToUpdate );
93
94 return $update_items;
95 }
96
97 /**
98 * Method get_update_wp_items().
99 *
100 * Get WP update to email.
101 *
102 * @return array $update_items WP update items.
103 */
104 public static function get_update_wp_items() {
105
106 $coreNewUpdate = get_option( 'mainwp_updatescheck_mail_update_core_new' );
107 if ( ! is_array( $coreNewUpdate ) ) {
108 $coreNewUpdate = array();
109 }
110 $coreToUpdate = get_option( 'mainwp_updatescheck_mail_update_core' );
111 if ( ! is_array( $coreToUpdate ) ) {
112 $coreToUpdate = array();
113 }
114 $ignoredCoreNewUpdate = get_option( 'mainwp_updatescheck_mail_ignore_core_new' );
115 if ( ! is_array( $ignoredCoreNewUpdate ) ) {
116 $ignoredCoreNewUpdate = array();
117 }
118 $ignoredCoreToUpdate = get_option( 'mainwp_updatescheck_mail_ignore_core' );
119 if ( ! is_array( $ignoredCoreToUpdate ) ) {
120 $ignoredCoreToUpdate = array();
121 }
122
123 $update_items = array();
124
125 $update_items = MainWP_Utility::array_merge( $coreNewUpdate, $coreToUpdate );
126 $update_items = MainWP_Utility::array_merge( $update_items, $ignoredCoreNewUpdate );
127 $update_items = MainWP_Utility::array_merge( $update_items, $ignoredCoreToUpdate );
128
129 return $update_items;
130 }
131
132 /**
133 * Method get_site_updates_items().
134 *
135 * Get Updates items of websites.
136 *
137 * @param string $what values: plugin, theme, wpcore.
138 * @param array $sites_ids Websites ids filter (option).
139 *
140 * @return array $update_items WP update items.
141 */
142 public static function get_site_updates_items( $what, $sites_ids = false ) {
143
144 $items = array();
145 if ( 'plugin' == $what ) {
146 $items = self::get_update_plugins_items();
147 } elseif ( 'theme' == $what ) {
148 $items = self::get_update_themes_items();
149 } elseif ( 'wpcore' == $what ) {
150 $items = self::get_update_wp_items();
151 }
152
153 $filters = array();
154 foreach ( $items as $item ) {
155 if ( isset( $item['id'] ) ) { // to valid and compatible data.
156 if ( ! empty( $sites_ids ) ) { // if filter by sites ids.
157 if ( ! in_array( $item['id'], $sites_ids ) ) {
158 continue;
159 }
160 }
161 $filters[] = $item;
162 }
163 }
164 return $filters;
165 }
166
167 /**
168 * Method format_email()
169 *
170 * Format email.
171 *
172 * @param string $to_email Send to emails.
173 * @param string $body Email's body.
174 * @param string $title Email's title.
175 * @param bool $plain_text text format.
176 *
177 * @return string Formatted content
178 */
179 public static function format_email( $to_email = null, $body, $title = '', $plain_text = false ) {
180
181 $current_year = gmdate( 'Y' );
182 if ( $plain_text ) {
183 $mail_send['header'] = '';
184 $mail_send['body'] = 'Hi,' . "\r\n\r\n" .
185 ( ( ! empty( $title ) ) ? $title . "\r\n\r\n" : '' ) .
186 $body . "\r\n\r\n";
187 $mail_send['footer'] = 'MainWP: https://mainwp.com' . "\r\n" .
188 'Extensions: https://mainwp.com/mainwp-extensions/' . "\r\n" .
189 'Documentation: https://kb.mainwp.com/' . "\r\n" .
190 'Blog: https://mainwp.com/mainwp-blog/' . "\r\n" .
191 'Codex: https://mainwp.dev/' . "\r\n" .
192 'Support: https://mainwp.com/support/' . "\r\n\r\n" .
193 'Follow us on Twitter: https://twitter.com/mymainwp' . "\r\n" .
194 'Friend us on Facebook: https://www.facebook.com/mainwp' . "\r\n\r\n" .
195 "Copyright {$current_year} MainWP, All rights reserved.";
196 } else {
197 $mail_send['header'] = <<<EOT
198 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
199 <html>
200 <head>
201 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
202 <title> {$title} </title>
203 <style type="text/css">
204 outlook a{padding:0;}
205 body{width:100% !important;}
206 .ReadMsgBody{width:100%;}
207 .ExternalClass{width:100%;}
208 body{-webkit-text-size-adjust:none;}
209 body{margin:0;padding:0;}
210 img{
211 border:0;
212 height:auto;
213 line-height:100%;
214 outline:none;
215 text-decoration:none;
216 }
217 table td{
218 border-collapse:collapse;
219 }
220 #backgroundTable{
221 height:100% !important;
222 margin:0;
223 padding:0;
224 width:100% !important;
225 }
226 body,#backgroundTable{
227 background-color:#FAFAFA;
228 }
229 #templateContainer{
230 border:1px solid #DDDDDD;
231 }
232 h1,.h1{
233 color:#202020;
234 display:block;
235 font-family:Arial;
236 font-size:34px;
237 font-weight:bold;
238 line-height:100%;
239 margin-top:0;
240 margin-right:0;
241 margin-bottom:10px;
242 margin-left:0;
243 text-align:left;
244 }
245 h2,.h2{
246 color:#202020;
247 display:block;
248 font-family:Arial;
249 font-size:30px;
250 font-weight:bold;
251 line-height:100%;
252 margin-top:0;
253 margin-right:0;
254 margin-bottom:10px;
255 margin-left:0;
256 text-align:left;
257 }
258 h3,.h3{
259 color:#202020;
260 display:block;
261 font-family:Arial;
262 font-size:26px;
263 font-weight:bold;
264 line-height:100%;
265 margin-top:0;
266 margin-right:0;
267 margin-bottom:10px;
268 margin-left:0;
269 text-align:left;
270 }
271 h4,.h4{
272 color:#202020;
273 display:block;
274 font-family:Arial;
275 font-size:22px;
276 font-weight:bold;
277 line-height:100%;
278 margin-top:0;
279 margin-right:0;
280 margin-bottom:10px;
281 margin-left:0;
282 text-align:left;
283 }
284 #templatePreheader{
285 background-color:#FAFAFA;
286 }
287 .preheaderContent div{
288 color:#505050;
289 font-family:Arial;
290 font-size:10px;
291 line-height:100%;
292 text-align:left;
293 }
294 .preheaderContent div a:link,.preheaderContent div a:visited,.prehead=
295 erContent div a .yshortcuts {
296 color:#446200;
297 font-weight:normal;
298 text-decoration:underline;
299 }
300 #templateHeader{
301 background-color:#FFFFFF;
302 border-bottom:0;
303 }
304 .headerContent{
305 color:#202020;
306 font-family:Arial;
307 font-size:34px;
308 font-weight:bold;
309 line-height:100%;
310 padding:0;
311 text-align:center;
312 vertical-align:middle;
313 }
314 .headerContent a:link,.headerContent a:visited,.headerContent a .ysho=
315 rtcuts {
316 color:#446200;
317 font-weight:normal;
318 text-decoration:underline;
319 }
320 #headerImage{
321 height:auto;
322 max-width:600px !important;
323 }
324 #templateContainer,.bodyContent{
325 background-color:#FFFFFF;
326 }
327 .bodyContent div{
328 color:#505050;
329 font-family:Arial;
330 font-size:14px;
331 line-height:150%;
332 text-align:left;
333 }
334 .bodyContent div a:link,.bodyContent div a:visited,.bodyContent div a=
335 .yshortcuts {
336 color:#446200;
337 font-weight:bold;
338 text-decoration:underline;
339 }
340 .bodyContent img{
341 display:inline;
342 height:auto;
343 }
344 #templateFooter{
345 background-color:#1d1b1c;
346 border-top:4px solid #7fb100;
347 }
348 .footerContent div{
349 color:#b8b8b8;
350 font-family:Arial;
351 font-size:12px;
352 line-height:125%;
353 text-align:center;
354 }
355 .footerContent div a:link,.footerContent div a:visited,.footerContent=
356 div a .yshortcuts {
357 color:#336699;
358 font-weight:normal;
359 text-decoration:underline;
360 }
361 .footerContent img{
362 display:inline;
363 }
364 #social{
365 background-color:#1d1b1c;
366 border:0;
367 }
368 #social div{
369 text-align:center;
370 }
371 #utility{
372 background-color:#1d1b1c;
373 border:0;
374 }
375 #utility div{
376 text-align:center;
377 }
378 #monkeyRewards img{
379 max-width:190px;
380 }
381 </style>
382 </head>
383 <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="-webkit-text-size-adjust: none;margin: 0;padding: 0;background-color: #FAFAFA;width: 100% !important;">
384 <center>
385 <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="backgroundTable" style="margin: 0;padding:0;background-color: #FAFAFA;height: 100% !important;width: 100% !important;">
386 <tr>
387 <td align="center" valign="top" style="border-collapse: collapse;">
388
389 <!-- // Begin: Template Pre-header \\ -->
390
391 <table border="0" cellpadding="10" cellspacing="0" width="600" id="templatePreheader" style="background-color: #FAFAFA;">
392 <tr>
393 <td valign="top" class="preheaderContent" style="border-collapse: collapse;">
394
395 <!-- // Begin: Standard Preheader \ -->
396
397 <table border="0" cellpadding="10" cellspacing="0" width="100%">
398 <tr>
399 <td valign="top" style="border-collapse: collapse;">
400 <div style="color: #505050;font-family: Arial;font-size: 10px;line-height: 100%;text-align: left;"></div>
401 </td>
402 <td valign="top" width="190" style="border-collapse: collapse;">
403 <div style="color: #505050;font-family: Arial;font-size: 10px;line-height: 100%;text-align: left;"></div>
404 </td>
405 </tr>
406 </table>
407
408 <!-- // End: Standard Preheader \ -->
409
410 </td>
411 </tr>
412 </table>
413
414 <!-- // End: Template Preheader \\ -->
415
416 <table border="0" cellpadding="0" cellspacing="0" width="600" id="templateContainer" style="border: 1px solid #DDDDDD;background-color: #FFFFFF;">
417 <tr>
418 <td align="center" valign="top" style="border-collapse: collapse;">
419
420 <!-- // Begin: Template Header \\ -->
421
422 <table border="0" cellpadding="0" cellspacing="0" width="600" id="templateHeader" style="background-color: #FFFFFF;border-bottom: 0;">
423 <tr>
424 <td class="headerContent" style="border-collapse: collapse;color: #202020;font-family: Arial;font-size: 34px;font-weight: bold;line-height: 100%;padding: 0;text-align: center;vertical-align: middle;">
425
426 <!-- // Begin: Standard Header Image \\ -->
427
428 <a href="https://mainwp.com" target="_blank" style="color: #446200;font-weight: normal;text-decoration: underline;"><img src="https://gallery.mailchimp.com/f3ac05fd307648a9c6bbe320a/images/header.png" alt="MainWP" border="0" style="border: px none;border-color: ;border-style: none;border-width: px;height: 130px;width: 600px;margin: 0;padding: 0;line-height: 100%;outline: none;text-decoration: none;" width="600" height="130"></a>
429
430 <!-- // End: Standard Header Image \\ -->
431
432 </td>
433 </tr>
434 </table>
435
436 <!-- // End: Template Header \\ -->
437
438 </td>
439 </tr>
440 <tr>
441 <td align="center" valign="top" style="border-collapse: collapse;">
442
443 <!-- // Begin: Template Body \\ -->
444
445 <table border="0" cellpadding="0" cellspacing="0" width="600" id="templateBody">
446 <tr>
447 <td valign="top" class="bodyContent" style="border-collapse: collapse;background-color: #FFFFFF;">
448
449 <!-- // Begin: Standard Content \\ -->
450 EOT;
451
452 $title_content = ! empty( $title ) ? '<b style="color: rgb(127, 177, 0); font-family: Helvetica, Sans; font-size: medium; line-height: normal;"> ' . $title . ' </b><br>' : '';
453
454 $mail_send['body'] = <<<EOT
455 <table border="0" cellpadding="20" cellspacing="0" width="100%">
456 <tr>
457 <td valign="top" style="border-collapse: collapse;">
458 <div style="color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;text-align: left;"> Hi, <br><br>
459 {$title_content}
460 <br>{$body}<br>
461 </div>
462 </td>
463 </tr>
464 </table>
465 EOT;
466
467 $mail_send['footer'] = <<<EOT
468 <!-- // End: Standard Content \\ -->
469
470 </td>
471 </tr>
472 </table>
473
474 <!-- // End: Template Body \\ -->
475
476 </td>
477 </tr>
478 <tr>
479 <td align="center" valign="top" style="border-collapse: collapse;">
480
481 <!-- // Begin: Template Footer \\ -->
482
483 <table border="0" cellpadding="10" cellspacing="0" width="600" id="templateFooter" style="background-color: #1d1b1c;border-top: 4px solid #7fb100;">
484 <tr>
485 <td valign="top" class="footerContent" style="border-collapse: collapse;">
486
487 <!-- // Begin: Standard Footer \\ -->
488
489 <table border="0" cellpadding="10" cellspacing="0" width="100%">
490 <tr>
491 <td valign="middle" id="social" style="border-collapse: collapse;background-color: #1d1b1c;border: 0;">
492 <div style="color: #b8b8b8;font-family: Arial;font-size: 12px;line-height: 125%;text-align: center;">
493 <style type="text/css">
494 #mainwp-links a {
495 text-transform: uppercase;
496 text-decoration: none;
497 color: #7fb100 ;
498 }
499 </style>
500 <div class="tpl-content-highlight" id="mainwp-links" style="color: #b8b8b8;font-family: Arial;font-size: 12px;line-height: 125%;text-align: center;">
501 <a href="https://mainwp.com" target="_self" style="color: #7fb100;font-weight: normal;text-decoration: none;text-transform: uppercase;">MainWP</a> | <a href="https://mainwp.com/mainwp-extensions/" target="_self" style="color: #7fb100;font-weight: normal;text-decoration: none;text-transform: uppercase;">Extensions</a> | <a href="https://kb.mainwp.com/" target="_self" style="color: #7fb100;font-weight: normal;text-decoration:none;text-transform: uppercase;">Documentation</a> | <a href="https://mainwp.com/mainwp-blog/" target="_self" style="color: #7fb100;font-weight: normal;text-decoration: none;text-transform: uppercase;">Blog</a> | <a href="http://codex.mainwp.com" target="_self" style="color: #7fb100;font-weight: normal;text-decoration: none;text-transform: uppercase;">Codex</a> | <a href="https://mainwp.com/support/" target="_self" style="color: #7fb100;font-weight: normal;text-decoration: none;text-transform: uppercase;">Support</a></div>
502
503 <hr><br>
504 <a href="https://twitter.com/mymainwp" target="_blank" style="color: #336699;font-weight: normal;text-decoration: underline;">Follow us on Twitter</a> | <a href="https://www.facebook.com/mainwp" style="color:#336699;font-weight: normal;text-decoration: underline;">Friend us on Facebook</a>
505 </td>
506 </tr>
507 <tr>
508 <td valign="top" style="border-collapse: collapse;">
509 <div style="color: #b8b8b8;font-family: Arial;font-size: 12px;line-height: 125%;text-align: center;"><div style="text-align: left;color: #b8b8b8;font-family: Arial;font-size: 12px;line-height: 125%;"><em>Copyright &copy; {$current_year} MainWP, All rights reserved.</em><br></div></div>
510 </td>
511 </tr>
512 </table>
513
514 <!-- // End: Standard Footer \\ -->
515
516 </td>
517 </tr>
518 </table>
519
520 <!-- // End: Template Footer \\ -->
521
522 </td>
523 </tr>
524 </table>
525 <br>
526 </td>
527 </tr>
528 </table>
529 </center>
530 </body>
531 </html>
532 EOT;
533 }
534 $mail_send = apply_filters( 'mainwp_format_email', $mail_send );
535 return $mail_send['header'] . $mail_send['body'] . $mail_send['footer'];
536 }
537
538 }
539