-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.php
44 lines (34 loc) · 1.07 KB
/
migrate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
function startMaintenanceMode() {
$maintenanceFileContent = '<?php $upgrading = ' . time() . '; ?>';
file_put_contents('.maintenance', $maintenanceFileContent);
}
function endMaintenanceMode() {
unlink('.maintenance');
}
function replaceFolder(
$name,
$prefix = 'wp-content'
) {
$targetDirectoryPath = "$prefix/$name";
$newDirectoryPath = "$targetDirectoryPath-new";
if (is_dir($targetDirectoryPath)) {
passthru("rm -rf $targetDirectoryPath");
}
rename($newDirectoryPath, $targetDirectoryPath);
}
$responseCode = 500;
startMaintenanceMode();
$zipArchive = new ZipArchive();
if ($zipArchive->open('wordpress.zip')) {
$zipArchive->extractTo('.');
$zipArchive->close();
replaceFolder('mu-plugins');
replaceFolder('plugins');
replaceFolder('themes');
$responseCode = 200;
}
endMaintenanceMode();
unlink('wordpress.zip');
unlink(__FILE__);
http_response_code($responseCode);