Skip to content

Instantly share code, notes, and snippets.

Created December 13, 2016 09:47
Show Gist options
  • Save millisami/807f38375d9023ce1a6ac2cc31096a45 to your computer and use it in GitHub Desktop.
Save millisami/807f38375d9023ce1a6ac2cc31096a45 to your computer and use it in GitHub Desktop.
Scaffold a new WordPress site using an Alfred workflow and WP-CLI. Development sites are spun up using Laravel Valet and a parked Sites folder in the root.
# Parse query name into theme and version variables (e.g. theme-name 1.0.0)
read theme version <<< "{query}"
# Create directory for new site
cd ~/Sites
mkdir $theme
cd $theme
# Download latest version of WordPress
wp core download
# Setup wp-config file with WP_DEBUG enabled
wp core config --skip-check --dbname=$theme --dbuser=root --extra-php <<PHP
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', true);
# Create database
wp db reset --yes
wp db create
# Install WordPress
wp core install --url="http://$" --title="$theme" --admin_user=lukemcdonald --admin_password=password --admin_email=""
# Update Options
wp option update comments_per_page 5
wp option update large_size_w ''
wp option update large_size_h ''
wp option update page_comments 1
wp option update permalink_structure '/%year%/%monthnum%/%day%/%postname%/'
wp option update posts_per_page 5
wp option update thread_comments 1
wp option update thread_comments_depth 3
wp option update timezone_string 'America/Chicago'
# Remove Default Themes and Plugins
wp theme delete twentyfourteen
wp theme delete twentyfifteen
wp plugin delete akismet
wp plugin delete hello
# Install and Activate Plugins
wp plugin install jetpack
wp plugin install jetpack-develop
wp plugin install piglatin
wp plugin install regenerate-thumbnails
wp plugin install rewrite-rules-inspector
wp plugin install theme-check
wp plugin install debug-bar --activate
wp plugin install debug-bar-extender --activate
wp plugin install log-deprecated-notices --activate
wp plugin install monster-widget --activate
wp plugin install plugin-toggle --activate
wp plugin install wordpress-importer --activate
# Install Test Data
curl -O
wp import ./theme-unit-test-data.xml --authors=create
rm theme-unit-test-data.xml
# Install Theme by Version
if [ $version ]; then
wp theme install$theme.$
# Activate Theme
wp theme activate $theme
# Regenerate Media
wp media regenerate --yes
# Flush Rewrite Rules
wp rewrite flush
# Open Theme Files in ST3
cd wp-content/themes/$theme/
sublime .
# Open Development Site in Browser
open http://$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment