I recently upgraded to WordPress 2.2 and found that Ultimate Tag Warrior wasn't working anymore for me. Although I managed to hack it a bit and eventually found UTW 3, the biggest problem (and show stopper) was when a new comment was placed on a post, all the tags would disappear.

So I've moved to Simple Tagging which imports UTW tags and works just fine.

Now for the patch to allow me to tag from textmate.

READER DISCOUNTSave $50 on terminal.training

I've published 38 videos for new developers, designers, UX, UI, product owners and anyone who needs to conquer the command line today.

Blogging Bundle

As per my tutorials on how to support tagging from TextMate for Ultimate Tag Warrior you have to patch the blogging bundle. You can use my patch, or patch the blogging.rb file yourself.

Note: that if you've done this before (from a previous tutorial), you don't this to do this again and you can skip to the XMLRPC changes.

Automatically Patching Blogging Bundle

Download the latest blogging.rb patch and run the patch command:

patch -p0 < blogging.rb.patch

Manually Patching Blogging Bundle

You'll need to edit the blogging.rb file in the /Applications/TextMate.app/Contents/SharedSupport/Bundles/Blogging.tmbundle/Support/lib/ directory.

Find the following lines:

@post['mt_tags'] = @headers['tags'] if @headers['tags']

Then copy it below the

elsif self.mode == 'wp'

Then change:

@post['mt_allow_comments'] = @headers['comments'] =~ /\b(on|1|y(es)?)\b/i ? 'open' : 'closed' if @headers['comments']
@post['mt_allow_pings'] = @headers['pings'] =~ /\b(on|1|y(es)?)\b/i ? 'open' : 'closed' if @headers['pings']

And change the instance of 'open' to '1' (keeping the number in the quotation) and 'closed' to '0' (again keeping the quotation), so you have this:

@post['mt_allow_comments'] = @headers['comments'] =~ /\b(on|1|y(es)?)\b/i ? '1' : '0' if @headers['comments']
@post['mt_allow_pings'] = @headers['pings'] =~ /\b(on|1|y(es)?)\b/i ? '1' : '0' if @headers['pings']

The second lot of changes (comments and pings) are added because WordPress 2.2 changes the flag it requires to turn these features on.

XMLRPC Changes

Next we need to change the xmlrpc.php file that should be located in the root directory of your blog. I am providing my own copy of xmlrpc.php for download, but please be warned that I am using WordPress 2.2 and I have no idea whether this specific file will work with previous versions.

Either way: backup your files!

Download xmlrpc.php for WordPress 2.2

I do know, however, that manually patched (using the instructions below) the tagging should work regardless of the WordPress version.

Manually Modifying xmlrpc.php

Step 1 - modify the setters

In the functions mw_newPost and mw_editPost add the following line of code:

$_REQUEST['tag_list'] = $content_struct['mt_tags'];

Above the comment in each of those functions, that reads:

// We've got all the data -- post it:

Step 2 - modify the getters

In the functions mw_getRecentPosts and mw_getPost, find where the array is built ($struct[] = array and $resp = array respectively) and add the following as the first array item:

'mt_tags' => get_keywords($post_ID),

Step 3 - get tags from Simply Tagging

Add the following function in the xmlrpc.php file (I've added it to the end of the file - but it doesn't matter, so long as it's global):

function get_keywords($postid) {
  global $STagging;
  $STagging->_postids = $postid;
  $tags = $STagging->getPostTags($postid, true);
  return (implode(', ', $tags));
}

Finishing up

That's everything you should need to be able to enable tagging from TextMate to Wordpress using Simply Tagging.

Keep reading for a few other tips, and let me know how you find this tutorial.

A Fix for Tag URLs

I noticed that my particular install of WordPress 2.2 and Simply Tagging 1.6.8 didn't handle /tag/textmate properly. It kept saying 404 not found.

I wrote a fix and patched my version of Simply Tagging to get it to work. Edit simpletagging.php and change line 697 from:

$this->search_tag = stripslashes(get_query_var($this->option['query_varname']));

To:

$this->search_tag = preg_replace('/\//', '', (get_query_var($this->option['query_varname'])));

And Finally: Ecto Tagging

Though I don't use Ecto, I'm pretty certain if you follow the instructions in the xmlrpc section, and follow the first two steps from Robin Lu's - How to make Ecto work it should enabling tagging.