Created
September 19, 2022 19:21
-
-
Save dingo-d/9da1f2808220fe5d537b09b51e3ce82a to your computer and use it in GitHub Desktop.
Scripts to quickly create wp site using wpcli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# WP-CLI site setup for Windows | |
# Usage create-site {folder name} {database name} {site title} | |
create-site () { | |
if [ $1 ] | |
then | |
mkdir $1 && cd $1 | |
wp core download --skip-content; | |
wp config create --dbname=$2 --dbuser=root; | |
wp config set DB_HOST "127.0.0.1" | |
mkdir wp-content && mkdir wp-content/themes && mkdir wp-content/plugins; | |
( | |
wp db create || true | |
wp core install --url="$1"".test" --title=$3 --admin_user=admin --admin_password=password [email protected] | |
) | |
cd /etc/nginx/conf.d | |
sudo cp templates/example.com.conf .$1.test.conf | |
sudo sed -i "s/example/$1/g" .$1.test.conf | |
sudo mv .$1.test.conf $1.test.conf | |
make-certificate $1.test | |
restart-server | |
cd "$HOME/Sites/$1" | |
wp search replace http://$1.test https://$1.test | |
# ADD SITE TO etc/hosts on Windows: C:\Windows\System32\drivers\etc\hosts !!!! | |
else | |
echo 'Missing arguments!' | |
echo 'Usage: site-create {folder name} {database name} {site title}' | |
fi | |
} | |
# WP-CLI site setup for mac OS | |
# Usage site-creates {folder name} {database name} {site title} | |
site-create () { | |
if [ $1 ] | |
then | |
mkdir $1 && cd $1 | |
wp core download --skip-content; | |
wp config create --dbname=$2 --dbuser=root; | |
mkdir wp-content && mkdir wp-content/themes && mkdir wp-content/plugins; | |
( | |
wp db create || true | |
wp core install --url="$1"".test" --title=$3 --admin_user=admin --admin_password=password [email protected] | |
) | |
cd "$HOME/Sites/$1" | |
valet link | |
valet secure $1 | |
wp search replace http://$1.test https://$1.test | |
pstorm . | |
else | |
echo 'Missing arguments!' | |
echo 'Usage: site-create {folder name} {database name} {site title}' | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment