Add a class to the first and last items of a WordPress menu

If you’re using the WordPress dynamic menus, you can use the following code to add first-menu-item and last-menu-item to the appropriate menu items.

Add the following to your theme’s functions.php:

function add_first_and_last($output) {
    $output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1);
    $output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item'));
    return $output;
}
add_filter('wp_nav_menu', 'add_first_and_last');

Via Kuroi at the WordPress.org forums.

Weekly link dump

OHNY: TWA Flight Center

A beautiful Flickr gallery showing the Eero Saarinen-designed TWA Flight Center. A far cry from the largely functional and brutal terminals in most airports.

Folding Text

Another simple Markdown-aware text editor with a few neat tricks. It has a focus mode that lets you view only the section on which you’re currently working. It allows text folding by heading. It can do to-do lists like Listary and Task Paper, and features a timer mode.

qTranslate

A very simple to use plugin to allow content in multiple languages in a WordPress site.

Weekly link dump

Bitbucket

github has definitely won the majority mindshare when it comes to open source git repository hosting. If you need private repositories it can get expensive. Bitbucket is a much better option. It isn’t as social as github, but offers most of the same features for free/cheap.

Perfect Workflow in Sublime Text

This free course from the Net Tuts+ premium side shows you everything you’ll need to get up and running quickly with Sublime Text 2. It even includes a chapter on Vintage Mode, Sublime’s modal vi-work-alike.

Writebox

Writebox is a simple editor for editing and creating text files in your Dropbox† account. No install, it runs in your web browser. (If that’s too easy for you, maybe vi in the Cloud is more your thing? vi in your browser with Dropbox integration.)

† This is an affiliate link. I’m that shameless.