IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
410 | 410 | } |
411 | 411 | |
412 | 412 | if ( $clear_destination ) { |
413 | | //We're going to clear the destination if there's something there |
414 | | $this->skin->feedback('remove_old'); |
415 | 413 | $removed = true; |
416 | 414 | if ( $wp_filesystem->exists( $remote_destination ) ) { |
| 415 | // Backup everything. |
| 416 | $this->skin->feedback('backup_old'); |
| 417 | $type = $args['hook_extra']['type']; |
| 418 | if ($this->backup_package( $remote_destination, $type, $backup_name, $backup_dir )) { |
| 419 | $this->backup_set_transient( $remote_destination, $type, $backup_name, $backup_dir ); |
| 420 | } |
| 421 | // Remove everything. |
| 422 | $this->skin->feedback('remove_old'); |
417 | 423 | $removed = $wp_filesystem->delete( $remote_destination, true ); |
418 | 424 | } |
419 | 425 | |
… |
… |
|
643 | 649 | } |
644 | 650 | } |
645 | 651 | |
646 | | } |
| 652 | /** |
| 653 | * Backup all files and directories (recursively) in the package_dir. |
| 654 | * |
| 655 | * @see backup_prefix |
| 656 | * |
| 657 | * @param string $package_dir The plugin/theme directory. |
| 658 | * @param string $type 'plugin' or 'theme'. |
| 659 | * @param string $backup_name The unique name of this backup. Used or defaulted. |
| 660 | * @param string $backup_dir The unique directory of this backup. Used or defaulted. |
| 661 | * |
| 662 | * @return true|WP_Error |
| 663 | */ |
| 664 | protected function backup_package( $package_dir, $type, &$backup_name, &$backup_dir ) { |
| 665 | if (is_null($backup_name)) { |
| 666 | $backup_prefix = backup_prefix( $package_dir, $type ); |
| 667 | $backup_name = uniqid($backup_prefix); // eg: 'backup_p_akismet_54c3c6107485f' |
| 668 | } |
| 669 | if (is_null($backup_dir)) { |
| 670 | // $backup_dir = get_temp_dir() . $backup_name; |
| 671 | $backup_dir = WP_CONTENT_DIR . '/tmp/' . $backup_name; |
| 672 | } |
| 673 | wp_mkdir_p($backup_dir); |
| 674 | $result = copy_dir($package_dir, $backup_dir); |
| 675 | return $result; |
| 676 | } |
647 | 677 | |
648 | | /** |
| 678 | /** |
| 679 | * Set backup data in a transient. |
| 680 | * |
| 681 | * @see backup_prefix |
| 682 | * |
| 683 | * @param string $package_dir The plugin/theme directory. |
| 684 | * @param string $type 'plugin' or 'theme'. |
| 685 | * @param string $backup_name The unique name of this backup. |
| 686 | * @param string $backup_dir The unique directory of this backup. |
| 687 | */ |
| 688 | protected function backup_set_transient( $package_dir, $type, $backup_name, $backup_dir ) { |
| 689 | $package_file = $type == 'plugin' |
| 690 | ? $package_dir . basename($package_dir) . '.php' |
| 691 | : $package_dir . 'style.css'; |
| 692 | $headers = get_file_data( $package_file, array('Version' => 'Version'), $type ); |
| 693 | $backup_data = array( |
| 694 | 'package_dir' => $package_dir, |
| 695 | 'package_ver' => $headers['Version'], |
| 696 | 'backup_dir' => $backup_dir, |
| 697 | 'backup_date' => date('Y-m-d H:i:s'), |
| 698 | ); |
| 699 | set_transient($backup_name, $backup_data, 1 * WEEK_IN_SECONDS); |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | /** |
649 | 704 | * Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file. |
650 | 705 | * |
651 | 706 | * @package WordPress |
… |
… |
|
681 | 736 | $this->strings['no_package'] = __('Update package not available.'); |
682 | 737 | $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>…'); |
683 | 738 | $this->strings['unpack_package'] = __('Unpacking the update…'); |
| 739 | $this->strings['backup_old'] = __('Backing up the old version of the plugin…'); |
684 | 740 | $this->strings['remove_old'] = __('Removing the old version of the plugin…'); |
685 | 741 | $this->strings['remove_old_failed'] = __('Could not remove the old plugin.'); |
686 | 742 | $this->strings['process_failed'] = __('Plugin update failed.'); |
… |
… |
|
1115 | 1171 | $this->strings['no_package'] = __('Update package not available.'); |
1116 | 1172 | $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>…'); |
1117 | 1173 | $this->strings['unpack_package'] = __('Unpacking the update…'); |
| 1174 | $this->strings['backup_old'] = __('Backing up the old version of the theme…'); |
1118 | 1175 | $this->strings['remove_old'] = __('Removing the old version of the theme…'); |
1119 | 1176 | $this->strings['remove_old_failed'] = __('Could not remove the old theme.'); |
1120 | 1177 | $this->strings['process_failed'] = __('Theme update failed.'); |