XPressME Integration Kit

Trac

source: trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/class-xpress-upgrader.php @ 698

Last change on this file since 698 was 698, checked in by toemon, 13 years ago

XPressME Integration Kit 自動アップグレード対応 fixes#375

File size: 2.7 KB
Line 
1<?php
2include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
3/**
4 * Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combiantion with the wp-admin/includes/update-core.php file
5 *
6 * @TODO More Detailed docs, for methods as well.
7 *
8 * @package WordPress
9 * @subpackage Upgrader
10 * @since 2.8.0
11 */
12class Xpress_Upgrader extends WP_Upgrader {
13
14        function upgrade_strings() {
15                $this->strings['up_to_date'] = __('XPressME Integration Kit is at the latest version.');
16                $this->strings['no_package'] = __('Upgrade package not available.');
17                $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>&#8230;');
18                $this->strings['unpack_package'] = __('Unpacking the update&#8230;');
19                $this->strings['copy_failed'] = __('Could not copy files.');
20                $this->strings['make_config'] = __('Delete source wp-config.php.');
21                $this->strings['delete_failed'] = __('Could not delete files.');
22        }
23
24        function upgrade($current) {
25                global $wp_filesystem;
26
27                $this->init();
28                $this->upgrade_strings();
29
30                if ( !empty($feedback) )
31                        add_filter('update_feedback', $feedback);
32
33                // Is an update available?
34                if ( !isset( $current->response ) || $current->response == 'latest' )
35                        return new WP_Error('up_to_date', $this->strings['up_to_date']);
36
37                $res = $this->fs_connect( array(ABSPATH, WP_CONTENT_DIR) );
38                if ( is_wp_error($res) )
39                        return $res;
40
41                $wp_dir = trailingslashit($wp_filesystem->abspath());
42
43                $download = $this->download_package( $current->package );
44                if ( is_wp_error($download) )
45                        return $download;
46
47                $working_dir = $this->unpack_package( $download );
48                if ( is_wp_error($working_dir) )
49                        return $working_dir;
50                $subdirs = $wp_filesystem->dirlist($working_dir,false);
51                foreach($subdirs as $subdir){
52                        $subdir_name = $subdir['name'];
53                }
54               
55                $kit_dir = $working_dir .'/' .$subdir_name .'/xpressme_integration_kit/';
56               
57                // Copy update-core.php from the new version into place.
58                $update_xpress_file = 'wp-content/plugins/xpressme/include/update_xpress.php';
59//              if ( !$wp_filesystem->copy($kit_dir . $update_xpress_file, $wp_dir . $update_xpress_file, true) ) {
60//                      $wp_filesystem->delete($working_dir, true);
61//                      return new WP_Error('copy_failed', $this->strings['copy_failed']);
62//              }
63                $wp_filesystem->chmod($wp_dir . $update_xpress_file, FS_CHMOD_FILE);
64
65                require(ABSPATH . $update_xpress_file);
66
67                return update_xpress($kit_dir, $wp_dir);
68               
69        // Remove working directory
70                $wp_filesystem->delete($working_dir, true);
71                if ( !$wp_filesystem->delete($working_dir, true)){
72                        return new WP_Error('delete_failed', $this->strings['delete_failed']);
73                }
74                show_message( __('Delete Working directory') );
75                $wp_filesystem->chmod($wp_dir . 'templates/', 0777);
76        }
77}
78
Note: See TracBrowser for help on using the repository browser.