-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmove-to-subdirectory.sh
61 lines (50 loc) · 1.18 KB
/
move-to-subdirectory.sh
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
#
# Moving a WordPress installation to a subdirectory.
#
# shellcheck disable=SC2317,SC2148
exit 0
SUBDIR="project"
URL="$(wp option get home)"
# Change "siteurl"
wp option update siteurl "${URL}/${SUBDIR}"
# Change URL in database
wp search-replace --precise --recurse-objects --all-tables-with-prefix "/wp-includes/" "/${SUBDIR}/wp-includes/"
# Change constants in wp-config.php
# - WP_CONTENT_DIR
# - WP_CONTENT_URL
# - TINY_CDN_INCLUDES_URL
# - TINY_CDN_CONTENT_URL
editor wp-config.php
# Move core to subdir
xargs -I % mv -v "./%" "./${SUBDIR}/" <<"EOF"
wp-admin
wp-includes
licenc.txt
license.txt
olvasdel.html
readme.html
wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-cron.php
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php
EOF
cp -v ./index.php "./${SUBDIR}/"
# Modify /index.php
sed -i -e "s#'/wp-blog-header\\.php'#'/${SUBDIR}/wp-blog-header.php'#" ./index.php
# Move files from parent directory
mv -v ../wp-config.php ./
mv -v ../waf4wordpress-http-analyzer.php ./
# Edit "path:" in wp-cli.yml
editor ../wp-cli.yml
# Fix Apache VirtualHost configuration
# Flush cache
wp cache flush