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.3 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 All 156 releases
← All changes | class/class-mainwp-post-plugin-theme-handler.php +90 -2 6.1.3 → 6.2.1 View file →
@@ -74,8 +74,9 @@
74 74 $this->add_action( 'mainwp_trust_theme', array( &$this, 'mainwp_trust_theme' ) );
75 75 $this->add_action( 'mainwp_updates_ignore_upgrades', array( &$this, 'ajax_ignore_core_updates' ) );
76 76 $this->add_action( 'mainwp_updates_unignore_upgrades', array( &$this, 'ajax_unignore_core_updates' ) );
77 77 $this->add_action( 'mainwp_updates_unignore_global_upgrades', array( &$this, 'ajax_unignore_global_upgrades' ) );
78 + $this->add_action( 'mainwp_overview_prepare_upgradeall', array( &$this, 'ajax_prepare_upgradeall' ) );
78 79
79 80 // Page: Themes.
80 81 $this->add_action( 'mainwp_themes_search', array( &$this, 'mainwp_themes_search' ) );
81 82 $this->add_action( 'mainwp_themes_search_all', array( &$this, 'mainwp_themes_search_all' ) );
@@ -544,9 +545,78 @@
544 545 );
545 546 }
546 547 }
547 548
549 +
548 550 /**
551 + * Method ajax_prepare_upgradeall()
552 + *
553 + * Prepare update all.
554 + */
555 + public function ajax_prepare_upgradeall() {
556 + $this->secure_request( 'mainwp_overview_prepare_upgradeall' );
557 +
558 + $update_type = isset( $_POST['which'] ) ? sanitize_text_field( wp_unslash( $_POST['which'] ) ) : ''; // phpcs:ignore --NOSONAR - none verified.
559 + if ( ! in_array( $update_type, array( 'all', 'plugin', 'theme', 'translation', 'wp' ), true ) ) {
560 + ?>
561 + <div class="ui yellow message"><i class="close icon"></i> <?php esc_html_e( 'Invalid update type. Please try again.', 'mainwp' ); ?></div>
562 + <?php
563 + die();
564 + }
565 + $current_siteid = isset( $_POST['site_id'] ) ? intval( $_POST['site_id'] ) : 0; // phpcs:ignore --NOSONAR - none verified.
566 +
567 + if ( 'translation' === $update_type ) {
568 + $update_type = 'trans'; // compatible.
569 + } elseif ( 'wp' === $update_type ) {
570 + $update_type = 'core'; // compatible.
571 + }
572 +
573 + $data = MainWP_Updates_Overview::prepare_update_data( $update_type, $current_siteid );
574 +
575 + $data = wp_parse_args(
576 + $data,
577 + array(
578 + 'total_wp_upgrades' => 0,
579 + 'all_wp_updates' => array(),
580 + 'total_plugin_upgrades' => 0,
581 + 'all_plugins_updates' => array(),
582 + 'total_theme_upgrades' => 0,
583 + 'all_themes_updates' => array(),
584 + 'total_translation_upgrades' => 0,
585 + 'all_translations_updates' => array(),
586 + )
587 + );
588 +
589 + extract( $data ); // phpcs:ignore -- NOSONAR - well structure.
590 +
591 + $user_can_update_translation = \mainwp_current_user_can( 'dashboard', 'update_translations' );
592 + $user_can_update_wordpress = \mainwp_current_user_can( 'dashboard', 'update_wordpress' );
593 + $user_can_update_themes = \mainwp_current_user_can( 'dashboard', 'update_themes' );
594 + $user_can_update_plugins = \mainwp_current_user_can( 'dashboard', 'update_plugins' );
595 +
596 + $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
597 +
598 + MainWP_Updates_Overview::render_global_update(
599 + $update_type,
600 + $user_can_update_wordpress,
601 + $total_wp_upgrades,
602 + $all_wp_updates,
603 + $user_can_update_plugins,
604 + $total_plugin_upgrades,
605 + $all_plugins_updates,
606 + $user_can_update_themes,
607 + $total_theme_upgrades,
608 + $all_themes_updates,
609 + $mainwp_show_language_updates,
610 + $user_can_update_translation,
611 + $total_translation_upgrades,
612 + $all_translations_updates
613 + );
614 +
615 + die();
616 + }
617 +
618 + /**
549 619 * Method mainwp_upgrade_plugintheme()
550 620 *
551 621 * Update plugin or theme.
552 622 *
@@ -633,10 +703,11 @@
633 703 }
634 704 $website = MainWP_DB::instance()->get_website_by_id( $websiteId );
635 705 try {
636 706 $info = array(
637 - 'result' => array(),
638 - 'result_error' => array(),
707 + 'result' => array(),
708 + 'result_error' => array(),
709 + 'result_started' => array(),
639 710 );
640 711
641 712 $result = MainWP_Updates_Handler::upgrade_plugin_theme_translation( $websiteId, sanitize_text_field( wp_unslash( $_POST['type'] ) ), $slugs ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
642 713
@@ -645,8 +716,25 @@
645 716 $info['result'] = $result['result'];
646 717 }
647 718 if ( isset( $result['result_error'] ) ) {
648 719 $info['result_error'] = $result['result_error'];
720 + }
721 + // for backward compatibility.
722 + if ( isset( $result['result_started'] ) ) {
723 + $info['result_started'] = $result['result_started'];
724 + }
725 + }
726 +
727 + // MWP-1660: append a generic licensing hint to failures of known premium
728 + // products; vendors only deliver update packages to licensed installs.
729 + $item_type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
730 + if ( ( 'plugin' === $item_type || 'theme' === $item_type ) && ! empty( $info['result_error'] ) && is_array( $info['result_error'] ) ) {
731 + $premium_ids = MainWP_Premium_Update_Registry::get_filter_defaults( $item_type, 'detect' );
732 + $premium_prefixes = MainWP_Premium_Update_Registry::get_prefixes( $item_type, 'detect' );
733 + foreach ( $info['result_error'] as $err_slug => $err_msg ) {
734 + if ( is_string( $err_msg ) && MainWP_Premium_Update_Registry::slug_matches( urldecode( $err_slug ), $premium_ids, $premium_prefixes ) ) {
735 + $info['result_error'][ $err_slug ] = $err_msg . ' ' . esc_html__( 'Premium updates usually require an active license on the child site; check that first.', 'mainwp' );
736 + }
649 737 }
650 738 }
651 739
652 740 if ( $chunk_support && ( ! empty( $chunk_slugs ) ) ) {