PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
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 +260 -98 6.1.2 → 6.2.1 View file →
@@ -125,9 +125,10 @@
125 125 * @global string
126 126 */
127 127 global $current_user;
128 128
129 - $current_wpid = MainWP_System_Utility::get_current_wpid();
129 + $current_wpid = (int) MainWP_System_Utility::get_current_wpid();
130 + $is_staging = 'no';
130 131
131 132 if ( $current_wpid ) {
132 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' ) );
133 134 $globalView = false;
@@ -133,9 +134,8 @@
133 134 $globalView = false;
134 135 } else {
135 136 $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
136 137 // To support staging extension.
137 - $is_staging = 'no';
138 138 if ( $staging_enabled ) {
139 139 $staging_updates_view = MainWP_System_Utility::get_select_staging_view_sites();
140 140 if ( 'staging' === $staging_updates_view ) {
141 141 $is_staging = 'yes';
@@ -158,13 +158,9 @@
158 158
159 159 $total_plugins_outdate = 0;
160 160 $total_themes_outdate = 0;
161 161
162 - $all_wp_updates = array();
163 - $all_plugins_updates = array();
164 - $all_themes_updates = array();
165 - $all_translations_updates = array();
166 - $sites_ids = array();
162 + $sites_ids = array();
167 163
168 164 $currentSite = null;
169 165
170 166 $count_plugins = 0;
@@ -196,13 +192,9 @@
196 192
197 193 $total_plugins_outdate = isset( $cache_overview['total_plugins_outdate'] ) ? intval( $cache_overview['total_plugins_outdate'] ) : 0;
198 194 $total_themes_outdate = isset( $cache_overview['total_themes_outdate'] ) ? intval( $cache_overview['total_themes_outdate'] ) : 0;
199 195
200 - $all_wp_updates = isset( $cache_overview['all_wp_updates'] ) && is_array( $cache_overview['all_wp_updates'] ) ? $cache_overview['all_wp_updates'] : array();
201 - $all_plugins_updates = isset( $cache_overview['all_plugins_updates'] ) && is_array( $cache_overview['all_plugins_updates'] ) ? $cache_overview['all_plugins_updates'] : array();
202 - $all_themes_updates = isset( $cache_overview['all_themes_updates'] ) && is_array( $cache_overview['all_themes_updates'] ) ? $cache_overview['all_themes_updates'] : array();
203 - $all_translations_updates = isset( $cache_overview['all_translations_updates'] ) && is_array( $cache_overview['all_translations_updates'] ) ? $cache_overview['all_translations_updates'] : array();
204 - $sites_ids = isset( $cache_overview['sites_ids'] ) && is_array( $cache_overview['sites_ids'] ) ? $cache_overview['sites_ids'] : array();
196 + $sites_ids = isset( $cache_overview['sites_ids'] ) && is_array( $cache_overview['sites_ids'] ) ? $cache_overview['sites_ids'] : array();
205 197 } else {
206 198 $decodedDismissedPlugins = ! empty( $userExtension->dismissed_plugins ) ? json_decode( $userExtension->dismissed_plugins, true ) : array();
207 199 $decodedDismissedThemes = ! empty( $userExtension->dismissed_themes ) ? json_decode( $userExtension->dismissed_themes, true ) : array();
208 200 $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
@@ -235,13 +227,8 @@
235 227 }
236 228
237 229 if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) {
238 230 ++$total_wp_upgrades;
239 - $all_wp_updates[] = array(
240 - 'id' => $website->id,
241 - 'name' => $website->name,
242 - 'is_suspended' => $website->suspended ? 1 : 0,
243 - );
244 231 }
245 232
246 233 $translation_upgrades = ! empty( $website->translation_upgrades ) ? json_decode( $website->translation_upgrades, true ) : array();
247 234
@@ -291,22 +278,9 @@
291 278 }
292 279 }
293 280
294 281 if ( is_array( $translation_upgrades ) ) {
295 -
296 282 $total_translation_upgrades += count( $translation_upgrades );
297 -
298 - if ( ! empty( $translation_upgrades ) ) {
299 - foreach ( $translation_upgrades as $trans_upgrade ) {
300 - $slug = $trans_upgrade['slug'];
301 - $all_translations_updates[] = array(
302 - 'id' => $website->id,
303 - 'name' => $website->name,
304 - 'translation_slug' => rawurlencode( $slug ),
305 - 'is_suspended' => $website->suspended ? 1 : 0,
306 - );
307 - }
308 - }
309 283 }
310 284
311 285 if ( is_array( $plugin_upgrades ) ) {
312 286 $ignored_plugins = ! empty( $website->ignored_plugins ) ? json_decode( $website->ignored_plugins, true ) : array();
@@ -321,19 +295,8 @@
321 295
322 296 }
323 297
324 298 $total_plugin_upgrades += count( $plugin_upgrades );
325 -
326 - if ( ! empty( $plugin_upgrades ) ) {
327 - foreach ( $plugin_upgrades as $slug => $value ) {
328 - $all_plugins_updates[] = array(
329 - 'id' => $website->id,
330 - 'name' => $website->name,
331 - 'plugin_slug' => $slug,
332 - 'is_suspended' => $website->suspended ? 1 : 0,
333 - );
334 - }
335 - }
336 299 }
337 300
338 301 if ( is_array( $theme_upgrades ) ) {
339 302 $ignored_themes = ! empty( $website->ignored_themes ) ? json_decode( $website->ignored_themes, true ) : array();
@@ -346,19 +309,8 @@
346 309 $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
347 310 }
348 311
349 312 $total_theme_upgrades += count( $theme_upgrades );
350 -
351 - if ( ! empty( $theme_upgrades ) ) {
352 - foreach ( $theme_upgrades as $slug => $value ) {
353 - $all_themes_updates[] = array(
354 - 'id' => $website->id,
355 - 'name' => $website->name,
356 - 'theme_slug' => $slug,
357 - 'is_suspended' => $website->suspended ? 1 : 0,
358 - );
359 - }
360 - }
361 313 }
362 314
363 315 $pluginsIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
364 316 $pluginsIgnoredAbandoned_perSites = ! empty( $pluginsIgnoredAbandoned_perSites ) ? json_decode( $pluginsIgnoredAbandoned_perSites, true ) : array();
@@ -410,12 +362,8 @@
410 362 'total_translation_upgrades',
411 363 'total_theme_upgrades',
412 364 'total_plugins_outdate',
413 365 'total_themes_outdate',
414 - 'all_wp_updates',
415 - 'all_plugins_updates',
416 - 'all_themes_updates',
417 - 'all_translations_updates',
418 366 'count_plugins',
419 367 'count_themes',
420 368 'sites_ids',
421 369 );
@@ -451,9 +399,9 @@
451 399
452 400 if ( ! $globalView ) {
453 401 $last_dtsSync = $currentSite->dtsSync;
454 402 } else {
455 - $result = MainWP_DB_Common::instance()->get_last_sync_status();
403 + $result = MainWP_DB_Common::instance()->get_last_sync_status( $is_staging );
456 404 $sync_status = $result['sync_status'];
457 405 $last_sync = $result['last_sync'];
458 406 $last_dtsSync = $result['last_sync'];
459 407
@@ -479,9 +427,9 @@
479 427 <div class="mainwp-scrolly-overflow">
480 428
481 429 <div class="ui small cards mainwp-cards">
482 430
483 - <?php static::render_total_update( $total_upgrades, $can_total_update, $limit_updates_all, $count_websites, $count_plugins, $count_themes ); ?>
431 + <?php static::render_total_update( $total_upgrades, $can_total_update, $limit_updates_all, $count_websites, $count_plugins, $count_themes, $current_wpid ); ?>
484 432 <?php static::render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid, $count_websites ); ?>
485 433 <?php static::render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid, $count_plugins ); ?>
486 434 <?php static::render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid, $count_themes ); ?>
487 435 <?php if ( 1 === (int) $mainwp_show_language_updates ) : ?>
@@ -503,28 +451,233 @@
503 451
504 452 </div>
505 453
506 454 </div>
455 + <div id="mainwp_prepare_global_update_all_container" style="display: none"></div>
507 456 <?php
508 457
509 - static::render_global_update(
510 - $user_can_update_wordpress,
511 - $total_wp_upgrades,
512 - $all_wp_updates,
513 - $user_can_update_plugins,
514 - $total_plugin_upgrades,
515 - $all_plugins_updates,
516 - $user_can_update_themes,
517 - $total_theme_upgrades,
518 - $all_themes_updates,
519 - $mainwp_show_language_updates,
520 - $user_can_update_translation,
521 - $total_translation_upgrades,
522 - $all_translations_updates
458 + static::render_bottom( $sites_ids, $globalView );
459 + }
460 +
461 + /**
462 + * Method prepare_update_data().
463 + *
464 + * @param string $update_type: Values all, core, plugin, theme, trans.
465 + * @param int $current_wpid Current site id.
466 + */
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 ),
523 474 );
524 - static::render_bottom( $sites_ids, $globalView );
475 +
476 + if ( $current_wpid ) {
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' ) );
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 + }
525 677 }
526 678
679 +
527 680 /**
528 681 * Renders Updates Overview widget header.
529 682 *
530 683 * @param string $lastSyncMsg last sync info.
@@ -571,10 +724,11 @@
571 724 * @param int $limit_updates_all limit number of update per request, 0 is no limit.
572 725 * @param int $count_websites count websites.
573 726 * @param int $count_plugins count plugins.
574 727 * @param int $count_themes count themes.
728 + * @param int $current_wpid Current site id.
575 729 */
576 - public static function render_total_update( $total_upgrades, $can_total_update, $limit_updates_all, $count_websites, $count_plugins, $count_themes ) { // phpcs:ignore -- NOSONAR - complex.
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.
577 731
578 732 if ( 0 < $count_plugins ) {
579 733 $outdated_percentage = round( ( ( intval( $total_upgrades ) / intval( $count_themes + $count_plugins + $count_websites ) ) * 100 ), 2 ) . '%';
580 734 } else {
@@ -617,9 +771,9 @@
617 771 <div class="ui grid">
618 772 <div class="center aligned middle alidgned column">
619 773 <?php if ( ! get_option( 'mainwp_hide_update_everything', false ) ) : ?>
620 774 <?php if ( $can_total_update ) : ?>
621 - <a href="#" <?php echo empty( $total_upgrades ) ? 'disabled' : 'onClick="updatesoverview_global_upgrade_all( \'all\' ); 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>
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>
622 776 <?php endif; ?>
623 777 <?php endif; ?>
624 778 </div>
625 779 </div>
@@ -702,9 +856,9 @@
702 856 <?php MainWP_Updates::set_continue_update_html_selector( 'wpcore_global_upgrade_all' ); ?>
703 857 <?php if ( ! empty( $wpcore_update_disabled_by ) ) : ?>
704 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>
705 859 <?php else : ?>
706 - <a href="#" onClick="updatesoverview_global_upgrade_all('wp'); 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>
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>
707 861 <?php endif; ?>
708 862 <?php else : ?>
709 863 <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
710 864 <?php endif; ?>
@@ -780,9 +934,9 @@
780 934 <div class="left aligned middle aligned column">
781 935 <?php if ( $user_can_update_plugins ) : ?>
782 936 <?php if ( ! empty( $total_plugin_upgrades ) ) : ?>
783 937 <?php MainWP_Updates::set_continue_update_html_selector( 'plugins_global_upgrade_all' ); ?>
784 - <a href="#" onClick="updatesoverview_global_upgrade_all('plugin'); 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>
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>
785 939 <?php else : ?>
786 940 <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
787 941 <?php endif; ?>
788 942 <?php endif; ?>
@@ -857,9 +1011,9 @@
857 1011 <div class="left aligned middle aligned column">
858 1012 <?php if ( $user_can_update_themes ) : ?>
859 1013 <?php if ( ! empty( $total_theme_upgrades ) ) : ?>
860 1014 <?php MainWP_Updates::set_continue_update_html_selector( 'themes_global_upgrade_all' ); ?>
861 - <a href="#" onClick="updatesoverview_global_upgrade_all('theme'); 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>
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>
862 1016 <?php else : ?>
863 1017 <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
864 1018 <?php endif; ?>
865 1019 <?php endif; ?>
@@ -920,9 +1074,9 @@
920 1074 <div class="left aligned middle aligned column">
921 1075 <?php if ( $user_can_update_translation ) : ?>
922 1076 <?php if ( ! empty( $total_translation_upgrades ) ) : ?>
923 1077 <?php MainWP_Updates::set_continue_update_html_selector( 'translations_global_upgrade_all' ); ?>
924 - <a href="#" onClick="updatesoverview_global_upgrade_all('translation'); 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>
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>
925 1079 <?php else : ?>
926 1080 <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
927 1081 <?php endif; ?>
928 1082 <?php endif; ?>
@@ -1073,26 +1227,28 @@
1073 1227 * Method render_global_update()
1074 1228 *
1075 1229 * Render global updates.
1076 1230 *
1077 - * @param bool $user_can_update_wordpress Permission to update WordPress.
1078 - * @param int $total_wp_upgrades Total WordPress update.
1079 - * @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.
1080 1235 *
1081 - * @param bool $user_can_update_plugins permission to update plugings.
1082 - * @param int $total_plugin_upgrades total WordPress update.
1083 - * @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.
1084 1239 *
1085 - * @param bool $user_can_update_themes permission to update themes.
1086 - * @param int $total_theme_upgrades total themes update.
1087 - * @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.
1088 1243 *
1089 - * @param mixed $mainwp_show_language_updates MainWP Language Updates.
1090 - * @param bool $user_can_update_translation permission to update languages.
1091 - * @param int $total_translation_upgrades total WordPress update.
1092 - * @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.
1093 1248 */
1094 1249 public static function render_global_update( // phpcs:ignore -- NOSONAR - complex.
1250 + $update_type,
1095 1251 $user_can_update_wordpress,
1096 1252 $total_wp_upgrades,
1097 1253 $all_wp_updates,
1098 1254 $user_can_update_plugins,
@@ -1105,14 +1261,21 @@
1105 1261 $user_can_update_translation,
1106 1262 $total_translation_upgrades,
1107 1263 $all_translations_updates
1108 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 +
1109 1273 ?>
1110 - <div style="display: none">
1111 1274
1112 1275 <div id="wp_upgrades">
1113 1276 <?php
1114 - if ( $user_can_update_wordpress && $total_wp_upgrades > 0 ) {
1277 + if ( $process['core'] && $user_can_update_wordpress && $total_wp_upgrades > 0 ) {
1115 1278 foreach ( $all_wp_updates as $item ) {
1116 1279 ?>
1117 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>
1118 1281 <?php
@@ -1122,9 +1285,9 @@
1122 1285 </div>
1123 1286
1124 1287 <div id="wp_plugin_upgrades">
1125 1288 <?php
1126 - if ( $user_can_update_plugins && $total_plugin_upgrades > 0 ) {
1289 + if ( $process['plugin'] && $user_can_update_plugins && $total_plugin_upgrades > 0 ) {
1127 1290 foreach ( $all_plugins_updates as $item ) {
1128 1291 ?>
1129 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>
1130 1293 <?php
@@ -1134,9 +1297,9 @@
1134 1297 </div>
1135 1298 <div id="wp_theme_upgrades">
1136 1299
1137 1300 <?php
1138 - if ( $user_can_update_themes && $total_theme_upgrades > 0 ) {
1301 + if ( $process['theme'] && $user_can_update_themes && $total_theme_upgrades > 0 ) {
1139 1302 foreach ( $all_themes_updates as $item ) {
1140 1303 ?>
1141 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>
1142 1305 <?php
@@ -1148,9 +1311,9 @@
1148 1311 <?php if ( 1 === (int) $mainwp_show_language_updates ) : ?>
1149 1312 <div id="wp_translation_upgrades">
1150 1313
1151 1314 <?php
1152 - if ( $user_can_update_translation && $total_translation_upgrades > 0 ) {
1315 + if ( $process['trans'] && $user_can_update_translation && $total_translation_upgrades > 0 ) {
1153 1316 foreach ( $all_translations_updates as $item ) {
1154 1317 ?>
1155 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>
1156 1319 <?php
@@ -1158,9 +1321,8 @@
1158 1321 }
1159 1322 ?>
1160 1323 </div>
1161 1324 <?php endif; ?>
1162 - </div>
1163 1325 <?php
1164 1326 }
1165 1327
1166 1328 /**