So a looooong time ago, I released my first WordPress plugin – expandable jQuery comment replies. I’ve been remiss in keeping it updated – it was written for WP 2.7, and here we are, almost on 3.1. So when I released by Back End Instructions plugin, I decided perhaps I should be a good girl and update my old plugin.
Updating it locally wasn’t an issue. however, updating the repository…. that’s a different story.
I don’t use Terminal a lot, so it’s still a little bit alien to me. I’m not terrified of it anymore, but I still walk on eggshells when I use it – I don’t want to ruin anything. (My stuff, I don’t care so much about – it’s accidentally…I dunno – wiping out the entire plugins database that scares me! LOL) Although the first time I added a plugin wasn’t so difficult, like I said – it’s been a while, updating is another story.
There’s a nice codex page on the issue, but it doesn’t really dive into the whole thing. I think it was written more for people who are used to downloading the nightlies, and adding code and plugins like crazy all the time. The Codex page is more of a “quick overview” kind of thing.
So while it’s fresh in my mind, I’m going to share a few little tidbits that I’ve come to understand – so when I do this again I don’t have to spend three hours just trying to update something.
Adding a brand-spanking new plugin
First off – when you want to add a fresh, new plugin, you have to ask first. I don’t remember doing this before, so it must be a new thing they’ve added to help maintain quality control (which is a good thing). From what I’m reading, when you submit the form for adding a plugin, you’re basically notifying the WP team that you want to add a new plugin, and apparently they download your file and take a few days to actually check it out (I’m being told it’s anywhere between 3 to 10 days – for me it was pretty quick). Then they’ll send you an email and give you your SVN directory so you can add the files to the repository.
Once you get the go-ahead to submit the plugin, you need to shell into the system to add it.
Now, again, I use Terminal. I’m on a Mac, and it comes with this sweet little program already built in. I don’t know what you’d use for a PC, but I do recall needing to shell some stuff back when I was using one, and I had to find and download a program – my system didn’t had anything built in for it. (Again, this is based on an old lady’s memory.) So if you’re on a PC, you’ll have to find something that allows you to shell into the plugins server. The following instructions are Mac-based, but I believe shell access doesn’t care if you’re on a Mac or PC, so if you’ve got something that gives you access, these instructions should work for you.
So, using terminal, you basically open up the puppy, and you should be in your root directory (Macintosh HD/Users/your computer name). It’ll basically look – in the Terminal Window – like:
192: ~ somename$
and have a little square cursor next to it.
Now, you want to create a new directory to store all your stuff in. So you type in (for purposes of example, we’ll use the name “plugins”)
and hit “enter.” If you have a Finder window open, you’ll see a new directory being created there
Now you need to access your own little part of the Repository world. The directory name they gave you (we’ll say it’s “love-potion-9″ in acknowledgement of Valentine’s Day) is your address. So next, you need to type in:
svn co http://svn.wp-plugins.org/love-potion-9 plugins
And this basically “checks out” what is there. If this is a new plugin, most likely there won’t be anything but some empty folders (trunk/trunk, branches, tags), and everything in your little area will be downloaded to your new plugins” directory.
So now you want to copy the plugin files you have on your computer to the “trunk” directory of the stuff the SVN just added to your hard drive. DO NOT create a subdirectory, and DO NOT put in a zipped file. Just take all the files from the root level of your plugin and move them to the “trunk” of the new area.
Now, back to Terminal. You need to “speak” to the WP server and tell it you’re preparing to commit some stuff to the server. You have to let it know that there’s new stuff there. So you need to change the directory to your local plugin area
and then you should see the beginning part change – instead of
192: ~ somename$
you should see
192: plugins somename$
that’ll tell you you’re in the right directory. (if you get an error that the directory doesn’t exist, type in
cdand it should move up a level, then try again.)
Now you want to “speak” to the repository, and tell it to take the files that are in your local copy and copy them to the matching directory in the WordPress repository. You do this by typing in:
svn add trunk/*
This basically tells WP that you are in your “plugins” directory that matches theirs, and you want to take everything in your local “trunk” directory and copy it to the WordPress’ matching “trunk” directory. You’ll see the terminal window sort of pause for a few seconds, then this stuff will show up. The lines will begin with “A” (the WP server telling you it’s “added” the files) and then the curosr will appear again.
Once you’re satisfied that all the files are properly in their place, you want to commit this. (If you quit now, then everything you’ve done up to this point will go away.) So you type in:
svn ci -m 'Adding first version of my plugin'
And you’ll see a message that the files are transmitting, and finally it’ll give you a “committed revision” message. All done – you can close out. Usually, in no more than 15 minutes after this point – the new plugin will show up is the plugins repository. You can easily see it by looking at the “Newest” section. By the way, the “Adding first version of my plugin” thing can really be any message you want to have there.
Updating an existing plugin
This is where I ran into trouble – apparently adding is much easier than editing! (Well, not really, but it seemed like it LOL). Really, it’s very similar to adding a new plugin. You want to start by opening up Terminal, and making sure you’re in whatever directory you want on your hard drive (I like to do my stuff at the very root of my hard drive, so I don’t accidentally edit it at some point in the future) and log into the repository to “check out” the file system that’s living there, again by typing in:
svn co http://svn.wp-plugins.org/love-potion-9 plugins
NOTE: be aware that when you do this, if you’re in your local copy, it’ll overwrite what’s there. So if you’ve already made changes, I HIGHLY recommend that you rename your existing “trunk” folder to “trunkNEW” or something so your changes don’t get overwritten, and then move the files after you’ve checked out what’s on the WP server, so you don’t lose your changes.
This will basically copy the files in the repository to your hard drive (“checking out” – like at the library). You can then open up whatever files you want to edit (I HIGHLY recommend the readme.txt file and the root file so you can change the version number and add to your changelog. But the readme.txt file is the big one.) Once you’ve made your changes, simply save them, and change your directory in the terminal so you’re in your plugin area (if you haven’t already) and then type in:
svn ci -m 'Updating my plugin to version whatever'
and hit enter. it magically knows which files you’ve changed – you’ll see them list up and it’ll end with “Committed revision [some number]“. In a bit, you’ll see the version number of your plugin in the plugins area of WordPress.org change to the new version, and everyone will be magically alerted to the update.
NOTE: there is a “code snippet” section that makes this more concise, and covers a couple of issues that you may come across. Feel free to look it over.