| @@ -6,8 +6,13 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace MainWP\Dashboard; |
| 9 | 9 | |
| 10 | +// Exit if accessed directly. | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | + | |
| 10 | 15 | /** |
| 11 | 16 | * Class MainWP_Post_Plugin_Theme_Handler |
| 12 | 17 | * |
| 13 | 18 | * @package MainWP\Dashboard |
| @@ -69,20 +74,21 @@ | ||
| 69 | 74 | $this->add_action( 'mainwp_trust_theme', array( &$this, 'mainwp_trust_theme' ) ); |
| 70 | 75 | $this->add_action( 'mainwp_updates_ignore_upgrades', array( &$this, 'ajax_ignore_core_updates' ) ); |
| 71 | 76 | $this->add_action( 'mainwp_updates_unignore_upgrades', array( &$this, 'ajax_unignore_core_updates' ) ); |
| 72 | 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' ) ); | |
| 73 | 79 | |
| 74 | 80 | // Page: Themes. |
| 75 | 81 | $this->add_action( 'mainwp_themes_search', array( &$this, 'mainwp_themes_search' ) ); |
| 76 | 82 | $this->add_action( 'mainwp_themes_search_all', array( &$this, 'mainwp_themes_search_all' ) ); |
| 77 | - if ( mainwp_current_user_have_right( 'dashboard', 'activate_themes' ) ) { | |
| 83 | + if ( \mainwp_current_user_can( 'dashboard', 'activate_themes' ) ) { | |
| 78 | 84 | $this->add_action( 'mainwp_theme_activate', array( &$this, 'mainwp_theme_activate' ) ); |
| 79 | 85 | } |
| 80 | - if ( mainwp_current_user_have_right( 'dashboard', 'delete_themes' ) ) { | |
| 86 | + if ( \mainwp_current_user_can( 'dashboard', 'delete_themes' ) ) { | |
| 81 | 87 | $this->add_action( 'mainwp_theme_delete', array( &$this, 'mainwp_theme_delete' ) ); |
| 82 | 88 | } |
| 83 | 89 | $this->add_action( 'mainwp_trusted_theme_notes_save', array( &$this, 'mainwp_trusted_theme_notes_save' ) ); |
| 84 | - if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 90 | + if ( \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 85 | 91 | $this->add_action( 'mainwp_theme_ignore_updates', array( &$this, 'mainwp_theme_ignore_updates' ) ); |
| 86 | 92 | } |
| 87 | 93 | |
| 88 | 94 | // Page: Plugins. |
| @@ -88,17 +94,17 @@ | ||
| 88 | 94 | // Page: Plugins. |
| 89 | 95 | $this->add_action( 'mainwp_plugins_search', array( &$this, 'mainwp_plugins_search' ) ); |
| 90 | 96 | $this->add_action( 'mainwp_plugins_search_all_active', array( &$this, 'mainwp_plugins_search_all_active' ) ); |
| 91 | 97 | |
| 92 | - if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { | |
| 98 | + if ( \mainwp_current_user_can( 'dashboard', 'activate_deactivate_plugins' ) ) { | |
| 93 | 99 | $this->add_action( 'mainwp_plugin_activate', array( &$this, 'mainwp_plugin_activate' ) ); |
| 94 | 100 | $this->add_action( 'mainwp_plugin_deactivate', array( &$this, 'mainwp_plugin_deactivate' ) ); |
| 95 | 101 | } |
| 96 | - if ( mainwp_current_user_have_right( 'dashboard', 'delete_plugins' ) ) { | |
| 102 | + if ( \mainwp_current_user_can( 'dashboard', 'delete_plugins' ) ) { | |
| 97 | 103 | $this->add_action( 'mainwp_plugin_delete', array( &$this, 'mainwp_plugin_delete' ) ); |
| 98 | 104 | } |
| 99 | 105 | |
| 100 | - if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 106 | + if ( \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 101 | 107 | $this->add_action( 'mainwp_plugin_ignore_updates', array( &$this, 'mainwp_plugin_ignore_updates' ) ); |
| 102 | 108 | } |
| 103 | 109 | $this->add_action( 'mainwp_trusted_plugin_notes_save', array( &$this, 'mainwp_trusted_plugin_notes_save' ) ); |
| 104 | 110 | |
| @@ -123,18 +129,19 @@ | ||
| 123 | 129 | */ |
| 124 | 130 | public function mainwp_themes_search() { |
| 125 | 131 | $this->secure_request( 'mainwp_themes_search' ); |
| 126 | 132 | // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 127 | - $keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : ''; | |
| 128 | - $status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : ''; | |
| 129 | - $groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : array(); | |
| 130 | - $sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : array(); | |
| 131 | - $clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : array(); | |
| 133 | + $keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : ''; | |
| 134 | + $status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : ''; | |
| 135 | + $groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : array(); | |
| 136 | + $sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : array(); | |
| 137 | + $clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : array(); | |
| 138 | + $not_criteria = isset( $_POST['not_criteria'] ) && 'true' === $_POST['not_criteria'] ? true : false; | |
| 139 | + $not_fetchdata = isset( $_POST['not_fetchdata'] ) && ! empty( $_POST['not_fetchdata'] ) ? true : false; | |
| 132 | 140 | |
| 133 | - $not_criteria = isset( $_POST['not_criteria'] ) && 'true' === $_POST['not_criteria'] ? true : false; | |
| 134 | 141 | // phpcs:enable |
| 135 | 142 | MainWP_Cache::init_session(); |
| 136 | - $result = MainWP_Themes::render_table( $keyword, $status, $groups, $sites, $not_criteria, $clients ); | |
| 143 | + $result = MainWP_Themes::render_table( $keyword, $status, $groups, $sites, $not_criteria, $clients, $not_fetchdata ); | |
| 137 | 144 | wp_send_json( $result ); |
| 138 | 145 | } |
| 139 | 146 | |
| 140 | 147 | /** |
| @@ -204,10 +211,17 @@ | ||
| 204 | 211 | * @uses \MainWP\Dashboard\MainWP_Themes_Handler::save_trusted_theme_note() |
| 205 | 212 | */ |
| 206 | 213 | public function mainwp_trusted_theme_notes_save() { |
| 207 | 214 | $this->secure_request( 'mainwp_trusted_theme_notes_save' ); |
| 208 | - MainWP_Themes_Handler::save_trusted_theme_note(); | |
| 209 | - die( wp_json_encode( array( 'result' => 'SUCCESS' ) ) ); | |
| 215 | + $esc_note = MainWP_Themes_Handler::save_trusted_theme_note(); | |
| 216 | + die( | |
| 217 | + wp_json_encode( | |
| 218 | + array( | |
| 219 | + 'result' => 'SUCCESS', | |
| 220 | + 'esc_note_content' => $esc_note, | |
| 221 | + ) | |
| 222 | + ) | |
| 223 | + ); | |
| 210 | 224 | } |
| 211 | 225 | |
| 212 | 226 | /** |
| 213 | 227 | * Method mainwp_plugins_search() |
| @@ -219,17 +233,19 @@ | ||
| 219 | 233 | */ |
| 220 | 234 | public function mainwp_plugins_search() { |
| 221 | 235 | $this->secure_request( 'mainwp_plugins_search' ); |
| 222 | 236 | // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 223 | - $keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : ''; | |
| 224 | - $status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : ''; | |
| 225 | - $groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : ''; | |
| 226 | - $sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : ''; | |
| 227 | - $clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : ''; | |
| 228 | - $not_criteria = isset( $_POST['not_criteria'] ) && 'true' === $_POST['not_criteria'] ? true : false; | |
| 237 | + $keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : ''; | |
| 238 | + $status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : ''; | |
| 239 | + $groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : ''; | |
| 240 | + $sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : ''; | |
| 241 | + $clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : ''; | |
| 242 | + $not_criteria = isset( $_POST['not_criteria'] ) && 'true' === $_POST['not_criteria'] ? true : false; | |
| 243 | + $not_fetchdata = isset( $_POST['not_fetchdata'] ) && ! empty( $_POST['not_fetchdata'] ) ? true : false; | |
| 244 | + | |
| 229 | 245 | // phpcs:enable |
| 230 | 246 | MainWP_Cache::init_session(); |
| 231 | - $result = MainWP_Plugins::render_table( $keyword, $status, $groups, $sites, $not_criteria, $clients ); | |
| 247 | + $result = MainWP_Plugins::render_table( $keyword, $status, $groups, $sites, $not_criteria, $clients, $not_fetchdata ); | |
| 232 | 248 | wp_send_json( $result ); |
| 233 | 249 | } |
| 234 | 250 | |
| 235 | 251 | /** |
| @@ -292,9 +308,9 @@ | ||
| 292 | 308 | |
| 293 | 309 | /** |
| 294 | 310 | * Method mainwp_plugin_ignore_updates() |
| 295 | 311 | * |
| 296 | - * Ignore plugins updates, | |
| 312 | + * Ignore plugin updates, | |
| 297 | 313 | * Page: Plugins. |
| 298 | 314 | * |
| 299 | 315 | * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::ignore_updates() |
| 300 | 316 | */ |
| @@ -313,10 +329,17 @@ | ||
| 313 | 329 | * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::save_trusted_plugin_note() |
| 314 | 330 | */ |
| 315 | 331 | public function mainwp_trusted_plugin_notes_save() { |
| 316 | 332 | $this->secure_request( 'mainwp_trusted_plugin_notes_save' ); |
| 317 | - MainWP_Plugins_Handler::save_trusted_plugin_note(); | |
| 318 | - die( wp_json_encode( array( 'result' => 'SUCCESS' ) ) ); | |
| 333 | + $esc_note = MainWP_Plugins_Handler::save_trusted_plugin_note(); | |
| 334 | + die( | |
| 335 | + wp_json_encode( | |
| 336 | + array( | |
| 337 | + 'result' => 'SUCCESS', | |
| 338 | + 'esc_note_content' => $esc_note, | |
| 339 | + ) | |
| 340 | + ) | |
| 341 | + ); | |
| 319 | 342 | } |
| 320 | 343 | |
| 321 | 344 | /** |
| 322 | 345 | * Method mainwp_widget_plugin_activate() |
| @@ -498,10 +521,10 @@ | ||
| 498 | 521 | * @uses \MainWP\Dashboard\MainWP_Exception |
| 499 | 522 | * @uses \MainWP\Dashboard\MainWP_Updates_Handler::upgrade_site() |
| 500 | 523 | */ |
| 501 | 524 | public function mainwp_upgradewp() { |
| 502 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'update_wordpress' ) ) { | |
| 503 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'update WordPress', 'mainwp' ), false ) ) ) ); | |
| 525 | + if ( ! \mainwp_current_user_can( 'dashboard', 'update_wordpress' ) ) { | |
| 526 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update WordPress', 'mainwp' ), false ) ) ) ); | |
| 504 | 527 | } |
| 505 | 528 | |
| 506 | 529 | $this->secure_request( 'mainwp_upgradewp' ); |
| 507 | 530 | |
| @@ -512,10 +535,11 @@ | ||
| 512 | 535 | die( |
| 513 | 536 | wp_json_encode( |
| 514 | 537 | array( |
| 515 | 538 | 'error' => array( |
| 516 | - 'message' => $e->getMessage(), | |
| 517 | - 'extra' => $e->get_message_extra(), | |
| 539 | + 'message' => $e->getMessage(), | |
| 540 | + 'extra' => $e->get_message_extra(), | |
| 541 | + 'errorCode' => $e->get_message_error_code(), | |
| 518 | 542 | ), |
| 519 | 543 | ) |
| 520 | 544 | ) |
| 521 | 545 | ); |
| @@ -521,9 +545,78 @@ | ||
| 521 | 545 | ); |
| 522 | 546 | } |
| 523 | 547 | } |
| 524 | 548 | |
| 549 | + | |
| 525 | 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 | + /** | |
| 526 | 619 | * Method mainwp_upgrade_plugintheme() |
| 527 | 620 | * |
| 528 | 621 | * Update plugin or theme. |
| 529 | 622 | * |
| @@ -539,18 +632,18 @@ | ||
| 539 | 632 | if ( ! isset( $_POST['type'] ) ) { |
| 540 | 633 | die( wp_json_encode( array( 'error' => '<i class="red times icon"></i> ' . esc_html__( 'Plugin or theme not specified. Please reload the page and try again.', 'mainwp' ) ) ) ); |
| 541 | 634 | } |
| 542 | 635 | |
| 543 | - if ( 'plugin' === $_POST['type'] && ! mainwp_current_user_have_right( 'dashboard', 'update_plugins' ) ) { | |
| 544 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'update plugins', 'mainwp' ), false ) ) ) ); | |
| 636 | + if ( 'plugin' === $_POST['type'] && ! \mainwp_current_user_can( 'dashboard', 'update_plugins' ) ) { | |
| 637 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update plugins', 'mainwp' ), false ) ) ) ); | |
| 545 | 638 | } |
| 546 | 639 | |
| 547 | - if ( 'theme' === $_POST['type'] && ! mainwp_current_user_have_right( 'dashboard', 'update_themes' ) ) { | |
| 548 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'update themes', 'mainwp' ), false ) ) ) ); | |
| 640 | + if ( 'theme' === $_POST['type'] && ! \mainwp_current_user_can( 'dashboard', 'update_themes' ) ) { | |
| 641 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update themes', 'mainwp' ), false ) ) ) ); | |
| 549 | 642 | } |
| 550 | 643 | |
| 551 | - if ( 'translation' === $_POST['type'] && ! mainwp_current_user_have_right( 'dashboard', 'update_translations' ) ) { | |
| 552 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'update translations', 'mainwp' ), false ) ) ) ); | |
| 644 | + if ( 'translation' === $_POST['type'] && ! \mainwp_current_user_can( 'dashboard', 'update_translations' ) ) { | |
| 645 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update translations', 'mainwp' ), false ) ) ) ); | |
| 553 | 646 | } |
| 554 | 647 | |
| 555 | 648 | $this->secure_request( 'mainwp_upgradeplugintheme' ); |
| 556 | 649 | |
| @@ -610,10 +703,11 @@ | ||
| 610 | 703 | } |
| 611 | 704 | $website = MainWP_DB::instance()->get_website_by_id( $websiteId ); |
| 612 | 705 | try { |
| 613 | 706 | $info = array( |
| 614 | - 'result' => array(), | |
| 615 | - 'result_error' => array(), | |
| 707 | + 'result' => array(), | |
| 708 | + 'result_error' => array(), | |
| 709 | + 'result_started' => array(), | |
| 616 | 710 | ); |
| 617 | 711 | |
| 618 | 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 |
| 619 | 713 | |
| @@ -623,10 +717,27 @@ | ||
| 623 | 717 | } |
| 624 | 718 | if ( isset( $result['result_error'] ) ) { |
| 625 | 719 | $info['result_error'] = $result['result_error']; |
| 626 | 720 | } |
| 721 | + // for backward compatibility. | |
| 722 | + if ( isset( $result['result_started'] ) ) { | |
| 723 | + $info['result_started'] = $result['result_started']; | |
| 724 | + } | |
| 627 | 725 | } |
| 628 | 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 | + } | |
| 737 | + } | |
| 738 | + } | |
| 739 | + | |
| 629 | 740 | if ( $chunk_support && ( ! empty( $chunk_slugs ) ) ) { |
| 630 | 741 | $info['chunk_slugs'] = implode( ',', $chunk_slugs ); |
| 631 | 742 | } |
| 632 | 743 | |
| @@ -632,8 +743,15 @@ | ||
| 632 | 743 | |
| 633 | 744 | if ( ! empty( $website ) ) { |
| 634 | 745 | $info['site_url'] = esc_url( $website->url ); |
| 635 | 746 | } |
| 747 | + | |
| 748 | + // Get max the scope of the largest change. | |
| 749 | + $max_scope = apply_filters( 'mainwp_html_regression_largest_change_scope', $websiteId, false ); | |
| 750 | + if ( ! empty( $max_scope ) && $max_scope !== $websiteId ) { | |
| 751 | + $info['result']['html_regression_max_scope'] = $max_scope; | |
| 752 | + } | |
| 753 | + | |
| 636 | 754 | wp_send_json( $info ); |
| 637 | 755 | } catch ( MainWP_Exception $e ) { |
| 638 | 756 | die( |
| 639 | 757 | wp_json_encode( |
| @@ -765,10 +883,10 @@ | ||
| 765 | 883 | */ |
| 766 | 884 | public function mainwp_dismissoutdatepluginsthemes() { |
| 767 | 885 | $this->secure_request( 'mainwp_dismissoutdatepluginsthemes' ); |
| 768 | 886 | |
| 769 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 770 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) ); | |
| 887 | + if ( ! \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 888 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) ); | |
| 771 | 889 | } |
| 772 | 890 | |
| 773 | 891 | // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 774 | 892 | if ( ! isset( $_POST['slug'] ) ) { |
| @@ -815,10 +933,10 @@ | ||
| 815 | 933 | */ |
| 816 | 934 | public function mainwp_ignorepluginsthemes() { |
| 817 | 935 | $this->secure_request( 'mainwp_ignorepluginsthemes' ); |
| 818 | 936 | |
| 819 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 820 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) ); | |
| 937 | + if ( ! \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 938 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) ); | |
| 821 | 939 | } |
| 822 | 940 | |
| 823 | 941 | // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 824 | 942 | if ( ! isset( $_POST['slug'] ) ) { |
| @@ -844,10 +962,10 @@ | ||
| 844 | 962 | public function ajax_ignore_core_updates() { //phpcs:ignore -- NOSONAR complex function. |
| 845 | 963 | |
| 846 | 964 | $this->secure_request( 'mainwp_updates_ignore_upgrades' ); |
| 847 | 965 | |
| 848 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 849 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) ); | |
| 966 | + if ( ! \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) { | |
| 967 | + die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) ); | |
| 850 | 968 | } |
| 851 | 969 | |
| 852 | 970 | // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 853 | 971 | if ( empty( $_POST['slug'] ) ) { |