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 | widgets/widget-mainwp-updates-overview.php +799 -548 5.1 → 6.2.2 View file →
@@ -8,8 +8,14 @@
8 8 */
9 9
10 10 namespace MainWP\Dashboard;
11 11
12 +// Exit if accessed directly.
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit;
15 +}
16 +
17 +
12 18 /**
13 19 * Class MainWP_Updates_Overview
14 20 *
15 21 * @package MainWP\Dashboard
@@ -119,19 +125,19 @@
119 125 * @global string
120 126 */
121 127 global $current_user;
122 128
123 - $current_wpid = MainWP_System_Utility::get_current_wpid();
129 + $current_wpid = (int) MainWP_System_Utility::get_current_wpid();
130 + $is_staging = 'no';
124 131
125 132 if ( $current_wpid ) {
126 - $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
133 + $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_updates', 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
127 134 $globalView = false;
128 135 } else {
129 136 $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
130 137 // To support staging extension.
131 - $is_staging = 'no';
132 138 if ( $staging_enabled ) {
133 - $staging_updates_view = MainWP_System_Utility::get_staging_options_sites_view_for_current_users();
139 + $staging_updates_view = MainWP_System_Utility::get_select_staging_view_sites();
134 140 if ( 'staging' === $staging_updates_view ) {
135 141 $is_staging = 'yes';
136 142 }
137 143 }
@@ -136,19 +142,16 @@
136 142 }
137 143 }
138 144 // end support.
139 145
140 - $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ), $is_staging );
146 + $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_updates', 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ), $is_staging, array( 'connected' => 'yes' ) );
141 147 }
142 148
143 149 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
144 - $websites = MainWP_DB::instance()->query( $sql );
145 150
146 151 $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
152 + $count_websites = 0;
147 153
148 - $decodedDismissedPlugins = ! empty( $userExtension->dismissed_plugins ) ? json_decode( $userExtension->dismissed_plugins, true ) : array();
149 - $decodedDismissedThemes = ! empty( $userExtension->dismissed_themes ) ? json_decode( $userExtension->dismissed_themes, true ) : array();
150 -
151 154 $total_wp_upgrades = 0;
152 155 $total_plugin_upgrades = 0;
153 156 $total_translation_upgrades = 0;
154 157 $total_theme_upgrades = 0;
@@ -155,188 +158,217 @@
155 158
156 159 $total_plugins_outdate = 0;
157 160 $total_themes_outdate = 0;
158 161
159 - $all_wp_updates = array();
160 - $all_plugins_updates = array();
161 - $all_themes_updates = array();
162 - $all_translations_updates = array();
162 + $sites_ids = array();
163 163
164 - MainWP_DB::data_seek( $websites, 0 );
165 -
166 164 $currentSite = null;
167 165
168 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
169 - if ( ! $globalView ) {
170 - $currentSite = $website;
171 - }
166 + $count_plugins = 0;
167 + $count_themes = 0;
172 168
173 - $pluginsIgnoredAbandoned_perSites = array();
174 - $themesIgnoredAbandoned_perSites = array();
169 + $cache_overview = array();
170 + $use_cached = false;
175 171
176 - $wp_upgrades = MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' );
177 - $wp_upgrades = ! empty( $wp_upgrades ) ? json_decode( $wp_upgrades, true ) : array();
172 + $cache_group = '';
173 + if ( $globalView ) {
174 + $count_websites = MainWP_DB::instance()->get_websites_count();
175 + $cache_group = MainWP_Cache_Helper::CGR_UPDATES;
176 + $cache_key = MainWP_Cache_Helper::get_cache_key( 'updates_overview', $cache_group, array( 'staging' => $is_staging ) );
177 + $cache_overview = MainWP_Cache_Helper::instance()->get_cache(
178 + $cache_key,
179 + $cache_group
180 + );
181 + }
178 182
179 - if ( $website->is_ignoreCoreUpdates ) {
180 - $wp_upgrades = array();
181 - }
183 + if ( ! empty( $cache_overview ) && is_array( $cache_overview ) ) {
184 + $use_cached = true;
185 + $total_wp_upgrades = isset( $cache_overview['total_wp_upgrades'] ) ? intval( $cache_overview['total_wp_upgrades'] ) : 0;
186 + $total_plugin_upgrades = isset( $cache_overview['total_plugin_upgrades'] ) ? intval( $cache_overview['total_plugin_upgrades'] ) : 0;
187 + $total_translation_upgrades = isset( $cache_overview['total_translation_upgrades'] ) ? intval( $cache_overview['total_translation_upgrades'] ) : 0;
188 + $total_theme_upgrades = isset( $cache_overview['total_theme_upgrades'] ) ? intval( $cache_overview['total_theme_upgrades'] ) : 0;
182 189
183 - if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) {
184 - ++$total_wp_upgrades;
185 - $all_wp_updates[] = array(
186 - 'id' => $website->id,
187 - 'name' => $website->name,
188 - );
189 - }
190 + $count_plugins = isset( $cache_overview['count_plugins'] ) ? intval( $cache_overview['count_plugins'] ) : 0;
191 + $count_themes = isset( $cache_overview['count_themes'] ) ? intval( $cache_overview['count_themes'] ) : 0;
190 192
191 - $translation_upgrades = ! empty( $website->translation_upgrades ) ? json_decode( $website->translation_upgrades, true ) : array();
193 + $total_plugins_outdate = isset( $cache_overview['total_plugins_outdate'] ) ? intval( $cache_overview['total_plugins_outdate'] ) : 0;
194 + $total_themes_outdate = isset( $cache_overview['total_themes_outdate'] ) ? intval( $cache_overview['total_themes_outdate'] ) : 0;
192 195
193 - $plugin_upgrades = ! empty( $website->plugin_upgrades ) ? json_decode( $website->plugin_upgrades, true ) : array();
194 -
195 - if ( $website->is_ignorePluginUpdates ) {
196 - $plugin_upgrades = array();
196 + $sites_ids = isset( $cache_overview['sites_ids'] ) && is_array( $cache_overview['sites_ids'] ) ? $cache_overview['sites_ids'] : array();
197 + } else {
198 + $decodedDismissedPlugins = ! empty( $userExtension->dismissed_plugins ) ? json_decode( $userExtension->dismissed_plugins, true ) : array();
199 + $decodedDismissedThemes = ! empty( $userExtension->dismissed_themes ) ? json_decode( $userExtension->dismissed_themes, true ) : array();
200 + $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
201 + if ( ! is_array( $decodedIgnoredCores ) ) {
202 + $decodedIgnoredCores = array();
197 203 }
204 + }
198 205
199 - $theme_upgrades = ! empty( $website->theme_upgrades ) ? json_decode( $website->theme_upgrades, true ) : array();
200 - if ( $website->is_ignoreThemeUpdates ) {
201 - $theme_upgrades = array();
202 - }
206 + if ( ! $globalView || ! $use_cached ) {
207 + $websites = MainWP_DB::instance()->query( $sql );
208 + MainWP_DB::data_seek( $websites, 0 );
209 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
210 + if ( ! $globalView ) {
211 + $currentSite = $website;
212 + }
203 213
204 - $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
205 - $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array();
214 + $sites_ids[] = $website->id;
206 215
207 - if ( is_array( $decodedPremiumUpgrades ) ) {
208 - foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
209 - $premiumUpgrade['premium'] = true;
216 + $count_plugins += ! empty( $website->plugins ) ? count( json_decode( $website->plugins, true ) ) : 0;
217 + $count_themes += ! empty( $website->themes ) ? count( json_decode( $website->themes, true ) ) : 0;
210 218
211 - if ( 'plugin' === $premiumUpgrade['type'] ) {
212 - if ( ! is_array( $plugin_upgrades ) ) {
213 - $plugin_upgrades = array();
214 - }
215 - if ( ! $website->is_ignorePluginUpdates ) {
219 + $pluginsIgnoredAbandoned_perSites = array();
220 + $themesIgnoredAbandoned_perSites = array();
216 221
217 - $premiumUpgrade = array_filter( $premiumUpgrade );
218 - if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
219 - $plugin_upgrades[ $crrSlug ] = array();
220 - }
222 + $wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array();
223 + $ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array();
221 224
222 - $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
223 - }
224 - } elseif ( 'theme' === $premiumUpgrade['type'] ) {
225 - if ( ! is_array( $theme_upgrades ) ) {
226 - $theme_upgrades = array();
227 - }
228 - if ( ! $website->is_ignoreThemeUpdates ) {
229 - $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
230 - }
231 - }
225 + if ( $website->is_ignoreCoreUpdates || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' ) ) {
226 + $wp_upgrades = array();
232 227 }
233 - }
234 228
235 - if ( is_array( $translation_upgrades ) ) {
229 + if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) {
230 + ++$total_wp_upgrades;
231 + }
236 232
237 - $total_translation_upgrades += count( $translation_upgrades );
233 + $translation_upgrades = ! empty( $website->translation_upgrades ) ? json_decode( $website->translation_upgrades, true ) : array();
238 234
239 - if ( ! empty( $translation_upgrades ) ) {
240 - foreach ( $translation_upgrades as $trans_upgrade ) {
241 - $slug = $trans_upgrade['slug'];
242 - $all_translations_updates[] = array(
243 - 'id' => $website->id,
244 - 'name' => $website->name,
245 - 'translation_slug' => $slug,
246 - );
247 - }
235 + if ( ! empty( $website->ignored_trans_updates ) ) {
236 + $translation_upgrades = array();
248 237 }
249 - }
250 238
251 - if ( is_array( $plugin_upgrades ) ) {
252 - $ignored_plugins = ! empty( $website->ignored_plugins ) ? json_decode( $website->ignored_plugins, true ) : array();
253 - if ( is_array( $ignored_plugins ) ) {
254 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
239 + $plugin_upgrades = ! empty( $website->plugin_upgrades ) ? json_decode( $website->plugin_upgrades, true ) : array();
240 +
241 + if ( $website->is_ignorePluginUpdates ) {
242 + $plugin_upgrades = array();
255 243 }
256 244
257 - $ignored_plugins = ! empty( $userExtension->ignored_plugins ) ? json_decode( $userExtension->ignored_plugins, true ) : array();
258 - if ( is_array( $ignored_plugins ) ) {
259 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
245 + $theme_upgrades = ! empty( $website->theme_upgrades ) ? json_decode( $website->theme_upgrades, true ) : array();
246 + if ( $website->is_ignoreThemeUpdates ) {
247 + $theme_upgrades = array();
260 248 }
261 249
262 - $total_plugin_upgrades += count( $plugin_upgrades );
250 + $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
251 + $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array();
263 252
264 - if ( ! empty( $plugin_upgrades ) ) {
265 - foreach ( $plugin_upgrades as $slug => $value ) {
266 - $all_plugins_updates[] = array(
267 - 'id' => $website->id,
268 - 'name' => $website->name,
269 - 'plugin_slug' => $slug,
270 - );
253 + if ( is_array( $decodedPremiumUpgrades ) ) {
254 + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
255 + $premiumUpgrade['premium'] = true;
256 +
257 + if ( 'plugin' === $premiumUpgrade['type'] ) {
258 + if ( ! is_array( $plugin_upgrades ) ) {
259 + $plugin_upgrades = array();
260 + }
261 + if ( ! $website->is_ignorePluginUpdates ) {
262 +
263 + $premiumUpgrade = array_filter( $premiumUpgrade );
264 + if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
265 + continue;
266 + }
267 +
268 + $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
269 + }
270 + } elseif ( 'theme' === $premiumUpgrade['type'] ) {
271 + if ( ! is_array( $theme_upgrades ) ) {
272 + $theme_upgrades = array();
273 + }
274 + if ( ! $website->is_ignoreThemeUpdates ) {
275 + $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
276 + }
277 + }
271 278 }
272 279 }
273 - }
274 280
275 - if ( is_array( $theme_upgrades ) ) {
276 - $ignored_themes = ! empty( $website->ignored_themes ) ? json_decode( $website->ignored_themes, true ) : array();
277 - if ( is_array( $ignored_themes ) ) {
278 - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes );
281 + if ( is_array( $translation_upgrades ) ) {
282 + $total_translation_upgrades += count( $translation_upgrades );
279 283 }
280 284
281 - $ignored_themes = ! empty( $userExtension->ignored_themes ) ? json_decode( $userExtension->ignored_themes, true ) : array();
282 - if ( is_array( $ignored_themes ) ) {
283 - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes );
284 - }
285 + if ( is_array( $plugin_upgrades ) ) {
286 + $ignored_plugins = ! empty( $website->ignored_plugins ) ? json_decode( $website->ignored_plugins, true ) : array();
287 + if ( is_array( $ignored_plugins ) ) {
288 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
285 289
286 - $total_theme_upgrades += count( $theme_upgrades );
290 + }
287 291
288 - if ( ! empty( $theme_upgrades ) ) {
289 - foreach ( $theme_upgrades as $slug => $value ) {
290 - $all_themes_updates[] = array(
291 - 'id' => $website->id,
292 - 'name' => $website->name,
293 - 'theme_slug' => $slug,
294 - );
292 + $ignored_plugins = ! empty( $userExtension->ignored_plugins ) ? json_decode( $userExtension->ignored_plugins, true ) : array();
293 + if ( is_array( $ignored_plugins ) ) {
294 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
295 +
295 296 }
297 +
298 + $total_plugin_upgrades += count( $plugin_upgrades );
296 299 }
297 - }
298 300
299 - $pluginsIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
300 - $pluginsIgnoredAbandoned_perSites = ! empty( $pluginsIgnoredAbandoned_perSites ) ? json_decode( $pluginsIgnoredAbandoned_perSites, true ) : array();
301 - if ( is_array( $pluginsIgnoredAbandoned_perSites ) ) {
302 - $pluginsIgnoredAbandoned_perSites = array_filter( $pluginsIgnoredAbandoned_perSites );
303 - }
301 + if ( is_array( $theme_upgrades ) ) {
302 + $ignored_themes = ! empty( $website->ignored_themes ) ? json_decode( $website->ignored_themes, true ) : array();
303 + if ( is_array( $ignored_themes ) ) {
304 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
305 + }
304 306
305 - $themesIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' );
306 - $themesIgnoredAbandoned_perSites = ! empty( $themesIgnoredAbandoned_perSites ) ? json_decode( $themesIgnoredAbandoned_perSites, true ) : array();
307 - if ( is_array( $themesIgnoredAbandoned_perSites ) ) {
308 - $themesIgnoredAbandoned_perSites = array_filter( $themesIgnoredAbandoned_perSites );
309 - }
307 + $ignored_themes = ! empty( $userExtension->ignored_themes ) ? json_decode( $userExtension->ignored_themes, true ) : array();
308 + if ( is_array( $ignored_themes ) ) {
309 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
310 + }
310 311
311 - $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' );
312 - $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array();
312 + $total_theme_upgrades += count( $theme_upgrades );
313 + }
313 314
314 - $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' );
315 - $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array();
316 -
317 - if ( is_array( $plugins_outdate ) ) {
315 + $pluginsIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
316 + $pluginsIgnoredAbandoned_perSites = ! empty( $pluginsIgnoredAbandoned_perSites ) ? json_decode( $pluginsIgnoredAbandoned_perSites, true ) : array();
318 317 if ( is_array( $pluginsIgnoredAbandoned_perSites ) ) {
319 - $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsIgnoredAbandoned_perSites );
318 + $pluginsIgnoredAbandoned_perSites = array_filter( $pluginsIgnoredAbandoned_perSites );
320 319 }
321 320
322 - if ( is_array( $decodedDismissedPlugins ) ) {
323 - $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins );
321 + $themesIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' );
322 + $themesIgnoredAbandoned_perSites = ! empty( $themesIgnoredAbandoned_perSites ) ? json_decode( $themesIgnoredAbandoned_perSites, true ) : array();
323 + if ( is_array( $themesIgnoredAbandoned_perSites ) ) {
324 + $themesIgnoredAbandoned_perSites = array_filter( $themesIgnoredAbandoned_perSites );
324 325 }
325 326
326 - $total_plugins_outdate += count( $plugins_outdate );
327 - }
327 + $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' );
328 + $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array();
328 329
329 - if ( is_array( $themes_outdate ) ) {
330 - if ( is_array( $themesIgnoredAbandoned_perSites ) ) {
331 - $themes_outdate = array_diff_key( $themes_outdate, $themesIgnoredAbandoned_perSites );
330 + $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' );
331 + $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array();
332 +
333 + if ( is_array( $plugins_outdate ) ) {
334 + if ( is_array( $pluginsIgnoredAbandoned_perSites ) ) {
335 + $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsIgnoredAbandoned_perSites );
336 + }
337 +
338 + if ( is_array( $decodedDismissedPlugins ) ) {
339 + $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins );
340 + }
341 +
342 + $total_plugins_outdate += count( $plugins_outdate );
332 343 }
333 344
334 - if ( is_array( $decodedDismissedThemes ) ) {
335 - $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes );
345 + if ( is_array( $themes_outdate ) ) {
346 + if ( is_array( $themesIgnoredAbandoned_perSites ) ) {
347 + $themes_outdate = array_diff_key( $themes_outdate, $themesIgnoredAbandoned_perSites );
348 + }
349 +
350 + if ( is_array( $decodedDismissedThemes ) ) {
351 + $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes );
352 + }
353 +
354 + $total_themes_outdate += count( $themes_outdate );
336 355 }
356 + }
337 357
338 - $total_themes_outdate += count( $themes_outdate );
358 + if ( $globalView && ! empty( $cache_key ) ) {
359 + $data = array(
360 + 'total_wp_upgrades',
361 + 'total_plugin_upgrades',
362 + 'total_translation_upgrades',
363 + 'total_theme_upgrades',
364 + 'total_plugins_outdate',
365 + 'total_themes_outdate',
366 + 'count_plugins',
367 + 'count_themes',
368 + 'sites_ids',
369 + );
370 + MainWP_Cache_Helper::add_cache( $cache_key, $cache_group, compact( $data ) );
339 371 }
340 372 }
341 373
342 374 // WP Upgrades part.
@@ -367,9 +399,9 @@
367 399
368 400 if ( ! $globalView ) {
369 401 $last_dtsSync = $currentSite->dtsSync;
370 402 } else {
371 - $result = MainWP_DB_Common::instance()->get_last_sync_status();
403 + $result = MainWP_DB_Common::instance()->get_last_sync_status( $is_staging );
372 404 $sync_status = $result['sync_status'];
373 405 $last_sync = $result['last_sync'];
374 406 $last_dtsSync = $result['last_sync'];
375 407
@@ -379,80 +411,283 @@
379 411 }
380 412
381 413 $lastSyncMsg = '';
382 414 if ( $last_dtsSync ) {
383 - $lastSyncMsg = esc_html__( 'Last successfully completed synchronization: ', 'mainwp' ) . MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $last_dtsSync ) );
415 + $lastSyncMsg = esc_html__( 'Last synchronization completed on: ', 'mainwp' ) . MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $last_dtsSync ) );
384 416 }
385 417
386 - $user_can_update_translation = mainwp_current_user_have_right( 'dashboard', 'update_translations' );
387 - $user_can_update_wordpress = mainwp_current_user_have_right( 'dashboard', 'update_wordpress' );
388 - $user_can_update_themes = mainwp_current_user_have_right( 'dashboard', 'update_themes' );
389 - $user_can_update_plugins = mainwp_current_user_have_right( 'dashboard', 'update_plugins' );
418 + $user_can_update_translation = \mainwp_current_user_can( 'dashboard', 'update_translations' );
419 + $user_can_update_wordpress = \mainwp_current_user_can( 'dashboard', 'update_wordpress' );
420 + $user_can_update_themes = \mainwp_current_user_can( 'dashboard', 'update_themes' );
421 + $user_can_update_plugins = \mainwp_current_user_can( 'dashboard', 'update_plugins' );
390 422
391 423 $can_total_update = ( $user_can_update_wordpress && $user_can_update_plugins && $user_can_update_themes && $user_can_update_translation ) ? true : false;
392 424
393 - static::render_total_update( $total_upgrades, $lastSyncMsg, $can_total_update, $limit_updates_all );
394 - echo '<div class="mainwp-scrolly-overflow">';
395 - static::render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid );
396 - static::render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid );
397 - static::render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid );
398 - if ( 1 === (int) $mainwp_show_language_updates ) {
399 - static::render_language_update( $user_can_update_translation, $total_translation_upgrades, $globalView, $current_wpid );
400 - }
425 + static::render_updates_overview_widget_header( $lastSyncMsg );
426 + ?>
427 + <div class="mainwp-scrolly-overflow">
401 428
402 - /**
403 - * Action: mainwp_updates_overview_after_update_details
404 - *
405 - * Fires at the bottom of the Update Details section in the Updates Overview widget.
406 - *
407 - * @since 4.1
408 - */
409 - do_action( 'mainwp_updates_overview_after_update_details', $currentSite, $globalView, $userExtension );
429 + <div class="ui small cards mainwp-cards">
410 430
411 - static::render_abandoned_plugins( $total_plugins_outdate, $globalView, $current_wpid );
412 - static::render_abandoned_themes( $total_themes_outdate, $globalView, $current_wpid );
431 + <?php static::render_total_update( $total_upgrades, $can_total_update, $limit_updates_all, $count_websites, $count_plugins, $count_themes, $current_wpid ); ?>
432 + <?php static::render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid, $count_websites ); ?>
433 + <?php static::render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid, $count_plugins ); ?>
434 + <?php static::render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid, $count_themes ); ?>
435 + <?php if ( 1 === (int) $mainwp_show_language_updates ) : ?>
436 + <?php static::render_language_update( $user_can_update_translation, $total_translation_upgrades, $globalView, $current_wpid ); ?>
437 + <?php endif; ?>
438 + <?php static::render_abandoned_plugins( $total_plugins_outdate, $globalView, $current_wpid, $count_plugins ); ?>
439 + <?php static::render_abandoned_themes( $total_themes_outdate, $globalView, $current_wpid, $count_themes ); ?>
413 440
414 - static::render_global_update(
415 - $user_can_update_wordpress,
416 - $total_wp_upgrades,
417 - $all_wp_updates,
418 - $user_can_update_plugins,
419 - $total_plugin_upgrades,
420 - $all_plugins_updates,
421 - $user_can_update_themes,
422 - $total_theme_upgrades,
423 - $all_themes_updates,
424 - $mainwp_show_language_updates,
425 - $user_can_update_translation,
426 - $total_translation_upgrades,
427 - $all_translations_updates
428 - );
429 - static::render_bottom( $websites, $globalView );
430 - echo '</div>';
431 - echo '<div class="ui stackable grid mainwp-widget-footer">';
432 - echo '<div class="eight wide column"></div>';
433 - echo '<div class="eight wide column"></div>';
434 - echo '</div>';
441 + <?php
442 + /**
443 + * Action: mainwp_updates_overview_after_update_details
444 + *
445 + * Fires at the bottom of the Update Details section in the Updates Overview widget.
446 + *
447 + * @since 4.1
448 + */
449 + do_action( 'mainwp_updates_overview_after_update_details', $currentSite, $globalView, $userExtension );
450 + ?>
451 +
452 + </div>
453 +
454 + </div>
455 + <div id="mainwp_prepare_global_update_all_container" style="display: none"></div>
456 + <?php
457 +
458 + static::render_bottom( $sites_ids, $globalView );
435 459 }
436 460
437 461 /**
438 - * Render total update.
462 + * Method prepare_update_data().
439 463 *
440 - * @param int $total_upgrades number of update.
441 - * @param string $lastSyncMsg last sync info.
442 - * @param bool true|false $can_total_update permission to update all.
443 - * @param int $limit_updates_all limit number of update per request, 0 is no limit.
464 + * @param string $update_type: Values all, core, plugin, theme, trans.
465 + * @param int $current_wpid Current site id.
444 466 */
445 - public static function render_total_update( $total_upgrades, $lastSyncMsg, $can_total_update, $limit_updates_all ) { // phpcs:ignore -- NOSONAR - complex.
446 - $current_wpid = MainWP_System_Utility::get_current_wpid();
447 - $globalView = true;
467 + public static function prepare_update_data( $update_type, $current_wpid ) { // phpcs:ignore -- NOSONAR - long function.
468 +
469 + $process = array(
470 + 'core' => in_array( $update_type, array( 'all', 'core' ), true ),
471 + 'plugin' => in_array( $update_type, array( 'all', 'plugin' ), true ),
472 + 'theme' => in_array( $update_type, array( 'all', 'theme' ), true ),
473 + 'trans' => in_array( $update_type, array( 'all', 'trans' ), true ),
474 + );
475 +
448 476 if ( $current_wpid ) {
449 - $globalView = false;
477 + $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_updates', 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
478 + } else {
479 + $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
480 + // To support staging extension.
481 + $is_staging = 'no';
482 + if ( $staging_enabled ) {
483 + $staging_updates_view = MainWP_System_Utility::get_select_staging_view_sites();
484 + if ( 'staging' === $staging_updates_view ) {
485 + $is_staging = 'yes';
486 + }
487 + }
488 + // end support.
489 +
490 + $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_updates', 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ), $is_staging, array( 'connected' => 'yes' ) );
450 491 }
492 +
493 + $userExtension = MainWP_DB_Common::instance()->get_user_extension();
494 +
495 + $total_wp_upgrades = 0;
496 + $total_plugin_upgrades = 0;
497 + $total_translation_upgrades = 0;
498 + $total_theme_upgrades = 0;
499 +
500 + $all_wp_updates = array();
501 + $all_plugins_updates = array();
502 + $all_themes_updates = array();
503 + $all_translations_updates = array();
504 +
505 + $decodedIgnoredCores = MainWP_Utility::get_decoded_array( $userExtension->ignored_wp_upgrades );
506 + $decodedIgnoredPlugins = MainWP_Utility::get_decoded_array( $userExtension->ignored_plugins );
507 + $decodedIgnoredThemes = MainWP_Utility::get_decoded_array( $userExtension->ignored_themes );
508 +
509 + $websites = MainWP_DB::instance()->query( $sql );
510 + MainWP_DB::data_seek( $websites, 0 );
511 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
512 +
513 + $plugin_upgrades = array();
514 + $theme_upgrades = array();
515 +
516 + if ( $process['core'] ) {
517 +
518 + $wp_upgrades = MainWP_Utility::get_decoded_array( $website->wp_upgrades );
519 + $ignored_core_upgrades = MainWP_Utility::get_decoded_array( $website->ignored_wp_upgrades );
520 +
521 + if (
522 + $website->is_ignoreCoreUpdates ||
523 + MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) ||
524 + MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' )
525 + ) {
526 + $wp_upgrades = array();
527 + }
528 +
529 + if ( ! empty( $wp_upgrades ) ) {
530 + ++$total_wp_upgrades;
531 +
532 + $all_wp_updates[] = array(
533 + 'id' => $website->id,
534 + 'name' => $website->name,
535 + 'is_suspended' => $website->suspended ? 1 : 0,
536 + );
537 + }
538 + }
539 +
540 + if ( $process['trans'] ) {
541 +
542 + $translation_upgrades = MainWP_Utility::get_decoded_array( $website->translation_upgrades );
543 +
544 + if ( ! empty( $website->ignored_trans_updates ) ) {
545 + $translation_upgrades = array();
546 + }
547 +
548 + if ( is_array( $translation_upgrades ) ) {
549 +
550 + $total_translation_upgrades += count( $translation_upgrades );
551 +
552 + foreach ( $translation_upgrades as $trans_upgrade ) {
553 + $all_translations_updates[] = array(
554 + 'id' => $website->id,
555 + 'name' => $website->name,
556 + 'translation_slug' => rawurlencode( $trans_upgrade['slug'] ),
557 + 'is_suspended' => $website->suspended ? 1 : 0,
558 + );
559 + }
560 + }
561 + }
562 +
563 + $decodedPremiumUpgrades = array();
564 +
565 + if ( $process['plugin'] || $process['theme'] ) {
566 + $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
567 + $decodedPremiumUpgrades = MainWP_Utility::get_decoded_array( $decodedPremiumUpgrades );
568 + }
569 +
570 + if ( $process['plugin'] ) {
571 + $plugin_upgrades = MainWP_Utility::get_decoded_array( $website->plugin_upgrades );
572 +
573 + if ( $website->is_ignorePluginUpdates ) {
574 + $plugin_upgrades = array();
575 + }
576 + if ( is_array( $decodedPremiumUpgrades ) ) {
577 + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
578 + $premiumUpgrade['premium'] = true;
579 + if ( 'plugin' === $premiumUpgrade['type'] ) {
580 + if ( ! is_array( $plugin_upgrades ) ) {
581 + $plugin_upgrades = array();
582 + }
583 + if ( ! $website->is_ignorePluginUpdates ) {
584 +
585 + $premiumUpgrade = array_filter( $premiumUpgrade );
586 + if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
587 + continue;
588 + }
589 +
590 + $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
591 + }
592 + }
593 + }
594 + }
595 + }
596 +
597 + if ( $process['theme'] ) {
598 + $theme_upgrades = MainWP_Utility::get_decoded_array( $website->theme_upgrades );
599 + if ( $website->is_ignoreThemeUpdates ) {
600 + $theme_upgrades = array();
601 + }
602 +
603 + if ( is_array( $decodedPremiumUpgrades ) ) {
604 + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
605 + $premiumUpgrade['premium'] = true;
606 + if ( 'theme' === $premiumUpgrade['type'] ) {
607 + if ( ! is_array( $theme_upgrades ) ) {
608 + $theme_upgrades = array();
609 + }
610 + if ( ! $website->is_ignoreThemeUpdates ) {
611 + $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
612 + }
613 + }
614 + }
615 + }
616 + }
617 +
618 + if ( $process['plugin'] && is_array( $plugin_upgrades ) ) {
619 + $ignored_plugins = MainWP_Utility::get_decoded_array( $website->ignored_plugins );
620 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
621 +
622 + if ( is_array( $decodedIgnoredPlugins ) ) {
623 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $decodedIgnoredPlugins );
624 +
625 + }
626 +
627 + $total_plugin_upgrades += count( $plugin_upgrades );
628 +
629 + if ( ! empty( $plugin_upgrades ) ) {
630 + foreach ( $plugin_upgrades as $slug => $value ) {
631 + $all_plugins_updates[] = array(
632 + 'id' => $website->id,
633 + 'name' => $website->name,
634 + 'plugin_slug' => $slug,
635 + 'is_suspended' => $website->suspended ? 1 : 0,
636 + );
637 + }
638 + }
639 + }
640 +
641 + if ( $process['theme'] && is_array( $theme_upgrades ) ) {
642 + $ignored_themes = MainWP_Utility::get_decoded_array( $website->ignored_themes );
643 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
644 +
645 + if ( is_array( $decodedIgnoredThemes ) ) {
646 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $decodedIgnoredThemes );
647 + }
648 +
649 + $total_theme_upgrades += count( $theme_upgrades );
650 +
651 + if ( ! empty( $theme_upgrades ) ) {
652 + foreach ( $theme_upgrades as $slug => $value ) {
653 + $all_themes_updates[] = array(
654 + 'id' => $website->id,
655 + 'name' => $website->name,
656 + 'theme_slug' => $slug,
657 + 'is_suspended' => $website->suspended ? 1 : 0,
658 + );
659 + }
660 + }
661 + }
662 + }
663 +
664 + switch ( $update_type ) {
665 + case 'core':
666 + return compact( 'total_wp_upgrades', 'all_wp_updates' );
667 + case 'plugin':
668 + return compact( 'total_plugin_upgrades', 'all_plugins_updates' );
669 + case 'theme':
670 + return compact( 'total_theme_upgrades', 'all_themes_updates' );
671 + case 'trans':
672 + return compact( 'total_translation_upgrades', 'all_translations_updates' );
673 + case 'all':
674 + default:
675 + return compact( 'total_wp_upgrades', 'total_plugin_upgrades', 'total_translation_upgrades', 'total_theme_upgrades', 'all_wp_updates', 'all_plugins_updates', 'all_themes_updates', 'all_translations_updates' );
676 + }
677 + }
678 +
679 +
680 + /**
681 + * Renders Updates Overview widget header.
682 + *
683 + * @param string $lastSyncMsg last sync info.
684 + */
685 + public static function render_updates_overview_widget_header( $lastSyncMsg ) {
451 686 ?>
452 687 <div class="ui grid mainwp-widget-header">
453 688 <div class="sixteen wide column">
454 - <h3 class="ui header handle-drag">
689 + <h2 class="ui header handle-drag">
455 690 <?php
456 691 /**
457 692 * Filter: mainwp_updates_overview_widget_title
458 693 *
@@ -462,62 +697,89 @@
462 697 */
463 698 echo esc_html( apply_filters( 'mainwp_updates_overview_widget_title', esc_html__( 'Updates Overview', 'mainwp' ) ) );
464 699 ?>
465 700 <div class="sub header"><?php echo $lastSyncMsg; // phpcs:ignore WordPress.Security.EscapeOutput ?></div>
466 - </h3>
701 + </h2>
467 702 </div>
468 703 </div>
704 + <?php
705 + }
469 706
470 - <input type="hidden" name="updatesoverview_limit_updates_all" id="updatesoverview_limit_updates_all" value="<?php echo intval( $limit_updates_all ); ?>">
471 - <?php
472 - /**
473 - * Action: mainwp_updates_overview_before_total_updates
474 - *
475 - * Fires before the total updates section in the Updates Overview widget.
476 - *
477 - * @since 4.1
478 - */
479 - do_action( 'mainwp_updates_overview_before_total_updates' );
480 - ?>
481 - <div class="ui stackable grid">
707 + /**
708 + * Renders Updates Overview widget footer.
709 + */
710 + public static function render_updates_overview_widget_footer() {
711 + ?>
712 + <div class="ui two column grid mainwp-widget-footer">
713 + <div class="left aligned middle aligned column"></div>
714 + <div class="right aligned middle aligned column"></div>
715 + </div>
716 + <?php
717 + }
482 718
483 - <div class="eight wide middle aligned column">
719 + /**
720 + * Render total update.
721 + *
722 + * @param int $total_upgrades number of update.
723 + * @param bool $can_total_update permission to update all.
724 + * @param int $limit_updates_all limit number of update per request, 0 is no limit.
725 + * @param int $count_websites count websites.
726 + * @param int $count_plugins count plugins.
727 + * @param int $count_themes count themes.
728 + * @param int $current_wpid Current site id.
729 + */
730 + public static function render_total_update( $total_upgrades, $can_total_update, $limit_updates_all, $count_websites, $count_plugins, $count_themes, $current_wpid ) { // phpcs:ignore -- NOSONAR - complex.
484 731
485 - <div class="ui large statistic horizontal">
486 - <div class="value">
487 - <?php echo intval( $total_upgrades ); ?>
488 - </div>
489 - <div class="label">
490 - <?php esc_html_e( 'Total Updates', 'mainwp' ); ?>
491 - </div>
492 - </div>
493 - </div>
732 + if ( 0 < $count_plugins ) {
733 + $outdated_percentage = round( ( ( intval( $total_upgrades ) / intval( $count_themes + $count_plugins + $count_websites ) ) * 100 ), 2 ) . '%';
734 + } else {
735 + $outdated_percentage = '0.00%';
736 + }
494 737
495 - <div class="eight wide middle aligned right aligned column">
496 - <?php
497 - /**
498 - * Filter: mainwp_update_everything_button_text
499 - *
500 - * Filters the Update Everything button text.
501 - *
502 - * @since 4.1
503 - */
738 + ?>
739 + <input type="hidden" name="updatesoverview_limit_updates_all" id="updatesoverview_limit_updates_all" value="<?php echo intval( $limit_updates_all ); ?>">
740 + <?php
741 + /**
742 + * Action: mainwp_updates_overview_before_total_updates
743 + *
744 + * Fires before the total updates section in the Updates Overview widget.
745 + *
746 + * @since 4.1
747 + */
748 + do_action( 'mainwp_updates_overview_before_total_updates' );
504 749
505 - $is_demo = MainWP_Demo_Handle::is_demo_mode();
506 - ?>
507 - <?php if ( $can_total_update ) : ?>
508 - <?php
509 - if ( ! get_option( 'mainwp_hide_update_everything', false ) ) :
510 - if ( $is_demo ) {
511 - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui big button green fluid disabled" disabled="disabled">' . esc_html( apply_filters( 'mainwp_update_everything_button_text', esc_html__( 'Update Everything', 'mainwp' ) ) ) . '</a>' );
512 - } else {
513 - ?>
514 - <a href="#" <?php echo empty( $total_upgrades ) ? 'disabled' : 'onClick="updatesoverview_global_upgrade_all( \'all\' ); return false;"'; ?> class="ui big button fluid green" id="mainwp-update-everything-button" data-tooltip="<?php $globalView ? esc_attr_e( 'Clicking this button will update all Plugins, Themes, WP Core files and translations on ALL your websites.', 'mainwp' ) : esc_attr_e( 'Clicking this button will update all Plugins, Themes, WP Core files and translations on this website.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php echo esc_html( apply_filters( 'mainwp_update_everything_button_text', esc_html__( 'Update Everything', 'mainwp' ) ) ); ?></a>
515 - <?php } ?>
750 + /**
751 + * Filter: mainwp_update_everything_button_text
752 + *
753 + * Filters the Update Everything button text.
754 + *
755 + * @since 4.1
756 + */
757 + ?>
758 + <div class="ui card">
759 + <div class="content">
760 + <div class="header">
761 + <span class="ui large text"><i class="sync alternate icon"></i> <?php echo esc_html( MainWP_Utility::short_number_format( intval( $total_upgrades ) ) ); ?></span>
762 + <?php if ( intval( $total_upgrades ) > 0 ) : ?>
763 + <span class="ui small text">(<?php echo esc_html( $outdated_percentage ); ?>)</span>
764 + <?php else : ?>
765 + <span class="ui small text">(0%)</span>
766 + <?php endif; ?>
767 + </div>
768 + <div class="description"><?php esc_html_e( 'Available updates.', 'mainwp' ); ?></div>
769 + </div>
770 + <div class="extra content">
771 + <div class="ui grid">
772 + <div class="center aligned middle alidgned column">
773 + <?php if ( ! get_option( 'mainwp_hide_update_everything', false ) ) : ?>
774 + <?php if ( $can_total_update ) : ?>
775 + <a href="#" <?php echo empty( $total_upgrades ) ? 'disabled' : 'onClick="updatesoverview_global_upgrade_all( \'all\', ' . intval( $current_wpid ) . ' ); return false;"'; ?> class="ui mini basic green fluid button" id="mainwp-update-everything-button"><?php echo esc_html( apply_filters( 'mainwp_update_everything_button_text', esc_html__( 'Update Everything', 'mainwp' ) ) ); ?></a>
516 776 <?php endif; ?>
517 - <?php endif; ?>
777 + <?php endif; ?>
778 + </div>
518 779 </div>
519 780 </div>
781 + </div>
520 782 <?php
521 783 /**
522 784 * Action: mainwp_updates_overview_after_total_updates
523 785 *
@@ -528,35 +790,34 @@
528 790 do_action( 'mainwp_updates_overview_after_total_updates' );
529 791 }
530 792
531 793 /**
532 - * Render WordPress update details.
794 + * Renders WordPress update details.
533 795 *
534 796 * @param bool $user_can_update_wordpress Permission to update WordPress.
535 797 * @param int $total_wp_upgrades Total number of WordPress update.
536 798 * @param bool $globalView Global view or not.
537 799 * @param int $current_wpid Current site ID.
800 + * @param int $count_websites Number of sites.
538 801 *
539 802 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
540 803 * @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector()
541 804 */
542 - public static function render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid ) {
543 - ?>
544 - <div class="ui hidden divider"></div>
545 - <div class="ui horizontal divider">
546 - <?php
547 - /**
548 - * Filter: mainwp_updates_overview_update_details_divider
549 - *
550 - * Filters the Update Details divider text in the Updates Overview widget.
551 - *
552 - * @since 4.1
553 - */
554 - echo esc_html( apply_filters( 'mainwp_updates_overview_update_details_divider', esc_html__( 'Available Updates', 'mainwp' ) ) );
555 - ?>
556 - </div>
557 - <div class="ui hidden divider"></div>
558 - <?php
805 + public static function render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid, $count_websites ) { //phpcs:ignore -- NOSONAR - complexity.
806 + if ( 0 < $count_websites ) {
807 + $outdated_percentage = round( ( ( intval( $total_wp_upgrades ) / $count_websites ) * 100 ), 2 ) . '%';
808 + } else {
809 + $outdated_percentage = '0.00%';
810 + }
811 +
812 + $wpcore_update_disabled_by = '';
813 + if ( $globalView ) {
814 + $detail_wp_up = 'admin.php?page=UpdatesManage&tab=wordpress-updates';
815 + } else {
816 + $detail_wp_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=wordpress-updates';
817 + $wpcore_update_disabled_by = MainWP_System_Utility::disabled_wpcore_update_by( $current_wpid );
818 + }
819 +
559 820 /**
560 821 * Action: mainwp_updates_overview_before_update_details
561 822 *
562 823 * Fires at the top of the Update Details section in the Updates Overview widget.
@@ -572,62 +833,44 @@
572 833 *
573 834 * @since 4.1
574 835 */
575 836 do_action( 'mainwp_updates_overview_before_wordpress_updates' );
576 -
577 - $is_demo = MainWP_Demo_Handle::is_demo_mode();
578 837 ?>
579 - <div class="ui grid">
580 - <div class="two column row">
581 838
582 - <div class="six wide column">
583 - <div class="ui horizontal statistic">
584 - <div class="value">
585 - <?php echo intval( $total_wp_upgrades ); ?>
586 - </div>
587 - <div class="label">
588 - <?php esc_html_e( 'WordPress', 'mainwp' ); ?>
589 - </div>
590 - </div>
591 - </div>
592 -
593 - <div class="ten wide right aligned column">
594 - <div class="ui small buttons">
595 - <?php
596 - if ( $user_can_update_wordpress ) :
597 - $wpcore_update_disabled_by = '';
598 - if ( $globalView ) {
599 - $detail_wp_up = 'admin.php?page=UpdatesManage&tab=wordpress-updates';
600 - } else {
601 - $detail_wp_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=wordpress-updates';
602 - $wpcore_update_disabled_by = MainWP_System_Utility::disabled_wpcore_update_by( $current_wpid );
603 - }
604 - ?>
605 - <?php if ( 0 < $total_wp_upgrades ) : ?>
606 - <?php MainWP_Updates::set_continue_update_html_selector( 'wpcore_global_upgrade_all' ); ?>
607 - <a href="<?php echo esc_url( $detail_wp_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
608 - <?php
609 - if ( ! empty( $wpcore_update_disabled_by ) ) {
610 - ?>
611 - <span data-tooltip="<?php echo esc_html( $wpcore_update_disabled_by ); ?>" data-inverted="" data-position="left center"><a href="javascript:void(0)" class="ui button basic green disabled mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a></span>
612 - <?php
613 - } elseif ( $is_demo ) {
614 - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green basic button disabled mainwp-update-all-button" disabled="disabled">' . esc_html__( 'Update All', 'mainwp' ) . '</a>' );
615 - } else {
616 - ?>
617 - <a href="#" onClick="updatesoverview_global_upgrade_all('wp'); return false;" class="ui green basic button mainwp-update-all-button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-tooltip="<?php esc_html_e( 'Clicking this button will update WP Core files on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top right"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
618 - <?php
619 - }
620 - ?>
839 + <div class="ui card">
840 + <div class="content">
841 + <div class="header">
842 + <span class="ui large text"><i class="wordpress icon"></i> <?php echo esc_html( MainWP_Utility::short_number_format( intval( $total_wp_upgrades ) ) ); ?></span> <?php // keep `wordpress`. ?>
843 + <?php if ( intval( $total_wp_upgrades ) > 0 ) : ?>
844 + <span class="ui small red text">(<?php echo esc_html( $outdated_percentage ); ?>)</span>
621 845 <?php else : ?>
622 -
623 - <a href="<?php echo esc_url( $detail_wp_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
624 - <a href="#" class="ui disabled green basic button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
625 -
846 + <span class="ui small green text">(0%)</span>
626 847 <?php endif; ?>
627 - <?php endif; ?>
628 848 </div>
849 + <div class="description"><?php esc_html_e( 'Available WordPress core updates.', 'mainwp' ); ?></div>
629 850 </div>
851 + <div class="extra content">
852 + <div class="ui two column grid">
853 + <div class="left aligned middle aligned column">
854 + <?php if ( $user_can_update_wordpress ) : ?>
855 + <?php if ( 0 < $total_wp_upgrades ) : ?>
856 + <?php MainWP_Updates::set_continue_update_html_selector( 'wpcore_global_upgrade_all' ); ?>
857 + <?php if ( ! empty( $wpcore_update_disabled_by ) ) : ?>
858 + <a href="javascript:void(0)" class="ui mini button basic green disabled mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
859 + <?php else : ?>
860 + <a href="#" onClick="updatesoverview_global_upgrade_all('wp', <?php echo intval( $current_wpid ); ?>); return false;" class="ui mini green button mainwp-update-all-button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
861 + <?php endif; ?>
862 + <?php else : ?>
863 + <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
864 + <?php endif; ?>
865 + <?php endif; ?>
866 + </div>
867 + <div class="right aligned middle aligned column">
868 + <?php if ( 0 < $total_wp_upgrades ) : ?>
869 + <a href="<?php echo esc_url( $detail_wp_up ); ?>" class="ui mini basic button" aria-label="<?php esc_attr_e( 'View WordPress core updates details', 'mainwp' ); ?>"><?php esc_html_e( 'Details', 'mainwp' ); ?></a>
870 + <?php endif; ?>
871 + </div>
872 + </div>
630 873 </div>
631 874 </div>
632 875 <?php
633 876 /**
@@ -640,19 +883,32 @@
640 883 do_action( 'mainwp_updates_overview_after_wordpress_updates' );
641 884 }
642 885
643 886 /**
644 - * Render Plugins update detail.
887 + * Renders Plugins update detail.
645 888 *
646 - * @param bool true|false $user_can_update_plugins permission to update.
647 - * @param int $total_plugin_upgrades total number of update.
648 - * @param bool true|false $globalView global view or not.
649 - * @param int $current_wpid current site id.
889 + * @param bool $user_can_update_plugins permission to update.
890 + * @param int $total_plugin_upgrades total number of update.
891 + * @param bool $globalView global view or not.
892 + * @param int $current_wpid current site id.
893 + * @param int $count_plugins count plugin.
650 894 *
651 895 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
652 896 * @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector()
653 897 */
654 - public static function render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid ) {
898 + public static function render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid, $count_plugins ) { //phpcs:ignore -- NOSONAR - complexity.
899 + if ( 0 < $count_plugins ) {
900 + $outdated_percentage = round( ( ( intval( $total_plugin_upgrades ) / $count_plugins ) * 100 ), 2 ) . '%';
901 + } else {
902 + $outdated_percentage = '0.00%';
903 + }
904 +
905 + if ( $globalView ) {
906 + $detail_plugins_up = 'admin.php?page=UpdatesManage&tab=plugins-updates';
907 + } else {
908 + $detail_plugins_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=plugins-updates';
909 + }
910 +
655 911 /**
656 912 * Action: mainwp_updates_overview_before_plugin_updates
657 913 *
658 914 * Fires before the Plugin updates section in the Updates Overview widget.
@@ -659,58 +915,41 @@
659 915 *
660 916 * @since 4.1
661 917 */
662 918 do_action( 'mainwp_updates_overview_before_plugin_updates' );
663 - $is_demo = MainWP_Demo_Handle::is_demo_mode();
664 919 ?>
665 - <div class="ui grid">
666 - <div class="two column row">
667 - <div class="six wide column">
668 - <div class="ui horizontal statistic">
669 - <div class="value">
670 - <?php echo intval( $total_plugin_upgrades ); ?>
671 - </div>
672 - <div class="label">
673 - <?php esc_html_e( 'Plugins', 'mainwp' ); ?>
920 + <div class="ui card">
921 + <div class="content">
922 + <div class="header">
923 + <span class="ui large text"><i class="plug icon"></i> <?php echo esc_html( MainWP_Utility::short_number_format( intval( $total_plugin_upgrades ) ) ); ?></span>
924 + <?php if ( intval( $total_plugin_upgrades ) > 0 ) : ?>
925 + <span class="ui small red text">(<?php echo esc_html( $outdated_percentage ); ?>)</span>
926 + <?php else : ?>
927 + <span class="ui small green text">(0%)</span>
928 + <?php endif; ?>
929 + </div>
930 + <div class="description"><?php esc_html_e( 'Available plugin updates.', 'mainwp' ); ?></div>
931 + </div>
932 + <div class="extra content">
933 + <div class="ui two column grid">
934 + <div class="left aligned middle aligned column">
935 + <?php if ( $user_can_update_plugins ) : ?>
936 + <?php if ( ! empty( $total_plugin_upgrades ) ) : ?>
937 + <?php MainWP_Updates::set_continue_update_html_selector( 'plugins_global_upgrade_all' ); ?>
938 + <a href="#" onClick="updatesoverview_global_upgrade_all('plugin', <?php echo intval( $current_wpid ); ?>); return false;" class="ui mini green mainwp-update-all-button button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
939 + <?php else : ?>
940 + <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
941 + <?php endif; ?>
942 + <?php endif; ?>
674 943 </div>
944 + <div class="right aligned middle aligned column">
945 + <?php if ( ! empty( $total_plugin_upgrades ) ) : ?>
946 + <a href="<?php echo esc_url( $detail_plugins_up ); ?>" class="ui mini basic button" aria-label="<?php esc_attr_e( 'View plugin updates details', 'mainwp' ); ?>"><?php esc_html_e( 'Details', 'mainwp' ); ?></a>
947 + <?php endif; ?>
675 948 </div>
676 949 </div>
677 - <div class="ten wide right aligned column">
678 - <div class="ui small buttons">
679 - <?php
680 - if ( $user_can_update_plugins ) {
681 - MainWP_Updates::set_continue_update_html_selector( 'plugins_global_upgrade_all' );
682 - if ( $globalView ) {
683 - $detail_plugins_up = 'admin.php?page=UpdatesManage&tab=plugins-updates';
684 - $update_all_tooltip = esc_html__( 'Clicking this button will update all Plugins on All your websites.', 'mainwp' );
685 - } else {
686 - $detail_plugins_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=plugins-updates';
687 - $update_all_tooltip = esc_html__( 'Clicking this button will update all Plugins on the website.', 'mainwp' );
688 - }
689 -
690 - if ( empty( $total_plugin_upgrades ) ) {
691 - ?>
692 - <a href="<?php echo esc_url( $detail_plugins_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
693 - <a href="#" class="ui disabled green basic button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
694 - <?php
695 - } else {
696 - ?>
697 - <a href="<?php echo esc_url( $detail_plugins_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
698 - <?php
699 - if ( $is_demo ) {
700 - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui basic green button mainwp-update-all-button disabled" disabled="disabled">' . esc_html__( 'Update All', 'mainwp' ) . '</a>' );
701 - } else {
702 - ?>
703 - <a href="#" onClick="updatesoverview_global_upgrade_all('plugin'); return false;" class="ui basic green mainwp-update-all-button button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-tooltip="<?php echo esc_attr( $update_all_tooltip ); ?>" data-inverted="" data-position="top right"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
704 - <?php
705 - }
706 - }
707 - }
708 - ?>
709 - </div>
710 950 </div>
711 - </div>
712 - </div>
951 + </div>
713 952 <?php
714 953 /**
715 954 * Action: mainwp_updates_overview_after_plugin_updates
716 955 *
@@ -723,17 +962,30 @@
723 962
724 963 /**
725 964 * Render Themes update detail.
726 965 *
727 - * @param bool true|false $user_can_update_themes permission to update.
728 - * @param int $total_theme_upgrades total number of update.
729 - * @param bool true|false $globalView global view or not.
730 - * @param int $current_wpid current site id.
966 + * @param bool $user_can_update_themes permission to update.
967 + * @param int $total_theme_upgrades total number of update.
968 + * @param bool $globalView global view or not.
969 + * @param int $current_wpid current site id.
970 + * @param int $count_themes count themes.
731 971 *
732 972 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
733 973 * @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector()
734 974 */
735 - public static function render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid ) {
975 + public static function render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid, $count_themes ) { //phpcs:ignore -- NOSONAR - complexity.
976 + if ( 0 < $count_themes ) {
977 + $outdated_percentage = round( ( ( intval( $total_theme_upgrades ) / $count_themes ) * 100 ), 2 ) . '%';
978 + } else {
979 + $outdated_percentage = '0.00%';
980 + }
981 +
982 + if ( $globalView ) {
983 + $detail_themes_up = 'admin.php?page=UpdatesManage&tab=themes-updates';
984 + } else {
985 + $detail_themes_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=themes-updates';
986 + }
987 +
736 988 /**
737 989 * Action: mainwp_updates_overview_before_theme_updates
738 990 *
739 991 * Fires before the Theme updates section in the Updates Overview widget.
@@ -740,55 +992,41 @@
740 992 *
741 993 * @since 4.1
742 994 */
743 995 do_action( 'mainwp_updates_overview_before_theme_updates' );
744 - $is_demo = MainWP_Demo_Handle::is_demo_mode();
745 996 ?>
746 - <div class="ui grid">
747 - <div class="two column row">
748 - <div class="six wide column">
749 - <div class="ui horizontal statistic">
750 - <div class="value">
751 - <?php echo intval( $total_theme_upgrades ); ?>
997 + <div class="ui card">
998 + <div class="content">
999 + <div class="header">
1000 + <span class="ui large text"><i class="tint icon"></i> <?php echo esc_html( MainWP_Utility::short_number_format( intval( $total_theme_upgrades ) ) ); ?></span>
1001 + <?php if ( intval( $total_theme_upgrades ) > 0 ) : ?>
1002 + <span class="ui small red text">(<?php echo esc_html( $outdated_percentage ); ?>)</span>
1003 + <?php else : ?>
1004 + <span class="ui small green text">(0%)</span>
1005 + <?php endif; ?>
1006 + </div>
1007 + <div class="description"><?php esc_html_e( 'Available theme updates.', 'mainwp' ); ?></div>
1008 + </div>
1009 + <div class="extra content">
1010 + <div class="ui two column grid">
1011 + <div class="left aligned middle aligned column">
1012 + <?php if ( $user_can_update_themes ) : ?>
1013 + <?php if ( ! empty( $total_theme_upgrades ) ) : ?>
1014 + <?php MainWP_Updates::set_continue_update_html_selector( 'themes_global_upgrade_all' ); ?>
1015 + <a href="#" onClick="updatesoverview_global_upgrade_all('theme', <?php echo intval( $current_wpid ); ?>); return false;" class="ui mini green mainwp-update-all-button button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
1016 + <?php else : ?>
1017 + <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
1018 + <?php endif; ?>
1019 + <?php endif; ?>
752 1020 </div>
753 - <div class="label">
754 - <?php esc_html_e( 'Themes', 'mainwp' ); ?>
1021 + <div class="right aligned middle aligned column">
1022 + <?php if ( ! empty( $total_theme_upgrades ) ) : ?>
1023 + <a href="<?php echo esc_url( $detail_themes_up ); ?>" class="ui mini basic button" aria-label="<?php esc_attr_e( 'View theme updates details', 'mainwp' ); ?>"><?php esc_html_e( 'Details', 'mainwp' ); ?></a>
1024 + <?php endif; ?>
755 1025 </div>
756 1026 </div>
757 1027 </div>
758 - <div class="ten wide right aligned column">
759 - <div class="ui small buttons">
760 - <?php
761 - if ( $user_can_update_themes ) {
762 - MainWP_Updates::set_continue_update_html_selector( 'themes_global_upgrade_all' );
763 - if ( $globalView ) {
764 - $detail_themes_up = 'admin.php?page=UpdatesManage&tab=themes-updates';
765 - } else {
766 - $detail_themes_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=themes-updates';
767 - }
768 - if ( empty( $total_theme_upgrades ) ) {
769 - ?>
770 - <a href="<?php echo esc_url( $detail_themes_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
771 - <a href="#" class="ui disabled green basic mainwp-update-all-button button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
772 - <?php
773 - } else {
774 - ?>
775 - <a href="<?php echo esc_url( $detail_themes_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
776 - <?php
777 - if ( $is_demo ) {
778 - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui basic green button mainwp-update-all-button disabled" disabled="disabled">' . esc_html__( 'Update All', 'mainwp' ) . '</a>' );
779 - } else {
780 - ?>
781 - <a href="#" onClick="updatesoverview_global_upgrade_all('theme'); return false;" class="ui basic green mainwp-update-all-button button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-tooltip="<?php esc_html_e( 'Clicking this button will update all Themes on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top right"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
782 - <?php
783 - }
784 - }
785 - }
786 - ?>
787 - </div>
788 1028 </div>
789 - </div>
790 - </div>
791 1029 <?php
792 1030 /**
793 1031 * Action: mainwp_updates_overview_after_theme_updates
794 1032 *
@@ -809,8 +1047,13 @@
809 1047 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
810 1048 * @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector()
811 1049 */
812 1050 public static function render_language_update( $user_can_update_translation, $total_translation_upgrades, $globalView, $current_wpid ) {
1051 + if ( $globalView ) {
1052 + $detail_trans_up = 'admin.php?page=UpdatesManage&tab=translations-updates';
1053 + } else {
1054 + $detail_trans_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=translations-updates';
1055 + }
813 1056 /**
814 1057 * Action: mainwp_updates_overview_before_translation_updates
815 1058 *
816 1059 * Fires before the Translation updates section in the Updates Overview widget.
@@ -817,55 +1060,36 @@
817 1060 *
818 1061 * @since 4.1
819 1062 */
820 1063 do_action( 'mainwp_updates_overview_before_translation_updates' );
821 - $is_demo = MainWP_Demo_Handle::is_demo_mode();
822 1064 ?>
823 - <div class="ui grid">
824 - <div class="two column row">
825 - <div class="six wide column">
826 - <div class="ui horizontal statistic">
827 - <div class="value">
828 - <?php echo intval( $total_translation_upgrades ); ?>
1065 + <div class="ui card">
1066 + <div class="content">
1067 + <div class="header">
1068 + <span class="ui large text"><i class="language icon"></i> <?php echo esc_html( MainWP_Utility::short_number_format( intval( $total_translation_upgrades ) ) ); ?></span>
1069 + </div>
1070 + <div class="description"><?php esc_html_e( 'Available translation updates.', 'mainwp' ); ?></div>
1071 + </div>
1072 + <div class="extra content">
1073 + <div class="ui two column grid">
1074 + <div class="left aligned middle aligned column">
1075 + <?php if ( $user_can_update_translation ) : ?>
1076 + <?php if ( ! empty( $total_translation_upgrades ) ) : ?>
1077 + <?php MainWP_Updates::set_continue_update_html_selector( 'translations_global_upgrade_all' ); ?>
1078 + <a href="#" onClick="updatesoverview_global_upgrade_all('translation', <?php echo intval( $current_wpid ); ?>); return false;" class="ui mini green mainwp-update-all-button button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
1079 + <?php else : ?>
1080 + <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
1081 + <?php endif; ?>
1082 + <?php endif; ?>
829 1083 </div>
830 - <div class="label">
831 - <?php esc_html_e( 'Translations', 'mainwp' ); ?>
1084 + <div class="right aligned middle aligned column">
1085 + <?php if ( ! empty( $total_translation_upgrades ) ) : ?>
1086 + <a href="<?php echo esc_url( $detail_trans_up ); ?>" class="ui mini basic button" aria-label="<?php esc_attr_e( 'View translation updates details', 'mainwp' ); ?>"><?php esc_html_e( 'Details', 'mainwp' ); ?></a>
1087 + <?php endif; ?>
832 1088 </div>
833 1089 </div>
834 1090 </div>
835 - <div class="ten wide right aligned column">
836 - <div class="ui small buttons">
837 - <?php
838 - if ( $user_can_update_translation ) {
839 - MainWP_Updates::set_continue_update_html_selector( 'translations_global_upgrade_all' );
840 - if ( $globalView ) {
841 - $detail_trans_up = 'admin.php?page=UpdatesManage&tab=translations-updates';
842 - } else {
843 - $detail_trans_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=translations-updates';
844 - }
845 - if ( empty( $total_translation_upgrades ) ) {
846 - ?>
847 - <a href="<?php echo esc_url( $detail_trans_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
848 - <a href="#" class="ui disabled green basic mainwp-update-all-button button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
849 - <?php
850 - } else {
851 - ?>
852 - <a href="<?php echo esc_url( $detail_trans_up ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
853 - <?php
854 - if ( $is_demo ) {
855 - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui basic green button mainwp-update-all-button disabled" disabled="disabled">' . esc_html__( 'Update All', 'mainwp' ) . '</a>' );
856 - } else {
857 - ?>
858 - <a href="#" onClick="updatesoverview_global_upgrade_all('translation'); return false;" class="ui basic green mainwp-update-all-button button <?php MainWP_Updates::get_continue_update_selector(); // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-tooltip="<?php esc_html_e( 'Clicking this button will update all Translations on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top right"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
859 - <?php
860 - }
861 - }
862 - }
863 - ?>
864 - </div>
865 - </div>
866 1091 </div>
867 - </div>
868 1092 <?php
869 1093 /**
870 1094 * Action: mainwp_updates_overview_after_translation_updates
871 1095 *
@@ -876,32 +1100,28 @@
876 1100 do_action( 'mainwp_updates_overview_after_translation_updates' );
877 1101 }
878 1102
879 1103 /**
880 - * Render abandoned plugins detail.
1104 + * Renders abandoned plugins detail.
881 1105 *
882 1106 * @param int $total_plugins_outdate total number of update.
883 1107 * @param bool $globalView global view or not.
884 1108 * @param int $current_wpid current site id.
1109 + * @param int $count_plugins count plugins.
885 1110 */
886 - public static function render_abandoned_plugins( $total_plugins_outdate, $globalView, $current_wpid ) {
887 - ?>
888 - <div class="ui hidden divider"></div>
889 - <div class="ui horizontal divider">
890 - <?php
1111 + public static function render_abandoned_plugins( $total_plugins_outdate, $globalView, $current_wpid, $count_plugins ) {
1112 + if ( $globalView ) {
1113 + $detail_aban_plugins = 'admin.php?page=PluginsAbandoned';
1114 + } else {
1115 + $detail_aban_plugins = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=abandoned-plugins';
1116 + }
1117 +
1118 + if ( 0 < $count_plugins ) {
1119 + $outdated_percentage = round( ( ( intval( $total_plugins_outdate ) / $count_plugins ) * 100 ), 2 ) . '%';
1120 + } else {
1121 + $outdated_percentage = '0.00%';
1122 + }
891 1123 /**
892 - * Filter: mainwp_updates_overview_abandoned_plugins_themes_divider
893 - *
894 - * Filters the Abandoned Plugins & Themes divider text in the Updates Overview widget.
895 - *
896 - * @since 4.1
897 - */
898 - echo esc_html( apply_filters( 'mainwp_updates_overview_abandoned_plugins_themes_divider', esc_html__( 'Abandoned Plugins & Themes', 'mainwp' ) ) );
899 - ?>
900 - </div>
901 - <div class="ui hidden divider"></div>
902 - <?php
903 - /**
904 1124 * Action: mainwp_updates_overview_before_abandoned_plugins_themes
905 1125 *
906 1126 * Fires at the top of the Abandoned Plugins & Themes section in the Updates Overview widget.
907 1127 *
@@ -908,30 +1128,35 @@
908 1128 * @since 4.1
909 1129 */
910 1130 do_action( 'mainwp_updates_overview_before_abandoned_plugins_themes' );
911 1131 ?>
912 - <div class="ui grid">
913 - <div class="two column row">
914 - <div class="six wide column">
915 - <div class="ui horizontal statistic">
916 - <?php
917 - if ( $globalView ) {
918 - $detail_aban_plugins = 'admin.php?page=UpdatesManage&tab=abandoned-plugins';
919 - } else {
920 - $detail_aban_plugins = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=abandoned-plugins';
921 - }
922 - ?>
923 - <div class="value">
924 - <?php echo intval( $total_plugins_outdate ); ?>
1132 + <div class="ui light card">
1133 + <div class="content">
1134 + <div class="header">
1135 + <span class="ui large text">
1136 + <i class="icons">
1137 + <i class="plug icon"></i>
1138 + <i class="inverted corner clock icon"></i>
1139 + </i>
1140 + <?php echo esc_html( MainWP_Utility::short_number_format( intval( $total_plugins_outdate ) ) ); ?>
1141 + </span>
1142 + <?php if ( intval( $total_plugins_outdate ) > 0 ) : ?>
1143 + <span class="ui small red text">(<?php echo esc_html( $outdated_percentage ); ?>)</span>
1144 + <?php else : ?>
1145 + <span class="ui small green text">(0%)</span>
1146 + <?php endif; ?>
1147 + </div>
1148 + <div class="description"><?php esc_html_e( 'Detected abandoned plugins.', 'mainwp' ); ?></div>
1149 + </div>
1150 + <div class="extra content">
1151 + <div class="ui two column grid">
1152 + <div class="left aligned middle aligned column">
1153 +
925 1154 </div>
926 - <div class="label">
927 - <?php esc_html_e( 'Plugins', 'mainwp' ); ?>
1155 + <div class="right aligned middle aligned column">
1156 + <a href="<?php echo esc_url( $detail_aban_plugins ); ?>" class="ui mini basic button" aria-label="<?php esc_attr_e( 'View abandoned plugins details', 'mainwp' ); ?>"><?php esc_html_e( 'Details', 'mainwp' ); ?></a>
928 1157 </div>
929 - </div>
930 - </div>
931 - <div class="ten wide right aligned column">
932 - <a href="<?php echo esc_url( $detail_aban_plugins ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
933 - </div>
1158 + </div>
934 1159 </div>
935 1160 </div>
936 1161 <?php
937 1162 }
@@ -936,38 +1161,56 @@
936 1161 <?php
937 1162 }
938 1163
939 1164 /**
940 - * Render abandoned themes detail.
1165 + * Renders abandoned themes detail.
941 1166 *
942 1167 * @param int $total_themes_outdate Total number of update.
943 1168 * @param bool $globalView global View or not.
944 1169 * @param int $current_wpid Current site ID.
1170 + * @param int $count_themes count themes.
945 1171 */
946 - public static function render_abandoned_themes( $total_themes_outdate, $globalView, $current_wpid ) {
1172 + public static function render_abandoned_themes( $total_themes_outdate, $globalView, $current_wpid, $count_themes ) {
1173 + if ( $globalView ) {
1174 + $detail_aban_themes = 'admin.php?page=ThemesAbandoned';
1175 + } else {
1176 + $detail_aban_themes = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=abandoned-themes';
1177 + }
1178 +
1179 + if ( 0 < $count_themes ) {
1180 + $outdated_percentage = round( ( ( intval( $total_themes_outdate ) / $count_themes ) * 100 ), 2 ) . '%';
1181 + } else {
1182 + $outdated_percentage = '0.00%';
1183 + }
1184 +
947 1185 ?>
948 - <div class="ui grid">
949 - <div class="two column row">
950 - <div class="six wide column">
951 - <div class="ui horizontal statistic">
952 - <?php
953 - if ( $globalView ) {
954 - $detail_aban_themes = 'admin.php?page=UpdatesManage&tab=abandoned-themes';
955 - } else {
956 - $detail_aban_themes = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=abandoned-themes';
957 - }
958 - ?>
959 - <div class="value">
960 - <?php echo intval( $total_themes_outdate ); ?>
961 - </div>
962 - <div class="label">
963 - <?php esc_html_e( 'Themes', 'mainwp' ); ?>
964 - </div>
1186 + <div class="ui light card">
1187 + <div class="content">
1188 + <div class="header">
1189 + <span class="ui large text">
1190 + <i class="icons">
1191 + <i class="tint icon"></i>
1192 + <i class="inverted corner clock icon"></i>
1193 + </i>
1194 + <?php echo esc_html( MainWP_Utility::short_number_format( intval( $total_themes_outdate ) ) ); ?>
1195 + </span>
1196 + <?php if ( intval( $total_themes_outdate ) > 0 ) : ?>
1197 + <span class="ui small red text">(<?php echo esc_html( $outdated_percentage ); ?>)</span>
1198 + <?php else : ?>
1199 + <span class="ui small green text">(0%)</span>
1200 + <?php endif; ?>
1201 + </div>
1202 + <div class="description"><?php esc_html_e( 'Detected abandoned themes.', 'mainwp' ); ?></div>
1203 + </div>
1204 + <div class="extra content">
1205 + <div class="ui two column grid">
1206 + <div class="left aligned middle aligned column">
1207 +
965 1208 </div>
1209 + <div class="right aligned middle aligned column">
1210 + <a href="<?php echo esc_url( $detail_aban_themes ); ?>" class="ui mini basic button" aria-label="<?php esc_attr_e( 'View abandoned themes details', 'mainwp' ); ?>"><?php esc_html_e( 'Details', 'mainwp' ); ?></a>
1211 + </div>
966 1212 </div>
967 - <div class="ten wide right aligned column">
968 - <a href="<?php echo esc_url( $detail_aban_themes ); ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a>
969 - </div>
970 1213 </div>
971 1214 </div>
972 1215 <?php
973 1216 /**
@@ -984,26 +1227,28 @@
984 1227 * Method render_global_update()
985 1228 *
986 1229 * Render global updates.
987 1230 *
988 - * @param bool $user_can_update_wordpress Permission to update WordPress.
989 - * @param int $total_wp_upgrades Total WordPress update.
990 - * @param array $all_wp_updates All WordPress update list.
1231 + * @param string $update_type Update type.
1232 + * @param bool $user_can_update_wordpress Permission to update WordPress.
1233 + * @param int $total_wp_upgrades Total WordPress update.
1234 + * @param array $all_wp_updates All WordPress update list.
991 1235 *
992 - * @param bool $user_can_update_plugins permission to update plugings.
993 - * @param int $total_plugin_upgrades total WordPress update.
994 - * @param array $all_plugins_updates all WordPress update list.
1236 + * @param bool $user_can_update_plugins permission to update plugings.
1237 + * @param int $total_plugin_upgrades total WordPress update.
1238 + * @param array $all_plugins_updates all WordPress update list.
995 1239 *
996 - * @param bool $user_can_update_themes permission to update themes.
997 - * @param int $total_theme_upgrades total themes update.
998 - * @param mixed $all_themes_updates all themes update list.
1240 + * @param bool $user_can_update_themes permission to update themes.
1241 + * @param int $total_theme_upgrades total themes update.
1242 + * @param mixed $all_themes_updates all themes update list.
999 1243 *
1000 - * @param mixed $mainwp_show_language_updates MainWP Language Updates.
1001 - * @param bool $user_can_update_translation permission to update languages.
1002 - * @param int $total_translation_upgrades total WordPress update.
1003 - * @param mixed $all_translations_updates all transations update list.
1244 + * @param mixed $mainwp_show_language_updates MainWP Language Updates.
1245 + * @param bool $user_can_update_translation permission to update languages.
1246 + * @param int $total_translation_upgrades total WordPress update.
1247 + * @param mixed $all_translations_updates all transations update list.
1004 1248 */
1005 1249 public static function render_global_update( // phpcs:ignore -- NOSONAR - complex.
1250 + $update_type,
1006 1251 $user_can_update_wordpress,
1007 1252 $total_wp_upgrades,
1008 1253 $all_wp_updates,
1009 1254 $user_can_update_plugins,
@@ -1016,17 +1261,24 @@
1016 1261 $user_can_update_translation,
1017 1262 $total_translation_upgrades,
1018 1263 $all_translations_updates
1019 1264 ) {
1265 +
1266 + $process = array(
1267 + 'core' => in_array( $update_type, array( 'all', 'core' ), true ),
1268 + 'plugin' => in_array( $update_type, array( 'all', 'plugin' ), true ),
1269 + 'theme' => in_array( $update_type, array( 'all', 'theme' ), true ),
1270 + 'trans' => in_array( $update_type, array( 'all', 'trans' ), true ),
1271 + );
1272 +
1020 1273 ?>
1021 - <div style="display: none">
1022 1274
1023 1275 <div id="wp_upgrades">
1024 1276 <?php
1025 - if ( $user_can_update_wordpress && $total_wp_upgrades > 0 ) {
1277 + if ( $process['core'] && $user_can_update_wordpress && $total_wp_upgrades > 0 ) {
1026 1278 foreach ( $all_wp_updates as $item ) {
1027 1279 ?>
1028 - <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" ></div>
1280 + <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" is-suspended="<?php echo ! empty( $item['is_suspended'] ) ? esc_attr( $item['is_suspended'] ) : ''; ?>"></div>
1029 1281 <?php
1030 1282 }
1031 1283 }
1032 1284 ?>
@@ -1033,12 +1285,12 @@
1033 1285 </div>
1034 1286
1035 1287 <div id="wp_plugin_upgrades">
1036 1288 <?php
1037 - if ( $user_can_update_plugins && $total_plugin_upgrades > 0 ) {
1289 + if ( $process['plugin'] && $user_can_update_plugins && $total_plugin_upgrades > 0 ) {
1038 1290 foreach ( $all_plugins_updates as $item ) {
1039 1291 ?>
1040 - <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" plugin_slug="<?php echo esc_attr( $item['plugin_slug'] ); ?>" ></div>
1292 + <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" plugin_slug="<?php echo esc_attr( $item['plugin_slug'] ); ?>" is-suspended="<?php echo ! empty( $item['is_suspended'] ) ? esc_attr( $item['is_suspended'] ) : ''; ?>"></div>
1041 1293 <?php
1042 1294 }
1043 1295 }
1044 1296 ?>
@@ -1045,12 +1297,12 @@
1045 1297 </div>
1046 1298 <div id="wp_theme_upgrades">
1047 1299
1048 1300 <?php
1049 - if ( $user_can_update_themes && $total_theme_upgrades > 0 ) {
1301 + if ( $process['theme'] && $user_can_update_themes && $total_theme_upgrades > 0 ) {
1050 1302 foreach ( $all_themes_updates as $item ) {
1051 1303 ?>
1052 - <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" theme_slug="<?php echo esc_attr( $item['theme_slug'] ); ?>" ></div>
1304 + <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" theme_slug="<?php echo esc_attr( $item['theme_slug'] ); ?>" is-suspended="<?php echo ! empty( $item['is_suspended'] ) ? esc_attr( $item['is_suspended'] ) : ''; ?>"></div>
1053 1305 <?php
1054 1306 }
1055 1307 }
1056 1308 ?>
@@ -1059,12 +1311,12 @@
1059 1311 <?php if ( 1 === (int) $mainwp_show_language_updates ) : ?>
1060 1312 <div id="wp_translation_upgrades">
1061 1313
1062 1314 <?php
1063 - if ( $user_can_update_translation && $total_translation_upgrades > 0 ) {
1315 + if ( $process['trans'] && $user_can_update_translation && $total_translation_upgrades > 0 ) {
1064 1316 foreach ( $all_translations_updates as $item ) {
1065 1317 ?>
1066 - <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" translation_slug="<?php echo esc_attr( $item['translation_slug'] ); ?>" ></div>
1318 + <div updated="0" site_id="<?php echo intval( $item['id'] ); ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" translation_slug="<?php echo esc_attr( $item['translation_slug'] ); ?>" is-suspended="<?php echo ! empty( $item['is_suspended'] ) ? esc_attr( $item['is_suspended'] ) : ''; ?>"></div>
1067 1319 <?php
1068 1320 }
1069 1321 }
1070 1322 ?>
@@ -1069,9 +1321,8 @@
1069 1321 }
1070 1322 ?>
1071 1323 </div>
1072 1324 <?php endif; ?>
1073 - </div>
1074 1325 <?php
1075 1326 }
1076 1327
1077 1328 /**
@@ -1076,24 +1327,17 @@
1076 1327
1077 1328 /**
1078 1329 * Render bottom of widget.
1079 1330 *
1080 - * @param object $websites Object containing child sites info.
1081 - * @param bool $globalView Whether it's global or individual site view.
1331 + * @param array $sites_ids Child sites ids.
1332 + * @param bool $globalView Whether it's global or individual site view.
1082 1333 *
1083 1334 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1084 1335 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1085 1336 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1086 1337 */
1087 - public static function render_bottom( $websites, $globalView ) {
1338 + public static function render_bottom( $sites_ids, $globalView ) {
1088 1339
1089 - MainWP_DB::data_seek( $websites, 0 );
1090 -
1091 - $site_ids = array();
1092 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1093 - $site_ids[] = $website->id;
1094 - }
1095 -
1096 1340 /**
1097 1341 * Action: mainwp_updatesoverview_widget_bottom
1098 1342 *
1099 1343 * Fires at the bottom of the Updates Overview widgets.
@@ -1102,22 +1346,20 @@
1102 1346 * @param bool $globalView Whether it's global or individual site view.
1103 1347 *
1104 1348 * @since 4.0
1105 1349 */
1106 - do_action( 'mainwp_updatesoverview_widget_bottom', $site_ids, $globalView );
1350 + do_action( 'mainwp_updatesoverview_widget_bottom', $sites_ids, $globalView );
1107 1351 ?>
1108 1352 <div class="ui modal" id="updatesoverview-backup-box" tabindex="0">
1109 - <div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div>
1110 - <div class="scrolling content mainwp-modal-content"></div>
1111 - <div class="actions mainwp-modal-actions">
1112 - <input id="updatesoverview-backup-all" type="button" name="Backup All" value="<?php esc_html_e( 'Backup All', 'mainwp' ); ?>" class="button-primary"/>
1113 - <a id="updatesoverview-backup-now" href="#" target="_blank" style="display: none" class="button-primary button"><?php esc_html_e( 'Backup Now', 'mainwp' ); ?></a>&nbsp;
1114 - <input id="updatesoverview-backup-ignore" type="button" name="Ignore" value="<?php esc_html_e( 'Ignore', 'mainwp' ); ?>" class="button"/>
1115 - </div>
1353 + <div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div>
1354 + <div class="scrolling content mainwp-modal-content"></div>
1355 + <div class="actions mainwp-modal-actions">
1356 + <input id="updatesoverview-backup-all" type="button" name="<?php esc_attr_e( 'Backup All', 'mainwp' ); ?>" value="<?php esc_attr_e( 'Backup All', 'mainwp' ); ?>" class="ui basic button"/>
1357 + <a id="updatesoverview-backup-now" href="#" target="_blank" style="display: none" class="ui basic button"><?php esc_html_e( 'Backup Now', 'mainwp' ); ?></a>&nbsp;
1358 + <input id="updatesoverview-backup-ignore" type="button" name="<?php esc_attr_e( 'Ignore', 'mainwp' ); ?>" value="<?php esc_attr_e( 'Ignore', 'mainwp' ); ?>" class="button"/>
1359 + </div>
1116 1360 </div>
1117 -
1118 1361 <?php
1119 - MainWP_DB::free_result( $websites );
1120 1362 }
1121 1363
1122 1364 /**
1123 1365 * Method dismiss_sync_errors()
@@ -1146,9 +1388,9 @@
1146 1388 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_primary_backup()
1147 1389 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_specific_dir()
1148 1390 */
1149 1391 public static function check_backups() { // phpcs:ignore -- NOSONAR - complex.
1150 - if ( empty( $_POST['sites'] ) || ! is_array( $_POST['sites'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1392 + if ( empty( $_POST['sites'] ) || ! is_array( $_POST['sites'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- NOSONAR - verified before.
1151 1393 return true;
1152 1394 }
1153 1395
1154 1396 $primaryBackup = MainWP_System_Utility::get_primary_backup();
@@ -1166,15 +1408,24 @@
1166 1408 if ( ( 0 === (int) $website->backup_before_upgrade ) || ( ( 2 === (int) $website->backup_before_upgrade ) && empty( $global_backup_before_upgrade ) ) ) {
1167 1409 continue;
1168 1410 }
1169 1411
1170 - if ( ! empty( $primaryBackup ) ) {
1412 + $backup_method = '';
1413 + if ( property_exists( $website, 'primary_backup_method' ) ) {
1414 + if ( '' === $website->primary_backup_method || 'global' === $website->primary_backup_method ) {
1415 + $backup_method = $primaryBackup;
1416 + } else {
1417 + $backup_method = $website->primary_backup_method;
1418 + }
1419 + }
1420 +
1421 + if ( ! empty( $backup_method ) ) {
1171 1422 $lastBackup = MainWP_DB::instance()->get_website_option( $website, 'primary_lasttime_backup' );
1172 1423
1173 1424 if ( -1 !== $lastBackup ) { // installed backup plugin.
1174 1425 $output['sites'][ $siteId ] = ( $lastBackup < ( time() - ( $mainwp_backup_before_upgrade_days * 24 * 60 * 60 ) ) ? false : true );
1175 1426 }
1176 - $output['primary_backup'] = $primaryBackup;
1427 + $output['primary_backup'] = $backup_method;
1177 1428 } else {
1178 1429 $dir = MainWP_System_Utility::get_mainwp_specific_dir( $siteId );
1179 1430 // Check if backup ok.
1180 1431 $lastBackup = - 1;