Category: Plugins

WordPress Plugin: Import Blogroll With Categories

I just wrote my first official WordPress plugin and have it listed in the WordPress plugin repository! Import Blogroll With Categories

By default, WordPress is lacking the functionality to handle categorized OPML feeds of links. When importing blogroll/links you are FORCED to select ONE category for ALL links to be inserted into.

My plugin adds an importer to WordPress, which is actually a modification of the standard OPML importer shipped with WP 2.7. The improved importer actually handles categories.

If the link categories already exist in your blog, links from the import within matching (case-insensitive) category names will be inserted into the correct category.

You can specify one of two options for the case where your blog doesn’t already have some categories that are found in the feed.

1) Allow it to create any new link categories needed (and insert the links into them)
2) Specify a default category that the links from unknown categories will be inserted into

I got jump start on some the coding changes a while ago here:

Until YESTERDAY there has been an item in the WordPress Trac that indicated that the milestone for its implementation in WordPress was version 2.8. I believe it would have nullified the reason for my plugin to exist. However, apparently, someone just changed the milestone from 2.8 to “Future Release (no date set)”.

So it looks like my plugin will still be useful for a long time =)

I’ve documented the steps of creating a plugin and getting it into the WordPress plugin repository here: Writing a WordPress Plugin

Writing a WordPress Plugin

I just wrote my first official WordPress plugin and have it listed in the WordPress plugin repository! Import Blogroll With Categories

I discuss the plugin in a separate post: WordPress Plugin: Import Blogroll With Categories

Since this was my first official WordPress plugin, I wanted to document the procedure. Writing a plugin and going all the way with it, is not for the faint-of-heart.

First, you actually have to come up with an idea that:
1) No one has written a plugin for yet (search for it!)
2) Is doable without donating years of your life
3) Functionality you really want!

Then you actually have to create the plugin. You’ll probably have to use multiple hooks called actions and filters. I wish I could tell you there was some easy way to learn exactly which you use and how to use them, but it seems to be something you mostly have to figure out on your own. Studying the code of other plugins you like will probably help.

In PHP you can’t override user defined functions, but you CAN override all the WordPress functions defined in: wp-includes/pluggable.php. WordPress only defines the default functions if plugin defined versions don’t exist.

Various sites provide a comprehensive list of WordPress functions, classes, and variables and indicates within which files they are used and defined. WordPress provides a decent one.

Many editors (including Dreamweaver) include a method to search over all files within a directory. The feature goes by many names and is not always easy to find, but is a life-saver for tracking down functions/code.

The general WordPress plugin creation guide:

After your plugin has been created, relatively well tested, and refined, a whole different journey begins (if you want your plugin in the WordPress plugin repository).

I chose to put my plugin on because I think it is best place for WP plugins to reside. It makes the most sense to users. WP is integrated with the automatic plugin installer/updater. It serves are one solid place to look for plugins that are all documented in the same fashion. If you are serious about your plugin, I recommend you follow the required steps to get it up there.

You need to submit a request to add your plugin. The request has to approved by a person. I had to wait 2 days to get my request approved. When you make the request, make sure you use the plugin name you want to use, and a solid description.

When approved, you will get access to a SVN (Subversion) directory just for your plugin. Like this:

What they don’t clearly explain, is how to actually upload your files. The only page they refer you to is:

Which is SOMEWHAT useful, but it is all in command-line. They make no reference to Subversion clients. When it comes to file transfer, I would prefer a nice GUI. For comparison, FTP is also a command-line based tool but we all use FTP clients don’t we?

After studying this chart of Subversion clients, I decided to try out SmartSVN (free)

I’ll admit it’s a bit overkill for updating a single plugin, but maybe I’ll use it for other SVN connections in the future. Once I got the authentication figured out ( login), I had no problems using the program. It worked pretty much just like I expected. Easy to see if a file has been changed locally or remotely, and update the files.

SmartSVN has a ton of features, and I only used the basic stuff, so if I start using it more, perhaps I’ll write a post reviewing its features.

After uploading files (use the general guidelines here and here), you can expect to wait up to 15 minutes to see your changes reflected on

BEFORE you upload anything you’ll want to do the most important thing. To create a VERY specifically formatted readme.txt file. This readme.txt file is used to CREATE your plugins page at:

You don’t have special admin access to update that page. The page is entirely controlled by the contents of your SVN directory (especially the readme.txt).

Because the readme.txt file is so important, WordPress provided a couple nice resources. An example readme.txt file containing notes about how to format your text. And a readme.txt validator. The validator is sweet. Not only does it validate your file, but it gives you a PREVIEW of the generated HTML formatting. This preview will help you work out formatting issues before you upload anything to your SVN folder.

Remember, your plugin will be live (in about 15 minutes) after you first upload your plugin file and valid readme.txt file. So try to already have a complete and properly formatted readme.txt file before you upload anything.