Skip to content

Commit 5e301ae

Browse files
committed
add check_requirements and deactivate_plugins functions. move listing into new list_plugins function
1 parent 241a819 commit 5e301ae

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

setup-wordpress.sh

+52-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ classic-editor
4747
redirection
4848
tablepress
4949
wordpress-importer
50+
wordpress-seo
51+
'
52+
# NOTE: wordfence does not play nice with Docker. Enabling it results in WP-CLI
53+
# commands taking approximately 13 times longer (ex. 10.8 seconds
54+
# instead of 0.8 seconds)
55+
PLUGINS_DEACTIVATE='
56+
google-analytics-for-wordpress
57+
wordfence
5058
'
5159
THEMES_ACTIVATE='
5260
vocabulary-theme
@@ -86,9 +94,6 @@ activate_plugins() {
8694
wpcli plugin activate "${_plugin}"
8795
fi
8896
done
89-
wpcli plugin list --format=csv \
90-
| column -s',' -t \
91-
| format_list
9297
echo
9398
}
9499

@@ -112,6 +117,24 @@ activate_themes() {
112117
}
113118

114119

120+
check_requirements() {
121+
# Ensure docker daemon is running
122+
if [[ ! -S /var/run/docker.sock ]]
123+
then
124+
error_exit 'docker daemon is not running'
125+
fi
126+
127+
# Ensure docker containers are running:
128+
for _container in index-web index-wpcli index-wpdb
129+
do
130+
if ! docker compose exec "${_container}" true &>/dev/null
131+
then
132+
error_exit "docker container unavailable: ${_container}"
133+
fi
134+
done
135+
}
136+
137+
115138
composer_install() {
116139
header 'Composer install'
117140
docker compose run --rm index-composer install --ansi 2>&1 \
@@ -150,6 +173,22 @@ database_update() {
150173
}
151174

152175

176+
deactivate_plugins() {
177+
local _bold _plugin _reset
178+
header 'Deactivate plugins'
179+
for _plugin in ${PLUGINS_DEACTIVATE}
180+
do
181+
if wpcli --no-color --quiet plugin is-active "${_plugin}" &> /dev/null
182+
then
183+
wpcli plugin deactivate "${_plugin}"
184+
else
185+
no_op "${_plugin} is already inactive"
186+
fi
187+
done
188+
echo
189+
}
190+
191+
153192
environment_info() {
154193
local _key _val IFS
155194
header 'Container information'
@@ -234,6 +273,13 @@ install_wordpress() {
234273
echo
235274
}
236275

276+
list_plugins() {
277+
header 'List plugins'
278+
wpcli plugin list --format=csv \
279+
| column -s',' -t \
280+
| format_list
281+
echo
282+
}
237283

238284
no_op() {
239285
# Print no-op message"
@@ -337,12 +383,15 @@ wpcli() {
337383

338384
#### MAIN #####################################################################
339385

386+
check_requirements
340387
environment_info
341388
composer_install
342389
install_wordpress
343390
update_options
344391
remove_themes
345392
activate_plugins
393+
deactivate_plugins
394+
list_plugins
346395
activate_themes
347396
database_update
348397
database_optimize

0 commit comments

Comments
 (0)