Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mi5t4n/e7d9d2ed94f865978649c53bc2e6a8d5 to your computer and use it in GitHub Desktop.
Save mi5t4n/e7d9d2ed94f865978649c53bc2e6a8d5 to your computer and use it in GitHub Desktop.
WordPress Core Development SetUp on Local by FlyWheel
#!/bin/bash
# Welcome to the WP Core Development Wizard.
#
# Author: Mehul Gohil
# Email: hello@mehulgohil.com
# Supports: Local 5.2.8. or later
#
# PreRequisites:
# 1. Install wget, subversion, curl, php5-cli, and git
#
# How to use?
# 1. git clone https://gist.github.com/b2ac1b8fcd8fe3519192dea024e5fcc1.git
# 2. Copy the file "wp_core_setup_local_by_flywheel.sh" to "<site folder>/app/"
# 3. Go to terminal at location "<site folder/app/
# 4. Run "bash wp_core_setup_local_by_flywheel.sh"
# 5. Restart Site from Local
# 6. Voila! Your WP Core Development setup will proceed.
#
# Edit Config File.
CONFIG=wp-config.php
# Directory to remove.
DIR=public
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
echo -e "Could not install packages. No internet connection detected.\n\n"
exit 1
fi
# Start Moving wp-config.php file to a better location to proceed removing public folder.
if [ -f "$DIR/$CONFIG" ]; then
# Step 1 - Move `wp-config.php` to safe location.
printf '%s\n' "Moving WordPress Configuration File: ($CONFIG)"
mv "$DIR/$CONFIG" "../"
printf '%s\n' "Successfully Moved WordPress Configuration File: ($CONFIG)"
# Step 2 - Remove `public` directory.
if [ -d "$DIR" ]; then
printf '%s\n' "Removing directory ($DIR)"
rm -rf "$DIR"
else
printf '%s\n' "Unable to find directory ($DIR)"
fi
# Step 3 - Clone WordPress Core Development Files.
printf "Cloning WordPress Development Files to ($DIR) folder. \n\n"
# Clone WordPress Development files to public folder.
git clone https://github.com/WordPress/wordpress-develop.git public
printf "Moving wp-config.php to ($DIR) folder."
# Move back the `wp-config.php` to public folder.
mv ../"$CONFIG" "$DIR/$CONFIG"
printf '%s\n' "Successfully Moved WordPress Configuration File: ($CONFIG) to ($DIR)"
# Step 4 - Update `site.conf`.
echo -e "Updating site.conf"
sed -i -e 's/"{{root}}"/"{{root}}\/src"/g' ../conf/nginx/site.conf.hbs
# Step 5 - Run npm
echo -e "Running NPM"
cd "${DIR}" && npm install && npm run dev
echo -e "==> Voila! Setup completed."
else
printf '%s\n' "Unable to locate WordPress Configuration File: ($CONFIG)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment