Rebuilding a WordPress Site in Phases

Ever since I started at Universal Yums, I’ve wanted to rebuild the WordPress theme. In its six years of existence style overrides have been layered on top of each other making new development really difficult. JavaScript was mostly in one massive file. The build system was outdated and clunky.

However, rebuilding a site that’s still in active development and has thousands of customers a day is tricky. You either freeze most development on the live site while the developers hide out and build a fresh theme (which wasn’t an option for us and has the risk of introducing too many bugs all at once), or very slowly refactor and rebuild the existing theme over time (which can be really difficult if you want to move to a completely new grid system or rip out Bootstrap v3 for example).

Or, maybe there is a third way?

It feels like a bit of a hack, but it definitely works. We found a method that allowed us to deploy a new theme in phases- one page or set of URLs at a time. This introduces much less risk and allows us to maintain a similar development velocity on the live site. The solution was to load the new theme for specific URLs as we completed development on them.

We’ve been successfully running on production for several weeks now with large amounts of traffic.
Continue reading

Deleted Laravel Logs Eating Up Disk Space

We had an odd situation where disk space was getting swallowed up on a Digital Ocean server running Laravel. The issue started happening after an upgrade from Laravel 7 to Laravel 8 (though it could have been there before unnoticed). The database size had been growing, so my first though was just to resize the droplet. But when an additional 100GB was eaten up over the weekend I realized there must be something else going on.

It turned out we had deleted log files that were still being kept open by a system process, and therefore could not be fully deleted, but were also continuing to grow:

We found these with the command:

lsof +L1

Which showed:

COMMAND  PID  USER   FD   TYPE DEVICE  SIZE/OFF NLINK    NODE NAME
php7.4  1543 forge   15w   REG  252,1 44241528600     0 1809826 /home/forge/data.example.com/storage/logs/laravel.log.1 (deleted)
php7.4  1544 forge   15w   REG  252,1 44242240400     0 1809826 /home/forge/data.example.com/storage/logs/laravel.log.1 (deleted)
php7.4  1545 forge   15w   REG  252,1 44242240400    0 1809826 /home/forge/data.example.com/storage/logs/laravel.log.1 (deleted)

This StackExchange post has a little more information about tracing down the issue, and this one has a more technical explanation for why it happens.

To resolve the issue, we truncated the deleted file using the method described here, which did free up the space:

:>/proc/1543/fd/15

Then we killed all the processes:

forge@data-service:~/data.example.com$ kill -SIGTERM 1543
forge@data-service:~/data.example.com$ kill -SIGTERM 1544
forge@data-service:~/data.example.com$ kill -SIGTERM 1545

This appeared to resolve the issue for us.

TablePlus for SQL Queries in WordPress

Having a nice GUI to make direct database queries can be really helpful when working with a complex WordPress site. TablePlus is the best one one I’ve found for the Mac.

Using TablePlus with WP Engine

Connecting to a local database and most remote databases should be pretty straightforward, but there’s a few extra steps if the database is hosted with WP Engine.

WP Engine has remote database access instructions here. Make sure to get your IP address whitelisted, include the cert, and get the ports right. Here’s a screenshot of what the settings should look like.

Continue reading

Working on a Theme Development Course

I just started work on video course for learning WordPress theme development. It’s designed for folks who are familiar with using WordPress and would like to start building themes professionally (for clients or for their own work). The plan is to release the entire video series for free.

Since the focus is on professional development, I’ll be covering developer tools as much as actual theme development. Introducing topics like local environments, version control and build tools all together as it relates to WordPress themes will (I think!) be really useful for new developers getting up to speed.

If you or a friend has been looking to move into WordPress theme development, get on the mailing list and I’ll let you know when the first video is available.

Sign Up to Get Notified When the Course is Ready

Continue reading

Create a WordPress Admin with Code

A few times I’ve gotten into a situation where I have access to WordPress files (via SFTP or other means) but I’m otherwise locked out of the site (my user hasn’t been created or was accidentally deleted). In those cases, the quickest option is generally just to create a new admin user with code.

If I know which theme is active, I’ll generally just drop this code into the bottom of functions.php for that theme, refresh the site once or twice in the browser, and then delete the code (important: make sure to delete it!)

https://gist.github.com/wpscholar/86c236469f3610400f8a
Continue reading

Themes Shops Might be Dead: Thoughts on an Alternative Business Model

For the past year I’ve been working at Cratejoy, a small venture funded startup in Austin. One of the most interesting aspects of the job has been learning first-hand what it takes to grow a small business into a much larger one. Specifically, I think the business model Cratejoy started with could work really well for many WordPress based businesses and consultancies.

Cratejoy began as an ecommerce website solution for subscription box companies. The business model was a monthly platform fee (~$30/mo) and 1.25% transaction fee on all sales. At the time subscription box businesses like Birchbox, Barkbox, and Naturebox were taking off, but creating a website solution for recurring physical sales was still really difficult. The founders of Cratejoy raised $4 million from investors who were interested in exploring a potential new ecommerce market. Continue reading

Importing Yahoo Mail into Gmail With Original Dates

With Yahoo being sold off in chunks to Verizon, I finally decided it was time to migrate my decade worth of Yahoo email over to Gmail.

Although Gmail offers an easy “Import mail and contacts” link from the “Settings > Accounts and Import” tab, this is not what you want to do (this is what I tried first). All your email will transfer over, but it won’t have the proper sender email address or date. Continue reading