| @@ -6,8 +6,13 @@ | ||
| 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_Format |
| 12 | 17 | * |
| 13 | 18 | * @package MainWP\Dashboard |
| @@ -52,8 +57,13 @@ | ||
| 52 | 57 | if ( ! is_array( $notTrustedPluginsToUpdate ) ) { |
| 53 | 58 | $notTrustedPluginsToUpdate = array(); |
| 54 | 59 | } |
| 55 | 60 | |
| 61 | + $pluginsNewUpdate = static::remove_duplicate_updates( $pluginsNewUpdate, $pluginsToUpdate ); | |
| 62 | + $pluginsToUpdate = static::remove_duplicate_updates( $pluginsToUpdate ); | |
| 63 | + $notTrustedPluginsNewUpdate = static::remove_duplicate_updates( $notTrustedPluginsNewUpdate, $notTrustedPluginsToUpdate ); | |
| 64 | + $notTrustedPluginsToUpdate = static::remove_duplicate_updates( $notTrustedPluginsToUpdate ); | |
| 65 | + | |
| 56 | 66 | $update_items = array(); |
| 57 | 67 | $update_items = MainWP_Utility::array_merge( $pluginsNewUpdate, $pluginsToUpdate ); |
| 58 | 68 | $update_items = MainWP_Utility::array_merge( $update_items, $notTrustedPluginsNewUpdate ); |
| 59 | 69 | $update_items = MainWP_Utility::array_merge( $update_items, $notTrustedPluginsToUpdate ); |
| @@ -60,9 +70,40 @@ | ||
| 60 | 70 | |
| 61 | 71 | return $update_items; |
| 62 | 72 | } |
| 63 | 73 | |
| 74 | + | |
| 64 | 75 | /** |
| 76 | + * Method remove_duplicate_updates | |
| 77 | + * | |
| 78 | + * @param array $checks checks. | |
| 79 | + * @param array $inputs inputs. | |
| 80 | + * @return mixed | |
| 81 | + */ | |
| 82 | + public static function remove_duplicate_updates( $checks, $inputs = array() ) { | |
| 83 | + $tmp = array(); | |
| 84 | + $filters = array(); | |
| 85 | + $done = false; | |
| 86 | + if ( is_array( $inputs ) ) { | |
| 87 | + foreach ( $inputs as $item ) { | |
| 88 | + if ( isset( $item['slug'] ) && isset( $item['id'] ) && isset( $item['current'] ) && ! isset( $filters[ $item['id'] . '_' . $item['slug'] . '_' . $item['current'] ] ) ) { | |
| 89 | + $filters[ $item['id'] . '_' . $item['slug'] . '_' . $item['current'] ] = 1; | |
| 90 | + $done = true; | |
| 91 | + } | |
| 92 | + } | |
| 93 | + } | |
| 94 | + // check not duplicate item in both arrays, for $checks array. | |
| 95 | + foreach ( $checks as $item ) { | |
| 96 | + if ( isset( $item['slug'] ) && isset( $item['id'] ) && isset( $item['current'] ) && ! isset( $filters[ $item['id'] . '_' . $item['slug'] . '_' . $item['current'] ] ) ) { | |
| 97 | + $filters[ $item['id'] . '_' . $item['slug'] . '_' . $item['current'] ] = 1; | |
| 98 | + $tmp[] = $item; | |
| 99 | + $done = true; | |
| 100 | + } | |
| 101 | + } | |
| 102 | + return $done ? $tmp : $checks; // to prevent bad format data. | |
| 103 | + } | |
| 104 | + | |
| 105 | + /** | |
| 65 | 106 | * Method get_update_themes_items(). |
| 66 | 107 | * |
| 67 | 108 | * Get themes update items to email. |
| 68 | 109 | * |
| @@ -88,8 +129,13 @@ | ||
| 88 | 129 | if ( ! is_array( $notTrustedThemesToUpdate ) ) { |
| 89 | 130 | $notTrustedThemesToUpdate = array(); |
| 90 | 131 | } |
| 91 | 132 | |
| 133 | + $themesNewUpdate = static::remove_duplicate_updates( $themesNewUpdate, $themesToUpdate ); | |
| 134 | + $themesToUpdate = static::remove_duplicate_updates( $themesToUpdate ); | |
| 135 | + $notTrustedThemesNewUpdate = static::remove_duplicate_updates( $notTrustedThemesNewUpdate, $notTrustedThemesToUpdate ); | |
| 136 | + $notTrustedThemesToUpdate = static::remove_duplicate_updates( $notTrustedThemesToUpdate ); | |
| 137 | + | |
| 92 | 138 | $update_items = array(); |
| 93 | 139 | |
| 94 | 140 | $update_items = MainWP_Utility::array_merge( $themesNewUpdate, $themesToUpdate ); |
| 95 | 141 | $update_items = MainWP_Utility::array_merge( $update_items, $notTrustedThemesNewUpdate ); |
| @@ -188,10 +234,10 @@ | ||
| 188 | 234 | $mail_send['body'] = 'Hi,' . "\r\n\r\n" . |
| 189 | 235 | ( ( ! empty( $title ) ) ? $title . "\r\n\r\n" : '' ) . |
| 190 | 236 | $body . "\r\n\r\n"; |
| 191 | 237 | $mail_send['footer'] = 'MainWP: https://mainwp.com' . "\r\n" . |
| 192 | - 'Extensions: https://mainwp.com/mainwp-extensions/' . "\r\n" . | |
| 193 | - 'Documentation: https://kb.mainwp.com/' . "\r\n" . | |
| 238 | + 'Add-ons: https://mainwp.com/mainwp-add-ons/' . "\r\n" . | |
| 239 | + 'Documentation: https://docs.mainwp.com/' . "\r\n" . | |
| 194 | 240 | 'Blog: https://mainwp.com/mainwp-blog/' . "\r\n" . |
| 195 | 241 | 'Codex: https://mainwp.dev/' . "\r\n" . |
| 196 | 242 | 'Support: https://mainwp.com/support/' . "\r\n\r\n" . |
| 197 | 243 | 'Follow us on X: https://x.com/mymainwp' . "\r\n" . |
| @@ -197,8 +243,9 @@ | ||
| 197 | 243 | 'Follow us on X: https://x.com/mymainwp' . "\r\n" . |
| 198 | 244 | 'Friend us on Facebook: https://www.facebook.com/mainwp' . "\r\n\r\n" . |
| 199 | 245 | "Copyright {$current_year} MainWP, All rights reserved."; |
| 200 | 246 | } else { |
| 247 | + // phpcs:disable PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- Email HTML templates; refactoring 250+ lines of HTML to string concatenation carries high regression risk with no security benefit as content is not browser-rendered. | |
| 201 | 248 | $mail_send['header'] = <<<EOT |
| 202 | 249 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 203 | 250 | <html> |
| 204 | 251 | <head> |
| @@ -501,9 +548,9 @@ | ||
| 501 | 548 | color: #7fb100 ; |
| 502 | 549 | } |
| 503 | 550 | </style> |
| 504 | 551 | <div class="tpl-content-highlight" id="mainwp-links" style="color: #b8b8b8;font-family: Arial;font-size: 12px;line-height: 125%;text-align: center;"> |
| 505 | - <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> | |
| 552 | + <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-add-ons/" target="_self" style="color: #7fb100;font-weight: normal;text-decoration: none;text-transform: uppercase;">Add-ons</a> | <a href="https://docs.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="https://mainwp.dev/" 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> | |
| 506 | 553 | |
| 507 | 554 | <hr><br> |
| 508 | 555 | <a href="https://x.com/mymainwp" target="_blank" style="color: #336699;font-weight: normal;text-decoration: underline;">Follow us on X</a> | <a href="https://www.facebook.com/mainwp" style="color:#336699;font-weight: normal;text-decoration: underline;">Friend us on Facebook</a> |
| 509 | 556 | </td> |
| @@ -533,8 +580,9 @@ | ||
| 533 | 580 | </center> |
| 534 | 581 | </body> |
| 535 | 582 | </html> |
| 536 | 583 | EOT; |
| 584 | + // phpcs:enable PluginCheck.CodeAnalysis.Heredoc.NotAllowed | |
| 537 | 585 | } |
| 538 | 586 | $mail_send = apply_filters( 'mainwp_format_email', $mail_send ); |
| 539 | 587 | return $mail_send['header'] . $mail_send['body'] . $mail_send['footer']; |
| 540 | 588 | } |