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;
|
---|
36 | show_message( __('Disable overwrite of wp-config.php...', 'xpressme') );
|
---|
37 | // remove wp-config.php from the new version into place.
|
---|
38 | $wp_config = $from . 'wp-config.php';
|
---|
39 | if ( !$wp_filesystem->delete($wp_config, true)){
|
---|
40 | return new WP_Error('delete_failed', $this->strings['delete_failed']);
|
---|
41 | }
|
---|
42 |
|
---|
43 | // Copy new versions of XPressME Integration Kit files into place.
|
---|
44 | show_message( __('Copy new versions of XPressME Integration Kit files into place...', 'xpressme') );
|
---|
45 | $result = copy_dir($from . $distro, $to);
|
---|
46 | if ( is_wp_error($result) ) {
|
---|
47 | $wp_filesystem->delete($maintenance_file);
|
---|
48 | $wp_filesystem->delete($from, true);
|
---|
49 | return $result;
|
---|
50 | }
|
---|
51 |
|
---|
52 | // Remove old files
|
---|
53 | show_message( __('Remove an unnecessary, old file...', 'xpressme') );
|
---|
54 | foreach ( $_old_xpress_files as $old_file ) {
|
---|
55 | $old_file = $to . $old_file;
|
---|
56 | if ( !$wp_filesystem->exists($old_file) )
|
---|
57 | continue;
|
---|
58 | $wp_filesystem->delete($old_file, true);
|
---|
59 | }
|
---|
60 | show_message( __('Set templates directory chmod 777', 'xpressme') );
|
---|
61 | $wp_filesystem->chmod($to . 'templates/', 0777);
|
---|
62 |
|
---|
63 | // Remove working directory
|
---|
64 | $working_dir = dirname(dirname($from));
|
---|
65 | show_message( sprintf(__('Remove working directory(%s)...', 'xpressme'),$working_dir) );
|
---|
66 | $wp_filesystem->delete($working_dir, true);
|
---|
67 |
|
---|
68 | }
|
---|
69 |
|
---|
70 | ?>
|
---|