When I’m working on a website, I’m often hopping between my local environment, development/staging, and production. I’ll use to a separate CodeKit URL for live updating when working on CSS. And as I build out functionality, I go to the project’s GitHub wiki to document it for my editor and developer training materials.
I created a simple plugin called BE Admin Bar Links that adds all these links to the admin bar. I place it in mu-plugins on my local install so it’s always running.
Inside my wp-config.php file I have a series of constants defined:
define('WP_DEBUG', true); define('BE_WPE_INSTALL', 'base'); //define('BE_PUSH_TO', 'staging' ); define('BE_WPE_USER', 'demo'); define('BE_WPE_PASSWORD', '1234'); define('BE_GITHUB_INSTALL', 'base' ); define('BE_PRODUCTION_URL', 'https://example.com' );
I use WPEngine as my development environment. One of the nice features is the ability to create unlimited transferrable installs, so I can develop all of my client sites there without worrying about the number of installs, storage, or bandwidth they’re using.
Transferrable installs are password-protected. The quick link generated in the admin bar has the login info already added to the URL so clicking it will automatically log you in. This is really helpful when sending links to clients. I can go to the appropriate page locally, copy and paste the “Dev” URL, and they can click through without having to bother with the frontend login.
You could define these variables in the plugin rather than using constants in wp-config.php, but I’m also using them in local bash scripts. For instance, typing
project.sh push pushes updated code to GitHub, pushes code to the proper WPEngine remote branch (production or staging), and runs Migrate DB Pro to push the database and media to WPEngine.