So a few months ago I mentioned wanting to get away from WordPress and PHP. It’s not going very well.
WordPress keeps sucking me back in. A favor here, a quick job there. Next thing I know, I swear I can’t remember how to iterate an array in Ruby or Python.
While sitting down to work on a WordPress project still fills me with dread, I did recently discover a few things which slightly alleviate my misery.
My favorite, as described here by David Winter, is the ability to move the wp-content directory out of the standard WordPress hierarchy. Aside from the database,
wp-content holds basically everything which makes a site unique; themes, plugins, uploads, etc. With those out of the way, all of the core WordPress application code can be removed from the site’s git repo and stored as a submodule (pulling from the WordPress GitHub mirror), making version control a lot cleaner and easier and giving me one less thing to think about.
This directory layout should really be the default. The WordPress folder ought be a sacrosanct library, only changing when the application is upgraded. The ability to move
wp-content was added back in version 2.6 released in July of 2008. I wish I’d learned about this sooner.
I’m also doing something inspired by Mark Jaquith’s WordPress local dev tips which also allows me to also keep my
wp-config.php file versioned and outside of the
Because it’s a really bad idea to keep password files in version control, I created a
wp-config-db-sample.php file containing placeholders for the database login information:
That file gets copied to
wp-config-db.php, populated with the appropriate settings (and added to
.gitignore), then included by changing the top of
wp-config.php like this: