WordPress is a tool that we at Plank have often leveraged. Many of our clients are already familiar with the clean and simple interface that WordPress provides. As a result, it is often requested as the basis for some of our projects – including awesome websites such as Bioware.com, CitiesForPeople.ca, Elua.com, Evolocity.ca and
MontrealBaseballProject.com. Over the past number of years, we have acquired a ton of experience working (and sometimes fighting) with the platform to develop the custom themes that make these websites shine.
As pretty and useful as the user interface of WordPress is, the code base sometimes leaves a little bit to be desired. It can be quite messy, inconsistent and sometimes downright inefficient, making it more time consuming to develop some of the awesome features we need for our project. In order to remedy this, with every project we take on, we try to refine our WordPress work-flow. We often collect useful code snippets, tutorials and plugins for our toolkit and build up our theme boilerplates to facilitate future projects. We have likewise delved deep into the wordpress core, but we haven’t come up empty handed.
Here is a little piece of our toolkit that I am happy to give back to the broader WordPress community: a plugin that makes our work-flow run as smooth as silk.
WP-Portability, as its name might suggest, is a plugin to help make your WordPress site more portable. It is designed to make it much simpler to move your wordpress installation from one directory to another or from one domain to another.
Why is this useful or necessary? Though anyone can make use of this plugin to move their blog to a new domain, it was conceived to facilitate development. Consider our workflow:
The Plank Workflow
When we develop a website (whether WordPress-based or another CMS), our development work-flow usually looks something like the following:
- Pre-production: creating sitemaps, functional specs, wireframes and mockups.
- Back-end development: building up the database and CMS to handle the site’s content.
- Front-end development: building and styling the templates of the website.
- Staging: Placing the site on a test server for QA.
- Deployment: Uploading the site to its final resting place for public enjoyment.
Pre-production aside, each of those steps involves a different work environment. Our front and back-end developers usually fire up the websites locally on their computers using localhost or a virtual host. Staging is done on a server in the office as a subdomain of plankdesign.com. And of course, deployment happens on the client’s remote server using the intended domain of the website. That is a minimum of 4 different website installs and an equivalent number of different domains.
WordPress and the Workflow
For many of the content management systems we work with, this doesn’t cause too much trouble. Many systems are able to run just fine, regardless of where they are located. WordPress, on the other hand, depends on a lot of absolute paths. The domain name to your wordpress install is normally hard-coded into the database and the system path is hard-coded into the htaccess file. This can make moving the site a real nuisance and makes sharing a database near impossible (i.e. between a front-end and back-end
Another point of frustration is the fact that any media or links added to the TinyMCE editor will use absolute links by default, meaning they will all break once the site is deployed to another server. Going through a database to update the urls in hundreds of posts is utterly monotonous. I have seen other plugin which try to address this by making all links root-relative (i.e. leading ‘/’ ), though this will still break if the depth of the WordPress install changes (
http://example.com). This is admittedly an issue that few content management systems are able to adequately address. Until now.
So What Does This Plugin Do?
The plugin works by making the following changes to the way WordPress operates in order to remove all the issues that tie it to an install directory or a domain:
- Dynamic File Paths: WP-Portability figures out where it is being run from programmatically so that WordPress no longer needs to depend on an absolute path in the database.
- Dynamic Rewrites: WP-Portability changes the way WordPress writes its htaccess files, so that it always uses relative paths from the install location, rather than the domain root.
- Always local URLs: WP-Portability filters the content of any post being saved in order to store absolute links. Any URL that points to media or pages in the current install is instead silently converted into a shortcode. Whenever the post is edited or
viewed, that shortcode is unpacked to rebuild the link so that it works regardless of the current installation directory.
WP-Portability allows you to freely move the wordpress install however you please with minimal complication. Moving your existing wordpress install from the domain root to
/blog? No problem. Copying your theme, database and uploads to a new wordpress install on a new server? Also Easy.
Give it a try. We hope this facilitates your development work-flow as much as it did ours.
A few features of WP-Portability are currently disabled on Network/Multi-Site WordPress Installs as they don’t play nicely with that configuration. We are working on it though.
Vous en voulez plus? Rejoignez notre infolettre.
Nous aimons partagé nos conseils à propos du web, nos idées et nos projets.