Skip to content

Instantly share code, notes, and snippets.

@teustice
Last active March 3, 2020 18:12
Show Gist options
  • Save teustice/ff4fcfab292342629e930aff8ec03e4c to your computer and use it in GitHub Desktop.
Save teustice/ff4fcfab292342629e930aff8ec03e4c to your computer and use it in GitHub Desktop.
WordPress setup script
#!/bin/bash
echo "Enter the WordPress project name :"
read name
name_slug=$(echo $name | iconv -t ascii//TRANSLIT | sed -E s/[^a-zA-Z0-9]+/-/g | sed -E s/^-+\|-+$//g | tr A-Z a-z)
db_slug=$(echo $name_slug |tr -d '-')
echo $db_slug;
echo "Admin Email:"
read admin_email
echo "Admin Username:"
read admin_name
echo "Admin Password:"
read admin_pass
mkdir $name_slug
cd $name_slug
wp core download
echo $db_slug;
/Applications/MAMP/Library/bin/mysql -uroot -proot -e "CREATE DATABASE ${db_slug}"
wp core config --dbhost=127.0.0.1:8889 --dbname=$db_slug --dbuser=root --dbpass=root
wp core install --url=http://localhost:8888/$name_slug --title="$name" --admin_user=$admin_name --admin_password=$admin_pass --admin_email=$admin_email --skip-email
# migrate theme folder
echo 'importing default theme'
git clone https://github.com/teustice/Wordpress-Starter-Theme.git ~/projects/${name_slug}/wp-content/themes/cb-theme
wp theme activate 'Wordpress-Starter-Theme'
# install plugins
wp plugin install wordpress-seo --activate
wp plugin install ninja-forms --activate
wp plugin install easy-wp-smtp --activate
wp plugin install regenerate-thumbnails --activate
wp plugin install ~/Documents/Resources/plugins/advanced-custom-fields-pro.zip --activate
# update gulpfile browser url
cd ~/projects/$name_slug/wp-content/themes/cb-theme
sed -i -e "s/WP_TEMPLATE/$name_slug/g" ~/projects/$name_slug/wp-content/themes/cb-theme/gulpfile.js
code .
npm install
gulp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment