Support multisite in ddev

This commit is contained in:
Alex P 2022-05-06 09:35:14 +03:00
parent 6dc0a995f6
commit 074f1f68f7
4 changed files with 54 additions and 9 deletions

View file

@ -5,11 +5,43 @@ if [ ! -z "${RECREATE_ENV}" ]; then
wp db clean --yes
fi
wp core install \
--title="${WP_TITLE}" \
--admin_user="${ADMIN_USER}" \
--admin_password="${ADMIN_PASS}" \
--url="${DDEV_PRIMARY_URL}" \
--admin_email="${ADMIN_EMAIL}" \
--skip-email
if [ "${WP_MULTISITE}" = "true" ]; then
wp core multisite-install \
--title="${WP_TITLE}" \
--admin_user="${ADMIN_USER}" \
--admin_password="${ADMIN_PASS}" \
--url="${DDEV_PRIMARY_URL}" \
--admin_email="${ADMIN_EMAIL}" \
--skip-email
cat << 'EOF' >> ".htaccess"
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
EOF
readarray -d , -t slugs <<< "${WP_MULTISITE_SLUGS},"; unset "slugs[-1]";
for slug in "${slugs[@]}"; do
if [ ! -z "${slug}" ]; then
wp site create --slug="${slug}"
fi
done
else
wp core install \
--title="${WP_TITLE}" \
--admin_user="${ADMIN_USER}" \
--admin_password="${ADMIN_PASS}" \
--url="${DDEV_PRIMARY_URL}" \
--admin_email="${ADMIN_EMAIL}" \
--skip-email
fi

View file

@ -2,4 +2,9 @@
pushd "${DDEV_DOCROOT}"
wp plugin activate "${PLUGIN_NAME:-$DDEV_PROJECT}"
flags=""
if [ "${WP_MULTISITE}" = "true" ]; then
flags+=" --network"
fi
wp plugin activate "${PLUGIN_NAME:-$DDEV_PROJECT}" $flags

View file

@ -1,3 +1,9 @@
#!/bin/bash
wp plugin install woocommerce --version="${WC_VERSION}" --activate
flags=""
if [ "${WP_MULTISITE}" = "true" ]; then
flags+=" --network"
fi
wp plugin install woocommerce --version="${WC_VERSION}"
wp plugin activate woocommerce $flags