Updating a WordPress Plugin use Subversion on Ubuntu

Document Sample
Updating a WordPress Plugin use Subversion on Ubuntu Powered By Docstoc
					                                     Web Dev, Coding, Business and Life!

          Using Ubuntu and SVN to
           Update the Wordpress

   •     http://technerdia.com/1687_subversion-guide.html

                             I have been using Linux / BSD for over a decade, but Windows has always been
                             my core work station, until recently. Software such as TortoiseSVN for Windows
                             and SCPlugin for MAC, makes updating the Wordpress Repository via
                             Subversion somewhat simple. Even if you forget what to do, dozens if not
                             hundreds of Websites clearly explain the process with nice pictures, videos, and
                             explanations galore.

                             That basically all ends with Ubuntu. While several Websites explain Subversion,
                             basically none of them explained updating the Wordpress Repository using
                             Ubuntu and Subversion in a nice clear step-by-step instructional process.

If you are new to the Repository or just confused how to update it on Ubuntu, then this step-by-step walk-
through should clear up any confusions you have.

       With articles like this I always welcome Feedback, if I missed a step, if something is confusing,
       or if you know of a better way achieve the end goal, please let me know by dropping me some

What is the Wordpress Repository?
The Repository is where you, the author of the Plugin, will store the plugin at Wordpress.org.
What is Subversion?
Subversion is an open source version control system that keeps track of the different versions of your
Wordpress plugin. Using Subversion will allow you to store your various plugin versions and if needed
restore a previous working version if a critical mistake is made in a current version.

Subversion is what allows to you Publish / Update your Wordpress Plugin at the Repository. You do not have
to commit every change you make, just the tested-working version.

Install Subversion
Before you can get started you will need to install Subversion on your Ubuntu machine.

sudo apt-get install subversion

Setup Your Local Directory Structure
Next you will need to create a document structure to store the Subversion copies of your Wordpress plugins.
My structure looks like this:

Update Your Local SVN
Now it is time to build a local copy of your Plugins. You will do this even if this is your first Plugin and you
have not added the plugin the Repository yet.

Within the /svn/ folder that you created, checkout (co) a copy of your plugin(s).

cd /home/username/wordpress/svn/
sudo svn co http://plugins.svn.wordpress.org/wp-my-admin-bar/
Within the plugin-name directory this will create a local directory structure that looks like:

The Plugins Readme.txt File
A plugins readme.txt file is the key file to making your plugin publish correctly. The readme.txt creates the
description of your plugin and is what determines the version of your plugin that will be available to the

    • The "Stable tag" is what "tags" the version of your plugin. The Stable tag must always be
      updated/changed when a new version of your plugin is published.

The readme.txt file also lays out the different tabbed pages displayed on wordpress.org, such as: Description,
Installation, FAQ, Screenshots, Other Notes, Changelog, and Other Notes. This is done based off the
structure of the readme.txt file. [Clean Robots.txt Template]

Copy Your Development Plugin Into /trunk/
Before we publish anything to the Repository, you will need to copy your development plugin to the /svn/
directory on your local harddrive. If you updated your Plugin, you will copy over the files that have Updated,
including the readme.txt file.

New Plugin or Full Plugin Update

For newly published plugins or if all of your plugin files have updated, you will recursively copy your core
plugin files into the /truck/ directory of the local SVN.

Change directories to the root plugins directory, and not within the plugin-name directory itself.

