Skip to content

Instantly share code, notes, and snippets.

@wturnerharris
Created March 19, 2018 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wturnerharris/08f2f6de03f3574581235ab560d65742 to your computer and use it in GitHub Desktop.
Save wturnerharris/08f2f6de03f3574581235ab560d65742 to your computer and use it in GitHub Desktop.
Setup process for a theme managed on WPE, without tracking entire WP install
#!/bin/bash
rm -rf *
git reset --hard HEAD
#!/bin/bash
#######################################################
#
# Wordpress installation is ignored by git.
# Run this script to download and install WordPress.
#
#######################################################
# WordPress version
VERSION="4.9.4"
# Theme name
THEME_NAME="theme-name"
# WP Engine Install Name
# The production URL should resemble:
# http://$WPE_INSTALL_NAME.wpengine.com/
WPE_INSTALL_NAME="name-of-site"
# WP Engine PHPMyAdmin Link
WPE_PHP_URL="https://my.wpengine.com/installs/$WPE_INSTALL_NAME/phpmyadmin"
# Theme Path
THEME_PATH="./wp-content/themes/$THEME_NAME/"
# Terminal colors
DEFAULT=$(tput setaf 7)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
# Download WordPress and decompress, assumes top level directory from archive to be stripped
printf "\n> Downloading WordPress and decompressing ... \n\n"
curl https://wordpress.org/wordpress-$VERSION.tar.gz | tar xzf - -C ./ --strip 1;
printf "\n\n${GREEN}done${DEFAULT}"
# Remove unmaintained core plugin and themes and setup config
printf "\n\n> Removing untracked WP Core themes and plugins ... "
rm -rf wp-content/themes/twenty*;
rm wp-content/plugins/hello.php
printf "\n\n> Creating wp-config.php and .htaccess from templates ... "
cp wp-config-local.php wp-config.php
cat > .htaccess << EOF
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
EOF
printf "\n\n${GREEN}done${DEFAULT}"
cd $THEME_PATH
NPM_VERSION=$(npm -v)
printf "\n\n> NPM version: ${YELLOW}$NPM_VERSION${DEFAULT}"
printf "\n\n> Installing package.json ... "
# Fix for Mac OS
# Remove next two lines on real unix or linux servers
echo > /usr/local/bin/ldconfig
chmod +x /usr/local/bin/ldconfig
npm i
rm -f /usr/local/bin/ldconfig
printf "\n${GREEN}done${DEFAULT}\n"
cat <<- EOF
-----------------------------------
${GREEN}I'M ALL SHOOK UP. Mm mm mm
${DEFAULT}-----------------------------------
1. Download the sql dump to the project root.
${BLUE}$WPE_PHP_URL${DEFAULT}
2. Import locally using ${YELLOW}lando db-import snapshot_$WPE_INSTALL_NAME.sql${DEFAULT}
3. Download wp-content/uploads from WP Engine SFTP
4. Run grunt from inside of the theme root.
-----------------------------------
EOF
@wturnerharris
Copy link
Author

General notes:

  • These are kept in ./private/scripts and only run from within the project/git root.
  • WP Engine does not allow remote requests for the database or uploads, so those must be manually obtained from the WP Engine Project Portal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment