PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.4.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.4.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.4.1, at class/class-mainwp-format.php

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