cd /home/username/wordpress/plugins/
sudo cp -r plugin-name/* ../svn/plugin-name/truck/

    • Note: The plugin has NOT been published at this point.

Copy Newly Updated Files Only

If only a couple of files changed, then copy over only the files that changed, this includes the readme.txt file.

Change directories to the plugin-name directory, then copy the changed file into the svn/trunk.

cd /home/username/wordpress/plugins/plugin-name/
sudo cp readme.txt ../../svn/plugin-name/trunk/

An Updated File Within A Directory

If you plugin is structured into directories, here is how you would copy a unique file within a directory.

cd /home/username/wordpress/plugins/plugin-name/
sudo cp -r includes/function.class.php ../../svn/plugin-name/trunk/includes

    • Note: The plugin has NOT been published at this point.

If you Screwed Up /svn/trunk
Here is how you would reset the /svn/trunk directory if you made an mistake.

Change into the /svn/plugin-name/ directory, remove the trunk directory, the checkout a new copy of the
trunk directory from the repository.
cd /home/username/wordpress/svn/plugin-name/
sudo rm -r trunk
sudo svn co http://plugins.svn.wordpress.org/wp-my-admin-bar/trunk

You will now need to re-copy your changed files back into the /svn/plugin-name/trunk directory.

Check The Status Of Your Files
To make sure all the proper files have been copied over to /trunk, check the status of the files.

cd /home/username/wordpress/svn/plugin-name/
sudo svn status

Tag Your New Local Version
Once your local /trunk/ has a copy of your developed plugin, it is time to copy the conents of trunk over to
your new Version tag.

The tag name / directory, will match your plugin Version in your readme.txt file. If the Stable tag within the
readme.txt is on Version 0.1 then your tagged directory name would be 0.1 as well.

Change directories into your local /svn/plugin-name directory.

cd /home/username/wordpress/svn/plugin-name/
sudo svn cp trunk tags/0.1

    • Remember: The tag version should relate to the "Stable tag" version number in your readme.txt file.

Check The Status Of Your Files
To make sure all the proper files have been copied over to the /tags directory, check the status of the files.

cd /home/username/wordpress/svn/plugin-name/
sudo svn status
You will notice only the changed files are displayed. However, if you navigate to the /svn/plugin-
name/tags/version-number and list the files in the directory, all of the plugins files have been added.

Commit Your Plugin
Now it is time to publish or commit your Plugin to the Repository.

cd /home/username/wordpress/svn/plugin-name/
sudo svn ci -m 'Adding Version 0.1'

    • Note: The area within the quote marks is a message to let you know what action is taking place.

At this point, Subversion at wordpress.org will ask you for your Wordpress.org password.

View Your Plugin
Open the svn http url to your plugin, example: http://plugins.svn.wordpress.org/wp-my-admin-bar/

Enter the /trunk/ and /tags/version-number directories and check that your modified files show up correctly.

After a few minutes has passed, check the plugin version at Wordpres.org, example:

You should see that you new version is now available for download.

Making Changes
If you noticed a "simple" error in a script or maybe you forget to update some information within the
readme.txt file, you will modify the needed files via root. Any changes you make will have to be done to both
copies in the /trunk/ and within /tags/

For a Linux text editor, such as pico, vi, emacs, etc run the editor using sudo.

cd /home/username/wordpress/svn/plugin-name/trunk/
sudo pico readme.txt

cd /home/username/wordpress/svn/plugin-name/tags/tag-version
sudo pico readme.txt

If you would rather use a GUI Editor, such as gedit or Blueflish, you will need to run those programs as root,
in the terminal window type: gksudo program-name

gksudo blueflish

gksudo gedit

Navigate to /home/username/wordpress/svn/plugin-name/trunk make the same modifications to the
/tags/version-number files. Save your changes.

Check The Status Of Your Files

To make sure your changes work, check the status of your files.

cd /home/username/wordpress/svn/plugin-name/
sudo svn status

Re-Commit Your Changes

Now that you have modified the files, re-commit your changes.

cd /home/username/wordpress/svn/plugin-name/
sudo svn ci -m 'Correction To Version 0.1'

Your Plugin Is Ready!
All Done! Your plugin has now been published to the Wordpress Repository and is available for download.

              Follow techNerdia on Google+ | Follow Chris on Google+
                        Subscribe to techNerdia's RSS Feed
                            Copyright 2012 © techNerdia - All Rights Reserved

Shared By:
Description: A Complete walk-through on how to use Ubuntu and Subversion to Update your Plugin at the Wordpress Repository.