WP Core Development with Local Lightning

Firstly, this is only meant as a how I do it. I’m using MacOS.

core.git.wordpress.org

It is based on using git://core.git.wordpress.org/. This would be similar to WP core development on a regular install using the WordPress Beta Tester plugin set for bleeding edge nightlies.

  • Create a new site in Local Lightning.
  • From Local Lightning Open Site Shell
  • You should cd into /app.
  • Move the wp-config.php and delete /public.
  • Then clone core.git.wordpress.org to /public.
cd ..
mv ./public/wp-config.php .
rm -rf ./public
git clone git://core.git.wordpress.org/ public

Create symlink of wp-config.php into /public

ln -sv $PWD/wp-config.php $PWD/public/wp-config.php

The following can be used to keep your clone less cluttered. Add ./app/public/.gitignore with the following data.

.gitignore
wp-config\.php
wp-tests-config\.php
debug\.log
local-phpinfo\.php
/wp-content/plugins/*
/wp-content/upgrade/*
/wp-content/db\.php

Add the above from my gist to the /app directory with the following command.

curl -o ./public/.gitignore https://gist.githubusercontent.com/afragen/43dfff563e942353d866c81904498cb2/raw/.gitignore

Add setup-phpunit.sh script for testing.

curl -o setup-phpunit.sh https://raw.githubusercontent.com/afragen/setup-phpunit/master/setup-phpunit.sh

I’ve written a script to aid in applying patches or changesets from core.trac.wordpress.org. It is added to the commands as well.

curl -o apply-trac-patch.sh https://gist.githubusercontent.com/afragen/977d765414189d5f5fae42215fe92a27/raw/apply-trac-patch.sh

Run setup-phpunit.sh script.

Update trunk via git pull from /app/public using Open Site Shell

Below are the list of sequential commands after Open Site Shell

cd ..
mv ./public/wp-config.php .
rm -rf ./public
git clone git://core.git.wordpress.org/ public
ln -sv $PWD/wp-config.php $PWD/public/wp-config.php
curl -o ./public/.gitignore https://gist.githubusercontent.com/afragen/43dfff563e942353d866c81904498cb2/raw/.gitignore
curl -o setup-phpunit.sh https://raw.githubusercontent.com/afragen/setup-phpunit/master/setup-phpunit.sh
curl -o apply-trac-patch.sh https://gist.githubusercontent.com/afragen/977d765414189d5f5fae42215fe92a27/raw/apply-trac-patch.sh
bash setup-phpunit.sh
cd public/

Someway to automate this setup in a one-click install or an advanced setting on the install would be tremendous. see https://localbyflywheel.com/community/t/feature-request-add-simple-install-of-a-wp-core-dev-environment/12985/3

develop.git.wordpress.org

A separate one-click install using git://develop.git.wordpress.org/ would also be great but that would also likely require installing npm and setting the database to display /build as the home URL endpoint.

As above you will need to create a new site in Local Lightning and then Open Site Shell from Local Lightning.

To make this function, before running the commands you must ensure that your local environment has wget and npm installed. If you’re on a Mac I highly recommend using Homebrew and brew install wget. Installing npm using Homebrew can be done but isn’t necessarily the recommended method.

I have to give lots of credit to Sal Ferrarello for his post WordPress Core Development on Local by Flywheel and to Kees Meijer for his script setup-phpunit.sh

I had to modify the setup-phpunit.sh script to work with Local Lightning. It is heavily biased towards using MacOS. I’m hoping I can get a little help making it more universal. My version is on GitHub

Here’s the sequential commands I’ve adapted from Sal’s post to use the git://develop.git.wordpress.org repository.

cd ..
mv ./public/wp-config.php .
rm -rf ./public
git clone git://develop.git.wordpress.org/ public
ln -sv $PWD/wp-config.php $PWD/public/wp-config.php
svn co https://plugins.svn.wordpress.org/wordpress-importer/trunk/ public/tests/phpunit/data/plugins/wordpress-importer
curl -o setup-phpunit.sh https://raw.githubusercontent.com/afragen/setup-phpunit/master/setup-phpunit.sh
curl -o apply-trac-patch.sh https://gist.githubusercontent.com/afragen/977d765414189d5f5fae42215fe92a27/raw/apply-trac-patch.sh
bash setup-phpunit.sh
cd public/
siteurl="$(wp option get siteurl | sed -e 's#/build##')";wp option update siteurl "$siteurl/build"
home="$(wp option get home | sed -e 's#/build##')";wp option update home "$home/build"
npm install && npm run build

The preceding bases your WordPress installation on develop.git.wordpess.org. You will open your site from a URL similar to mylocalsite.local/build/ and the dashboard is mylocalsite.local/build/wp-admin/.

One-click Install

For a one-click install you can use the following commands.

# Setup environment from core.git.wordpress.org
sh -c "$(curl -fsSL https://gist.github.com/afragen/e1aa3ffccf1a73618ee6e756bd95d297/raw/core-git-wp.sh)";cd .

# Setup environment from develop.git.wordpress.org
sh -c "$(curl -fsSL https://gist.github.com/afragen/e1aa3ffccf1a73618ee6e756bd95d297/raw/develop-git-wp.sh)";cd .