-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
77 lines (68 loc) · 1.82 KB
/
install.php
File metadata and controls
77 lines (68 loc) · 1.82 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env php
<?php
/**
* Install Pow
*
* @todo Q&A => db setup
* @todo no comments ? => clean up db, set options
* @todo create Site Manager role ?
*
* @package Pow
* @version 0.0.0
* @since 0.0.0
*/
$public_dir = __DIR__ . '/public';
$wp_dir = $public_dir . '/wp';
$run = $argv[1] ?? null;
if ($run && function_exists($run)) {
/** @var Callable $run */
$run();
}
/**
* Pre install actions
*
* Move custom plugin folders temporarily outside WordPress folder,
* so they are not overwritten by the composer installed WordPress.
*
* @return void
*/
function pre()
{
global $public_dir, $wp_dir;
# move plugins folders inside /public/wp
if (is_dir("$wp_dir/wp-mu-plugins")) {
rename("$wp_dir/wp-mu-plugins", "$public_dir/wp-mu-plugins");
}
if (is_dir("$wp_dir/wp-plugins")) {
rename("$wp_dir/wp-plugins", "$public_dir/wp-plugins");
}
}
/**
* Post install actions
*
* Move plugin folders back; remove installed wp-content folder
* with all its themes; copy env file.
*
* @return void
*/
function post()
{
global $public_dir, $wp_dir;
require_once("$wp_dir/wp-includes/formatting.php");
require_once("$wp_dir/wp-includes/class-wp-error.php");
require_once("$wp_dir/wp-admin/includes/class-wp-filesystem-base.php");
require_once("$wp_dir/wp-admin/includes/class-wp-filesystem-direct.php");
# delete downloaded wp-content
$fs = new WP_Filesystem_Direct('');
$fs->delete("$wp_dir/wp-content", true);
# move plugins folders back into place
if (is_dir("$public_dir/wp-mu-plugins")) {
rename("$public_dir/wp-mu-plugins", "$wp_dir/wp-mu-plugins");
}
if (is_dir("$public_dir/wp-plugins")) {
rename("$public_dir/wp-plugins", "$wp_dir/wp-plugins");
}
if (!file_exists('.env')) {
copy('.env-example', '.env');
}
}