Using SVN to Manage WordPress Plugins

Subversion (SVN) is a widely-used version control system that WordPress utilizes to manage its plugin repository. If you’re a developer looking to host or update your plugin in the official WordPress Plugin Directory, SVN is essential. Let’s go through the steps of setting up and using SVN for managing your WordPress plugin.

Why Use SVN?

The WordPress Plugin Directory relies on SVN for plugin management, which allows you to:

  • Efficiently control plugin versions;
  • Publish updates and fixes;
  • Maintain multiple versions and test changes without affecting released versions.

Initial Setup: Cloning the Repository

  1. Install SVN
    Ensure you have SVN installed on your computer. For Linux, you can typically install it with:
sudo apt-get install subversion  # Linux

To install SVN on Mac, you can use Homebrew, a popular package manager for macOS. If Homebrew is already installed, run:

brew install svn

For Windows, you might consider using TortoiseSVN or another SVN graphical interface.

  1. Retrieve Repository Access Credentials
    To upload your plugin to the WordPress Directory, you’ll need repository access. WordPress will send you these credentials after approving your plugin submission.
  2. Clone the Repository
    You can now clone (download) the repository to your local machine:
svn checkout https://plugins.svn.wordpress.org/your-plugin-name

This command will create a local copy of your plugin’s repository, where you can manage its files.

Key Directories in the WordPress Repository

Once in your WordPress repository, you’ll see the following primary directories:

  • trunk/ — contains the current version of your plugin;
  • branches/ — holds separate branches for different development versions;
  • tags/ — contains stable plugin releases.

Basic SVN Commands for Plugin Management

  1. Adding Files After cloning the repository, start adding your plugin files. Use the following command:
svn add file_or_folder_name

To add all files in the current directory, use:

svn add --force .
  1. First Commit (Uploading Changes) After adding all necessary files, perform an initial commit to upload your changes to the repository:
svn commit -m "Initial commit"

This commits all added changes and uploads them to the server.

  1. Updating the Local Repository When working on a plugin that may also be modified by other developers, regularly update your local copy:
svn update

Updating the Plugin: Commands for Future Changes

When your plugin is ready for a new release, follow these steps to update it in the WordPress directory:

  1. Editing Files in trunk/
    Make updates in the trunk/ directory. When the plugin is ready for an update, ensure all necessary files are up-to-date.
  2. Creating a Tag for the New Version To release a new stable plugin version, copy the files from trunk/ into the tags/ directory:
svn copy trunk tags/x.x.x

This command creates a folder with your plugin’s version, such as tags/1.0.0.

  1. Commit Changes After making your changes, add any new files with svn add, then commit them:
svn commit -m "Update plugin version to x.x.x with new features"
  1. Reviewing Changes To view all changes, use the following command:
svn status

This shows a list of modified files and their status.

  1. Deleting Unnecessary Files If you need to remove a file from the repository, use the following command:
svn delete file_name

Don’t forget to commit the change to update it on the server.

Tips for Efficient SVN Workflow

  • Always create tags for each new version, enabling users to revert to previous versions if needed.
  • Update the repository regularly — even if you’re not committing changes, staying updated can help avoid conflicts.
  • Include a readme.txt file with plugin descriptions and a change log. This file is essential for displaying information about your plugin in the WordPress Directory.

Conclusion

Working with SVN for managing your WordPress plugin may seem complex, but the outlined commands for initial setup (checkout, add, commit) and subsequent updates (update, copy, delete) will help you keep your plugin current and compliant with WordPress standards.