Your cart is currently empty!
Simple Tips for Developing Plugins and Themes Against WordPress Trunk
If you often develop plugins or themes for WordPress, you may have heard about one of the strategies that are often recommended, which is doing so against trunk of WordPress. This practice often works best to any web developers or someone who is looking for ways to improve their development practices. Not to mention how easy you can view the source code on the web at any time, since WordPress is open source software.
Besides, you can also work with it easily as you can download it to your local computer. Therefore, in this article we would like to describe how to work with the current snapshot of code with WordPress and why it may be beneficial to use this codebase when working on projects of others. So, if you are curious to know how to develop plugins and themes against WordPress trunk, you can continue reading the article below.
Developing Against WordPress Trunk
We recommend you to have Subversion or a Subversion client installed before getting started. By having a package manager like Homebrew to handle software and a command-line client, you can easily enter this in your terminal:
$ brew install subversion
If you are looking to use a front-end, you can also use something like Versions or Cornerstone. Below are the steps that you have to follow:
Download the Latest Code
Download the latest snapshot of the WordPress codebase by using this command:
$ svn co https://core.svn.wordpress.org/trunk/ .
However, if you’re using a front-end then you might need to use the following URL in your client of choice to browse the repository:
https://core.svn.wordpress.org/trunk
Then, you can download the contents of the trunk directory to your computer and prepare to install it on your computer.
Or you can use your front-end of choice:
In order to do this, you have to make sure that a database is prepared and then walk through the standard installation procedure.
Setup Debug Mode
After all is installed, you can set your WordPress into debug mode, so you are able to see information in the debug logs as well as in your browser.
To do this, you can open wp-config.php and change the line that reads:
define( ‘WP_DEBUG’, false );
To read:
define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, false );
@ini_set( ‘display_errors’, 0 );
define( ‘SCRIPT_DEBUG’, true );
At this point, you will see information printed out to the screen every time you’re working with code and every time you have information written to debug.log which you can also view in your preferred text editor or console.
Work with the Proper Directories
After all of your WordPress is set, you’re ready to work on your project, note on whether or not you’re working plugins or themes. Furthermore, in general, you’ll find each in wp-content/plugins or wp-content/themes.
For instance, if you’re working on a plugin then you’re going to keep your plugin in the plugins’ directory. You can see on the screenshot above that you may need to use Scheduled Post Shortcut against trunk.
A Word about Stable Versions
So, whenever you are working with a plugin or a theme that runs against a stable version of WordPress, remember the choices you have to make:
- Work against the stable version of the code that’s available at WordPress.org.
- Work against the snapshot of code in trunk.
If you happen to use the former, then your code is going to work with the latest stable version. However, if you choose to work with the latter, then you will need to work with the upcoming version of WordPress in order to make it work. However, remember that things can change between what’s in trunk and what’s ultimately released. Therefore, if you prefer to work with trunk, you may need to keep testing your work against the code until the core team tags trunk as a stable version.