-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwp.sh
executable file
·141 lines (116 loc) · 3.57 KB
/
wp.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
if [[ ! -f "./.env" ]]; then
echo "Missing .env file."
else
export $(grep -v '^#' .env | xargs)
fi
function db:anonimize() {
wp option set blog_public 0
LIST=$(wp user list --field=ID --exclude="1")
if [ ! -z "$LIST" ]
then
wp user delete $LIST --reassign=1
fi
wp user update $(wp user list --field=ID) --user_pass=test1234 --skip-email
}
function db:export() {
wp db export db.sql
gzip db.sql
}
function db:export:prod() {
wp search-replace $DOMAIN_LOCAL $DOMAIN_PROD --all-tables
db:export
wp search-replace $DOMAIN_PROD $DOMAIN_LOCAL --all-tables
}
function db:export:staging() {
wp search-replace $DOMAIN_LOCAL $DOMAIN_STAGING --all-tables
db:export
wp search-replace $DOMAIN_STAGING $DOMAIN_LOCAL --all-tables
}
function db:import() {
gzip -d db.sql.gz
wp db import db.sql
rm db.sql
}
function db:import:prod() {
db:import
wp search-replace $DOMAIN_PROD $DOMAIN_LOCAL --all-tables
db:anonimize
}
function db:import:staging() {
db:import
wp search-replace $DOMAIN_STAGING $DOMAIN_LOCAL --all-tables
}
function wp:env() {
curl https://raw.githubusercontent.com/przemekhernik/templates/main/bash/.env -o .env
}
function wp:init() {
read -p "Are you sure? (y/n) " choice
if [ "$choice" == "y" ]
then
wp core download
curl https://raw.githubusercontent.com/przemekhernik/templates/main/gitignore/.gitignore.wp -o .gitignore
curl https://raw.githubusercontent.com/przemekhernik/templates/main/htaccess/.htaccess.wp -o .htaccess
curl https://raw.githubusercontent.com/przemekhernik/templates/main/htaccess/.htpasswd.wpt -o .htpasswd
wp config create --dbname=$DB_NAME --dbuser=$DB_USER --dbpass=$DB_PASS --dbhost=$DB_HOST --dbcharset=utf8mb4 --dbcollate=utf8mb4_general_ci
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_DISPLAY true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_ENVIRONMENT_TYPE development
wp config set DISALLOW_FILE_EDIT true --raw
wp config set WP_AUTO_UPDATE_CORE true --raw
wp db reset --yes
wp core install --url=https://$DOMAIN_LOCAL --title=$TITLE --admin_user=$ADMIN_LOGIN --admin_password=$ADMIN_PASS --admin_email="$ADMIN_EMAIL" --skip-email
wp user update 1 --first_name=Dev --last_name=Team
wp post delete 3 --force
wp post update 2 --post_title=Homepage --post_name=homepage
wp term update category 1 --name=News --slug=news
wp plugin delete hello akismet
wp theme activate twentytwentyone
wp theme delete twentytwentytwo twentytwentythree
wp plugin install wordpress-seo
wp comment delete 1 --force
wp menu create "Primary"
wp menu create "Secondary"
wp menu create "Footer"
wp widget reset --all
wp widget delete $(wp widget list wp_inactive_widgets --format=ids)
wp rewrite structure '/%postname%/'
wp option set blog_public 0
wp option update show_on_front page
wp option update page_on_front 2
wp option update page_for_posts $(wp post create --post_title=Blog --post_name=blog --post_type=page --post_status=publish --post_author=1 --porcelain)
wp option update default_comment_status closed
wp option update default_ping_status closed
open "https://$DOMAIN_LOCAL"
fi
}
case $1 in
"db:anonimize")
db:anonimize
;;
"db:export")
db:export
;;
"db:export:prod")
db:export:prod
;;
"db:export:staging")
db:export:staging
;;
"db:import")
db:import
;;
"db:import:prod")
db:import:prod
;;
"db:import:staging")
db:import:staging
;;
"wp:env")
wp:env
;;
"wp:init")
wp:init
;;
esac