Contents
Overview #
Like all software development, develop and test your code in your local WordPress.org development environment before committing the code to WordPress.com. We often deploy beta versions of WordPress to WordPress.com early, so we recommend using a SVN checkout of WordPress trunk rather than the latest stable release version. This way you won’t get caught off guard when new versions of WordPress are rolled out to WordPress.com.
No direct access to WordPress.com databases is possible from your local development environment. An updated copy of your site’s data can be easily exported and imported locally.
Setting up your environment #
Here’s how we generally recommend local dev environments be set up:
- Install WordPress
- Do an svn checkout of
trunkfrom http://core.svn.wordpress.org/trunk/ - Enable multisite (this is recommended, but not necessary)
- Make sure to
svn upevery day or so so that you’re working off the latest code (this isn’t necessary during early development phases of a WordPress version but required as the project nears alpha and beta releases). - Populate your site with some test data (you can use our demo files, though, you’re better off using test data from your own sites)
- Do an svn checkout of
- Install and activate the Developer Plugin.
- The plugin will help you optimize your development environment by making sure that you have all the essential tools and plugins installed and available.
- Make sure to select “WordPress.com VIP” as your project type.
- Install and setup Jetpack.
- Install VIP Shared plugins
- See below
- Again, make sure to
svn upevery day or so
- Set up your theme
- Themes in the VIP environment live in
WP_CONTENT_DIR . '/themes/vip/'. For example, your theme path might be/wp-content/themes/vip/my-theme/ - If your theme is already in the VIP SVN, do an svn checkout in the vip themes folder:
svn co https://vip-svn.wordpress.com/my-theme/ wp-content/themes/vip/my-theme/
- Themes in the VIP environment live in
- Enable debugging to catch errors early and often
- See below.
VIP Plugins and Helper Functions #
You should already have read access to our shared VIP plugins directory containing a growing list of plugins that you can use.
To test these plugins in your development environment, use your WordPress.com username and password to check out a copy of them from https://vip-svn.wordpress.com/plugins/ using Subversion. To match our environment, they should be checked out to wp-content/themes/vip/plugins/ and not wp-content/plugins/ like you would normally.
svn co https://vip-svn.wordpress.com/plugins/ wp-content/themes/vip/plugins
Once you’ve checked out that directory to your local environment, you should add the following to the very top of your theme’s functions.php file:
(hover over the below code to make the toolbar appear which contains a button allowing you to easily copy the code)
// Init WP.com VIP environment require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-init.php' );
This initializes most of the code necessary to develop well in a VIP environment. Here are a few things the init process loads:
wpcom_vip_load_helper_wpcom()includes thevip-helper-wpcom.phpfile which defines some helper functions that are specific to WordPress.com.- The
vip-local-development-helper.phpfile defines some helper functions that assist in loading plugins and helper files. This file is automaticallyinclude()‘ed on WordPress.com. - The
vip-powered-wpcom.phpfile defines some helper functions that assist you in displaying the “Powered by WordPress.com” text or image. wpcom_vip_load_helper()includes thevip-helper.phpfile which defines some helper functions that will work on both WordPress.com and your hosting environment.
To load plugins from the shared themes/vip/plugins/ folder, you can use the following function call:
wpcom_vip_load_plugin( 'zoninator' );
Jetpack #
Jetpack is a plugin that brings the many great features of WordPress.com to your self‑hosted WordPress install. It’s especially useful for testing various WordPress.com features like Contact Forms.
Jetpack currently requires that WordPress sites be reachable by WordPress.com to enable many of its cloud-specific features. For development in local or offline environments, you can enable Jetpack’s development mode by adding the following to your wp-config.php file:
define( 'JETPACK_DEV_DEBUG', true );
Note: development mode automatically gets enabled if you don’t have a period in your site’s hostname, i.e. localhost.
Debugging #
You should have have PHP error display on in your development environment to banish the WSOD (white screen of death).
- display_errors in PHP: That can either be done via your php.ini (don’t forget to restart Apache) or via your .htaccess file (
php_flag display_errors on). - Add
define('WP_DEBUG', true);to your wp-config.php file for additional warnings and notices (especially regarding the use of deprecated WordPress functions). plugin.
Using Git with Subversion #
Read about how to use Git with Subversion for your local development environment.