PluginProbe
The WP Remote WordPress Plugin / 6.36
The WP Remote WordPress Plugin v6.36
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | callback/wings/manage.php +286 -41 5.226.36 View file →
@@ -4,13 +4,15 @@
4 4 if (!class_exists('BVManageCallback')) :
5 5 class BVManageCallback extends BVCallbackBase {
6 6 public $settings;
7 7 public $skin;
8 + public $bvinfo;
8 9
9 - const MANAGE_WING_VERSION = 1.2;
10 + const MANAGE_WING_VERSION = 1.7;
10 11
11 12 public function __construct($callback_handler) {
12 13 $this->settings = $callback_handler->settings;
14 + $this->bvinfo = new WPRInfo($this->settings);
13 15 }
14 16
15 17 function getError($err) {
16 18 return $this->objectToArray($err);
@@ -42,9 +44,8 @@
42 44 @include_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
43 45 @include_once ABSPATH.'wp-admin/includes/class-theme-upgrader.php';
44 46 @include_once ABSPATH.'wp-admin/includes/class-plugin-upgrader.php';
45 47 @include_once ABSPATH.'wp-admin/includes/user.php';
46 - @include_once ABSPATH.'wp-includes/registration.php';
47 48 @include_once ABSPATH.'wp-admin/includes/upgrade.php';
48 49 @include_once ABSPATH.'wp-admin/includes/update.php';
49 50 @require_once ABSPATH.'wp-admin/includes/update-core.php';
50 51 }
@@ -280,18 +281,8 @@
280 281 } else {
281 282 return array('status' => 'Done');
282 283 }
283 284 } else {
284 - $resp = array("wp_update_core", function_exists('wp_update_core'));
285 - if (function_exists('wp_update_core')) {
286 - $result = wp_update_core($to_update);
287 - if (is_wp_error($result)) {
288 - return array('status' => "Error", "message" => $this->getError($result));
289 - } else {
290 - return array('status' => 'Done');
291 - }
292 - }
293 -
294 285 $resp = array("WP_Upgrader", class_exists('WP_Upgrader'));
295 286 if (class_exists('WP_Upgrader')) {
296 287 $upgrader = new WP_Upgrader();
297 288
@@ -340,8 +331,9 @@
340 331 }
341 332 }
342 333
343 334 function bv_plugin_bulk_upgrade($upgrader, $_plugins) {
335 + global $wp_version;
344 336 $plugins = array_keys($_plugins);
345 337 $args = array();
346 338 $defaults = array(
347 339 'clear_update_cache' => true,
@@ -371,20 +363,51 @@
371 363 foreach($plugins as $plugin) {
372 364 $upgrader->update_current++;
373 365 $upgrader->skin->plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin, false, true);
374 366 $upgrader->skin->plugin_active = is_plugin_active($plugin);
375 - $result = $upgrader->run(
376 - array(
377 - 'package' => $_plugins[$plugin],
378 - 'destination' => WP_PLUGIN_DIR,
379 - 'clear_destination' => true,
380 - 'clear_working' => true,
381 - 'is_multi' => true,
382 - 'hook_extra' => array(
383 - 'plugin' => $plugin,
384 - ),
385 - )
386 - );
367 + if ( isset( $_plugins[$plugin]['requires'] ) && function_exists('is_wp_version_compatible') && !is_wp_version_compatible( $_plugins[$plugin]['requires'] ) ) {
368 + $result = new WP_Error(
369 + 'incompatible_wp_required_version',
370 + sprintf(
371 + __( 'Your WordPress version is %1$s, however the new plugin version requires %2$s.' ),
372 + $wp_version,
373 + $_plugins[$plugin]['requires']
374 + )
375 + );
376 +
377 + $upgrader->skin->before( $result );
378 + $upgrader->skin->error( $result );
379 + $upgrader->skin->after();
380 + } elseif ( isset( $_plugins[$plugin]['requires_php'] ) && function_exists('is_php_version_compatible') && !is_php_version_compatible( $_plugins[$plugin]['requires_php'] ) ) {
381 +
382 + $result = new WP_Error(
383 + 'incompatible_php_required_version',
384 + sprintf(
385 + __( 'The PHP version on your server is %1$s, however the new plugin version requires %2$s.' ),
386 + PHP_VERSION,
387 + $_plugins[$plugin]['requires_php']
388 + )
389 + );
390 +
391 + $upgrader->skin->before( $result );
392 + $upgrader->skin->error( $result );
393 + $upgrader->skin->after();
394 + } else {
395 + add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
396 + $result = $upgrader->run(
397 + array(
398 + 'package' => $_plugins[$plugin]['package'],
399 + 'destination' => WP_PLUGIN_DIR,
400 + 'clear_destination' => true,
401 + 'clear_working' => true,
402 + 'is_multi' => true,
403 + 'hook_extra' => array(
404 + 'plugin' => $plugin,
405 + ),
406 + )
407 + );
408 + remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
409 + }
387 410 $results[$plugin] = $result;
388 411 if (false === $result) {
389 412 break;
390 413 }
@@ -419,9 +442,18 @@
419 442 $result = array();
420 443 $_plugins = array();
421 444 $plugins_by_name = array();
422 445 foreach ($plugins as $plugin) {
423 - $_plugins[$plugin['file']] = $plugin['package'];
446 + $_plugins[$plugin['file']] = [
447 + 'package' => $plugin['package']
448 + ];
449 + if (isset($plugin['requires'])) {
450 + $_plugins[$plugin['file']]['requires'] = $plugin['requires'];
451 + }
452 +
453 + if (isset($plugin['requires_php'])) {
454 + $_plugins[$plugin['file']]['requires_php'] = $plugin['requires_php'];
455 + }
424 456 $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin['file'], false, true);
425 457 $plugins_by_name[$plugin_data['Name']] = $plugin['file'];
426 458 }
427 459 if (empty(array_keys($_plugins))) {
@@ -441,8 +473,11 @@
441 473 $result = $this->bv_plugin_bulk_upgrade($upgrader, $_plugins);
442 474 } else {
443 475 $result = $upgrader->bulk_upgrade(array_keys($_plugins));
444 476 }
477 + if (!is_array($result)) {
478 + return array('status' => "Error", 'message' =>'result is not an array');
479 + }
445 480 foreach (array_keys($_plugins) as $file) {
446 481 if (!array_key_exists($file, $result)) {
447 482 $result[$file] = array('status' => "Error");
448 483 } else {
@@ -458,8 +493,9 @@
458 493 return $result;
459 494 }
460 495
461 496 function bv_theme_bulk_upgrade($upgrader, $_themes) {
497 + global $wp_version;
462 498 $themes = array_keys($_themes);
463 499 $args = array();
464 500 $defaults = array(
465 501 'clear_update_cache' => true,
@@ -490,21 +526,50 @@
490 526 $upgrader->update_current = 0;
491 527 foreach ($themes as $theme) {
492 528 $upgrader->update_current++;
493 529 $upgrader->skin->theme_info = $upgrader->theme_info($theme);
494 - $result = $upgrader->run(
495 - array(
496 - 'package' => $_themes[$theme],
497 - 'destination' => get_theme_root($theme),
498 - 'clear_destination' => true,
499 - 'clear_working' => true,
500 - 'is_multi' => true,
501 - 'hook_extra' => array(
502 - 'theme' => $theme,
503 - ),
504 - )
505 - );
530 + if ( isset( $_themes[$theme]['requires'] ) && function_exists('is_wp_version_compatible') && !is_wp_version_compatible( $_themes[$theme]['requires'] ) ) {
531 + $result = new WP_Error(
532 + 'incompatible_wp_required_version',
533 + sprintf(
534 + __( 'Your WordPress version is %1$s, however the new theme version requires %2$s.' ),
535 + $wp_version,
536 + $_themes[$theme]['requires']
537 + )
538 + );
506 539
540 + $upgrader->skin->before( $result );
541 + $upgrader->skin->error( $result );
542 + $upgrader->skin->after();
543 + } elseif ( isset( $_themes[$theme]['requires_php'] ) && function_exists('is_php_version_compatible') && !is_php_version_compatible( $_themes[$theme]['requires_php'] ) ) {
544 + $result = new WP_Error(
545 + 'incompatible_php_required_version',
546 + sprintf(
547 + __( 'The PHP version on your server is %1$s, however the new theme version requires %2$s.' ),
548 + PHP_VERSION,
549 + $_themes[$theme]['requires_php']
550 + )
551 + );
552 +
553 + $upgrader->skin->before( $result );
554 + $upgrader->skin->error( $result );
555 + $upgrader->skin->after();
556 + } else {
557 + add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
558 + $result = $upgrader->run(
559 + array(
560 + 'package' => $_themes[$theme]['package'],
561 + 'destination' => get_theme_root($theme),
562 + 'clear_destination' => true,
563 + 'clear_working' => true,
564 + 'is_multi' => true,
565 + 'hook_extra' => array(
566 + 'theme' => $theme,
567 + ),
568 + )
569 + );
570 + remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
571 + }
507 572 $results[$theme] = $result;
508 573 if (false === $result) {
509 574 break;
510 575 }
@@ -540,9 +605,17 @@
540 605 function upgradeThemes($themes, $has_bv_skin = false, $bv_bulk_upgrade = false) {
541 606 $result = array();
542 607 $_themes = array();
543 608 foreach ($themes as $theme) {
544 - $_themes[$theme['stylesheet']] = $theme['package'];
609 + $_themes[$theme['stylesheet']] = [
610 + 'package' => $theme['package']
611 + ];
612 + if (isset($theme['requires'])) {
613 + $_themes[$theme['stylesheet']]['requires'] = $theme['requires'];
614 + }
615 + if (isset($theme['requires_php'])) {
616 + $_themes[$theme['stylesheet']]['requires_php'] = $theme['requires_php'];
617 + }
545 618 }
546 619 if (empty(array_keys($_themes))) {
547 620 return $result;
548 621 }
@@ -559,8 +632,11 @@
559 632 $result = $this->bv_theme_bulk_upgrade($upgrader, $_themes);
560 633 } else {
561 634 $result = $upgrader->bulk_upgrade(array_keys($_themes));
562 635 }
636 + if (!is_array($result)) {
637 + return array('status' => "Error", 'message' =>'result is not an array');
638 + }
563 639 foreach (array_keys($_themes) as $stylesheet) {
564 640 if (!array_key_exists($stylesheet, $result)) {
565 641 $result[$stylesheet] = array('status' => "Error");
566 642 } else {
@@ -628,10 +704,14 @@
628 704 $upgrader->init();
629 705 $destination = $params['dest'];
630 706 $clear_destination = isset($params['cleardest']) ? $params['cleardest'] : false;
631 707 $package_url = $params['package'];
708 + $is_parent_theme_install_disabled = isset($params['is_parent_theme_install_disabled']) ? $params['is_parent_theme_install_disabled'] : false;
632 709 $key = basename($package_url);
633 710 add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
711 + if ("theme" === $type && false === $is_parent_theme_install_disabled) {
712 + add_filter('upgrader_post_install', array($upgrader, 'check_parent_theme_filter'), 10, 3);
713 + }
634 714 $res = $upgrader->run(
635 715 array(
636 716 'package' => $package_url,
637 717 'destination' => $destination,
@@ -643,8 +723,11 @@
643 723 ),
644 724 )
645 725 );
646 726 remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
727 + if ("theme" === $type && false === $is_parent_theme_install_disabled) {
728 + remove_filter('upgrader_post_install', array($upgrader, 'check_parent_theme_filter'), 10);
729 + }
647 730 if (is_wp_error($res)) {
648 731 $res = array('status' => "Error", 'message' => $this->getError($res));
649 732 } else {
650 733 $res = array( 'status' => "Done");
@@ -659,9 +742,17 @@
659 742 function getPremiumUpgradesInfo() {
660 743 return apply_filters( 'mwp_premium_perform_update', array() );
661 744 }
662 745
663 - function autoLogin($username, $isHttps) {
746 + function autoLogin($username, $isHttps, $auto_login_token = null) {
747 + # Validate nonce if provided (other plugin compatibility: allow login if token missing)
748 + if ($auto_login_token !== null && $auto_login_token !== '') {
749 + $validation_result = $this->validateAutoLoginToken($auto_login_token);
750 + if ($validation_result !== true) {
751 + return $validation_result;
752 + }
753 + }
754 +
664 755 $user = get_user_by('login', $username);
665 756 if ($user != FALSE) {
666 757 wp_set_current_user( $user->ID );
667 758 if ($isHttps) {
@@ -676,8 +767,41 @@
676 767 exit;
677 768 }
678 769 }
679 770
771 + private function validateAutoLoginToken($auto_login_token) {
772 + # Get plugin name for transient key prefix
773 + $plugname = $this->bvinfo->plugname;
774 + if (empty($plugname)) {
775 + return array(
776 + 'status' => 'Error',
777 + 'message' => 'PLUGIN_NAME_NOT_FOUND',
778 + 'error_code' => 'PLUGIN_NAME_ERROR'
779 + );
780 + }
781 +
782 + # Construct transient key: {plugname}_auto_login_tk_{token}
783 + $transient_key = $plugname . '_auto_login_tk_' . $auto_login_token;
784 +
785 + # Check if token has already been used
786 + $used_token = $this->settings->getTransient($transient_key);
787 + if ($used_token !== false) {
788 + # Token already used - prevent replay attack
789 + return array(
790 + 'status' => 'Error',
791 + 'message' => 'AUTO_LOGIN_TOKEN_ALREADY_USED',
792 + 'error_code' => 'AUTO_LOGIN_TOKEN_ERROR'
793 + );
794 + }
795 +
796 + # Store token as used for 24 hours to prevent reuse
797 + # WordPress will automatically clean up expired transients
798 + $this->settings->setTransient($transient_key, true, DAY_IN_SECONDS);
799 +
800 + # Token is valid and has been marked as used
801 + return true;
802 + }
803 +
680 804 public function refreshPluginUpdates() {
681 805 global $wp_current_filter;
682 806 $wp_current_filter[] = 'load-update-core.php';
683 807
@@ -702,12 +826,115 @@
702 826
703 827 return true;
704 828 }
705 829
830 + function upgradeElementorDB($file) {
831 + try {
832 + $managerClass = $file === "elementor/elementor.php" ? '\Elementor\Core\Upgrade\Manager' : '\ElementorPro\Core\Upgrade\Manager';
833 +
834 + if (!class_exists($managerClass)) {
835 + return array('status' => 'Error', 'error' => 'Elementor plugin not found or disabled', 'source' => 'BV');
836 + }
837 +
838 + $manager = new $managerClass();
839 + $required_methods = array('get_task_runner', 'should_upgrade', 'on_runner_complete',
840 + 'get_current_version', 'get_new_version');
841 + foreach ($required_methods as $method) {
842 + if (!method_exists($manager, $method)) {
843 + return array('status' => 'Error', 'error' => 'Required methods are missing', 'source' => 'BV');
844 + }
845 + }
846 +
847 + $updateInfo = array(
848 + 'from' => $manager->get_current_version(),
849 + 'to' => $manager->get_new_version(),
850 + );
851 +
852 + if ($manager->should_upgrade()) {
853 + $callbacks = $manager->get_upgrade_callbacks();
854 +
855 + if (!empty($callbacks)) {
856 + $manager->get_task_runner()->handle_immediately($callbacks);
857 + $manager->on_runner_complete(true);
858 + }
859 + } else {
860 + return array('status' => 'Error', 'error' => 'Database Update is not available currently',
861 + 'update_info' => $updateInfo, 'source' => 'BV');
862 + }
863 +
864 + return array('status' => 'Done', 'update_info' => $updateInfo);
865 + } catch (Exception $e) {
866 + return array('status' => 'Error', 'error' => $e->getMessage());
867 + }
868 + }
869 +
870 + function upgradeWoocommerceDb() {
871 + try {
872 + if (!defined('WC_ABSPATH')) {
873 + return array('status' => 'Error', 'error' => 'WC not found', 'source' => 'BV');
874 + }
875 +
876 + if (file_exists(WC_ABSPATH . 'includes/class-wc-install.php')) {
877 + include_once WC_ABSPATH . 'includes/class-wc-install.php';
878 + }
879 +
880 + if (file_exists(WC_ABSPATH . 'includes/wc-update-functions.php')) {
881 + include_once WC_ABSPATH . 'includes/wc-update-functions.php';
882 + }
883 +
884 + if (!class_exists('WC_Install') || !method_exists('WC_Install', 'needs_db_update') ||
885 + !method_exists('WC_Install', 'get_db_update_callbacks')) {
886 + return array('status' => 'Error', 'error' => 'WC files missing or corrupted', 'source' => 'BV');
887 + }
888 +
889 + $current_db_version = $this->settings->getOption('woocommerce_db_version');
890 + if (!$current_db_version) {
891 + return array('status' => 'Error', 'error' => 'Current WC DB version not available', 'source' => 'BV');
892 + }
893 +
894 + $latest_db_version = $this->bvinfo->getLatestWooCommerceDBVersion();
895 + if ($current_db_version >= $latest_db_version) {
896 + return array('status' => 'Error', 'error' => 'WC DB update not available', 'source' => 'BV');
897 + }
898 +
899 + $db_update_callbacks = WC_Install::get_db_update_callbacks();
900 +
901 + $loop = 0;
902 + foreach ($db_update_callbacks as $version => $update_callbacks) {
903 + if (version_compare($current_db_version, $version, '<')) {
904 + foreach ($update_callbacks as $update_callback) {
905 + WC()->queue()->schedule_single(
906 + time() + $loop,
907 + 'woocommerce_run_update_callback',
908 + array('update_callback' => $update_callback),
909 + 'woocommerce-db-updates'
910 + );
911 + $loop++;
912 + }
913 + }
914 + }
915 +
916 + $current_wc_version = WC()->version;
917 + if (version_compare($current_db_version, $current_wc_version, '<') &&
918 + !WC()->queue()->get_next('woocommerce_update_db_to_current_version')) {
919 + WC()->queue()->schedule_single(
920 + time() + $loop,
921 + 'woocommerce_update_db_to_current_version',
922 + array('version' => $current_wc_version),
923 + 'woocommerce-db-updates'
924 + );
925 + }
926 +
927 + return array('status' => 'Done');
928 + } catch (Exception $e) {
929 + return array('status' => 'Error', 'error' => $e->getMessage());
930 + }
931 + }
932 +
706 933 function upgrade_db(){
707 934 if (function_exists('wp_upgrade')) {
708 935 wp_upgrade();
709 - return "DONE";
936 + return "Done";
710 937 } else {
711 938 return "NOUPGRADERFUNCTION";
712 939 }
713 940 }
@@ -767,12 +994,30 @@
767 994 case "atolgn":
768 995 $isHttps = false;
769 996 if (array_key_exists('https', $params))
770 997 $isHttps = true;
771 - $resp = array("autologin" => $this->autoLogin($params['username'], $isHttps));
998 + $auto_login_token = array_key_exists('auto_login_token', $params) ? $params['auto_login_token'] : null;
999 + $resp = array("autologin" => $this->autoLogin($params['username'], $isHttps, $auto_login_token));
772 1000 break;
773 1001 case "updatedb":
774 1002 $resp = array("status" => $this->upgrade_db());
1003 + break;
1004 + case "updateplgndb":
1005 + $resp = array();
1006 + $files = $params['files'];
1007 +
1008 + foreach ($files as $file) {
1009 + switch ($file) {
1010 + case "woocommerce/woocommerce.php":
1011 + $resp[$file] = $this->upgradeWoocommerceDb();
1012 + break;
1013 + case "elementor/elementor.php":
1014 + case "elementor-pro/elementor-pro.php":
1015 + $resp[$file] = $this->upgradeElementorDB($file);
1016 + break;
1017 + }
1018 + }
1019 +
775 1020 break;
776 1021 default:
777 1022 $resp = false;
778 1023 }