Skip to content

Instantly share code, notes, and snippets.

Last active September 5, 2022 01:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Site setup script example

Site setup script example

This script is an example of how a custom site setup automation could look like to improve personal developer productivity.

This script was originally assembled by @johnbillion for a workshop at WordCamp Torino 2018.


#!/usr/bin/env bash
# Configure the script to exit immediately if any command fails:
set -e
# Download WordPress core files if they're not already present:
if [ ! -f "wp-load.php" ]; then
wp core download
echo "WordPress files are already present."
# Create a wp-config.php file if it's not already present:
if [ ! -f "wp-config.php" ]; then
echo "Please enter your database credentials:"
wp config create --prompt
# Install WordPress if it isn't already:
if ! $(wp core is-installed); then
echo "Please enter your WordPress installation details:"
wp core install --prompt
echo "WordPress is already installed."
# Install some of our favourite plugins all at once:
echo "Installing plugins..."
wp plugin install jetpack wp-super-cache contact-form-7 wordpress-seo user-switching
# Activate and configure a few plugins:
echo "Configuring plugins..."
wp plugin activate wordpress-seo
wp option patch update wpseo_titles metadesc-home-wpseo "My new website"
# Create a child theme that we can start working on:
wp theme list
echo "Please enter your child theme details:"
wp scaffold child-theme --prompt
# Install the wp-admin package:
if ! $(wp cli has-command admin); then
echo "Installing the admin package..."
wp package install wp-cli/admin-command
# Let's go!
echo "Done!"
wp admin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment