1 | <?php
|
---|
2 | /**
|
---|
3 | * XPressME Integration Kit upgrade functionality.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Stores files to be deleted.
|
---|
8 | */
|
---|
9 | global $_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 | // 3.0.0
|
---|
22 | 'include/pre_check.php',
|
---|
23 | 'xp-config-sample.php',
|
---|
24 | 'module_icon.png',
|
---|
25 | );
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Upgrade the XPressME .
|
---|
29 | *
|
---|
30 | * @param string $from New release unzipped path.
|
---|
31 | * @param string $to Path to old WordPress installation.
|
---|
32 | * @return WP_Error|null WP_Error on failure, null on success.
|
---|
33 | */
|
---|
34 | function update_xpress($from, $to) {
|
---|
35 | global $wp_filesystem, $_old_xpress_files, $wpdb, $modInfo;
|
---|
36 | show_message( __('Disable overwrite of wp-config.php...', 'xpressme') );
|
---|
37 | $mod_ver = $modInfo->get_module_version();
|
---|
38 | // Rewrite wp-config.php when update it to Ver.3 from Ver.2.
|
---|
39 | if (version_compare($mod_ver, '3.0', '>=')){
|
---|
40 | // remove wp-config.php from the new version into place.
|
---|
41 | $wp_config = $from . 'wp-config.php';
|
---|
42 | if ( !$wp_filesystem->delete($wp_config, true)){
|
---|
43 | return new WP_Error('delete_failed', $this->strings['delete_failed']);
|
---|
44 | }
|
---|
45 | }
|
---|
46 | // Copy new versions of XPressME Integration Kit files into place.
|
---|
47 | show_message( __('Copy new versions of XPressME Integration Kit files into place...', 'xpressme') );
|
---|
48 | $result = copy_dir($from . $distro, $to);
|
---|
49 | if ( is_wp_error($result) ) {
|
---|
50 | $wp_filesystem->delete($maintenance_file);
|
---|
51 | $wp_filesystem->delete($from, true);
|
---|
52 | return $result;
|
---|
53 | }
|
---|
54 |
|
---|
55 | // Remove old files
|
---|
56 | show_message( __('Remove an unnecessary, old file...', 'xpressme') );
|
---|
57 | foreach ( $_old_xpress_files as $old_file ) {
|
---|
58 | $old_file = $to . $old_file;
|
---|
59 | if ( !$wp_filesystem->exists($old_file) )
|
---|
60 | continue;
|
---|
61 | $wp_filesystem->delete($old_file, true);
|
---|
62 | }
|
---|
63 | show_message( __('Set templates directory chmod 777', 'xpressme') );
|
---|
64 | $wp_filesystem->chmod($to . 'templates/', 0777);
|
---|
65 |
|
---|
66 | // Remove working directory
|
---|
67 | $working_dir = dirname(dirname($from));
|
---|
68 | show_message( sprintf(__('Remove working directory(%s)...', 'xpressme'),$working_dir) );
|
---|
69 | $wp_filesystem->delete($working_dir, true);
|
---|
70 |
|
---|
71 | }
|
---|
72 |
|
---|
73 | ?>
|
---|