XPressME Integration Kit

Trac

source: branches/Ver2.5/xpressme_integration_kit/wp-content/plugins/xpressme/include/update_xpress.php @ 773

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

Ver2.XからVer3.0へのアップグレード時wp-config.phpを上書きするようにする

File size: 2.4 KB
Line 
1<?php
2/**
3 * XPressME Integration Kit upgrade functionality.
4 */
5
6/**
7 * Stores files to be deleted.
8 */
9global $_old_xpress_files;
10
11$_old_xpress_files = array(
12// 2.03
13'wp-content/themes/xpress_default/images/titleline.jpg',
14'wp-content/themes/xpress_default/ja.mo',
15'wp-content/themes/xpress_default/ja.po',
16// 2.3.0
17'wp-content/themes/xpress_default/ja_EUC.mo',
18'wp-content/themes/xpress_default/ja_EUC.po',
19'wp-content/themes/xpress_default/ja_UTF.mo',
20'wp-content/themes/xpress_default/ja_UTF.po',
21);
22
23/**
24 * Upgrade the XPressME .
25 *
26 * @param string $from New release unzipped path.
27 * @param string $to Path to old WordPress installation.
28 * @return WP_Error|null WP_Error on failure, null on success.
29 */
30function update_xpress($from, $to) {
31        global $wp_filesystem, $_old_xpress_files, $wpdb, $modInfo;
32        show_message( __('Disable overwrite of wp-config.php...', 'xpressme') );
33       
34        $mod_ver = $modInfo->get_module_version();
35        // Rewrite wp-config.php when update it to Ver.3 from Ver.2.
36        if (version_compare($mod_ver, '3.0', '>=')){
37            if (file_exists($wp_version_file)){
38                include $wp_version_file;
39                $now_virsion = str_replace("ME", "", $wp_version);
40            }
41        }
42        // remove wp-config.php from the new version into place.
43        $wp_config = $from . 'wp-config.php';
44        if ( !$wp_filesystem->delete($wp_config, true)){
45                return new WP_Error('delete_failed', $this->strings['delete_failed']);
46        }
47
48        // Copy new versions of XPressME Integration Kit files into place.
49        show_message( __('Copy new versions of XPressME Integration Kit files into place...', 'xpressme') );
50        $result = copy_dir($from . $distro, $to);
51        if ( is_wp_error($result) ) {
52                $wp_filesystem->delete($maintenance_file);
53                $wp_filesystem->delete($from, true);
54                return $result;
55        }
56
57        // Remove old files
58        show_message( __('Remove an unnecessary, old file...', 'xpressme') );
59        foreach ( $_old_xpress_files as $old_file ) {
60                $old_file = $to . $old_file;
61                if ( !$wp_filesystem->exists($old_file) )
62                        continue;
63                $wp_filesystem->delete($old_file, true);
64        }
65        show_message( __('Set templates directory chmod 777', 'xpressme') );
66        $wp_filesystem->chmod($to . 'templates/', 0777);
67
68        // Remove working directory
69        $working_dir = dirname(dirname($from));
70        show_message( sprintf(__('Remove working directory(%s)...', 'xpressme'),$working_dir) );
71        $wp_filesystem->delete($working_dir, true);
72
73}
74
75?>
Note: See TracBrowser for help on using the repository browser.