| @@ -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,12 +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 | - ); | |
| 243 | 231 | } |
| 244 | 232 | |
| 245 | 233 | $translation_upgrades = ! empty( $website->translation_upgrades ) ? json_decode( $website->translation_upgrades, true ) : array(); |
| 246 | 234 | |
| @@ -290,21 +278,9 @@ | ||
| 290 | 278 | } |
| 291 | 279 | } |
| 292 | 280 | |
| 293 | 281 | if ( is_array( $translation_upgrades ) ) { |
| 294 | - | |
| 295 | 282 | $total_translation_upgrades += count( $translation_upgrades ); |
| 296 | - | |
| 297 | - if ( ! empty( $translation_upgrades ) ) { | |
| 298 | - foreach ( $translation_upgrades as $trans_upgrade ) { | |
| 299 | - $slug = $trans_upgrade['slug']; | |
| 300 | - $all_translations_updates[] = array( | |
| 301 | - 'id' => $website->id, | |
| 302 | - 'name' => $website->name, | |
| 303 | - 'translation_slug' => rawurlencode( $slug ), | |
| 304 | - ); | |
| 305 | - } | |
| 306 | - } | |
| 307 | 283 | } |
| 308 | 284 | |
| 309 | 285 | if ( is_array( $plugin_upgrades ) ) { |
| 310 | 286 | $ignored_plugins = ! empty( $website->ignored_plugins ) ? json_decode( $website->ignored_plugins, true ) : array(); |
| @@ -319,18 +295,8 @@ | ||
| 319 | 295 | |
| 320 | 296 | } |
| 321 | 297 | |
| 322 | 298 | $total_plugin_upgrades += count( $plugin_upgrades ); |
| 323 | - | |
| 324 | - if ( ! empty( $plugin_upgrades ) ) { | |
| 325 | - foreach ( $plugin_upgrades as $slug => $value ) { | |
| 326 | - $all_plugins_updates[] = array( | |
| 327 | - 'id' => $website->id, | |
| 328 | - 'name' => $website->name, | |
| 329 | - 'plugin_slug' => $slug, | |
| 330 | - ); | |
| 331 | - } | |
| 332 | - } | |
| 333 | 299 | } |
| 334 | 300 | |
| 335 | 301 | if ( is_array( $theme_upgrades ) ) { |
| 336 | 302 | $ignored_themes = ! empty( $website->ignored_themes ) ? json_decode( $website->ignored_themes, true ) : array(); |
| @@ -343,18 +309,8 @@ | ||
| 343 | 309 | $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); |
| 344 | 310 | } |
| 345 | 311 | |
| 346 | 312 | $total_theme_upgrades += count( $theme_upgrades ); |
| 347 | - | |
| 348 | - if ( ! empty( $theme_upgrades ) ) { | |
| 349 | - foreach ( $theme_upgrades as $slug => $value ) { | |
| 350 | - $all_themes_updates[] = array( | |
| 351 | - 'id' => $website->id, | |
| 352 | - 'name' => $website->name, | |
| 353 | - 'theme_slug' => $slug, | |
| 354 | - ); | |
| 355 | - } | |
| 356 | - } | |
| 357 | 313 | } |
| 358 | 314 | |
| 359 | 315 | $pluginsIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' ); |
| 360 | 316 | $pluginsIgnoredAbandoned_perSites = ! empty( $pluginsIgnoredAbandoned_perSites ) ? json_decode( $pluginsIgnoredAbandoned_perSites, true ) : array(); |
| @@ -406,12 +362,8 @@ | ||
| 406 | 362 | 'total_translation_upgrades', |
| 407 | 363 | 'total_theme_upgrades', |
| 408 | 364 | 'total_plugins_outdate', |
| 409 | 365 | 'total_themes_outdate', |
| 410 | - 'all_wp_updates', | |
| 411 | - 'all_plugins_updates', | |
| 412 | - 'all_themes_updates', | |
| 413 | - 'all_translations_updates', | |
| 414 | 366 | 'count_plugins', |
| 415 | 367 | 'count_themes', |
| 416 | 368 | 'sites_ids', |
| 417 | 369 | ); |
| @@ -447,9 +399,9 @@ | ||
| 447 | 399 | |
| 448 | 400 | if ( ! $globalView ) { |
| 449 | 401 | $last_dtsSync = $currentSite->dtsSync; |
| 450 | 402 | } else { |
| 451 | - $result = MainWP_DB_Common::instance()->get_last_sync_status(); | |
| 403 | + $result = MainWP_DB_Common::instance()->get_last_sync_status( $is_staging ); | |
| 452 | 404 | $sync_status = $result['sync_status']; |
| 453 | 405 | $last_sync = $result['last_sync']; |
| 454 | 406 | $last_dtsSync = $result['last_sync']; |
| 455 | 407 | |
| @@ -475,9 +427,9 @@ | ||
| 475 | 427 | <div class="mainwp-scrolly-overflow"> |
| 476 | 428 | |
| 477 | 429 | <div class="ui small cards mainwp-cards"> |
| 478 | 430 | |
| 479 | - <?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 ); ?> | |
| 480 | 432 | <?php static::render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid, $count_websites ); ?> |
| 481 | 433 | <?php static::render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid, $count_plugins ); ?> |
| 482 | 434 | <?php static::render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid, $count_themes ); ?> |
| 483 | 435 | <?php if ( 1 === (int) $mainwp_show_language_updates ) : ?> |
| @@ -499,28 +451,233 @@ | ||
| 499 | 451 | |
| 500 | 452 | </div> |
| 501 | 453 | |
| 502 | 454 | </div> |
| 455 | + <div id="mainwp_prepare_global_update_all_container" style="display: none"></div> | |
| 503 | 456 | <?php |
| 504 | 457 | |
| 505 | - static::render_global_update( | |
| 506 | - $user_can_update_wordpress, | |
| 507 | - $total_wp_upgrades, | |
| 508 | - $all_wp_updates, | |
| 509 | - $user_can_update_plugins, | |
| 510 | - $total_plugin_upgrades, | |
| 511 | - $all_plugins_updates, | |
| 512 | - $user_can_update_themes, | |
| 513 | - $total_theme_upgrades, | |
| 514 | - $all_themes_updates, | |
| 515 | - $mainwp_show_language_updates, | |
| 516 | - $user_can_update_translation, | |
| 517 | - $total_translation_upgrades, | |
| 518 | - $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 ), | |
| 519 | 474 | ); |
| 520 | - 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 | + } | |
| 521 | 677 | } |
| 522 | 678 | |
| 679 | + | |
| 523 | 680 | /** |
| 524 | 681 | * Renders Updates Overview widget header. |
| 525 | 682 | * |
| 526 | 683 | * @param string $lastSyncMsg last sync info. |
| @@ -567,10 +724,11 @@ | ||
| 567 | 724 | * @param int $limit_updates_all limit number of update per request, 0 is no limit. |
| 568 | 725 | * @param int $count_websites count websites. |
| 569 | 726 | * @param int $count_plugins count plugins. |
| 570 | 727 | * @param int $count_themes count themes. |
| 728 | + * @param int $current_wpid Current site id. | |
| 571 | 729 | */ |
| 572 | - 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. | |
| 573 | 731 | |
| 574 | 732 | if ( 0 < $count_plugins ) { |
| 575 | 733 | $outdated_percentage = round( ( ( intval( $total_upgrades ) / intval( $count_themes + $count_plugins + $count_websites ) ) * 100 ), 2 ) . '%'; |
| 576 | 734 | } else { |
| @@ -613,9 +771,9 @@ | ||
| 613 | 771 | <div class="ui grid"> |
| 614 | 772 | <div class="center aligned middle alidgned column"> |
| 615 | 773 | <?php if ( ! get_option( 'mainwp_hide_update_everything', false ) ) : ?> |
| 616 | 774 | <?php if ( $can_total_update ) : ?> |
| 617 | - <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> | |
| 618 | 776 | <?php endif; ?> |
| 619 | 777 | <?php endif; ?> |
| 620 | 778 | </div> |
| 621 | 779 | </div> |
| @@ -698,9 +856,9 @@ | ||
| 698 | 856 | <?php MainWP_Updates::set_continue_update_html_selector( 'wpcore_global_upgrade_all' ); ?> |
| 699 | 857 | <?php if ( ! empty( $wpcore_update_disabled_by ) ) : ?> |
| 700 | 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> |
| 701 | 859 | <?php else : ?> |
| 702 | - <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> | |
| 703 | 861 | <?php endif; ?> |
| 704 | 862 | <?php else : ?> |
| 705 | 863 | <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 706 | 864 | <?php endif; ?> |
| @@ -776,9 +934,9 @@ | ||
| 776 | 934 | <div class="left aligned middle aligned column"> |
| 777 | 935 | <?php if ( $user_can_update_plugins ) : ?> |
| 778 | 936 | <?php if ( ! empty( $total_plugin_upgrades ) ) : ?> |
| 779 | 937 | <?php MainWP_Updates::set_continue_update_html_selector( 'plugins_global_upgrade_all' ); ?> |
| 780 | - <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> | |
| 781 | 939 | <?php else : ?> |
| 782 | 940 | <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 783 | 941 | <?php endif; ?> |
| 784 | 942 | <?php endif; ?> |
| @@ -853,9 +1011,9 @@ | ||
| 853 | 1011 | <div class="left aligned middle aligned column"> |
| 854 | 1012 | <?php if ( $user_can_update_themes ) : ?> |
| 855 | 1013 | <?php if ( ! empty( $total_theme_upgrades ) ) : ?> |
| 856 | 1014 | <?php MainWP_Updates::set_continue_update_html_selector( 'themes_global_upgrade_all' ); ?> |
| 857 | - <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> | |
| 858 | 1016 | <?php else : ?> |
| 859 | 1017 | <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 860 | 1018 | <?php endif; ?> |
| 861 | 1019 | <?php endif; ?> |
| @@ -916,9 +1074,9 @@ | ||
| 916 | 1074 | <div class="left aligned middle aligned column"> |
| 917 | 1075 | <?php if ( $user_can_update_translation ) : ?> |
| 918 | 1076 | <?php if ( ! empty( $total_translation_upgrades ) ) : ?> |
| 919 | 1077 | <?php MainWP_Updates::set_continue_update_html_selector( 'translations_global_upgrade_all' ); ?> |
| 920 | - <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> | |
| 921 | 1079 | <?php else : ?> |
| 922 | 1080 | <a href="#" class="ui disabled green mini button mainwp-update-all-button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 923 | 1081 | <?php endif; ?> |
| 924 | 1082 | <?php endif; ?> |
| @@ -1069,26 +1227,28 @@ | ||
| 1069 | 1227 | * Method render_global_update() |
| 1070 | 1228 | * |
| 1071 | 1229 | * Render global updates. |
| 1072 | 1230 | * |
| 1073 | - * @param bool $user_can_update_wordpress Permission to update WordPress. | |
| 1074 | - * @param int $total_wp_upgrades Total WordPress update. | |
| 1075 | - * @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. | |
| 1076 | 1235 | * |
| 1077 | - * @param bool $user_can_update_plugins permission to update plugings. | |
| 1078 | - * @param int $total_plugin_upgrades total WordPress update. | |
| 1079 | - * @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. | |
| 1080 | 1239 | * |
| 1081 | - * @param bool $user_can_update_themes permission to update themes. | |
| 1082 | - * @param int $total_theme_upgrades total themes update. | |
| 1083 | - * @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. | |
| 1084 | 1243 | * |
| 1085 | - * @param mixed $mainwp_show_language_updates MainWP Language Updates. | |
| 1086 | - * @param bool $user_can_update_translation permission to update languages. | |
| 1087 | - * @param int $total_translation_upgrades total WordPress update. | |
| 1088 | - * @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. | |
| 1089 | 1248 | */ |
| 1090 | 1249 | public static function render_global_update( // phpcs:ignore -- NOSONAR - complex. |
| 1250 | + $update_type, | |
| 1091 | 1251 | $user_can_update_wordpress, |
| 1092 | 1252 | $total_wp_upgrades, |
| 1093 | 1253 | $all_wp_updates, |
| 1094 | 1254 | $user_can_update_plugins, |
| @@ -1101,17 +1261,24 @@ | ||
| 1101 | 1261 | $user_can_update_translation, |
| 1102 | 1262 | $total_translation_upgrades, |
| 1103 | 1263 | $all_translations_updates |
| 1104 | 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 | + | |
| 1105 | 1273 | ?> |
| 1106 | - <div style="display: none"> | |
| 1107 | 1274 | |
| 1108 | 1275 | <div id="wp_upgrades"> |
| 1109 | 1276 | <?php |
| 1110 | - if ( $user_can_update_wordpress && $total_wp_upgrades > 0 ) { | |
| 1277 | + if ( $process['core'] && $user_can_update_wordpress && $total_wp_upgrades > 0 ) { | |
| 1111 | 1278 | foreach ( $all_wp_updates as $item ) { |
| 1112 | 1279 | ?> |
| 1113 | - <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> | |
| 1114 | 1281 | <?php |
| 1115 | 1282 | } |
| 1116 | 1283 | } |
| 1117 | 1284 | ?> |
| @@ -1118,12 +1285,12 @@ | ||
| 1118 | 1285 | </div> |
| 1119 | 1286 | |
| 1120 | 1287 | <div id="wp_plugin_upgrades"> |
| 1121 | 1288 | <?php |
| 1122 | - if ( $user_can_update_plugins && $total_plugin_upgrades > 0 ) { | |
| 1289 | + if ( $process['plugin'] && $user_can_update_plugins && $total_plugin_upgrades > 0 ) { | |
| 1123 | 1290 | foreach ( $all_plugins_updates as $item ) { |
| 1124 | 1291 | ?> |
| 1125 | - <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> | |
| 1126 | 1293 | <?php |
| 1127 | 1294 | } |
| 1128 | 1295 | } |
| 1129 | 1296 | ?> |
| @@ -1130,12 +1297,12 @@ | ||
| 1130 | 1297 | </div> |
| 1131 | 1298 | <div id="wp_theme_upgrades"> |
| 1132 | 1299 | |
| 1133 | 1300 | <?php |
| 1134 | - if ( $user_can_update_themes && $total_theme_upgrades > 0 ) { | |
| 1301 | + if ( $process['theme'] && $user_can_update_themes && $total_theme_upgrades > 0 ) { | |
| 1135 | 1302 | foreach ( $all_themes_updates as $item ) { |
| 1136 | 1303 | ?> |
| 1137 | - <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> | |
| 1138 | 1305 | <?php |
| 1139 | 1306 | } |
| 1140 | 1307 | } |
| 1141 | 1308 | ?> |
| @@ -1144,12 +1311,12 @@ | ||
| 1144 | 1311 | <?php if ( 1 === (int) $mainwp_show_language_updates ) : ?> |
| 1145 | 1312 | <div id="wp_translation_upgrades"> |
| 1146 | 1313 | |
| 1147 | 1314 | <?php |
| 1148 | - if ( $user_can_update_translation && $total_translation_upgrades > 0 ) { | |
| 1315 | + if ( $process['trans'] && $user_can_update_translation && $total_translation_upgrades > 0 ) { | |
| 1149 | 1316 | foreach ( $all_translations_updates as $item ) { |
| 1150 | 1317 | ?> |
| 1151 | - <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> | |
| 1152 | 1319 | <?php |
| 1153 | 1320 | } |
| 1154 | 1321 | } |
| 1155 | 1322 | ?> |
| @@ -1154,9 +1321,8 @@ | ||
| 1154 | 1321 | } |
| 1155 | 1322 | ?> |
| 1156 | 1323 | </div> |
| 1157 | 1324 | <?php endif; ?> |
| 1158 | - </div> | |
| 1159 | 1325 | <?php |
| 1160 | 1326 | } |
| 1161 | 1327 | |
| 1162 | 1328 | /** |